Salome HOME
Move generation of AIS presentation into SketchPlugin
[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 const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
16 const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
17
18
19 /*  Description: 
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.
25  *
26  *    The attributes below are named independent of the SolveSpace.
27  *    Some of them may be unused. 
28  *
29  *    Also the list of possible attributes is provided to simplify assignment.
30  */
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 /// The value parameter for the constraint
36 const std::string CONSTRAINT_ATTR_FLYOUT_VALUE("ConstraintFlyoutValue");
37 /// First entity for the constraint
38 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
39 /// Second entity for the constraint
40 const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
41 /// Third entity for the constraint
42 const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
43 /// Fourth entity for the constraint
44 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
45 /// List of constraint attributes
46 const unsigned int CONSTRAINT_ATTR_SIZE = 4;
47 const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
48                       {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
49                        CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
50
51
52 /** \class SketchPlugin_Constraint
53  *  \ingroup DataModel
54  *  \brief Feature for creation of a new constraint between other features.
55  *         Base class for all constraints.
56  */
57 class SketchPlugin_Constraint: public SketchPlugin_Feature
58 {
59 public:
60   /// \brief Returns to which group in the document must be added feature
61   SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
62   {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
63
64   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
65    *  \param theFeature sub-feature
66    */
67   SKETCHPLUGIN_EXPORT virtual const void addSub(
68     const FeaturePtr& theFeature) {}
69
70   /// \brief Returns the sketch preview
71   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
72
73   /// Returns the AIS preview
74   SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
75
76   /// Moves the feature
77   /// \param theDeltaX the delta for X coordinate is moved
78   /// \param theDeltaY the delta for Y coordinate is moved
79   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
80
81   /// Return the distance between the feature and the point
82   /// \param thePoint the point
83   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
84
85 protected:
86   /// \brief Use plugin manager for features creation
87   SketchPlugin_Constraint() {}
88 };
89
90 #endif