Salome HOME
Implemented methods for adding constraints
[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 <ModelAPI_AttributeReference.h>
11 #include <ModelAPI_AttributeRefAttr.h>
12 #include <list>
13
14 /*  Description: 
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.
20  *
21  *    The attributes below are named independent of the SolveSpace.
22  *    Some of them may be unused. 
23  *
24  *    Also the list of possible attributes is provided to simplify assignment.
25  */
26 /// The value parameter for the constraint
27 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
28 /// First entity for the constraint
29 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
30 /// Second entity for the constraint
31 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
32 /// Third entity for the constraint
33 const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
34 /// Fourth entity for the constraint
35 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
36 /// List of constraint attributes
37 const unsigned int CONSTRAINT_ATTR_SIZE = 4;
38 const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
39                       {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
40                        CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
41
42
43 /** \class SketchPlugin_Constraint
44  *  \ingroup DataModel
45  *  \brief Feature for creation of a new constraint between other features.
46  *         Base class for all constraints.
47  */
48 class SketchPlugin_Constraint: public SketchPlugin_Feature
49 {
50 public:
51   /// \brief Returns the kind of a feature
52   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
53   {static std::string MY_KIND = "SketchConstraint"; return MY_KIND;}
54
55   /// \brief Returns to which group in the document must be added feature
56   SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
57   {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
58
59   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
60    *  \param theFeature sub-feature
61    */
62   SKETCHPLUGIN_EXPORT virtual const void addSub(
63     const boost::shared_ptr<ModelAPI_Feature>& theFeature) {}
64
65   /// \brief Use plugin manager for features creation
66   SketchPlugin_Constraint() {}
67 };
68
69 #endif