Salome HOME
Dimensions move using ModelAPI_ObjectMovedMessage mechanism. Move by deltas is obsole...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintDistanceVertical.cpp
index 6691ee51bba8ad4a231d9cf4953c9e4d5ce363ec..e9f645a0256063bfc40381de14ec9ae4045a84a2 100644 (file)
@@ -73,42 +73,6 @@ AISObjectPtr SketchPlugin_ConstraintDistanceVertical::getAISObject(AISObjectPtr
   return anAIS;
 }
 
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceVertical::move(double theDeltaX, double theDeltaY)
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  if (!aData->isValid())
-    return;
-
-  // Recalculate a shift of flyout point in terms of local coordinates
-  std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  if (!aPointA || !aPointB)
-    return;
-
-  std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
-  std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
-  std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-  double dX = aDir->dot(aLineDir->xy());
-  double dY = -aDir->cross(aLineDir->xy());
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  myFlyoutUpdate = true;
-  if (aPoint->isInitialized()) {
-    aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
-  } else {
-    aPoint->setValue(dX, dY);
-  }
-  myFlyoutUpdate = false;
-}
-
 double SketchPlugin_ConstraintDistanceVertical::calculateCurrentDistance()
 {
   std::shared_ptr<ModelAPI_Data> aData = data();
@@ -133,7 +97,6 @@ void SketchPlugin_ConstraintDistanceVertical::attributeChanged(const std::string
       aValueAttr->setValue(aDistance);
     }
   } else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
-    myFlyoutUpdate = true;
     // Recalculate flyout point in local coordinates of the distance constraint:
     // the X coordinate is a length of projection of the flyout point on the
     //                  line binding two distanced points
@@ -156,11 +119,10 @@ void SketchPlugin_ConstraintDistanceVertical::attributeChanged(const std::string
     if (aEndPnt->distance(aStartPnt) < tolerance)
       return;
 
-    std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-    std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
-
-    double X = aFlyoutDir->dot(aLineDir->xy());
-    double Y = -aFlyoutDir->cross(aLineDir->xy());
+    std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aEndPnt);
+    myFlyoutUpdate = true;
+    double X =  aFlyoutDir->y(); // Dot on OY axis
+    double Y = -aFlyoutDir->x(); // Cross to OY axis
     aFlyoutAttr->setValue(X, Y);
     myFlyoutUpdate = false;
   }