Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into BR_coding_rules
[modules/shaper.git] / src / Model / Model_AttributeDoubleArray.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeDoubleArray.h
4 // Created:     08 July 2016
5 // Author:      Dmitry Bobylev
6
7 #ifndef Model_AttributeDoubleArray_H_
8 #define Model_AttributeDoubleArray_H_
9
10 #include "Model.h"
11
12 #include <ModelAPI_AttributeDoubleArray.h>
13
14 #include <TDF_Label.hxx>
15 #include <TDataStd_RealArray.hxx>
16
17 #include <string>
18
19 /// \class Model_AttributeDoubleArray
20 /// \ingroup DataModel
21 /// \brief API for the attribute that contains several double in the array inside.
22 class Model_AttributeDoubleArray: public ModelAPI_AttributeDoubleArray
23 {
24 public:
25   /// Returns the size of the array (zero means that it is empty)
26   MODEL_EXPORT virtual int size();
27
28   /// Sets the new size of the array. The previous data is erased.
29   MODEL_EXPORT virtual void setSize(const int theSize);
30
31   /// Defines the value of the array by index [0; size-1]
32   MODEL_EXPORT virtual void setValue(const int theIndex,
33                                      const double theValue);
34
35   /// Returns the value by the index
36   MODEL_EXPORT virtual double value(const int theIndex);
37
38 protected:
39   /// Initializes attibutes
40   Model_AttributeDoubleArray(TDF_Label& theLabel);
41   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
42   virtual void reinit();
43
44 private:
45   /// The OCCT array that keeps all values.
46   Handle_TDataStd_RealArray myArray;
47
48   /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
49   TDF_Label myLab;
50
51   friend class Model_Data;
52 };
53
54 #endif