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 <SketchPlugin_Sketch.h>
11 #include <ModelAPI_AttributeReference.h>
12 #include <ModelAPI_AttributeRefAttr.h>
15 const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
16 const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
20 * Each constraint uses a set of parameters. In the SolveSpace library
21 * these parameters are named "valA", "ptA", "ptB", "entityA", "entityB".
22 * The "ptA" and "ptB" parameters represents a point in the constraint.
23 * The "entityA" and "entityB" represents any other object (and a point too).
24 * And the "valA" represents a real value.
26 * The attributes below are named independent of the SolveSpace.
27 * Some of them may be unused.
29 * Also the list of possible attributes is provided to simplify assignment.
31 /// The value parameter for the constraint
32 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
33 /// The 2D value parameter for the constraint
34 const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
35 /// First entity for the constraint
36 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
37 /// Second entity for the constraint
38 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
39 /// Third entity for the constraint
40 const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
41 /// Fourth entity for the constraint
42 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
43 /// List of constraint attributes
44 const unsigned int CONSTRAINT_ATTR_SIZE = 4;
45 const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] =
46 {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B,
47 CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
50 /** \class SketchPlugin_Constraint
52 * \brief Feature for creation of a new constraint between other features.
53 * Base class for all constraints.
55 class SketchPlugin_Constraint: public SketchPlugin_Feature
58 /// \brief Returns to which group in the document must be added feature
59 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
60 {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
62 /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
63 * \param theFeature sub-feature
65 SKETCHPLUGIN_EXPORT virtual const void addSub(
66 const FeaturePtr& theFeature) {}
68 /// \brief Returns the sketch preview
69 SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
71 /// Returns the AIS preview
72 SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
75 /// \param theDeltaX the delta for X coordinate is moved
76 /// \param theDeltaY the delta for Y coordinate is moved
77 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
79 /// Return the distance between the feature and the point
80 /// \param thePoint the point
81 virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
84 /// \brief Use plugin manager for features creation
85 SketchPlugin_Constraint() {}