1 // File: SketchPlugin_ConstraintDistance.h
2 // Created: 08 May 2014
3 // Author: Artem ZHIDKOV
5 #ifndef SketchPlugin_ConstraintDistance_HeaderFile
6 #define SketchPlugin_ConstraintDistance_HeaderFile
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_Constraint.h"
12 /// The distance value
13 const std::string CONSTRAINT_ATTR_DISTANCE(CONSTRAINT_ATTR_VALUE);
16 /** \class SketchPlugin_ConstraintDistance
18 * \brief Feature for creation of a new constraint which fixes the distance
19 * between two other features.
21 * There are allowed several kinds of distances:
22 * \li The next constraints use "valA", "ptA" and "entityA" parameters:
23 * point-point, point-line, point-plane, point-face;
24 * \li The distance between two points projected on a line (or vector)
25 * uses "valA", "ptA", "ptB", "entityA";
26 * \li The diameter of a circle is defined by "valA" and "entityA";
27 * \li The angle between two lines (or vectors) uses "valA", "entityA", "entityB".
29 * The default list of attributes contains only CONSTRAINT_ATTR_DISTANCE.
31 * \remark As far as the constraint may have different attributes,
32 * it is strongly recommended to use setAttibutes() methods
33 * instead of direct intialization of the attributes
35 class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
38 /// \brief Returns the kind of a feature
39 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
40 {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;}
42 /// \brief Returns to which group in the document must be added feature
43 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
44 {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
46 /// \brief Creates a new part document if needed
47 SKETCHPLUGIN_EXPORT virtual void execute();
49 /** \brief Request for initialization of data model of the feature: adding all attributes
51 * The setAttributes() methods should be used instead.
53 SKETCHPLUGIN_EXPORT virtual void initAttributes()
56 /// \brief Use plugin manager for features creation
57 SketchPlugin_ConstraintDistance();
59 /** \brief Initializes the attributes of the constraint
61 * Defines the distance between a point and another entity,
62 * or defines the angle between two vectors.
64 * \param[in] theDistance distance (or angle) between two entities
65 * \param[in] theEntityA first parameter of the constraint
66 * \param[in] theEntityB second parameter of the constraint
68 SKETCHPLUGIN_EXPORT void setAttributes(
69 const double theDistance,
70 const boost::shared_ptr<SketchPlugin_Feature> theEntityA,
71 const boost::shared_ptr<SketchPlugin_Feature> theEntityB);
72 /** \brief Initializes the attributes of the constraint
74 * Defines the distance between a point defined by reference and another entity.
76 * \param[in] theDistance distance between the point and other entity
77 * \param[in] thePoint reference to the point attribute
78 * \param[in] theEntity other parameter of the constraint
80 SKETCHPLUGIN_EXPORT void setAttributes(
81 const double theDistance,
82 const boost::shared_ptr<ModelAPI_Attribute> thePoint,
83 const boost::shared_ptr<SketchPlugin_Feature> theEntity);
84 /** \brief Initializes the attributes of the constraint
86 * Defines the distance between two points which defined by references.
88 * \param[in] theDistance distance between the points
89 * \param[in] thePointA reference to the first point attribute
90 * \param[in] thePointB reference to the second point attribute
92 SKETCHPLUGIN_EXPORT void setAttributes(
93 const double theDistance,
94 const boost::shared_ptr<ModelAPI_Attribute> thePointA,
95 const boost::shared_ptr<ModelAPI_Attribute> thePointB);
96 /** \brief Initializes the attributes of the constraint
98 * Defines radius of a circle.
100 * \param[in] theRadius radius of the circle
101 * \param[in] theCircle the circle which has specified radius
103 SKETCHPLUGIN_EXPORT void setAttributes(
104 const double theRadius,
105 const boost::shared_ptr<SketchPlugin_Feature> theCircle);
106 /** \brief Initializes the attributes of the constraint
108 * Defines the distance between two points projected on specified vector (or line).
110 * \param[in] theDistance distance between projected points
111 * \param[in] thePointA first point for the projection
112 * \param[in] thePointB second point for the projection
113 * \param[in] theEntity direction of the line which the points projected on
115 SKETCHPLUGIN_EXPORT void setAttributes(
116 const double theDistance,
117 const boost::shared_ptr<SketchPlugin_Feature> thePointA,
118 const boost::shared_ptr<SketchPlugin_Feature> thePointB,
119 const boost::shared_ptr<SketchPlugin_Feature> theEntity);
122 /** \brief Returns the list of attributes for the certain type of constraint.
123 * \return names of attributes
125 const std::list<std::string>& getAttributesList() const
126 { return myAttrList; }
129 std::list<std::string> myAttrList; ///< List of attributes for current constraint