Salome HOME
Issue #2024: Redesign of circle and arc of circle
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroCircle.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_MacroCircle.h
4 // Created:     26 May 2014
5 // Author:      Artem ZHIDKOV
6
7 #ifndef SketchPlugin_MacroCircle_H_
8 #define SketchPlugin_MacroCircle_H_
9
10 #include "SketchPlugin.h"
11
12 #include "SketchPlugin_Sketch.h"
13 #include "SketchPlugin_SketchEntity.h"
14
15 #include <GeomAPI_IPresentable.h>
16 #include <GeomAPI_Pnt2d.h>
17
18 /**\class SketchPlugin_MacroCircle
19  * \ingroup Plugins
20  * \brief Feature for creation of the new circle in Sketch.
21  */
22 class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
23                                 public GeomAPI_IPresentable
24 {
25  public:
26   /// Circle feature kind
27   inline static const std::string& ID()
28   {
29     static const std::string ID("SketchMacroCircle");
30     return ID;
31   }
32
33   inline static const std::string& CIRCLE_TYPE()
34   {
35     static const std::string ID("circle_type");
36     return ID;
37   }
38
39   /// Creation method by center and passed point.
40   inline static const std::string& CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
41   {
42     static const std::string ID("circle_type_by_center_and_passed_points");
43     return ID;
44   }
45
46   /// Creation method by three points.
47   inline static const std::string& CIRCLE_TYPE_BY_THREE_POINTS()
48   {
49     static const std::string ID("circle_type_by_three_points");
50     return ID;
51   }
52
53   /// 2D point - center of the circle.
54   inline static const std::string& CENTER_POINT_ID()
55   {
56     static const std::string ID("center_point");
57     return ID;
58   }
59
60   /// Reference for center point selection.
61   inline static const std::string& CENTER_POINT_REF_ID()
62   {
63     static const std::string ID("center_point_ref");
64     return ID;
65   }
66
67   /// 2D point - passed point of the circle
68   inline static const std::string& PASSED_POINT_ID()
69   {
70     static const std::string ID("passed_point");
71     return ID;
72   }
73
74   /// Reference for passed point selection.
75   inline static const std::string& PASSED_POINT_REF_ID()
76   {
77     static const std::string ID("passed_point_ref");
78     return ID;
79   }
80
81   /// First point id.
82   inline static const std::string& FIRST_POINT_ID()
83   {
84     static const std::string ID("first_point");
85     return ID;
86   }
87
88   /// Second point id.
89   inline static const std::string& SECOND_POINT_ID()
90   {
91     static const std::string ID("second_point");
92     return ID;
93   }
94
95   /// Third point id.
96   inline static const std::string& THIRD_POINT_ID()
97   {
98     static const std::string ID("third_point");
99     return ID;
100   }
101
102   /// Radius of the circle
103   inline static const std::string& CIRCLE_RADIUS_ID()
104   {
105     static const std::string ID("circle_radius");
106     return ID;
107   }
108
109   /// Returns the kind of a feature
110   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
111   {
112     static std::string MY_KIND = SketchPlugin_MacroCircle::ID();
113     return MY_KIND;
114   }
115
116   /// \brief Request for initialization of data model of the feature: adding all attributes.
117   SKETCHPLUGIN_EXPORT virtual void initAttributes();
118
119   /// Called on change of any argument-attribute of this object
120   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
121
122   /// Returns the AIS preview
123   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
124
125   /// Creates a new part document if needed
126   SKETCHPLUGIN_EXPORT virtual void execute();
127
128   /// Moves the feature
129   /// \param theDeltaX the delta for X coordinate is moved
130   /// \param theDeltaY the delta for Y coordinate is moved
131   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
132   {};
133
134   /// Reimplemented from ModelAPI_Feature::isMacro().
135   /// \returns true
136   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
137
138   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
139
140   /// Use plugin manager for features creation
141   SketchPlugin_MacroCircle();
142
143 private:
144   void resetAttribute(const std::string& theId);
145
146 private:
147   std::shared_ptr<GeomAPI_Pnt2d> myCenter;
148   double myRadius;
149 };
150
151 #endif