Salome HOME
Copyright update 2022
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Ellipse.h
1 // Copyright (C) 2017-2022  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 #ifndef SketchPlugin_Ellipse_H_
21 #define SketchPlugin_Ellipse_H_
22
23 #include <SketchPlugin.h>
24 #include <SketchPlugin_SketchEntity.h>
25
26 /**\class SketchPlugin_Ellipse
27  * \ingroup Plugins
28  * \brief Feature for creation of the new ellipse in Sketch.
29  */
30 class SketchPlugin_Ellipse: public SketchPlugin_SketchEntity
31 {
32  public:
33   /// Ellipse feature kind
34   inline static const std::string& ID()
35   {
36     static const std::string ID("SketchEllipse");
37     return ID;
38   }
39
40   /// 2D point - center of the ellipse
41   inline static const std::string& CENTER_ID()
42   {
43     static const std::string ID("ellipse_center");
44     return ID;
45   }
46
47   /// 2D point - focus of the ellipse
48   inline static const std::string& FIRST_FOCUS_ID()
49   {
50     static const std::string ID("ellipse_first_focus");
51     return ID;
52   }
53   /// 2D point - second focus of the ellipse
54   inline static const std::string& SECOND_FOCUS_ID()
55   {
56     static const std::string ID("ellipse_second_focus");
57     return ID;
58   }
59
60   /// 2D point - start point of major axis
61   inline static const std::string& MAJOR_AXIS_START_ID()
62   {
63     static const std::string ID("ellipse_major_axis_start_point");
64     return ID;
65   }
66   /// 2D point - end point of major axis
67   inline static const std::string& MAJOR_AXIS_END_ID()
68   {
69     static const std::string ID("ellipse_major_axis_end_point");
70     return ID;
71   }
72
73   /// 2D point - start point of minor axis
74   inline static const std::string& MINOR_AXIS_START_ID()
75   {
76     static const std::string ID("ellipse_minor_axis_start_point");
77     return ID;
78   }
79   /// 2D point - end point of minor axis
80   inline static const std::string& MINOR_AXIS_END_ID()
81   {
82     static const std::string ID("ellipse_minor_axis_end_point");
83     return ID;
84   }
85
86   /// Major radius of the ellipse
87   inline static const std::string& MAJOR_RADIUS_ID()
88   {
89     static const std::string ID("ellipse_major_radius");
90     return ID;
91   }
92
93   /// Minor radius of the ellipse
94   inline static const std::string& MINOR_RADIUS_ID()
95   {
96     static const std::string ID("ellipse_minor_radius");
97     return ID;
98   }
99
100   /// Returns the kind of a feature
101   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
102   {
103     static std::string MY_KIND = SketchPlugin_Ellipse::ID();
104     return MY_KIND;
105   }
106
107   /// Returns true is sketch element is under the rigid constraint
108   SKETCHPLUGIN_EXPORT virtual bool isFixed();
109
110   /// Called on change of any argument-attribute of this object
111   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
112
113   /// Creates a new part document if needed
114   SKETCHPLUGIN_EXPORT virtual void execute();
115
116   /// Use plugin manager for features creation
117   SketchPlugin_Ellipse();
118
119 protected:
120   /// \brief Initializes attributes of derived class.
121   virtual void initDerivedClassAttributes();
122
123 private:
124   bool fillCharacteristicPoints();
125
126   void createEllipse(SketchPlugin_Sketch* theSketch, const int theResultIndex);
127 };
128
129 #endif