1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeTables.h
4 // Created: 14 Nov 2016
5 // Author: Mikhail Ponikarov
7 #ifndef Model_AttributeTables_H_
8 #define Model_AttributeTables_H_
12 #include <ModelAPI_AttributeTables.h>
14 #include <TDF_Label.hxx>
15 #include <TDataStd_IntegerList.hxx>
19 /// \class Model_AttributeTables
20 /// \ingroup DataModel
21 /// \brief API for the attribute that contains tables of some values type.
23 /// The type of values can be changed. But all the values in the tables must have the same one
24 /// type. The currently allowed types now are: Boolean, Integer, Double, String.
25 /// By default there is only one table, but it may be increased/decreased by adding/removing
26 /// tables one by one.
27 /// The number of rows and columns are equal in all tables. If table, row or column is added,
28 /// the previous values are kept unchanged. New cells are filled by zero, false or empty strings.
29 class Model_AttributeTables: public ModelAPI_AttributeTables
32 /// Returns the number of rows in the table
33 MODEL_EXPORT virtual int rows();
34 /// Returns the number of columns in the table
35 MODEL_EXPORT virtual int columns();
36 /// Returns the number of tables
37 MODEL_EXPORT virtual int tables();
39 /// Sets the new size of the tables set. This method tries to keep old values if number of
40 /// rows, columns or tables is increased.
41 MODEL_EXPORT virtual void setSize(
42 const int theRows, const int theColumns, const int theTables = 1);
44 /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
45 MODEL_EXPORT virtual void setType(ValueType theType);
46 /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
47 MODEL_EXPORT virtual const ValueType& type() const;
48 /// Defines the value by the index in the tables set (indexes are zero-based).
49 MODEL_EXPORT virtual void setValue(
50 const Value theValue, const int theRow, const int theColumn, const int theTable = 0);
51 /// Returns the value by the index (indexes are zero-based).
52 MODEL_EXPORT virtual Value value(
53 const int theRow, const int theColumn, const int theTable = 0);
55 /// Returns the value in the format of string (usefull for the python connection)
56 MODEL_EXPORT virtual std::string valueStr(
57 const int theRow, const int theColumn, const int theTable = 0);
60 /// Objects are created for features automatically
61 MODEL_EXPORT Model_AttributeTables(TDF_Label& theLabel);
62 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
63 virtual void reinit();
66 /// The OCCT array that keeps all values. Indexes are computed as:
67 /// TableNum * NbRows * NbColumns + RowNum * NbColumns + ColNum
68 //Handle_TDF_Attribute myArray;
70 /// Container that stores properties of the tables set: type, nbtables, nbrows, nbcolumns
71 /// If sizes are zero, myArray IsNull and vice-versa
72 Handle_TDataStd_IntegerList myProp;
74 /// cashed main properties
75 int myTables, myRows, myCols;
76 /// cashed main properties
77 ModelAPI_AttributeTables::ValueType myType;
79 /// Stores the label as a field
82 friend class Model_Data;