1 // Copyright (C) 2014-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SketchAPI_MacroCircle.h"
22 #include <GeomAPI_Pnt2d.h>
24 #include <ModelHighAPI_Double.h>
25 #include <ModelHighAPI_Dumper.h>
26 #include <ModelHighAPI_Selection.h>
27 #include <ModelHighAPI_Tools.h>
29 #include <SketchAPI_Point.h>
30 #include <SketchPlugin_ConstraintCoincidenceInternal.h>
32 //==================================================================================================
33 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature)
34 : SketchAPI_SketchEntity(theFeature)
39 //==================================================================================================
40 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
46 : SketchAPI_SketchEntity(theFeature)
49 setByCenterAndPassedPoints(theCenterX, theCenterY, thePassedX, thePassedY, theAngle);
53 //==================================================================================================
54 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
55 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
56 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
58 : SketchAPI_SketchEntity(theFeature)
61 setByCenterAndPassedPoints(theCenterPoint, thePassedPoint, theAngle);
65 //==================================================================================================
66 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
67 double theX1, double theY1,
68 double theX2, double theY2,
69 double theX3, double theY3,
71 : SketchAPI_SketchEntity(theFeature)
74 setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3, theAngle);
78 //==================================================================================================
79 SketchAPI_MacroCircle::SketchAPI_MacroCircle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
80 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
81 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
82 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
84 : SketchAPI_SketchEntity(theFeature)
87 setByThreePoints(thePoint1, thePoint2, thePoint3, theAngle);
91 //==================================================================================================
92 SketchAPI_MacroCircle::~SketchAPI_MacroCircle()
96 //==================================================================================================
97 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(double theCenterX,
103 fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
104 fillAttribute(centerPoint(), theCenterX, theCenterY);
105 fillAttribute(passedPoint(), thePassedX, thePassedY);
108 feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
111 fillAttribute(theAngle, angle());
116 //==================================================================================================
117 void SketchAPI_MacroCircle::setByCenterAndPassedPoints(
118 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
119 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
122 fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS(), mycircleType);
123 fillAttribute(theCenterPoint, mycenterPoint);
124 fillAttribute(thePassedPoint, mypassedPoint);
127 feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
130 fillAttribute(theAngle, angle());
135 //==================================================================================================
136 void SketchAPI_MacroCircle::setByThreePoints(double theX1, double theY1,
137 double theX2, double theY2,
138 double theX3, double theY3,
141 fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
142 fillAttribute(firstPoint(), theX1, theY1);
143 fillAttribute(secondPoint(), theX2, theY2);
144 fillAttribute(thirdPoint(), theX3, theY3);
147 feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
150 fillAttribute(theAngle, angle());
155 //==================================================================================================
156 void SketchAPI_MacroCircle::setByThreePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
157 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
158 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
161 fillAttribute(SketchPlugin_MacroCircle::CIRCLE_TYPE_BY_THREE_POINTS(), mycircleType);
162 fillAttribute(thePoint1, myfirstPoint);
163 fillAttribute(thePoint2, mysecondPoint);
164 fillAttribute(thePoint3, mythirdPoint);
167 feature()->integer(SketchPlugin_MacroCircle::VERSION_ID())->value() > 0;
170 fillAttribute(theAngle, angle());
175 // return created point
176 std::shared_ptr<SketchAPI_SketchEntity> SketchAPI_MacroCircle::createdPoint() const
178 std::shared_ptr<SketchAPI_SketchEntity> anEnt;
180 AttributeRefAttrPtr anRef = feature()->refattr(SketchPlugin_MacroCircle::ROTATE_POINT_REF_ID());
181 if (!anRef->isInitialized())
184 ObjectPtr aPointObj = anRef->object();
185 FeaturePtr aFeature = ModelAPI_Feature::feature(aPointObj);
186 if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
188 anEnt = std::shared_ptr < SketchAPI_SketchEntity>(new SketchAPI_Point(aFeature));