Salome HOME
2.17. Improved management of overconstraint situation: dimension constraints are...
[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 /** \class SketchPlugin_ConstraintRadius
15  *  \ingroup Plugins
16  *  \brief Feature for creation of a new constraint which defines 
17  *         a radius of a circle or an arc of circle
18  *
19  *  This constraint has two attributes:
20  *  SketchPlugin_Constraint::VALUE() (radius), SketchPlugin_Constraint::ENTITY_A() (a circle)
21  */
22 class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase
23 {
24  public:
25   /// Radius constraint kind
26   inline static const std::string& ID()
27   {
28     static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius");
29     return MY_CONSTRAINT_RADIUS_ID;
30   }
31   /// \brief Returns the kind of a feature
32   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
33   {
34     static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID();
35     return MY_KIND;
36   }
37
38   /// \brief Creates a new part document if needed
39   SKETCHPLUGIN_EXPORT virtual void execute();
40
41   /// Computes the attribute value on the base of other attributes if the value can be computed
42   /// \param theAttributeId an attribute index to be computed
43   /// \return a boolean value about it is computed
44   SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
45
46   /// \brief Request for initialization of data model of the feature: adding all attributes
47   SKETCHPLUGIN_EXPORT virtual void initAttributes();
48
49   /// Retuns the parameters of color definition in the resources config manager
50   SKETCHPLUGIN_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
51                                                    std::string& theDefault);
52
53   /// Returns the AIS preview
54   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
55
56   /// Moves the feature
57   /// \param theDeltaX the delta for X coordinate is moved
58   /// \param theDeltaY the delta for Y coordinate is moved
59   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
60
61   /// Called on change of any argument-attribute of this object
62   /// \param theID identifier of changed attribute
63   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
64
65   /// \brief Use plugin manager for features creation
66   SketchPlugin_ConstraintRadius();
67
68 private:
69   /// Checks and gets the radius of referenced circle (or arc) otherwise returns -1.
70   /// \param theCircData the found referenced circle returned by this method
71   double circleRadius(std::shared_ptr<ModelAPI_Feature>& theCirc);
72
73 private:
74   bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
75 };
76
77 #endif