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