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