1 // File: SketchPlugin_ConstraintLength.h
2 // Created: 30 May 2014
3 // Author: Artem ZHIDKOV
5 #ifndef SketchPlugin_ConstraintLength_H_
6 #define SketchPlugin_ConstraintLength_H_
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_ConstraintBase.h"
10 #include <SketchPlugin_Sketch.h>
13 class GeomDataAPI_Point2D;
15 #define LENGTH_COLOR "#ff00ff"
17 /** \class SketchPlugin_ConstraintLength
19 * \brief Feature for creation of a new constraint which defines a length of a line segment
21 * This constraint has two attributes:
22 * SketchPlugin_Constraint::VALUE() (length) and SketchPlugin_Constraint::ENTITY_A() (segment),
23 * SketchPlugin_Constraint::FLYOUT_VALUE_PNT() (distance of a constraints handle)
25 class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase
28 /// Length constraint kind
29 inline static const std::string& ID()
31 static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength");
32 return MY_CONSTRAINT_LENGTH_ID;
34 /// \brief Returns the kind of a feature
35 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
37 static std::string MY_KIND = SketchPlugin_ConstraintLength::ID();
41 /// \brief Creates a new part document if needed
42 SKETCHPLUGIN_EXPORT virtual void execute();
44 /// \brief Request for initialization of data model of the feature: adding all attributes
45 SKETCHPLUGIN_EXPORT virtual void initAttributes();
47 /// Returns the AIS preview
48 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
51 /// \param theDeltaX the delta for X coordinate is moved
52 /// \param theDeltaY the delta for Y coordinate is moved
53 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
55 /// Called on change of any argument-attribute of this object
56 /// \param theID identifier of changed attribute
57 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
59 /// \brief Use plugin manager for features creation
60 SketchPlugin_ConstraintLength();
63 // retrns the points-base of length, returns false if it is not possible
65 std::shared_ptr<GeomAPI_Pnt>& thePoint1, std::shared_ptr<GeomAPI_Pnt>& thePoint2,
66 std::shared_ptr<GeomDataAPI_Point2D>& theStartPoint,
67 std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint);