Salome HOME
Implementation of color as integer array attribute
[modules/shaper.git] / src / Model / Model_AttributeIntArray.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeIntArray.h
4 // Created:     6 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef MODEL_ATTRIBUTEINTARRAY_H_
8 #define MODEL_ATTRIBUTEINTARRAY_H_
9
10 #include <Model.h>
11 #include <ModelAPI_AttributeIntArray.h>
12
13 #include <TDF_Label.hxx>
14 #include <TDataStd_IntegerArray.hxx>
15
16 #include <string>
17
18 /**\class Model_AttributeIntArray
19  * \ingroup DataModel
20  * \brief API for the attribute that contains several integers in the array inside.
21  * Used for RGB color storage for an example. By default size is one, zero-based.
22  * Represented as array in OCCT. Empty array means that this attribute does not exists.
23  */
24
25 class Model_AttributeIntArray : public ModelAPI_AttributeIntArray
26 {
27   /// The OCCT array that keeps all values. 
28   Handle_TDataStd_IntegerArray myArray;
29   /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
30   TDF_Label myLab;
31  public:
32
33   /// Returns the size of the array (zero means that it is empty)
34   MODEL_EXPORT virtual int size();
35
36   /// Sets the new size of the array. The previous data is erased.
37   MODEL_EXPORT virtual void setSize(const int theSize);
38
39   /// Defines the value of the array by index [0; size-1]
40   MODEL_EXPORT virtual void setValue(const int theIndex,
41                                      const int theValue);
42
43   /// Returns the value by the index
44   MODEL_EXPORT virtual int value(const int theIndex);
45
46
47  protected:
48   /// Initializes attibutes
49   Model_AttributeIntArray(TDF_Label& theLabel);
50
51   friend class Model_Data;
52 };
53
54 #endif