Salome HOME
2.17. Improved management of overconstraint situation: dimension constraints are...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintDistance.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_ConstraintDistance.h
4 // Created: 23 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_ConstraintDistance_H_
8 #define SketchPlugin_ConstraintDistance_H_
9
10 #include "SketchPlugin.h"
11 #include "SketchPlugin_ConstraintBase.h"
12 #include "SketchPlugin_Sketch.h"
13 #include "ModelAPI_Data.h"
14
15 #include <GeomAPI_ICustomPrs.h>
16
17 #include <list>
18
19 class SketchPlugin_Line;
20 class GeomDataAPI_Point2D;
21
22 /** \class SketchPlugin_ConstraintDistance
23  *  \ingroup Plugins
24  *  \brief Feature for creation of a new constraint which defines a distance
25  *         between a point and another feature (point, line, plane or face)
26  *
27  *  This constraint has three attributes:
28  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
29  */
30 class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
31 {
32  public:
33   /// Distance constraint kind
34   inline static const std::string& ID()
35   {
36     static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
37     return MY_CONSTRAINT_DISTANCE_ID;
38   }
39
40   /// \brief Returns the kind of a feature
41   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
42   {
43     static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID();
44     return MY_KIND;
45   }
46
47   /// \brief Creates a new part document if needed
48   SKETCHPLUGIN_EXPORT virtual void execute();
49
50   /// Computes the attribute value on the base of other attributes if the value can be computed
51   /// \param theAttributeId an attribute index to be computed
52   /// \return a boolean value about it is computed
53   SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
54
55   /// \brief Request for initialization of data model of the feature: adding all attributes
56   SKETCHPLUGIN_EXPORT virtual void initAttributes();
57
58   /// Retuns the parameters of color definition in the resources config manager
59   SKETCHPLUGIN_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
60                                                    std::string& theDefault);
61
62   /// Returns the AIS preview
63   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
64
65   /// Moves the feature
66   /// \param theDeltaX the delta for X coordinate is moved
67   /// \param theDeltaY the delta for Y coordinate is moved
68   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
69
70   /// Called on change of any argument-attribute of this object
71   /// \param theID identifier of changed attribute
72   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
73
74   /// \brief Use plugin manager for features creation
75   SketchPlugin_ConstraintDistance();
76
77 protected:
78   /// Returns the current distance between the feature attributes
79   double calculateCurrentDistance();
80
81 private:
82   bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
83 };
84
85 #endif