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