Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintRadius.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_ConstraintRadius.h
4 // Created: 26 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_ConstraintRadius_H_
8 #define SketchPlugin_ConstraintRadius_H_
9
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_Sketch.h>
12 #include "SketchPlugin_ConstraintBase.h"
13
14 #define RADIUS_COLOR "#ff00ff"
15
16 /** \class SketchPlugin_ConstraintRadius
17  *  \ingroup DataModel
18  *  \brief Feature for creation of a new constraint which defines 
19  *         a radius of a circle or an arc of circle
20  *
21  *  This constraint has two attributes:
22  *  SketchPlugin_Constraint::VALUE() (radius), SketchPlugin_Constraint::ENTITY_A() (a circle)
23  */
24 class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase
25 {
26  public:
27   /// Radius constraint kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius");
31     return MY_CONSTRAINT_RADIUS_ID;
32   }
33   /// \brief Returns the kind of a feature
34   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
35   {
36     static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID();
37     return MY_KIND;
38   }
39
40   /// \brief Creates a new part document if needed
41   SKETCHPLUGIN_EXPORT virtual void execute();
42
43   /// \brief Request for initialization of data model of the feature: adding all attributes
44   SKETCHPLUGIN_EXPORT virtual void initAttributes();
45
46   /// Returns the AIS preview
47   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
48
49   /// Moves the feature
50   /// \param theDeltaX the delta for X coordinate is moved
51   /// \param theDeltaY the delta for Y coordinate is moved
52   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
53
54   /// Called on change of any argument-attribute of this object
55   /// \param theID identifier of changed attribute
56   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
57
58   /// \brief Use plugin manager for features creation
59   SketchPlugin_ConstraintRadius();
60
61 private:
62   /// Checks and gets the radius of referenced circle (or arc) otherwise returns -1.
63   /// \param theCircData the found referenced circle returned by this method
64   double circleRadius(std::shared_ptr<ModelAPI_Feature>& theCirc);
65 };
66
67 #endif