Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Constraint.h
index e69a316cc46a6b0fa4867fe09ccceda9a0553901..632243ba608557cc11ea325f61724794fde566ce 100644 (file)
@@ -7,10 +7,15 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Feature.h"
+#include <SketchPlugin_Sketch.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <list>
 
+const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
+const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+
+
 /*  Description: 
  *    Each constraint uses a set of parameters. In the SolveSpace library 
  *    these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". 
@@ -25,6 +30,8 @@
  */
 /// The value parameter for the constraint
 const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
+/// The 2D value parameter for the constraint
+const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
 /// First entity for the constraint
 const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
 /// Second entity for the constraint
@@ -34,7 +41,8 @@ const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
 /// Fourth entity for the constraint
 const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
 /// List of constraint attributes
-const std::string CONSTRAINT_ATTRIBUTES[4] = 
+const unsigned int CONSTRAINT_ATTR_SIZE = 4;
+const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
                       {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
                        CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
 
@@ -47,20 +55,32 @@ const std::string CONSTRAINT_ATTRIBUTES[4] =
 class SketchPlugin_Constraint: public SketchPlugin_Feature
 {
 public:
-  /// \brief Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraint"; return MY_KIND;}
-
   /// \brief Returns to which group in the document must be added feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
    *  \param theFeature sub-feature
    */
   SKETCHPLUGIN_EXPORT virtual const void addSub(
-    const boost::shared_ptr<ModelAPI_Feature>& theFeature) {}
+    const FeaturePtr& theFeature) {}
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+
+  /// Moves the feature
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
+
+  /// Return the distance between the feature and the point
+  /// \param thePoint the point
+  virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
 
+protected:
   /// \brief Use plugin manager for features creation
   SketchPlugin_Constraint() {}
 };