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();
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
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;
}