+ } 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
+ // or a line of projection of the distanced point onto the distanced segment
+ // the Y coordinate is a distance from the flyout point to the line
+ std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ std::shared_ptr<GeomAPI_Pnt2d> aFlyoutPnt = aFlyoutAttr->pnt();
+
+ 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);
+
+ std::shared_ptr<GeomAPI_XY> aStartPnt;
+ std::shared_ptr<GeomAPI_XY> aEndPnt;
+ if (aPointA && aPointB) {
+ aStartPnt = aPointA->pnt()->xy();
+ aEndPnt = aPointB->pnt()->xy();
+ } else if (aPointA) {
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(data(),
+ SketchPlugin_Constraint::ENTITY_B());
+ if (!aLine)
+ return;
+ std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointA->pnt();
+ aStartPnt = aPoint->xy();
+ aEndPnt = SketcherPrs_Tools::getProjectionPoint(aLine, aPoint)->xy();
+ } else if (aPointB) {
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(data(),
+ SketchPlugin_Constraint::ENTITY_A());
+ if (!aLine)
+ return;
+ std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointB->pnt();
+ aStartPnt = SketcherPrs_Tools::getProjectionPoint(aLine, aPoint)->xy();
+ aEndPnt = aPoint->xy();
+ } else
+ return;
+
+ 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());
+ aFlyoutAttr->setValue(X, Y);
+ myFlyoutUpdate = false;