Skip to content

Commit

Permalink
Sketcher: Merged constraint selection fix.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Neinei0k committed Oct 16, 2020
1 parent df9282d commit 4516547
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -1727,21 +1727,26 @@ 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();

if (!pCam)
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();
Expand Down

0 comments on commit 4516547

Please sign in to comment.