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>
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& FIRST_POINT_ID()
72 static const std::string ID("first_point");
76 /// Reference to the first selected point.
77 inline static const std::string& FIRST_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& SECOND_POINT_ID()
86 static const std::string ID("second_point");
90 /// Reference to the second selected point.
91 inline static const std::string& SECOND_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 /// Major radius of the ellipse
112 inline static const std::string& MAJOR_RADIUS_ID()
114 static const std::string ID("major_radius");
118 /// Minor radius of the ellipse
119 inline static const std::string& MINOR_RADIUS_ID()
121 static const std::string ID("minor_radius");
125 /// Returns the kind of a feature
126 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
128 static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
132 /// \brief Request for initialization of data model of the feature: adding all attributes.
133 SKETCHPLUGIN_EXPORT virtual void initAttributes();
135 /// Called on change of any argument-attribute of this object
136 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
138 /// Returns the AIS preview
139 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
141 /// Creates a new part document if needed
142 SKETCHPLUGIN_EXPORT virtual void execute();
144 /// Reimplemented from ModelAPI_Feature::isMacro().
146 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
149 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
152 /// Apply information of the message to current object. It fills reference object,
153 /// tangent type and tangent point refence in case of tangent arc
154 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
156 /// Use plugin manager for features creation
157 SketchPlugin_MacroEllipse();
160 void constraintsForEllipseByCenterAxisAndPassed(FeaturePtr theEllipseFeature);
161 void constraintsForEllipseByMajoxAxisAndPassed(FeaturePtr theEllipseFeature);
163 FeaturePtr createEllipseFeature();
166 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
167 std::shared_ptr<GeomAPI_Pnt2d> myFocus;
168 double myMajorRadius;
169 double myMinorRadius;