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 // File: SketchPlugin_MacroEllipse.h
21 // Created: 26 April 2017
22 // Author: Artem ZHIDKOV
24 #ifndef SketchPlugin_MacroEllipse_H_
25 #define SketchPlugin_MacroEllipse_H_
27 #include <ModelAPI_IReentrant.h>
28 #include <SketchPlugin.h>
29 #include <SketchPlugin_SketchEntity.h>
30 #include <GeomAPI_IPresentable.h>
32 ////class GeomAPI_Circ2d;
35 /**\class SketchPlugin_MacroEllipse
37 * \brief Feature for creation of the new ellipse in Sketch.
39 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
40 public GeomAPI_IPresentable,
41 public ModelAPI_IReentrant
44 /// Ellipse feature kind
45 inline static const std::string& ID()
47 static const std::string ID("SketchMacroEllipse");
51 /// 2D point - center of the ellipse.
52 inline static const std::string& CENTER_POINT_ID()
54 static const std::string ID("center_point");
58 /// Reference for center point selection.
59 inline static const std::string& CENTER_POINT_REF_ID()
61 static const std::string ID("center_point_ref");
65 /// 2D point - major axis point of the ellipse.
66 inline static const std::string& MAJOR_AXIS_POINT_ID()
68 static const std::string ID("major_axis_point");
72 /// Reference for major axis point selection.
73 inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
75 static const std::string ID("major_axis_point_ref");
79 /// 2D point - passed point of the ellipse
80 inline static const std::string& PASSED_POINT_ID()
82 static const std::string ID("passed_point");
86 /// Reference for passed point selection.
87 inline static const std::string& PASSED_POINT_REF_ID()
89 static const std::string ID("passed_point_ref");
93 /// Major radius of the ellipse
94 inline static const std::string& MAJOR_RADIUS_ID()
96 static const std::string ID("ellipse_major_radius");
100 /// Minor radius of the ellipse
101 inline static const std::string& MINOR_RADIUS_ID()
103 static const std::string ID("ellipse_minor_radius");
107 /// Returns the kind of a feature
108 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
110 static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
114 /// \brief Request for initialization of data model of the feature: adding all attributes.
115 SKETCHPLUGIN_EXPORT virtual void initAttributes();
117 /// Called on change of any argument-attribute of this object
118 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
120 /// Returns the AIS preview
121 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
123 /// Creates a new part document if needed
124 SKETCHPLUGIN_EXPORT virtual void execute();
126 /// Reimplemented from ModelAPI_Feature::isMacro().
128 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
131 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
134 /// Apply information of the message to current object. It fills reference object,
135 /// tangent type and tangent point refence in case of tangent arc
136 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
138 /// Use plugin manager for features creation
139 SketchPlugin_MacroEllipse();
142 void constraintsForEllipse(FeaturePtr theEllipseFeature);
144 FeaturePtr createEllipseFeature();
147 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
148 std::shared_ptr<GeomAPI_Pnt2d> myFocus;
149 double myMajorRadius;
150 double myMinorRadius;