Salome HOME
Update copyrights
[modules/shaper.git] / src / SketchAPI / SketchAPI_MacroCircle.cpp
1 // Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 //
19
20 #include "SketchAPI_MacroCircle.h"
21
22 #include <GeomAPI_Pnt2d.h>
23
24 #include <ModelHighAPI_Double.h>
25 #include <ModelHighAPI_Dumper.h>
26 #include <ModelHighAPI_Selection.h>
27 #include <ModelHighAPI_Tools.h>
28
29 //==================================================================================================
30 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature)
31 : SketchAPI_SketchEntity(theFeature)
32 {
33   initialize();
34 }
35
36 //==================================================================================================
37 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
38                                              double theCenterX,
39                                              double theCenterY,
40                                              double thePassedX,
41                                              double thePassedY)
42 : SketchAPI_SketchEntity(theFeature)
43 {
44   if(initialize()) {
45     setByCenterAndPassedPoints(theCenterX, theCenterY, thePassedX, thePassedY);
46   }
47 }
48
49 //==================================================================================================
50 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
51                                              const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
52                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
53 : SketchAPI_SketchEntity(theFeature)
54 {
55   if(initialize()) {
56     setByCenterAndPassedPoints(theCenterPoint, thePassedPoint);
57   }
58 }
59
60 //==================================================================================================
61 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
62                                              double theX1, double theY1,
63                                              double theX2, double theY2,
64                                              double theX3, double theY3)
65 : SketchAPI_SketchEntity(theFeature)
66 {
67   if(initialize()) {
68     setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3);
69   }
70 }
71
72 //==================================================================================================
73 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
74                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
75                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
76                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
77 : SketchAPI_SketchEntity(theFeature)
78 {
79   if(initialize()) {
80     setByThreePoints(thePoint1, thePoint2, thePoint3);
81   }
82 }
83
84 //==================================================================================================
85 SketchAPI_MacroCircle::~SketchAPI_MacroCircle()
86 {
87 }
88
89 //==================================================================================================
90 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(double theCenterX,
91                                                        double theCenterY,
92                                                        double thePassedX,
93                                                        double thePassedY)
94 {
95   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
96   fillAttribute(centerPoint(), theCenterX, theCenterY);
97   fillAttribute(passedPoint(), thePassedX, thePassedY);
98
99   execute();
100 }
101
102 //==================================================================================================
103 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(
104     const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
105     const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
106 {
107   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
108   fillAttribute(theCenterPoint, mycenterPoint);
109   fillAttribute(thePassedPoint, mypassedPoint);
110
111   execute();
112 }
113
114 //==================================================================================================
115 void SketchAPI_MacroCircle::setByThreePoints(double theX1, double theY1,
116                                              double theX2, double theY2,
117                                              double theX3, double theY3)
118 {
119   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
120   fillAttribute(firstPoint(), theX1, theY1);
121   fillAttribute(secondPoint(), theX2, theY2);
122   fillAttribute(thirdPoint(), theX3, theY3);
123
124   execute();
125 }
126
127 //==================================================================================================
128 void SketchAPI_MacroCircle::setByThreePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
129                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
130                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
131 {
132   fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
133   fillAttribute(thePoint1, myfirstPoint);
134   fillAttribute(thePoint2, mysecondPoint);
135   fillAttribute(thePoint3, mythirdPoint);
136
137   execute();
138 }