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 #ifndef SketchPlugin_MacroCircle_H_
21 #define SketchPlugin_MacroCircle_H_
23 #include <ModelAPI_IReentrant.h>
25 #include "SketchPlugin.h"
27 #include "SketchPlugin_SketchEntity.h"
29 #include <GeomAPI_IPresentable.h>
34 /**\class SketchPlugin_MacroCircle
36 * \brief Feature for creation of the new circle in Sketch.
38 class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
39 public GeomAPI_IPresentable,
40 public ModelAPI_IReentrant
43 /// Circle feature kind
44 inline static const std::string& ID()
46 static const std::string ID("SketchMacroCircle");
50 inline static const std::string& CIRCLE_TYPE()
52 static const std::string ID("circle_type");
56 inline static const std::string& EDIT_CIRCLE_TYPE()
58 static const std::string ID("edit_circle_type");
62 /// Creation method by center and passed point.
63 inline static const std::string& CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
65 static const std::string ID("circle_type_by_center_and_passed_points");
69 /// Creation method by three points.
70 inline static const std::string& CIRCLE_TYPE_BY_THREE_POINTS()
72 static const std::string ID("circle_type_by_three_points");
76 /// 2D point - center of the circle.
77 inline static const std::string& CENTER_POINT_ID()
79 static const std::string ID("center_point");
83 /// Reference for center point selection.
84 inline static const std::string& CENTER_POINT_REF_ID()
86 static const std::string ID("center_point_ref");
90 /// 2D point - passed point of the circle
91 inline static const std::string& PASSED_POINT_ID()
93 static const std::string ID("passed_point");
97 /// Reference for passed point selection.
98 inline static const std::string& PASSED_POINT_REF_ID()
100 static const std::string ID("passed_point_ref");
105 inline static const std::string& FIRST_POINT_ID()
107 static const std::string ID("first_point");
111 /// Reference for first point selection.
112 inline static const std::string& FIRST_POINT_REF_ID()
114 static const std::string ID("first_point_ref");
119 inline static const std::string& SECOND_POINT_ID()
121 static const std::string ID("second_point");
125 /// Reference for second point selection.
126 inline static const std::string& SECOND_POINT_REF_ID()
128 static const std::string ID("second_point_ref");
133 inline static const std::string& THIRD_POINT_ID()
135 static const std::string ID("third_point");
139 /// Reference for third point selection.
140 inline static const std::string& THIRD_POINT_REF_ID()
142 static const std::string ID("third_point_ref");
146 /// Radius of the circle
147 inline static const std::string& CIRCLE_RADIUS_ID()
149 static const std::string ID("circle_radius");
153 /// Returns the kind of a feature
154 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
156 static std::string MY_KIND = SketchPlugin_MacroCircle::ID();
160 /// \brief Request for initialization of data model of the feature: adding all attributes.
161 SKETCHPLUGIN_EXPORT virtual void initAttributes();
163 /// Called on change of any argument-attribute of this object
164 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
166 /// Returns the AIS preview
167 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
169 /// Creates a new part document if needed
170 SKETCHPLUGIN_EXPORT virtual void execute();
172 /// Reimplemented from ModelAPI_Feature::isMacro().
174 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
176 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
178 /// Apply information of the message to current object. It fills reference object,
179 /// tangent type and tangent point refence in case of tangent arc
180 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
182 /// Use plugin manager for features creation
183 SketchPlugin_MacroCircle();
186 void fillByCenterAndPassed();
187 void fillByThreePoints();
188 /// set fields if only two of three points is initialized
189 void fillByTwoPassedPoints();
191 void constraintsForCircleByCenterAndPassed(FeaturePtr theCircleFeature);
192 void constraintsForCircleByThreePoints(FeaturePtr theCircleFeature);
194 FeaturePtr createCircleFeature();
197 std::shared_ptr<GeomAPI_Pnt2d> myCenter;