Salome HOME
Issue #2052: Modification of parameters don't work (sketch, extrusion)
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeTables.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeTables.h
4 // Created:     14 Nov 2016
5 // Author:      Mikhail Ponikarov
6
7 #ifndef ModelAPI_AttributeTables_H_
8 #define ModelAPI_AttributeTables_H_
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Attribute.h>
12
13 #include <string>
14
15 /// \class ModelAPI_AttributeTables
16 /// \ingroup DataModel
17 /// \brief API for the attribute that contains tables of some values type.
18 ///
19 /// The type of values can be changed. But all the values in the tables must have the same one
20 /// type. The currently allowed types now are: Boolean, Integer, Double, String.
21 /// By default there is only one table, but it may be increased/decreased by adding/removing
22 /// tables one by one.
23 /// The number of rows and columns are equal in all tables. If table, row or column is added,
24 /// the previous values are kept unchanged. New cells are filled by zero, false or empty strings.
25 class ModelAPI_AttributeTables: public ModelAPI_Attribute
26 {
27 public:
28   /// Type of the value in the table
29   enum ValueType {
30     BOOLEAN,
31     INTEGER,
32     DOUBLE,
33     STRING
34   };
35
36   struct Value {
37     bool myBool;
38     int myInt;
39     double myDouble;
40     std::string myStr;
41   };
42
43   /// Returns the number of rows in the table
44   MODELAPI_EXPORT virtual int rows() = 0;
45   /// Returns the number of columns in the table
46   MODELAPI_EXPORT virtual int columns() = 0;
47   /// Returns the number of tables
48   MODELAPI_EXPORT virtual int tables() = 0;
49
50   /// Sets the new size of the tables set. This method tries to keep old values if number of
51   /// rows, columns or tables is increased.
52   MODELAPI_EXPORT virtual void setSize(
53     const int theRows, const int theColumns, const int theTables = 1) = 0;
54
55   /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
56   MODELAPI_EXPORT virtual void setType(ValueType theType) = 0;
57   /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
58   MODELAPI_EXPORT virtual const ValueType& type() const = 0;
59   /// Defines the value by the index in the tables set (indexes are zero-based).
60   MODELAPI_EXPORT virtual void setValue(
61     const Value theValue, const int theRow, const int theColumn, const int theTable = 0) = 0;
62   /// Returns the value by the index (indexes are zero-based).
63   MODELAPI_EXPORT virtual Value value(
64     const int theRow, const int theColumn, const int theTable = 0) = 0;
65
66   /// Returns the value in the format of string (usefull for the python connection)
67   MODELAPI_EXPORT virtual std::string valueStr(
68     const int theRow, const int theColumn, const int theTable = 0) = 0;
69
70   /// Returns the type of this class of attributes
71   MODELAPI_EXPORT static std::string typeId()
72   {
73     return "Tables";
74   }
75   /// Returns the type of this class of attributes, not static method
76   MODELAPI_EXPORT virtual std::string attributeType();
77   /// To virtually destroy the fields of successors
78   MODELAPI_EXPORT virtual ~ModelAPI_AttributeTables();
79
80 protected:
81   /// Objects are created for features automatically
82   MODELAPI_EXPORT ModelAPI_AttributeTables();
83 };
84
85 /// Pointer on double attribute
86 typedef std::shared_ptr<ModelAPI_AttributeTables> AttributeTablesPtr;
87
88 #endif