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_MacroEllipticArc_H_
21 #define SketchPlugin_MacroEllipticArc_H_
23 #include <ModelAPI_IReentrant.h>
24 #include <SketchPlugin.h>
25 #include <SketchPlugin_SketchEntity.h>
26 #include <GeomAPI_IPresentable.h>
31 /**\class SketchPlugin_MacroEllipticArc
33 * \brief Feature for creation of the new elliptic arc in Sketch.
35 class SketchPlugin_MacroEllipticArc: public SketchPlugin_SketchEntity,
36 public GeomAPI_IPresentable,
37 public ModelAPI_IReentrant
40 /// Elliptic arc feature kind
41 inline static const std::string& ID()
43 static const std::string ID("SketchMacroEllipticArc");
47 /// Attribute for the central point selected during elliptic arc creation.
48 inline static const std::string& CENTER_ID()
50 static const std::string ID("center");
54 /// Reference to the first selected point (center of ellipse).
55 inline static const std::string& CENTER_REF_ID()
57 static const std::string ID("center_ref");
61 /// Attribute for the point on major semi-axis selected during elliptic arc creation.
62 inline static const std::string& MAJOR_AXIS_POINT_ID()
64 static const std::string ID("major_axis_point");
68 /// Reference to the second selected point (major semi-axis of the ellipse).
69 inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
71 static const std::string ID("major_axis_point_ref");
75 /// Attribute for the start point of the elliptic arc selected during creation.
76 inline static const std::string& START_POINT_ID()
78 static const std::string ID("start_point");
82 /// Reference for the start point selection.
83 inline static const std::string& START_POINT_REF_ID()
85 static const std::string ID("start_point_ref");
89 /// Attribute for the end point of the elliptic arc selected during creation.
90 inline static const std::string& END_POINT_ID()
92 static const std::string ID("end_point");
96 /// Reference for the end point selection.
97 inline static const std::string& END_POINT_REF_ID()
99 static const std::string ID("end_point_ref");
103 /// Major radius of the ellipse
104 inline static const std::string& MAJOR_RADIUS_ID()
106 static const std::string ID("major_radius");
110 /// Minor radius of the ellipse
111 inline static const std::string& MINOR_RADIUS_ID()
113 static const std::string ID("minor_radius");
117 /// Flag the arc is reversed
118 inline static const std::string& REVERSED_ID()
120 static const std::string ID("reversed");
124 /// Returns the kind of a feature
125 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
127 static std::string MY_KIND = SketchPlugin_MacroEllipticArc::ID();
131 /// \brief Request for initialization of data model of the feature: adding all attributes.
132 SKETCHPLUGIN_EXPORT virtual void initAttributes();
134 /// Called on change of any argument-attribute of this object
135 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
137 /// Returns the AIS preview
138 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
140 /// Creates a new part document if needed
141 SKETCHPLUGIN_EXPORT virtual void execute();
143 /// Reimplemented from ModelAPI_Feature::isMacro().
145 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
148 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
151 /// Apply information of the message to current object. It fills reference object,
152 /// tangent type and tangent point refence in case of tangent arc
153 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
155 /// Use plugin manager for features creation
156 SketchPlugin_MacroEllipticArc();
159 std::shared_ptr<GeomAPI_Shape> getArcShape();
161 FeaturePtr createEllipticArcFeature();
162 void constraintsForEllipticArc(FeaturePtr theEllipticArc);
165 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
166 std::shared_ptr<GeomAPI_Pnt2d> myMajorAxis;
167 std::shared_ptr<GeomAPI_Pnt2d> myStartPnt;
168 std::shared_ptr<GeomAPI_Pnt2d> myEndPnt;
169 double myMajorRadius;
170 double myMinorRadius;