Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintLength.cpp
index 4ec9e30ce42a328991b6d668f193a562094b3d5a..6e48926c662b7f26eeedfd4cedab1b415ce5d7b6 100644 (file)
@@ -5,6 +5,8 @@
 #include "SketchPlugin_ConstraintLength.h"
 #include <SketchPlugin_Line.h>
 
+#include <GeomDataAPI_Point2D.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
@@ -22,6 +24,7 @@ void SketchPlugin_ConstraintLength::initAttributes()
 {
   data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
 }
 
@@ -107,3 +110,14 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintLength::getAISShape(
   return anAIS;
 }
 
+void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+  if (!aData->isValid())
+    return;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
+