Skip to content

Commit

Permalink
MeasureGui: Return the relative label offset for the initial position
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorus authored and WandererFan committed Aug 19, 2024
1 parent d11f710 commit 0b8c8ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ Base::Vector3d ViewProviderMeasure::getBasePosition(){
return placement.getPosition();
}


Base::Vector3d ViewProviderMeasure::getTextPosition(){
// Return the initial position relative to the base position
auto basePoint = getBasePosition();

Gui::View3DInventor* view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
Expand All @@ -652,12 +652,14 @@ Base::Vector3d ViewProviderMeasure::getTextPosition(){
return Base::Vector3d();
}

Gui::View3DInventorViewer* viewer = view->getViewer();
Gui::View3DInventorViewer* viewer = view->getViewer();

// Convert to screenspace, offset and convert back to world space
SbVec2s screenPos = viewer->getPointOnViewport(SbVec3f(basePoint.x, basePoint.y, basePoint.z));
SbVec3f textPos = viewer->getPointOnFocalPlane(screenPos + SbVec2s(30.0, 30.0));
return Base::Vector3d(textPos[0], textPos[1], textPos[2]);
SbVec3f vec = viewer->getPointOnFocalPlane(screenPos + SbVec2s(30.0, 30.0));
Base::Vector3d textPos(vec[0], vec[1], vec[2]);

return textPos - basePoint;
}

//! called by the system when it is time to display this measure
Expand Down

0 comments on commit 0b8c8ce

Please sign in to comment.