Measurement: label drag when infront of model (#27832)

Co-authored-by: Nishendra Singh <[email protected]>
(cherry picked from commit 2d6e49cb7f)
This commit is contained in:
nishi
2026-03-02 20:10:35 +00:00
committed by github-actions[bot]
parent c8547e1e9f
commit b8adfad244
2 changed files with 23 additions and 15 deletions
+22 -15
View File
@@ -143,8 +143,12 @@ ViewProviderMeasureBase::ViewProviderMeasureBase()
transformEngine->matrix.connectFrom(&matrixEngine->matrix);
pLabelTranslation->translation.connectFrom(&transformEngine->point);
auto pTextPickStyle = new SoPickStyle();
pTextPickStyle->style = SoPickStyle::SHAPE_ON_TOP;
pTextSeparator = new SoSeparator();
pTextSeparator->ref();
pTextSeparator->addChild(pTextPickStyle);
pTextSeparator->addChild(dragSeparator);
pTextSeparator->addChild(pLabelTranslation);
pTextSeparator->addChild(pLabel);
@@ -341,11 +345,28 @@ void ViewProviderMeasureBase::updateIcon()
pLabel->setIcon(Gui::BitmapFactory().pixmapFromSvg(sPixmap, QSize(20, 20), colorMap));
}
void ViewProviderMeasureBase::syncDraggerOrientationToView()
{
Gui::View3DInventor* view = nullptr;
try {
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
}
catch (const Base::RuntimeError&) {
return;
}
if (view) {
auto* cam = view->getViewer()->getSoRenderManager()->getCamera();
if (cam) {
pDraggerOrientation->rotation.connectFrom(&cam->orientation);
}
}
}
void ViewProviderMeasureBase::attach(App::DocumentObject* pcObj)
{
ViewProviderDocumentObject::attach(pcObj);
updateIcon();
syncDraggerOrientationToView();
}
@@ -621,21 +642,7 @@ ViewProviderMeasure::ViewProviderMeasure()
points->numPoints = 1;
lineSep->addChild(points);
// Connect dragger local orientation to view orientation
Gui::View3DInventor* view = nullptr;
try {
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
}
catch (const Base::RuntimeError&) {
Base::Console().log("ViewProviderMeasure::ViewProviderMeasure: Could not get active view\n");
}
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
auto renderManager = viewer->getSoRenderManager();
auto cam = renderManager->getCamera();
pDraggerOrientation->rotation.connectFrom(&cam->orientation);
}
syncDraggerOrientationToView();
}
ViewProviderMeasure::~ViewProviderMeasure()
@@ -140,6 +140,7 @@ protected:
void setLabelValue(const QString& value);
void setLabelTranslation(const SbVec3f& position);
void updateIcon();
void syncDraggerOrientationToView();
SoPickStyle* getSoPickStyle();
SoDrawStyle* getSoLineStylePrimary();