1 // File: SketchPlugin_Constraint.h
2 // Created: 08 May 2014
3 // Author: Artem ZHIDKOV
5 #ifndef SketchPlugin_Constraint_HeaderFile
6 #define SketchPlugin_Constraint_HeaderFile
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_Feature.h"
10 #include <ModelAPI_AttributeReference.h>
11 #include <ModelAPI_AttributeRefAttr.h>
15 * Each constraint uses a set of parameters. In the SolveSpace library
16 * these parameters are named "valA", "ptA", "ptB", "entityA", "entityB".
17 * The "ptA" and "ptB" parameters represents a point in the constraint.
18 * The "entityA" and "entityB" represents any other object (and a point too).
19 * And the "valA" represents a real value.
21 * The attributes below are named corresponding to the SolveSpace,
22 * some of them may be unused. The list of used attributes is defined
23 * inside the certain constraint.
25 /// The value parameter for the constraint
26 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValueA");
27 /// First point for the constraint
28 const std::string CONSTRAINT_ATTR_POINT_A("ConstraintPointA");
29 /// Second point for the constraint
30 const std::string CONSTRAINT_ATTR_POINT_B("ConstraintPointB");
31 /// First entity for the constraint
32 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
33 /// Second entity for the constraint
34 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
37 /** \class SketchPlugin_Constraint
39 * \brief Feature for creation of a new constraint between other features.
41 class SketchPlugin_Constraint: public SketchPlugin_Feature
44 /// \brief Returns the kind of a feature
45 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
46 {static std::string MY_KIND = "SketchConstraint"; return MY_KIND;}
48 /// \brief Returns to which group in the document must be added feature
49 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
50 {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
52 /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
53 * \param theFeature sub-feature
55 SKETCHPLUGIN_EXPORT virtual const void addSub(
56 const boost::shared_ptr<ModelAPI_Feature>& theFeature) {}
58 /** \brief Adds an object of the constraint. The object added by the reference.
59 * \param theReference reference to the feature, which will be constrained
61 SKETCHPLUGIN_EXPORT virtual void addConstrainedObject(
62 const boost::shared_ptr<ModelAPI_AttributeReference>& theReference);
64 /** \brief Adds an object of the constraint. The object added by the reference to its attribute.
65 * \param theReference reference to the attribute feature, which will be constrained
67 SKETCHPLUGIN_EXPORT virtual void addConstrainedObject(
68 const boost::shared_ptr<ModelAPI_AttributeRefAttr>& theReference);
70 /// \brief Use plugin manager for features creation
71 SketchPlugin_Constraint() {}
74 /** \brief Returns the list of attributes for the certain type of constraint.
75 * \return names of attributes
77 virtual const std::list<std::string>& getAttributesList() const = 0;