Salome HOME
Fix for the issue #2808 : Documentation on the "Groups" panel. Added description...
[modules/shaper.git] / src / SketchAPI / SketchAPI_MacroArc.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_MacroArc.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 #include <SketchPlugin_ConstraintCoincidence.h>
31 #include <SketchPlugin_ConstraintTangent.h>
32
33 /// Obtain constraints prepared by tangent arc
34 static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
35
36 //================================================================================================
37 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
38 : SketchAPI_SketchEntity(theFeature)
39 {
40   initialize();
41 }
42
43 //================================================================================================
44 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45                              double theCenterX, double theCenterY,
46                              double theStartX, double theStartY,
47                              double theEndX, double theEndY,
48                              bool theInversed)
49 : SketchAPI_SketchEntity(theFeature)
50 {
51   if(initialize()) {
52     setByCenterStartEnd(theCenterX, theCenterY, theStartX,
53                         theStartY, theEndX, theEndY, theInversed);
54   }
55 }
56
57 //================================================================================================
58 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
59                              const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
60                              const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
61                              const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
62                              bool theInversed)
63 : SketchAPI_SketchEntity(theFeature)
64 {
65   if(initialize()) {
66     setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
67   }
68 }
69
70 //================================================================================================
71 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
72                              double theStartX, double theStartY,
73                              double theEndX, double theEndY,
74                              double thePassedX, double thePassedY)
75 : SketchAPI_SketchEntity(theFeature)
76 {
77   if (initialize()) {
78     setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
79   }
80 }
81
82 //===============================================================================================
83 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
84                              const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
85                              const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
86                              const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
87 : SketchAPI_SketchEntity(theFeature)
88 {
89   if (initialize()) {
90     setByStartEndPassed(theStart, theEnd, thePassed);
91   }
92 }
93
94 //================================================================================================
95 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
96                              const ModelHighAPI_RefAttr& theTangentPoint,
97                              double theEndX, double theEndY,
98                              bool theInversed)
99 : SketchAPI_SketchEntity(theFeature)
100 {
101   if (initialize()) {
102     setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
103   }
104 }
105
106 //================================================================================================
107 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
108                              const ModelHighAPI_RefAttr& theTangentPoint,
109                              const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
110                              bool theInversed)
111 : SketchAPI_SketchEntity(theFeature)
112 {
113   if (initialize()) {
114     setByTangent(theTangentPoint, theEnd, theInversed);
115   }
116 }
117
118 //================================================================================================
119 SketchAPI_MacroArc::~SketchAPI_MacroArc()
120 {
121
122 }
123
124 //================================================================================================
125 void SketchAPI_MacroArc::setByCenterStartEnd(double theCenterX, double theCenterY,
126                                         double theStartX, double theStartY,
127                                         double theEndX, double theEndY,
128                                         bool theInversed)
129 {
130   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
131   fillAttribute(center(), theCenterX, theCenterY);
132   fillAttribute(startPoint1(), theStartX, theStartY);
133   fillAttribute(endPoint1(), theEndX, theEndY);
134   fillAttribute(theInversed, myreversed);
135
136   execute();
137 }
138
139 //================================================================================================
140 void SketchAPI_MacroArc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
141                                         const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
142                                         const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
143                                         bool theInversed)
144 {
145   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
146   fillAttribute(theCenter, mycenter);
147   fillAttribute(theStart, mystartPoint1);
148   fillAttribute(theEnd, myendPoint1);
149   fillAttribute(theInversed, myreversed);
150
151   execute();
152 }
153
154 //================================================================================================
155 void SketchAPI_MacroArc::setByStartEndPassed(double theStartX, double theStartY,
156                                         double theEndX, double theEndY,
157                                         double thePassedX, double thePassedY)
158 {
159   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
160   fillAttribute(startPoint2(), theStartX, theStartY);
161   fillAttribute(endPoint2(), theEndX, theEndY);
162   fillAttribute(passedPoint(), thePassedX, thePassedY);
163
164   execute();
165 }
166
167 //================================================================================================
168 void SketchAPI_MacroArc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
169                                         const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
170                                         const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
171 {
172   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
173   fillAttribute(theStart, mystartPoint2);
174   fillAttribute(theEnd, myendPoint2);
175   fillAttribute(thePassed, mypassedPoint);
176
177   execute();
178 }
179
180 //================================================================================================
181 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
182                                  double theEndX, double theEndY,
183                                  bool theInversed)
184 {
185   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
186   fillAttribute(theTangentPoint, mytangentPoint);
187   fillAttribute(endPoint3(), theEndX, theEndY);
188   fillAttribute(theInversed, myreversed);
189
190   execute();
191 }
192
193 //================================================================================================
194 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
195                                  const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
196                                  bool theInversed)
197 {
198   fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
199   fillAttribute(theTangentPoint, mytangentPoint);
200   fillAttribute(theEnd, myendPoint3);
201   fillAttribute(theInversed, myreversed);
202
203   execute();
204 }