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.
This commit is contained in:
Neinei0k
2020-10-16 08:57:32 +03:00
committed by abdullahtahiriyo
parent d702536f3a
commit b1afdc8f61

View File

@@ -1727,7 +1727,15 @@ std::set<int> ViewProviderSketch::detectPreselectionConstr(const SoPickedPoint *
trans += static_cast<SoZoomTranslation *>(static_cast<SoSeparator *>(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<int> 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();