Salome HOME
#refs 156 - Behavior of the Sketch during edition
authornds <natalia.donis@opencascade.com>
Wed, 29 Oct 2014 11:44:29 +0000 (14:44 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 29 Oct 2014 11:44:29 +0000 (14:44 +0300)
move() method implementation in GeomDataAPI_Point2D

src/GeomDataAPI/GeomDataAPI_Point2D.h
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp

index 6189e87d21ab221a2945c6fe792b37064e1f664e..c0eb001cfbbafe1a24dae931ac524364ca01b32e 100644 (file)
@@ -30,6 +30,13 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute
   /// Returns the 2D point
   virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
 
+  /// Appends the delta values to point
+  void move(const double theDeltaX, const double theDeltaY)
+  {
+    setValue(x() + theDeltaX, y() + theDeltaY);
+  }
+
+
   /// Returns the type of this class of attributes
   static inline std::string type()
   {
index ec9d227deec81d97d63e91b2eec985cee2d73a7b..34e46fc5a1e9b1fb2017e92991c6f1e0a70881bb 100644 (file)
@@ -108,15 +108,15 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Arc::CENTER_ID()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint1->move(theDeltaX, theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Arc::START_ID()));
-  aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
+  aPoint2->move(theDeltaX, theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Arc::END_ID()));
-  aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
+  aPoint3->move(theDeltaX, theDeltaY);
 }
 
 double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
index 4828a0f7b91a7b247e6e833caa30d6abaf493664..860368b51e59eed5506b21100541a706d5c91b08 100644 (file)
@@ -91,7 +91,7 @@ void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Circle::CENTER_ID()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint1->move(theDeltaX, theDeltaY);
 }
 
 double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
index 65c6cf9cee8a0fdb5e2b5f7d5bbb245bc45a6933..90e1a2437e5fcf7733e46e0096e2189320a54ef7 100644 (file)
@@ -143,9 +143,9 @@ void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
   if (!aData->isValid())
     return;
 
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint->setValue(theDeltaX, theDeltaY);
 }
 
 //*************************************************************************************
index 00061c7390de1321b522f79522dd83e368e71d06..ff8a480b46ea314aad8fe37a1e8d0a78d7a5e0a8 100644 (file)
@@ -110,8 +110,8 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
   if (!aData->isValid())
     return;
 
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint->move(theDeltaX, theDeltaY);
 }
 
index 056eda9396ea1ef111796055c762de7e6a46a3a0..ae105caa331fbe7a061c60c441a24d19bda6aaa1 100644 (file)
@@ -98,6 +98,6 @@ void SketchPlugin_ConstraintParallel::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
+  aPoint->move(theDeltaX, theDeltaY);
 }
 
index 72a20f8618db061541c325f0ca7162a8f8d992ff..bdb608e6da9bb641d80360d78df214433997dfe6 100644 (file)
@@ -64,11 +64,11 @@ void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Line::START_ID()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint1->move(theDeltaX, theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Line::END_ID()));
-  aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
+  aPoint2->move(theDeltaX, theDeltaY);
 }
 
 double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
index c198e9b90fd22c44e7c066ea30ee88a022aa2df1..a905d8486f731997ad95d03efe182f9821d1bafc 100644 (file)
@@ -54,7 +54,7 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Point::COORD_ID()));
-  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+  aPoint1->move(theDeltaX, theDeltaY);
 }
 
 double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)