Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Arc.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Arc.h
4 // Created:     26 May 2014
5 // Author:      Artem ZHIDKOV
6
7 #ifndef SketchPlugin_Arc_H_
8 #define SketchPlugin_Arc_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_Arc
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_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
23 {
24   /// to avoid cyclic dependencies in automatic updates: they mean that
25   /// update is performed right now and automatic updates are not needed
26   bool myStartUpdate, myEndUpdate;
27   /// to avoid (if possible) additional modification of changed coordinate (issue #855)
28   double myXEndBefore, myYEndBefore;
29
30   /// to define in which direction draw arc
31   double myParamBefore;
32
33  public:
34   /// Arc feature kind
35   inline static const std::string& ID()
36   {
37     static const std::string MY_SKETCH_ARC_ID("SketchArc");
38     return MY_SKETCH_ARC_ID;
39   }
40
41   inline static const std::string& ARC_TYPE()
42   {
43     static const std::string TYPE("ArcType");
44     return TYPE;
45   }
46
47   inline static const std::string& ARC_TYPE_TANGENT()
48   {
49     static const std::string TYPE("Tangent");
50     return TYPE;
51   }
52
53   static const std::string& ARC_TYPE_CENTER_START_END()
54   {
55     static const std::string TYPE("CenterStartEnd");
56     return TYPE;
57   }
58   static const std::string& ARC_TYPE_THREE_POINTS()
59   {
60     static const std::string TYPE("ThreePoints");
61     return TYPE;
62   }
63
64   static const std::string& TANGENT_POINT_ID()
65   {
66     static const std::string TANGENT_PNT("ArcTangentPoint");
67     return TANGENT_PNT;
68   }
69
70   /// Central 2D point of the circle which contains the arc
71   inline static const std::string& CENTER_ID()
72   {
73     static const std::string MY_CENTER_ID = "ArcCenter";
74     return MY_CENTER_ID;
75   }
76   /// Start 2D point of the arc
77   inline static const std::string& START_ID()
78   {
79     static const std::string MY_START_ID = "ArcStartPoint";
80     return MY_START_ID;
81   }
82   /// End 2D point of the arc
83   inline static const std::string& END_ID()
84   {
85     static const std::string MY_END_ID = "ArcEndPoint";
86     return MY_END_ID;
87   }
88
89   /// Inversed flag
90   inline static const std::string& INVERSED_ID()
91   {
92     static const std::string MY_INVERSED_ID("InversedArc");
93     return MY_INVERSED_ID;
94   }
95
96   /// Passed point of the arc.
97   static const std::string& PASSED_POINT_ID()
98   {
99     static const std::string PASSED_PNT("ArcPassedPoint");
100     return PASSED_PNT;
101   }
102
103   /// Arc radius.
104   static const std::string& RADIUS_ID()
105   {
106     static const std::string RADIUS("ArcRadius");
107     return RADIUS;
108   }
109
110   /// Arc angle.
111   static const std::string& ANGLE_ID()
112   {
113     static const std::string ANGLE("ArcAngle");
114     return ANGLE;
115   }
116
117   /// Returns the kind of a feature
118   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
119   {
120     static std::string MY_KIND = SketchPlugin_Arc::ID();
121     return MY_KIND;
122   }
123
124   /// Returns true is sketch element is under the rigid constraint
125   SKETCHPLUGIN_EXPORT virtual bool isFixed();
126
127   /// Creates an arc-shape
128   SKETCHPLUGIN_EXPORT virtual void execute();
129
130   /// Called on change of any argument-attribute of this object
131   /// \param theID identifier of changed attribute
132   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
133
134   /// Returns the AIS preview
135   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
136
137   /// Moves the feature
138   /// \param theDeltaX the delta for X coordinate is moved
139   /// \param theDeltaY the delta for Y coordinate is moved
140   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
141
142   /// Updates the "reversed" flag
143   /// \param isReversed  whether the arc will be reversed
144   void setReversed(bool isReversed);
145   /// Returns \c true is the arc is reversed
146   bool isReversed();
147
148   /// Use plugin manager for features creation
149   SketchPlugin_Arc();
150
151 protected:
152   /// \brief Initializes attributes of derived class.
153   virtual void initDerivedClassAttributes();
154
155 private:
156   /// Returns true if all obligatory attributes are initialized
157   bool isFeatureValid();
158
159   /// Compose constraints to build tangency arc
160   void tangencyArcConstraints();
161
162 };
163
164 #endif