]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_MacroArc.h
Salome HOME
Issue #2024: Redesign of circle and arc of circle
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroArc.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_MacroArc.h
4 // Created:     26 May 2014
5 // Author:      Artem ZHIDKOV
6
7 #ifndef SketchPlugin_MacroArc_H_
8 #define SketchPlugin_MacroArc_H_
9
10 #include "SketchPlugin.h"
11
12 #include "SketchPlugin_SketchEntity.h"
13
14 #include <GeomAPI_IPresentable.h>
15
16 class GeomAPI_Pnt2d;
17
18 /**\class SketchPlugin_MacroArc
19  * \ingroup Plugins
20  * \brief Feature for creation of the new arc of circle in PartSet.
21  * The visualization of this object is separated in two parts. The first one is an AIS object
22  * calculated when there is non-initialized attributes of the arc. The second is a result and
23  * it is calculated if all attributes are initialized.
24  */
25 class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
26                              public GeomAPI_IPresentable
27 {
28  public:
29   /// Arc feature kind
30   inline static const std::string& ID()
31   {
32     static const std::string ID("SketchMacroArc");
33     return ID;
34   }
35
36   inline static const std::string& ARC_TYPE()
37   {
38     static const std::string ID("arc_type");
39     return ID;
40   }
41
42   static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS()
43   {
44     static const std::string ID("by_center_and_points");
45     return ID;
46   }
47   static const std::string& ARC_TYPE_BY_THREE_POINTS()
48   {
49     static const std::string ID("by_three_points");
50     return ID;
51   }
52
53   inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE()
54   {
55     static const std::string ID("by_tangent_edge");
56     return ID;
57   }
58
59   /// Central 2D point of the circle which contains the arc
60   inline static const std::string& CENTER_POINT_ID()
61   {
62     static const std::string ID = "center_point";
63     return ID;
64   }
65
66   inline static const std::string& CENTER_POINT_REF_ID()
67   {
68     static const std::string ID = "center_point_ref";
69     return ID;
70   }
71
72   /// Start 2D point of the arc
73   inline static const std::string& START_POINT_1_ID()
74   {
75     static const std::string ID = "start_point_1";
76     return ID;
77   }
78
79   /// Start 2D point of the arc
80   inline static const std::string& START_POINT_2_ID()
81   {
82     static const std::string ID = "start_point_2";
83     return ID;
84   }
85
86   inline static const std::string& START_POINT_REF_ID()
87   {
88     static const std::string ID = "start_point_ref";
89     return ID;
90   }
91
92   /// End 2D point of the arc
93   inline static const std::string& END_POINT_1_ID()
94   {
95     static const std::string ID = "end_point_1";
96     return ID;
97   }
98
99   /// End 2D point of the arc
100   inline static const std::string& END_POINT_2_ID()
101   {
102     static const std::string ID = "end_point_2";
103     return ID;
104   }
105
106   /// End 2D point of the arc
107   inline static const std::string& END_POINT_3_ID()
108   {
109     static const std::string ID = "end_point_3";
110     return ID;
111   }
112
113   inline static const std::string& END_POINT_REF_ID()
114   {
115     static const std::string ID = "end_point_ref";
116     return ID;
117   }
118
119   /// Passed point of the arc.
120   static const std::string& PASSED_POINT_ID()
121   {
122     static const std::string ID("passed_point");
123     return ID;
124   }
125
126   static const std::string& PASSED_POINT_REF_ID()
127   {
128     static const std::string ID("passed_point_ref");
129     return ID;
130   }
131
132   static const std::string& TANGENT_POINT_ID()
133   {
134     static const std::string ID("tangent_point");
135     return ID;
136   }
137
138   /// Reversed flag
139   inline static const std::string& REVERSED_ID()
140   {
141     static const std::string ID("reversed");
142     return ID;
143   }
144
145   /// Arc radius.
146   static const std::string& RADIUS_ID()
147   {
148     static const std::string ID("radius");
149     return ID;
150   }
151
152   /// Arc angle.
153   static const std::string& ANGLE_ID()
154   {
155     static const std::string ID("angle");
156     return ID;
157   }
158
159   /// Returns the kind of a feature
160   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
161   {
162     static std::string MY_KIND = SketchPlugin_MacroArc::ID();
163     return MY_KIND;
164   }
165
166   /// \brief Request for initialization of data model of the feature: adding all attributes.
167   SKETCHPLUGIN_EXPORT virtual void initAttributes();
168
169   /// Called on change of any argument-attribute of this object
170   /// \param theID identifier of changed attribute
171   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
172
173   /// Returns the AIS preview
174   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
175
176   /// Creates an arc-shape
177   SKETCHPLUGIN_EXPORT virtual void execute();
178
179   /// Moves the feature
180   /// \param theDeltaX the delta for X coordinate is moved
181   /// \param theDeltaY the delta for Y coordinate is moved
182   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
183   {
184   };
185
186   /// Reimplemented from ModelAPI_Feature::isMacro().
187   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
188
189   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
190
191   /// Use plugin manager for features creation.
192   SketchPlugin_MacroArc();
193
194 private:
195   std::shared_ptr<GeomAPI_Pnt2d> myCenter;
196   std::shared_ptr<GeomAPI_Pnt2d> myStart;
197   std::shared_ptr<GeomAPI_Pnt2d> myEnd;
198
199   /// To define in which direction draw arc.
200   double myParamBefore;
201 };
202
203 #endif