1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_ConstraintDistance.h
4 // Created: 23 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_ConstraintDistance_H_
8 #define SketchPlugin_ConstraintDistance_H_
10 #include "SketchPlugin.h"
11 #include "SketchPlugin_ConstraintBase.h"
12 #include "SketchPlugin_Sketch.h"
13 #include "ModelAPI_Data.h"
17 class SketchPlugin_Line;
18 class GeomDataAPI_Point2D;
20 #define DISTANCE_COLOR "#ff00ff"
22 /** \class SketchPlugin_ConstraintDistance
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)
27 * This constraint has three attributes:
28 * SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
30 class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
33 /// Distance constraint kind
34 inline static const std::string& ID()
36 static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
37 return MY_CONSTRAINT_DISTANCE_ID;
40 /// \brief Returns the kind of a feature
41 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
43 static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID();
47 /// \brief Creates a new part document if needed
48 SKETCHPLUGIN_EXPORT virtual void execute();
50 /// \brief Request for initialization of data model of the feature: adding all attributes
51 SKETCHPLUGIN_EXPORT virtual void initAttributes();
53 /// Returns the AIS preview
54 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
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);
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);
65 /// Returns the current distance between the feature attributes
66 double calculateCurrentDistance() const;
68 /// \brief Use plugin manager for features creation
69 SketchPlugin_ConstraintDistance();
72 /// Obtain the point object from specified constraint parameter
73 std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
74 const std::string& theAttribute);
76 std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
77 const std::string& theAttribute);
79 std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
80 const std::shared_ptr<SketchPlugin_Line>& theLine,
81 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);