Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchAPI / SketchAPI_MacroCircle.cpp
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 #include "SketchAPI_MacroCircle.h"
22
23 #include <GeomAPI_Pnt2d.h>
24
25 #include <ModelHighAPI_Double.h>
26 #include <ModelHighAPI_Dumper.h>
27 #include <ModelHighAPI_Selection.h>
28 #include <ModelHighAPI_Tools.h>
29
30 //==================================================================================================
31 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature)
32 : SketchAPI_SketchEntity(theFeature)
33 {
34   initialize();
35 }
36
37 //==================================================================================================
38 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
39                                              double theCenterX,
40                                              double theCenterY,
41                                              double thePassedX,
42                                              double thePassedY)
43 : SketchAPI_SketchEntity(theFeature)
44 {
45   if(initialize()) {
46     setByCenterAndPassedPoints(theCenterX, theCenterY, thePassedX, thePassedY);
47   }
48 }
49
50 //==================================================================================================
51 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
52                                              const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
53                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
54 : SketchAPI_SketchEntity(theFeature)
55 {
56   if(initialize()) {
57     setByCenterAndPassedPoints(theCenterPoint, thePassedPoint);
58   }
59 }
60
61 //==================================================================================================
62 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
63                                              double theX1, double theY1,
64                                              double theX2, double theY2,
65                                              double theX3, double theY3)
66 : SketchAPI_SketchEntity(theFeature)
67 {
68   if(initialize()) {
69     setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3);
70   }
71 }
72
73 //==================================================================================================
74 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
75                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
76                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
77                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
78 : SketchAPI_SketchEntity(theFeature)
79 {
80   if(initialize()) {
81     setByThreePoints(thePoint1, thePoint2, thePoint3);
82   }
83 }
84
85 //==================================================================================================
86 SketchAPI_MacroCircle::~SketchAPI_MacroCircle()
87 {
88 }
89
90 //==================================================================================================
91 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(double theCenterX,
92                                                        double theCenterY,
93                                                        double thePassedX,
94                                                        double thePassedY)
95 {
96   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
97   fillAttribute(centerPoint(), theCenterX, theCenterY);
98   fillAttribute(passedPoint(), thePassedX, thePassedY);
99
100   execute();
101 }
102
103 //==================================================================================================
104 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(
105     const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
106     const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
107 {
108   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
109   fillAttribute(theCenterPoint, mycenterPoint);
110   fillAttribute(thePassedPoint, mypassedPoint);
111
112   execute();
113 }
114
115 //==================================================================================================
116 void SketchAPI_MacroCircle::setByThreePoints(double theX1, double theY1,
117                                              double theX2, double theY2,
118                                              double theX3, double theY3)
119 {
120   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
121   fillAttribute(firstPoint(), theX1, theY1);
122   fillAttribute(secondPoint(), theX2, theY2);
123   fillAttribute(thirdPoint(), theX3, theY3);
124
125   execute();
126 }
127
128 //==================================================================================================
129 void SketchAPI_MacroCircle::setByThreePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
130                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
131                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
132 {
133   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
134   fillAttribute(thePoint1, myfirstPoint);
135   fillAttribute(thePoint2, mysecondPoint);
136   fillAttribute(thePoint3, mythirdPoint);
137
138   execute();
139 }
140
141 //==================================================================================================
142 void SketchAPI_MacroCircle::setCenterPoint(double theX, double theY)
143 {
144   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
145   fillAttribute(centerPoint(), theX, theY);
146
147   execute();
148 }
149
150 //==================================================================================================
151 void SketchAPI_MacroCircle::setCenterPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint)
152 {
153   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
154   fillAttribute(theCenterPoint, mycenterPoint);
155
156   execute();
157 }
158
159 //==================================================================================================
160 void SketchAPI_MacroCircle::setPassedPoint(double theX, double theY)
161 {
162   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
163   fillAttribute(passedPoint(), theX, theY);
164
165   execute();
166 }
167
168 //==================================================================================================
169 void SketchAPI_MacroCircle::setPassedPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
170 {
171   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
172   fillAttribute(thePassedPoint, mypassedPoint);
173
174   execute();
175 }
176
177 //==================================================================================================
178 void SketchAPI_MacroCircle::setFirstPoint(double theX, double theY)
179 {
180   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
181   fillAttribute(firstPoint(), theX, theY);
182
183   execute();
184 }
185
186 //==================================================================================================
187 void SketchAPI_MacroCircle::setFirstPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
188 {
189   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
190   fillAttribute(thePoint, myfirstPoint);
191
192   execute();
193 }
194
195 //==================================================================================================
196 void SketchAPI_MacroCircle::setSecondPoint(double theX, double theY)
197 {
198   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
199   fillAttribute(secondPoint(), theX, theY);
200
201   execute();
202 }
203
204 //==================================================================================================
205 void SketchAPI_MacroCircle::setSecondPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
206 {
207   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
208   fillAttribute(thePoint, mysecondPoint);
209
210   execute();
211 }
212
213 //==================================================================================================
214 void SketchAPI_MacroCircle::setThirdPoint(double theX, double theY)
215 {
216   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
217   fillAttribute(thirdPoint(), theX, theY);
218
219   execute();
220 }
221
222 //==================================================================================================
223 void SketchAPI_MacroCircle::setThirdPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
224 {
225   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
226   fillAttribute(thePoint, mythirdPoint);
227
228   execute();
229 }