Salome HOME
Add support of ModelAPI_AttributeRefAttrList
[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_RefAttr.h"
34 #include "ModelHighAPI_Selection.h"
35
36 //--------------------------------------------------------------------------------------
37 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
38                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
39 {
40   theAttribute->setValue(theValue);
41 }
42
43 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
44                    double theX, double theY)
45 {
46   theAttribute->setValue(theX, theY);
47 }
48
49 //--------------------------------------------------------------------------------------
50 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
51                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
52 {
53   theAttribute->setValue(theValue);
54 }
55
56 //--------------------------------------------------------------------------------------
57 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
58                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
59 {
60   theAttribute->setValue(theValue);
61 }
62
63 //--------------------------------------------------------------------------------------
64 void fillAttribute(bool theValue,
65                    const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute)
66 {
67   theAttribute->setValue(theValue);
68 }
69
70 //--------------------------------------------------------------------------------------
71 void fillAttribute(const ModelHighAPI_Double & theValue,
72                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
73 {
74   theValue.fillAttribute(theAttribute);
75 }
76 void fillAttribute(double theValue,
77                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
78 {
79   theAttribute->setValue(theValue);
80 }
81
82 //--------------------------------------------------------------------------------------
83 void fillAttribute(const ModelHighAPI_Integer & theValue,
84                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute)
85 {
86   theValue.fillAttribute(theAttribute);
87 }
88
89 //--------------------------------------------------------------------------------------
90 void fillAttribute(const ModelHighAPI_RefAttr & theValue,
91                    const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
92 {
93   theValue.fillAttribute(theAttribute);
94 }
95
96 //--------------------------------------------------------------------------------------
97 void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
98                    const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
99 {
100   theAttribute->clear();
101   for (auto it = theValue.begin(); it != theValue.end(); ++it)
102     it->appendToList(theAttribute);
103 }
104
105 //--------------------------------------------------------------------------------------
106 void fillAttribute(const ModelHighAPI_Selection & theValue,
107                    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
108 {
109   theValue.fillAttribute(theAttribute);
110 }
111
112 //--------------------------------------------------------------------------------------
113 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
114                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
115 {
116   theAttribute->clear();
117   for (auto it = theValue.begin(); it != theValue.end(); ++it)
118     it->appendToList(theAttribute);
119 }
120
121 //--------------------------------------------------------------------------------------
122 void fillAttribute(const std::string & theValue,
123                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
124 {
125   theAttribute->setValue(theValue);
126 }
127 void fillAttribute(const char * theValue,
128                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
129 {
130   theAttribute->setValue(theValue);
131 }
132
133 //--------------------------------------------------------------------------------------