Salome HOME
296b849bc0bebb6204d094c1aec97b784095c37a
[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   /// Central 2D point of the circle which contains the arc
42   inline static const std::string& CENTER_ID()
43   {
44     static const std::string MY_CENTER_ID = "ArcCenter";
45     return MY_CENTER_ID;
46   }
47   /// Start 2D point of the arc
48   inline static const std::string& START_ID()
49   {
50     static const std::string MY_START_ID = "ArcStartPoint";
51     return MY_START_ID;
52   }
53   /// End 2D point of the arc
54   inline static const std::string& END_ID()
55   {
56     static const std::string MY_END_ID = "ArcEndPoint";
57     return MY_END_ID;
58   }
59
60   /// Inversed flag
61   inline static const std::string& INVERSED_ID()
62   {
63     static const std::string MY_INVERSED_ID("InversedArc");
64     return MY_INVERSED_ID;
65   }
66
67   /// Returns the kind of a feature
68   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
69   {
70     static std::string MY_KIND = SketchPlugin_Arc::ID();
71     return MY_KIND;
72   }
73
74   /// Returns true is sketch element is under the rigid constraint
75   SKETCHPLUGIN_EXPORT virtual bool isFixed();
76
77   /// Creates an arc-shape
78   SKETCHPLUGIN_EXPORT virtual void execute();
79
80   /// Called on change of any argument-attribute of this object
81   /// \param theID identifier of changed attribute
82   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
83
84   /// Returns the AIS preview
85   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
86
87   /// Moves the feature
88   /// \param theDeltaX the delta for X coordinate is moved
89   /// \param theDeltaY the delta for Y coordinate is moved
90   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
91
92   /// Updates the "reversed" flag
93   /// \param isReversed  whether the arc will be reversed
94   void setReversed(bool isReversed);
95   /// Returns \c true is the arc is reversed
96   bool isReversed();
97
98   /// Use plugin manager for features creation
99   SketchPlugin_Arc();
100
101 protected:
102   /// \brief Initializes attributes of derived class.
103   virtual void initDerivedClassAttributes();
104
105 private:
106   /// Returns true if all obligatory attributes are initialized
107   bool isFeatureValid();
108 };
109
110 #endif