Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[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_Feature.h>
12 #include <SketchPlugin_Sketch.h>
13 #include <GeomAPI_IPresentable.h>
14
15 /**\class SketchPlugin_Arc
16  * \ingroup DataModel
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_Feature, 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
28  public:
29   /// Arc feature kind
30   inline static const std::string& ID()
31   {
32     static const std::string MY_SKETCH_ARC_ID("SketchArc");
33     return MY_SKETCH_ARC_ID;
34   }
35
36   /// Central 2D point of the circle which contains the arc
37   inline static const std::string& CENTER_ID()
38   {
39     static const std::string MY_CENTER_ID = "ArcCenter";
40     return MY_CENTER_ID;
41   }
42   /// Start 2D point of the arc
43   inline static const std::string& START_ID()
44   {
45     static const std::string MY_START_ID = "ArcStartPoint";
46     return MY_START_ID;
47   }
48   /// End 2D point of the arc
49   inline static const std::string& END_ID()
50   {
51     static const std::string MY_END_ID = "ArcEndPoint";
52     return MY_END_ID;
53   }
54
55   /// Returns the kind of a feature
56   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
57   {
58     static std::string MY_KIND = SketchPlugin_Arc::ID();
59     return MY_KIND;
60   }
61
62   /// Returns true is sketch element is under the rigid constraint
63   SKETCHPLUGIN_EXPORT virtual bool isFixed();
64
65   /// Creates an arc-shape
66   SKETCHPLUGIN_EXPORT virtual void execute();
67
68   /// Request for initialization of data model of the feature: adding all attributes
69   SKETCHPLUGIN_EXPORT virtual void initAttributes();
70
71   /// Called on change of any argument-attribute of this object
72   /// \param theID identifier of changed attribute
73   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
74
75   /// Returns the AIS preview
76   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
77
78   /// Moves the feature
79   /// \param theDeltaX the delta for X coordinate is moved
80   /// \param theDeltaY the delta for Y coordinate is moved
81   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
82
83   /// Return the distance between the feature and the point
84   /// \param thePoint the point
85   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
86
87   /// Use plugin manager for features creation
88   SketchPlugin_Arc();
89
90 private:
91   /// Returns true if all obligatory attributes are initialized
92   bool isFeatureValid();
93 };
94
95 #endif