1 // Copyright (C) 2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 // File: SketchPlugin_MacroEllipse.h
22 // Created: 26 April 2017
23 // Author: Artem ZHIDKOV
25 #ifndef SketchPlugin_MacroEllipse_H_
26 #define SketchPlugin_MacroEllipse_H_
28 #include <ModelAPI_IReentrant.h>
29 #include <SketchPlugin.h>
30 #include <SketchPlugin_SketchEntity.h>
31 #include <GeomAPI_IPresentable.h>
33 ////class GeomAPI_Circ2d;
36 /**\class SketchPlugin_MacroEllipse
38 * \brief Feature for creation of the new ellipse in Sketch.
40 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
41 public GeomAPI_IPresentable,
42 public ModelAPI_IReentrant
45 /// Ellipse feature kind
46 inline static const std::string& ID()
48 static const std::string ID("SketchMacroEllipse");
52 /// 2D point - center of the ellipse.
53 inline static const std::string& CENTER_POINT_ID()
55 static const std::string ID("center_point");
59 /// Reference for center point selection.
60 inline static const std::string& CENTER_POINT_REF_ID()
62 static const std::string ID("center_point_ref");
66 /// 2D point - major axis point of the ellipse.
67 inline static const std::string& MAJOR_AXIS_POINT_ID()
69 static const std::string ID("major_axis_point");
73 /// Reference for major axis point selection.
74 inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
76 static const std::string ID("major_axis_point_ref");
80 /// 2D point - passed point of the ellipse
81 inline static const std::string& PASSED_POINT_ID()
83 static const std::string ID("passed_point");
87 /// Reference for passed point selection.
88 inline static const std::string& PASSED_POINT_REF_ID()
90 static const std::string ID("passed_point_ref");
94 /// Major radius of the ellipse
95 inline static const std::string& MAJOR_RADIUS_ID()
97 static const std::string ID("ellipse_major_radius");
101 /// Minor radius of the ellipse
102 inline static const std::string& MINOR_RADIUS_ID()
104 static const std::string ID("ellipse_minor_radius");
108 /// Returns the kind of a feature
109 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
111 static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
115 /// \brief Request for initialization of data model of the feature: adding all attributes.
116 SKETCHPLUGIN_EXPORT virtual void initAttributes();
118 /// Called on change of any argument-attribute of this object
119 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
121 /// Returns the AIS preview
122 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
124 /// Creates a new part document if needed
125 SKETCHPLUGIN_EXPORT virtual void execute();
127 /// Moves the feature
128 /// \param theDeltaX the delta for X coordinate is moved
129 /// \param theDeltaY the delta for Y coordinate is moved
130 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
133 /// Reimplemented from ModelAPI_Feature::isMacro().
135 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
138 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
141 /// Apply information of the message to current object. It fills reference object,
142 /// tangent type and tangent point refence in case of tangent arc
143 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
145 /// Use plugin manager for features creation
146 SketchPlugin_MacroEllipse();
149 void constraintsForEllipse(FeaturePtr theEllipseFeature);
151 FeaturePtr createEllipseFeature();
154 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
155 std::shared_ptr<GeomAPI_Pnt2d> myFocus;
156 double myMajorRadius;
157 double myMinorRadius;