1 // Copyright (C) 2017-2019 CEA/DEN, EDF R&D
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>
28 ////class GeomAPI_Circ2d;
31 /**\class SketchPlugin_MacroEllipse
33 * \brief Feature for creation of the new ellipse in Sketch.
35 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
36 public GeomAPI_IPresentable,
37 public ModelAPI_IReentrant
40 /// Ellipse feature kind
41 inline static const std::string& ID()
43 static const std::string ID("SketchMacroEllipse");
47 static const std::string& ELLIPSE_TYPE()
49 static const std::string ID("ellipse_type");
53 static const std::string& ELLIPSE_TYPE_BY_CENTER_AXIS_POINT()
55 static const std::string ID("by_center_axis_point");
58 static const std::string& ELLIPSE_TYPE_BY_AXIS_AND_POINT()
60 static const std::string ID("by_major_axis_and_point");
64 static const std::string& EDIT_ELLIPSE_TYPE()
66 static const std::string ID("edit_ellipse_type");
70 /// Attribute for the first point selected during ellipse creation.
71 inline static const std::string& FIRST_POINT_ID()
73 static const std::string ID("first_point");
77 /// Reference to the first selected point.
78 inline static const std::string& FIRST_POINT_REF_ID()
80 static const std::string ID("first_point_ref");
84 /// Attribute for the second point selected during ellipse creation.
85 inline static const std::string& SECOND_POINT_ID()
87 static const std::string ID("second_point");
91 /// Reference to the second selected point.
92 inline static const std::string& SECOND_POINT_REF_ID()
94 static const std::string ID("second_point_ref");
98 /// Attribute for the third point selected during ellipse creation.
99 inline static const std::string& PASSED_POINT_ID()
101 static const std::string ID("passed_point");
105 /// Reference for passed point selection.
106 inline static const std::string& PASSED_POINT_REF_ID()
108 static const std::string ID("passed_point_ref");
112 /// Major radius of the ellipse
113 inline static const std::string& MAJOR_RADIUS_ID()
115 static const std::string ID("major_radius");
119 /// Minor radius of the ellipse
120 inline static const std::string& MINOR_RADIUS_ID()
122 static const std::string ID("minor_radius");
126 /// Returns the kind of a feature
127 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
129 static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
133 /// \brief Request for initialization of data model of the feature: adding all attributes.
134 SKETCHPLUGIN_EXPORT virtual void initAttributes();
136 /// Called on change of any argument-attribute of this object
137 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
139 /// Returns the AIS preview
140 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
142 /// Creates a new part document if needed
143 SKETCHPLUGIN_EXPORT virtual void execute();
145 /// Reimplemented from ModelAPI_Feature::isMacro().
147 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
150 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
153 /// Apply information of the message to current object. It fills reference object,
154 /// tangent type and tangent point refence in case of tangent arc
155 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
157 /// Use plugin manager for features creation
158 SketchPlugin_MacroEllipse();
161 void constraintsForEllipseByCenterAxisAndPassed(FeaturePtr theEllipseFeature);
162 void constraintsForEllipseByMajoxAxisAndPassed(FeaturePtr theEllipseFeature);
164 FeaturePtr createEllipseFeature();
167 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
168 std::shared_ptr<GeomAPI_Pnt2d> myFocus;
169 double myMajorRadius;
170 double myMinorRadius;