Salome HOME
Merge remote-tracking branch 'remotes/origin/Filters_Development_2'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroEllipse.h
1 // Copyright (C) 2017-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:        SketchPlugin_MacroEllipse.h
21 // Created:     26 April 2017
22 // Author:      Artem ZHIDKOV
23
24 #ifndef SketchPlugin_MacroEllipse_H_
25 #define SketchPlugin_MacroEllipse_H_
26
27 #include <ModelAPI_IReentrant.h>
28 #include <SketchPlugin.h>
29 #include <SketchPlugin_SketchEntity.h>
30 #include <GeomAPI_IPresentable.h>
31
32 ////class GeomAPI_Circ2d;
33 class GeomAPI_Pnt2d;
34
35 /**\class SketchPlugin_MacroEllipse
36  * \ingroup Plugins
37  * \brief Feature for creation of the new ellipse in Sketch.
38  */
39 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
40                                  public GeomAPI_IPresentable,
41                                  public ModelAPI_IReentrant
42 {
43  public:
44   /// Ellipse feature kind
45   inline static const std::string& ID()
46   {
47     static const std::string ID("SketchMacroEllipse");
48     return ID;
49   }
50
51   /// 2D point - center of the ellipse.
52   inline static const std::string& CENTER_POINT_ID()
53   {
54     static const std::string ID("center_point");
55     return ID;
56   }
57
58   /// Reference for center point selection.
59   inline static const std::string& CENTER_POINT_REF_ID()
60   {
61     static const std::string ID("center_point_ref");
62     return ID;
63   }
64
65   /// 2D point - major axis point of the ellipse.
66   inline static const std::string& MAJOR_AXIS_POINT_ID()
67   {
68     static const std::string ID("major_axis_point");
69     return ID;
70   }
71
72   /// Reference for major axis point selection.
73   inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
74   {
75     static const std::string ID("major_axis_point_ref");
76     return ID;
77   }
78
79   /// 2D point - passed point of the ellipse
80   inline static const std::string& PASSED_POINT_ID()
81   {
82     static const std::string ID("passed_point");
83     return ID;
84   }
85
86   /// Reference for passed point selection.
87   inline static const std::string& PASSED_POINT_REF_ID()
88   {
89     static const std::string ID("passed_point_ref");
90     return ID;
91   }
92
93   /// Major radius of the ellipse
94   inline static const std::string& MAJOR_RADIUS_ID()
95   {
96     static const std::string ID("ellipse_major_radius");
97     return ID;
98   }
99
100   /// Minor radius of the ellipse
101   inline static const std::string& MINOR_RADIUS_ID()
102   {
103     static const std::string ID("ellipse_minor_radius");
104     return ID;
105   }
106
107   /// Returns the kind of a feature
108   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
109   {
110     static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
111     return MY_KIND;
112   }
113
114   /// \brief Request for initialization of data model of the feature: adding all attributes.
115   SKETCHPLUGIN_EXPORT virtual void initAttributes();
116
117   /// Called on change of any argument-attribute of this object
118   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
119
120   /// Returns the AIS preview
121   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
122
123   /// Creates a new part document if needed
124   SKETCHPLUGIN_EXPORT virtual void execute();
125
126   /// Reimplemented from ModelAPI_Feature::isMacro().
127   /// \returns true
128   SKETCHPLUGIN_EXPORT virtual bool isMacro() const
129   {return true;}
130
131   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
132   {return false;}
133
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);
137
138   /// Use plugin manager for features creation
139   SketchPlugin_MacroEllipse();
140
141 private:
142   void constraintsForEllipse(FeaturePtr theEllipseFeature);
143
144   FeaturePtr createEllipseFeature();
145
146 private:
147   std::shared_ptr<GeomAPI_Pnt2d> myCenter;
148   std::shared_ptr<GeomAPI_Pnt2d> myFocus;
149   double                         myMajorRadius;
150   double                         myMinorRadius;
151 };
152
153 #endif