Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / Model / Model_AttributeDoubleArray.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef Model_AttributeDoubleArray_H_
22 #define Model_AttributeDoubleArray_H_
23
24 #include "Model.h"
25
26 #include <ModelAPI_AttributeDoubleArray.h>
27
28 #include <TDF_Label.hxx>
29 #include <TDataStd_RealArray.hxx>
30
31 #include <string>
32
33 /// \class Model_AttributeDoubleArray
34 /// \ingroup DataModel
35 /// \brief API for the attribute that contains several double in the array inside.
36 class Model_AttributeDoubleArray: public ModelAPI_AttributeDoubleArray
37 {
38 public:
39   /// Returns the size of the array (zero means that it is empty)
40   MODEL_EXPORT virtual int size();
41
42   /// Sets the new size of the array. The previous data is erased.
43   MODEL_EXPORT virtual void setSize(const int theSize);
44
45   /// Defines the value of the array by index [0; size-1]
46   MODEL_EXPORT virtual void setValue(const int theIndex,
47                                      const double theValue);
48
49   /// Returns the value by the index
50   MODEL_EXPORT virtual double value(const int theIndex);
51
52 protected:
53   /// Initializes attibutes
54   Model_AttributeDoubleArray(TDF_Label& theLabel);
55   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
56   virtual void reinit();
57
58 private:
59   /// The OCCT array that keeps all values.
60   Handle_TDataStd_RealArray myArray;
61
62   /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
63   TDF_Label myLab;
64
65   friend class Model_Data;
66 };
67
68 #endif