Salome HOME
Changes in the presentations of features
[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
16 /*  Description: 
17  *    Each constraint uses a set of parameters. In the SolveSpace library 
18  *    these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". 
19  *    The "ptA" and "ptB" parameters represents a point in the constraint.
20  *    The "entityA" and "entityB" represents any other object (and a point too).
21  *    And the "valA" represents a real value.
22  *
23  *    The attributes below are named independent of the SolveSpace.
24  *    Some of them may be unused. 
25  *
26  *    Also the list of possible attributes is provided to simplify assignment.
27  */
28 /// The value parameter for the constraint
29 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
30 /// The 2D value parameter for the constraint
31 const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
32 /// First entity for the constraint
33 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
34 /// Second entity for the constraint
35 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
36 /// Third entity for the constraint
37 const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
38 /// Fourth entity for the constraint
39 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
40 /// List of constraint attributes
41 const unsigned int CONSTRAINT_ATTR_SIZE = 4;
42 const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
43                       {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
44                        CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
45
46
47 /** \class SketchPlugin_Constraint
48  *  \ingroup DataModel
49  *  \brief Feature for creation of a new constraint between other features.
50  *         Base class for all constraints.
51  */
52 class SketchPlugin_Constraint: public SketchPlugin_Feature
53 {
54 public:
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_KIND; 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 FeaturePtr& theFeature) {}
64
65   /// \brief Returns the sketch preview
66   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
67
68   /// Returns the AIS preview
69   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
70                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
71
72   /// Moves the feature
73   /// \param theDeltaX the delta for X coordinate is moved
74   /// \param theDeltaY the delta for Y coordinate is moved
75   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
76
77   /// Return the distance between the feature and the point
78   /// \param thePoint the point
79   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
80
81 protected:
82   /// \brief Use plugin manager for features creation
83   SketchPlugin_Constraint() {}
84 };
85
86 #endif