Salome HOME
Merge remote-tracking branch 'origin/Dev_0.6'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Arc.h
1 // File:        SketchPlugin_Arc.h
2 // Created:     26 May 2014
3 // Author:      Artem ZHIDKOV
4
5 #ifndef SketchPlugin_Arc_H_
6 #define SketchPlugin_Arc_H_
7
8 #include "SketchPlugin.h"
9 #include <SketchPlugin_Feature.h>
10 #include <SketchPlugin_Sketch.h>
11 #include <GeomAPI_IPresentable.h>
12
13 /**\class SketchPlugin_Arc
14  * \ingroup DataModel
15  * \brief Feature for creation of the new arc of circle in PartSet.
16  * The visualization of this object is separated in two parts. The first one is an AIS object
17  * calculated when there is non-initialized attributes of the arc. The second is a result and
18  * it is calculated if all attributes are initialized.
19  */
20 class SketchPlugin_Arc : public SketchPlugin_Feature, public GeomAPI_IPresentable
21 {
22   /// to avoid cyclic dependencies in automatic updates: they mean that 
23   /// update is performed right now and automatic updates are not needed
24   bool myStartUpdate, myEndUpdate;
25
26  public:
27   /// Arc feature kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_SKETCH_ARC_ID("SketchArc");
31     return MY_SKETCH_ARC_ID;
32   }
33
34   /// Central 2D point of the circle which contains the arc
35   inline static const std::string& CENTER_ID()
36   {
37     static const std::string MY_CENTER_ID = "ArcCenter";
38     return MY_CENTER_ID;
39   }
40   /// Start 2D point of the arc
41   inline static const std::string& START_ID()
42   {
43     static const std::string MY_START_ID = "ArcStartPoint";
44     return MY_START_ID;
45   }
46   /// End 2D point of the arc
47   inline static const std::string& END_ID()
48   {
49     static const std::string MY_END_ID = "ArcEndPoint";
50     return MY_END_ID;
51   }
52
53   /// Returns the kind of a feature
54   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
55   {
56     static std::string MY_KIND = SketchPlugin_Arc::ID();
57     return MY_KIND;
58   }
59
60   /// Returns true is sketch element is under the rigid constraint
61   SKETCHPLUGIN_EXPORT virtual bool isFixed();
62
63   /// Creates an arc-shape
64   SKETCHPLUGIN_EXPORT virtual void execute();
65
66   /// Request for initialization of data model of the feature: adding all attributes
67   SKETCHPLUGIN_EXPORT virtual void initAttributes();
68
69   /// Called on change of any argument-attribute of this object
70   /// \param theID identifier of changed attribute
71   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
72
73   /// Returns the AIS preview
74   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
75
76   /// Moves the feature
77   /// \param theDeltaX the delta for X coordinate is moved
78   /// \param theDeltaY the delta for Y coordinate is moved
79   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
80
81   /// Return the distance between the feature and the point
82   /// \param thePoint the point
83   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
84
85   /// Use plugin manager for features creation
86   SketchPlugin_Arc();
87
88 private:
89   /// Returns true if all obligatory attributes are initialized
90   bool isFeatureValid();
91 };
92
93 #endif