Salome HOME
Add Integer attribute support
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.cpp
1 // Name   : ModelHighAPI_Tools.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Tools.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Dir.h>
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Pnt2d.h>
13 //--------------------------------------------------------------------------------------
14 #include <GeomDataAPI_Dir.h>
15 #include <GeomDataAPI_Point.h>
16 #include <GeomDataAPI_Point2D.h>
17 //--------------------------------------------------------------------------------------
18 #include <ModelAPI_AttributeBoolean.h>
19 #include <ModelAPI_AttributeDocRef.h>
20 #include <ModelAPI_AttributeDouble.h>
21 #include <ModelAPI_AttributeIntArray.h>
22 #include <ModelAPI_AttributeInteger.h>
23 #include <ModelAPI_AttributeRefAttr.h>
24 #include <ModelAPI_AttributeRefAttrList.h>
25 #include <ModelAPI_AttributeReference.h>
26 #include <ModelAPI_AttributeRefList.h>
27 #include <ModelAPI_AttributeSelection.h>
28 #include <ModelAPI_AttributeSelectionList.h>
29 #include <ModelAPI_AttributeString.h>
30 //--------------------------------------------------------------------------------------
31 #include "ModelHighAPI_Double.h"
32 #include "ModelHighAPI_Integer.h"
33 #include "ModelHighAPI_Selection.h"
34
35 //--------------------------------------------------------------------------------------
36 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
37                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
38 {
39   theAttribute->setValue(theValue);
40 }
41
42 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
43                    double theX, double theY)
44 {
45   theAttribute->setValue(theX, theY);
46 }
47
48 //--------------------------------------------------------------------------------------
49 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
50                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
51 {
52   theAttribute->setValue(theValue);
53 }
54
55 //--------------------------------------------------------------------------------------
56 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
57                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
58 {
59   theAttribute->setValue(theValue);
60 }
61
62 //--------------------------------------------------------------------------------------
63 void fillAttribute(bool theValue,
64                    const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute)
65 {
66   theAttribute->setValue(theValue);
67 }
68
69 //--------------------------------------------------------------------------------------
70 void fillAttribute(const ModelHighAPI_Double & theValue,
71                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
72 {
73   theValue.fillAttribute(theAttribute);
74 }
75
76 //--------------------------------------------------------------------------------------
77 void fillAttribute(const ModelHighAPI_Integer & theValue,
78                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute)
79 {
80   theValue.fillAttribute(theAttribute);
81 }
82
83 //--------------------------------------------------------------------------------------
84 void fillAttribute(const ModelHighAPI_Selection & theValue,
85                    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
86 {
87   theValue.fillAttribute(theAttribute);
88 }
89
90 //--------------------------------------------------------------------------------------
91 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
92                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
93 {
94   theAttribute->clear();
95   for (auto it = theValue.begin(); it != theValue.end(); ++it)
96     it->appendToList(theAttribute);
97 }
98
99 //--------------------------------------------------------------------------------------
100 void fillAttribute(const std::string & theValue,
101                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
102 {
103   theAttribute->setValue(theValue);
104 }
105 //--------------------------------------------------------------------------------------