1 // Copyright (C) 2017-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_MacroEllipse_H_
21 #define SketchPlugin_MacroEllipse_H_
23 #include <ModelAPI_IReentrant.h>
24 #include <SketchPlugin.h>
25 #include <SketchPlugin_SketchEntity.h>
26 #include <GeomAPI_IPresentable.h>
30 /**\class SketchPlugin_MacroEllipse
32 * \brief Feature for creation of the new ellipse in Sketch.
34 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
35 public GeomAPI_IPresentable,
36 public ModelAPI_IReentrant
39 /// Ellipse feature kind
40 inline static const std::string& ID()
42 static const std::string ID("SketchMacroEllipse");
46 static const std::string& ELLIPSE_TYPE()
48 static const std::string ID("ellipse_type");
52 static const std::string& ELLIPSE_TYPE_BY_CENTER_AXIS_POINT()
54 static const std::string ID("by_center_axis_point");
57 static const std::string& ELLIPSE_TYPE_BY_AXIS_AND_POINT()
59 static const std::string ID("by_major_axis_and_point");
63 static const std::string& EDIT_ELLIPSE_TYPE()
65 static const std::string ID("edit_ellipse_type");
69 /// Attribute for the first point selected during ellipse creation.
70 inline static const std::string& CENTER_POINT_ID()
72 static const std::string ID("first_point");
76 /// Reference to the first selected point.
77 inline static const std::string& CENTER_POINT_REF_ID()
79 static const std::string ID("first_point_ref");
83 /// Attribute for the second point selected during ellipse creation.
84 inline static const std::string& MAJOR_AXIS_POINT_ID()
86 static const std::string ID("second_point");
90 /// Reference to the second selected point.
91 inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
93 static const std::string ID("second_point_ref");
97 /// Attribute for the third point selected during ellipse creation.
98 inline static const std::string& PASSED_POINT_ID()
100 static const std::string ID("passed_point");
104 /// Reference for passed point selection.
105 inline static const std::string& PASSED_POINT_REF_ID()
107 static const std::string ID("passed_point_ref");
111 /// Attribute for the first point selected during ellipse creation.
112 inline static const std::string& MAJOR_AXIS_START_ID()
114 static const std::string ID("first_point_1");
118 /// Reference to the first selected point.
119 inline static const std::string& MAJOR_AXIS_START_REF_ID()
121 static const std::string ID("first_point_ref_1");
125 /// Attribute for the second point selected during ellipse creation.
126 inline static const std::string& MAJOR_AXIS_END_ID()
128 static const std::string ID("second_point_1");
132 /// Reference to the second selected point.
133 inline static const std::string& MAJOR_AXIS_END_REF_ID()
135 static const std::string ID("second_point_ref_1");
139 /// Attribute for the third point selected during ellipse creation.
140 inline static const std::string& PASSED_POINT_1_ID()
142 static const std::string ID("passed_point_1");
146 /// Reference for passed point selection.
147 inline static const std::string& PASSED_POINT_1_REF_ID()
149 static const std::string ID("passed_point_ref_1");
153 /// Major radius of the ellipse
154 inline static const std::string& MAJOR_RADIUS_ID()
156 static const std::string ID("major_radius");
160 /// Minor radius of the ellipse
161 inline static const std::string& MINOR_RADIUS_ID()
163 static const std::string ID("minor_radius");
167 /// Returns the kind of a feature
168 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
170 static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
174 /// \brief Request for initialization of data model of the feature: adding all attributes.
175 SKETCHPLUGIN_EXPORT virtual void initAttributes();
177 /// Called on change of any argument-attribute of this object
178 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
180 /// Returns the AIS preview
181 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
183 /// Creates a new part document if needed
184 SKETCHPLUGIN_EXPORT virtual void execute();
186 /// Reimplemented from ModelAPI_Feature::isMacro().
188 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
191 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
194 /// Apply information of the message to current object. It fills reference object,
195 /// tangent type and tangent point refence in case of tangent arc
196 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
198 /// Use plugin manager for features creation
199 SketchPlugin_MacroEllipse();
202 void constraintsForEllipseByCenterAxisAndPassed(FeaturePtr theEllipseFeature);
203 void constraintsForEllipseByMajoxAxisAndPassed(FeaturePtr theEllipseFeature);
205 FeaturePtr createEllipseFeature();
208 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
209 std::shared_ptr<GeomAPI_Pnt2d> myFocus;
210 double myMajorRadius;
211 double myMinorRadius;