From affc49049eb919587ed0b2f0ae0833291ddb4855 Mon Sep 17 00:00:00 2001 From: Rexbas Date: Fri, 24 Nov 2023 22:43:48 +0100 Subject: [PATCH 1/2] Gui: Update rotation center indicator after zoom --- src/Gui/NavigationStyle.cpp | 6 ++++++ src/Gui/View3DInventorViewer.cpp | 15 +++++++++++++++ src/Gui/View3DInventorViewer.h | 1 + 3 files changed, 22 insertions(+) diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 0d03e51d29..166251a852 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -739,6 +739,12 @@ void NavigationStyle::doZoom(SoCamera* camera, float logfactor, const SbVec2f& p SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio()); SbPlane panplane = vv.getPlane(camera->focalDistance.getValue()); panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, pos, SbVec2f(0.5,0.5)); + + // Change the position of the rotation center indicator after zooming at cursor + // Rotation mode is WindowCenter + if (!rotationCenterMode) { + viewer->changeRotationCenterPosition(getFocalPoint()); + } } } diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index fc4ff34ad1..734a4f51fe 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1407,6 +1407,7 @@ void View3DInventorViewer::showRotationCenter(bool show) material->transparency = 1.0F - float(color.alphaF()); auto translation = new SoTranslation(); + translation->setName("translation"); translation->translation.setValue(center); auto annotation = new SoAnnotation(); @@ -1433,6 +1434,20 @@ void View3DInventorViewer::showRotationCenter(bool show) } } +// Changes the position of the rotation center indicator +void View3DInventorViewer::changeRotationCenterPosition(const SbVec3f& newCenter) { + if (!rotationCenterGroup) { + return; + } + + SoTranslation* translation = dynamic_cast(rotationCenterGroup->getByName("translation")); + if (!translation) { + return; + } + + translation->translation = newCenter; +} + void View3DInventorViewer::setNavigationType(Base::Type type) { if (this->navigation && this->navigation->getTypeId() == type) { diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index cb00008924..5d30e65523 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -416,6 +416,7 @@ public: bool hasAxisCross(); void showRotationCenter(bool show); + void changeRotationCenterPosition(const SbVec3f& newCenter); void setEnabledFPSCounter(bool on); void setEnabledNaviCube(bool on); From 21f10dd36b6c7b37d7bafac5d5a152978b386697 Mon Sep 17 00:00:00 2001 From: Rexbas Date: Sat, 25 Nov 2023 09:40:49 +0100 Subject: [PATCH 2/2] Gui: Find scene bounding sphere after zoom --- src/Gui/NavigationStyle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 166251a852..9618b78fa7 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -744,6 +744,7 @@ void NavigationStyle::doZoom(SoCamera* camera, float logfactor, const SbVec2f& p // Rotation mode is WindowCenter if (!rotationCenterMode) { viewer->changeRotationCenterPosition(getFocalPoint()); + findBoundingSphere(); } } }