]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_MacroEllipse.h
Salome HOME
Task 2.1. Creation of ellipses and arcs of ellipse.
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroEllipse.h
1 // Copyright (C) 2017-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_MacroEllipse.h
4 // Created:     26 April 2017
5 // Author:      Artem ZHIDKOV
6
7 #ifndef SketchPlugin_MacroEllipse_H_
8 #define SketchPlugin_MacroEllipse_H_
9
10 #include <ModelAPI_IReentrant.h>
11 #include <SketchPlugin.h>
12 #include <SketchPlugin_SketchEntity.h>
13 #include <GeomAPI_IPresentable.h>
14
15 ////class GeomAPI_Circ2d;
16 class GeomAPI_Pnt2d;
17
18 /**\class SketchPlugin_MacroEllipse
19  * \ingroup Plugins
20  * \brief Feature for creation of the new ellipse in Sketch.
21  */
22 class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
23                                  public GeomAPI_IPresentable,
24                                  public ModelAPI_IReentrant
25 {
26  public:
27   /// Ellipse feature kind
28   inline static const std::string& ID()
29   {
30     static const std::string ID("SketchMacroEllipse");
31     return ID;
32   }
33
34   /// 2D point - center of the ellipse.
35   inline static const std::string& CENTER_POINT_ID()
36   {
37     static const std::string ID("center_point");
38     return ID;
39   }
40
41   /// Reference for center point selection.
42   inline static const std::string& CENTER_POINT_REF_ID()
43   {
44     static const std::string ID("center_point_ref");
45     return ID;
46   }
47
48   /// 2D point - major axis point of the ellipse.
49   inline static const std::string& MAJOR_AXIS_POINT_ID()
50   {
51     static const std::string ID("major_axis_point");
52     return ID;
53   }
54
55   /// Reference for major axis point selection.
56   inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
57   {
58     static const std::string ID("major_axis_point_ref");
59     return ID;
60   }
61
62   /// 2D point - passed point of the ellipse
63   inline static const std::string& PASSED_POINT_ID()
64   {
65     static const std::string ID("passed_point");
66     return ID;
67   }
68
69   /// Reference for passed point selection.
70   inline static const std::string& PASSED_POINT_REF_ID()
71   {
72     static const std::string ID("passed_point_ref");
73     return ID;
74   }
75
76   /// Major radius of the ellipse
77   inline static const std::string& MAJOR_RADIUS_ID()
78   {
79     static const std::string ID("ellipse_major_radius");
80     return ID;
81   }
82
83   /// Minor radius of the ellipse
84   inline static const std::string& MINOR_RADIUS_ID()
85   {
86     static const std::string ID("ellipse_minor_radius");
87     return ID;
88   }
89
90   /// Returns the kind of a feature
91   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
92   {
93     static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
94     return MY_KIND;
95   }
96
97   /// \brief Request for initialization of data model of the feature: adding all attributes.
98   SKETCHPLUGIN_EXPORT virtual void initAttributes();
99
100   /// Called on change of any argument-attribute of this object
101   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
102
103   /// Returns the AIS preview
104   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
105
106   /// Creates a new part document if needed
107   SKETCHPLUGIN_EXPORT virtual void execute();
108
109   /// Moves the feature
110   /// \param theDeltaX the delta for X coordinate is moved
111   /// \param theDeltaY the delta for Y coordinate is moved
112   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
113   {}
114
115   /// Reimplemented from ModelAPI_Feature::isMacro().
116   /// \returns true
117   SKETCHPLUGIN_EXPORT virtual bool isMacro() const
118   {return true;}
119
120   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
121   {return false;}
122
123   /// Apply information of the message to current object. It fills reference object,
124   /// tangent type and tangent point refence in case of tangent arc
125   virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
126
127   /// Use plugin manager for features creation
128   SketchPlugin_MacroEllipse();
129
130 private:
131   void constraintsForEllipse(FeaturePtr theEllipseFeature);
132
133   FeaturePtr createEllipseFeature();
134
135 private:
136   std::shared_ptr<GeomAPI_Pnt2d> myCenter;
137   std::shared_ptr<GeomAPI_Pnt2d> myFocus;
138   double                         myMajorRadius;
139   double                         myMinorRadius;
140 };
141
142 #endif