Salome HOME
Temporary modification to check whether the compilation on Linux is correct. OCCT...
[modules/shaper.git] / src / SketchAPI / SketchAPI_Circle.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchAPI_Circle.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "SketchAPI_Circle.h"
8
9 #include <GeomAPI_Pnt2d.h>
10
11 #include <ModelHighAPI_Double.h>
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14
15 //==================================================================================================
16 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
18 {
19   initialize();
20 }
21
22 //==================================================================================================
23 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
24                                    double theCenterX,
25                                    double theCenterY,
26                                    double theRadius)
27 : SketchAPI_SketchEntity(theFeature)
28 {
29   if(initialize()) {
30     setByCenterAndRadius(theCenterX, theCenterY, theRadius);
31   }
32 }
33
34 //==================================================================================================
35 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
36                                    const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
37                                    double theRadius)
38 : SketchAPI_SketchEntity(theFeature)
39 {
40   if(initialize()) {
41     setByCenterAndRadius(theCenter, theRadius);
42   }
43 }
44
45 //==================================================================================================
46 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
47                                    double theX1, double theY1,
48                                    double theX2, double theY2,
49                                    double theX3, double theY3)
50 : SketchAPI_SketchEntity(theFeature)
51 {
52   if (initialize()) {
53     setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3);
54   }
55 }
56
57 //==================================================================================================
58 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
59                                    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
60                                    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
61                                    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
62 : SketchAPI_SketchEntity(theFeature)
63 {
64   if (initialize()) {
65     setByThreePoints(thePoint1, thePoint2, thePoint3);
66   }
67 }
68
69 //==================================================================================================
70 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
71                                    const ModelHighAPI_Selection& theExternal)
72 : SketchAPI_SketchEntity(theFeature)
73 {
74   if (initialize()) {
75     setByExternal(theExternal);
76   }
77 }
78
79 //==================================================================================================
80 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
81                                    const std::string& theExternalName)
82 : SketchAPI_SketchEntity(theFeature)
83 {
84   if (initialize()) {
85     setByExternalName(theExternalName);
86   }
87 }
88
89 //==================================================================================================
90 SketchAPI_Circle::~SketchAPI_Circle()
91 {
92
93 }
94
95 //==================================================================================================
96 void SketchAPI_Circle::setByCenterAndRadius(double theCenterX, double theCenterY, double theRadius)
97 {
98   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
99   fillAttribute(center(), theCenterX, theCenterY);
100   fillAttribute(theRadius, myradius);
101
102   execute();
103 }
104
105 //==================================================================================================
106 void SketchAPI_Circle::setByCenterAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
107                                             double theRadius)
108 {
109   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
110   fillAttribute(theCenter, mycenter);
111   fillAttribute(theRadius, myradius);
112
113   execute();
114 }
115
116 //==================================================================================================
117 void SketchAPI_Circle::setByThreePoints(double theX1, double theY1,
118                                         double theX2, double theY2,
119                                         double theX3, double theY3)
120 {
121   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
122   fillAttribute(firstPoint(), theX1, theY1);
123   fillAttribute(secondPoint(), theX2, theY2);
124   fillAttribute(thirdPoint(), theX3, theY3);
125
126   execute();
127 }
128
129 //==================================================================================================
130 void SketchAPI_Circle::setByThreePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
131                                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
132                                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
133 {
134   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
135   fillAttribute(thePoint1, myfirstPoint);
136   fillAttribute(thePoint2, mysecondPoint);
137   fillAttribute(thePoint3, mythirdPoint);
138
139   execute();
140 }
141
142 //==================================================================================================
143 void SketchAPI_Circle::setByExternal(const ModelHighAPI_Selection & theExternal)
144 {
145   fillAttribute(theExternal, external());
146
147   execute();
148 }
149
150 //==================================================================================================
151 void SketchAPI_Circle::setByExternalName(const std::string & theExternalName)
152 {
153   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
154
155   execute();
156 }
157
158 //==================================================================================================
159 void SketchAPI_Circle::setCenter(double theX, double theY)
160 {
161   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
162   fillAttribute(center(), theX, theY);
163
164   execute();
165 }
166
167 //==================================================================================================
168 void SketchAPI_Circle::setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter)
169 {
170   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
171   fillAttribute(theCenter, mycenter);
172
173   execute();
174 }
175
176 //==================================================================================================
177 void SketchAPI_Circle::setRadius(double theRadius)
178 {
179   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
180   fillAttribute(ModelHighAPI_Double(theRadius), myradius);
181
182   execute();
183 }
184
185 //==================================================================================================
186 void SketchAPI_Circle::setFirstPoint(double theX, double theY)
187 {
188   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
189   fillAttribute(firstPoint(), theX, theY);
190
191   execute();
192 }
193
194 //==================================================================================================
195 void SketchAPI_Circle::setFirstPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
196 {
197   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
198   fillAttribute(thePoint, myfirstPoint);
199
200   execute();
201 }
202
203 //==================================================================================================
204 void SketchAPI_Circle::setSecondPoint(double theX, double theY)
205 {
206   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
207   fillAttribute(secondPoint(), theX, theY);
208
209   execute();
210 }
211
212 //==================================================================================================
213 void SketchAPI_Circle::setSecondPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
214 {
215   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
216   fillAttribute(thePoint, mysecondPoint);
217
218   execute();
219 }
220
221 //==================================================================================================
222 void SketchAPI_Circle::setThirdPoint(double theX, double theY)
223 {
224   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
225   fillAttribute(thirdPoint(), theX, theY);
226
227   execute();
228 }
229
230 //==================================================================================================
231 void SketchAPI_Circle::setThirdPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
232 {
233   fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
234   fillAttribute(thePoint, mythirdPoint);
235
236   execute();
237 }