Salome HOME
Issue #1664: In the Sketcher, add the function Split a segment: split constraints
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Circle.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Circle.h
4 // Created:     26 May 2014
5 // Author:      Artem ZHIDKOV
6
7 #ifndef SketchPlugin_Circle_H_
8 #define SketchPlugin_Circle_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_Circle
16  * \ingroup Plugins
17  * \brief Feature for creation of the new circle in PartSet.
18  */
19 class SketchPlugin_Circle : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
20 {
21  public:
22   /// Circle feature kind
23   inline static const std::string& ID()
24   {
25     static const std::string MY_CIRCLE_ID("SketchCircle");
26     return MY_CIRCLE_ID;
27   }
28
29   inline static const std::string& CIRCLE_TYPE()
30   {
31     static const std::string TYPE("CircleType");
32     return TYPE;
33   }
34
35   /// Creation method by center and radius.
36   inline static const std::string& CIRCLE_TYPE_CENTER_AND_RADIUS()
37   {
38     static const std::string TYPE("CenterRadius");
39     return TYPE;
40   }
41
42   /// Creation method by three points.
43   inline static const std::string& CIRCLE_TYPE_THREE_POINTS()
44   {
45     static const std::string TYPE("ThreePoints");
46     return TYPE;
47   }
48
49   /// 2D point - center of the circle
50   inline static const std::string& CENTER_ID()
51   {
52     static const std::string MY_CIRCLE_CENTER_ID("CircleCenter");
53     return MY_CIRCLE_CENTER_ID;
54   }
55
56   /// Radius of the circle
57   inline static const std::string& RADIUS_ID()
58   {
59     static const std::string MY_CIRCLE_RADIUS_ID("CircleRadius");
60     return MY_CIRCLE_RADIUS_ID;
61   }
62
63   /// First point id.
64   inline static const std::string& FIRST_POINT_ID()
65   {
66     static const std::string FIRST_PNT("FirstPoint");
67     return FIRST_PNT;
68   }
69
70   /// Second point id.
71   inline static const std::string& SECOND_POINT_ID()
72   {
73     static const std::string SECOND_PNT("SecondPoint");
74     return SECOND_PNT;
75   }
76
77   /// Third point id.
78   inline static const std::string& THIRD_POINT_ID()
79   {
80     static const std::string THIRD_PNT("ThirdPoint");
81     return THIRD_PNT;
82   }
83
84   /// Returns the kind of a feature
85   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
86   {
87     static std::string MY_KIND = SketchPlugin_Circle::ID();
88     return MY_KIND;
89   }
90
91   /// Returns true is sketch element is under the rigid constraint
92   SKETCHPLUGIN_EXPORT virtual bool isFixed();
93
94   /// Creates a new part document if needed
95   SKETCHPLUGIN_EXPORT virtual void execute();
96
97   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
98   /// \param theFeature sub-feature
99   SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature)
100   {
101   }
102
103   /// Moves the feature
104   /// \param theDeltaX the delta for X coordinate is moved
105   /// \param theDeltaY the delta for Y coordinate is moved
106   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
107
108   /// Called on change of any argument-attribute of this object
109   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
110
111   /// Returns the AIS preview
112   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
113
114   /// Use plugin manager for features creation
115   SketchPlugin_Circle();
116
117 protected:
118   /// \brief Initializes attributes of derived class.
119   virtual void initDerivedClassAttributes();
120
121 private:
122   /// Returns true if all obligatory attributes are initialized
123   bool isFeatureValid();
124
125   /// Update coordinates of representation by three points
126   void adjustThreePoints();
127 };
128
129 #endif