]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_Constraint.h
Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Constraint.h
1 // File:    SketchPlugin_Constraint.h
2 // Created: 08 May 2014
3 // Author:  Artem ZHIDKOV
4
5 #ifndef SketchPlugin_Constraint_HeaderFile
6 #define SketchPlugin_Constraint_HeaderFile
7
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_Feature.h"
10 #include <SketchPlugin_Sketch.h>
11 #include <ModelAPI_AttributeReference.h>
12 #include <ModelAPI_AttributeRefAttr.h>
13 #include <list>
14
15 /*  Description: 
16  *    Each constraint uses a set of parameters. In the SolveSpace library 
17  *    these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". 
18  *    The "ptA" and "ptB" parameters represents a point in the constraint.
19  *    The "entityA" and "entityB" represents any other object (and a point too).
20  *    And the "valA" represents a real value.
21  *
22  *    The attributes below are named independent of the SolveSpace.
23  *    Some of them may be unused. 
24  *
25  *    Also the list of possible attributes is provided to simplify assignment.
26  */
27 /// The value parameter for the constraint
28 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
29 /// The 2D value parameter for the constraint
30 const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
31 /// The value parameter for the constraint
32 const std::string CONSTRAINT_ATTR_FLYOUT_VALUE("ConstraintFlyoutValue");
33 /// First entity for the constraint
34 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
35 /// Second entity for the constraint
36 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
37 /// Third entity for the constraint
38 const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
39 /// Fourth entity for the constraint
40 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
41 /// List of constraint attributes
42 const unsigned int CONSTRAINT_ATTR_SIZE = 4;
43 const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
44                       {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
45                        CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
46
47
48 /** \class SketchPlugin_Constraint
49  *  \ingroup DataModel
50  *  \brief Feature for creation of a new constraint between other features.
51  *         Base class for all constraints.
52  */
53 class SketchPlugin_Constraint: public SketchPlugin_Feature
54 {
55 public:
56   /// \brief Returns to which group in the document must be added feature
57   SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
58   {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
59
60   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
61    *  \param theFeature sub-feature
62    */
63   SKETCHPLUGIN_EXPORT virtual const void addSub(
64     const FeaturePtr& theFeature) {}
65
66   /// Moves the feature
67   /// \param theDeltaX the delta for X coordinate is moved
68   /// \param theDeltaY the delta for Y coordinate is moved
69   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
70
71   /// Return the distance between the feature and the point
72   /// \param thePoint the point
73   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
74
75 protected:
76   /// \brief Use plugin manager for features creation
77   SketchPlugin_Constraint() {}
78 };
79
80 #endif