From 4516547c8743e44b08441a924f9220efb8b4cd14 Mon Sep 17 00:00:00 2001 From: Neinei0k Date: Fri, 16 Oct 2020 08:57:32 +0300 Subject: [PATCH] Sketcher: Merged constraint selection fix. When the sketch is not in XY plane, individual constraints from the merged constraint icon can't be selected. Constraint icon coordinates are given in sketcher coordinates. The function getCoordsOnSketchPlane projects vector in global coordinates to the sketch plane. So, it makes no sense to use sketcher coordinates with it. If the sketch is in the XY plane, then the global coordinates are the same as sketcher coordinates. The solution is to get global coordinates of the icon from the sketcher coordinates and use it to project icon to the screen. --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 1d2f6117da0f..11a6acc08786 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1727,7 +1727,15 @@ std::set ViewProviderSketch::detectPreselectionConstr(const SoPickedPoint * trans += static_cast(static_cast(tailFather)->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_TRANSLATION))->translation.getValue(); } - double x,y; + Base::Placement sketchPlacement = getEditingPlacement(); + Base::Vector3d sketchPos(sketchPlacement.getPosition()); + Base::Rotation sketchRot(sketchPlacement.getRotation()); + + // get global coordinates from sketcher coordinates + SbVec3f constrPos = absPos + trans*getScaleFactor(); + Base::Vector3d pos(constrPos[0],constrPos[1],0); + sketchRot.multVec(pos,pos); + pos = pos + sketchPos; SoCamera* pCam = viewer->getSoRenderManager()->getCamera(); @@ -1735,13 +1743,10 @@ std::set ViewProviderSketch::detectPreselectionConstr(const SoPickedPoint * continue; SbViewVolume vol = pCam->getViewVolume(); - - getCoordsOnSketchPlane(x,y,absPos+trans*getScaleFactor(),vol.getProjectionDirection()); - - Gui::ViewVolumeProjection proj(viewer->getSoRenderManager()->getCamera()->getViewVolume()); + Gui::ViewVolumeProjection proj(vol); // dimensionless [0 1] (or 1.5 see View3DInventorViewer.cpp ) - Base::Vector3d screencoords = proj(Base::Vector3d(x,y,0)); + Base::Vector3d screencoords = proj(pos); int width = viewer->getGLWidget()->width(), height = viewer->getGLWidget()->height();