From 165c46413a782fc8505c4d4e51c3e51bcd75aef5 Mon Sep 17 00:00:00 2001 From: Bas Ruigrok Date: Mon, 23 Jun 2025 19:25:51 +0200 Subject: [PATCH 1/3] Part: Remove use of adjustCameraPosition() --- src/Mod/Part/Gui/Command.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index efe07d270c..bed30dac11 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -1635,9 +1635,7 @@ void CmdPartOffset::activated(int iMsg) updateActive(); doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",offset.c_str()); - - adjustCameraPosition(); - + copyVisual(offset.c_str(), "ShapeAppearance", shape->getNameInDocument()); copyVisual(offset.c_str(), "LineColor" , shape->getNameInDocument()); copyVisual(offset.c_str(), "PointColor", shape->getNameInDocument()); @@ -1692,7 +1690,6 @@ void CmdPartOffset2D::activated(int iMsg) doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",offset.c_str()); updateActive(); doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",offset.c_str()); - adjustCameraPosition(); copyVisual(offset.c_str(), "ShapeAppearance", shape->getNameInDocument()); copyVisual(offset.c_str(), "LineColor" , shape->getNameInDocument()); @@ -1876,7 +1873,6 @@ void CmdPartThickness::activated(int iMsg) obj->getDocument()->getName(), obj->getNameInDocument()); } doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",thick.c_str()); - adjustCameraPosition(); copyVisual(thick.c_str(), "ShapeAppearance", obj->getNameInDocument()); copyVisual(thick.c_str(), "LineColor" , obj->getNameInDocument()); From 699c06dd0c9f4b538ee8bd439d3947daf6b6be89 Mon Sep 17 00:00:00 2001 From: Bas Ruigrok Date: Mon, 23 Jun 2025 19:28:56 +0200 Subject: [PATCH 2/3] PartDesign: Remove use of adjustCameraPosition() --- src/Mod/PartDesign/Gui/Command.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 400fc4269e..aa8ebd3ad9 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1075,7 +1075,6 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which, double len } finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, cmd, which, worker); @@ -1172,7 +1171,6 @@ void CmdPartDesignHole::activated(int iMsg) return; finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "Hole", worker); @@ -1228,7 +1226,6 @@ void CmdPartDesignRevolution::activated(int iMsg) FCMD_OBJ_CMD(Feat,"Reversed = 1"); finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "Revolution", worker); @@ -1292,7 +1289,6 @@ void CmdPartDesignGroove::activated(int iMsg) } finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "Groove", worker); @@ -1339,7 +1335,6 @@ void CmdPartDesignAdditivePipe::activated(int iMsg) Gui::Command::updateActive(); finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "AdditivePipe", worker); @@ -1387,7 +1382,6 @@ void CmdPartDesignSubtractivePipe::activated(int iMsg) Gui::Command::updateActive(); finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "SubtractivePipe", worker); @@ -1435,7 +1429,6 @@ void CmdPartDesignAdditiveLoft::activated(int iMsg) Gui::Command::updateActive(); finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "AdditiveLoft", worker); @@ -1483,7 +1476,6 @@ void CmdPartDesignSubtractiveLoft::activated(int iMsg) Gui::Command::updateActive(); finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "SubtractiveLoft", worker); @@ -1555,8 +1547,6 @@ void CmdPartDesignAdditiveHelix::activated(int iMsg) view->makeTemporaryVisible(true); } } - - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "AdditiveHelix", worker); @@ -1611,7 +1601,6 @@ void CmdPartDesignSubtractiveHelix::activated(int iMsg) } finishProfileBased(cmd, sketch, Feat); - cmd->adjustCameraPosition(); }; prepareProfileBased(pcActiveBody, this, "SubtractiveHelix", worker); From 7fa89f965a85b74ebc8c29db5d7e91ae8e90d2dc Mon Sep 17 00:00:00 2001 From: Bas Ruigrok Date: Mon, 23 Jun 2025 19:29:11 +0200 Subject: [PATCH 3/3] Gui: Remove adjustCameraPosition() --- src/Gui/Command.cpp | 41 ----------------------------------------- src/Gui/Command.h | 5 ----- 2 files changed, 46 deletions(-) diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 0bc31de89c..c7a830945c 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -916,47 +916,6 @@ const char* Command::keySequenceToAccel(int sk) const return (strings[sk] = static_cast(data)).c_str(); } -void Command::adjustCameraPosition() -{ - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (doc) { - auto view = static_cast(doc->getActiveView()); - Gui::View3DInventorViewer* viewer = view->getViewer(); - SoCamera* camera = viewer->getSoRenderManager()->getCamera(); - if (!camera || !camera->isOfType(SoOrthographicCamera::getClassTypeId())) - return; - - // get scene bounding box - SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion()); - action.apply(viewer->getSceneGraph()); - SbBox3f box = action.getBoundingBox(); - if (box.isEmpty()) - return; - - // get cirumscribing sphere and check if camera is inside - SbVec3f cam_pos = camera->position.getValue(); - SbVec3f box_cnt = box.getCenter(); - SbSphere bs; - bs.circumscribe(box); - float radius = bs.getRadius(); - float distance_to_midpoint = (box_cnt-cam_pos).length(); - if (radius >= distance_to_midpoint) { - // Move the camera to the edge of the bounding sphere, while still - // pointing at the scene. - SbVec3f direction = cam_pos - box_cnt; - (void) direction.normalize(); // we know this is not a null vector - camera->position.setValue(box_cnt + direction * radius); - - // New distance to mid point - distance_to_midpoint = - (camera->position.getValue() - box.getCenter()).length(); - camera->nearDistance = distance_to_midpoint - radius; - camera->farDistance = distance_to_midpoint + radius; - camera->focalDistance = distance_to_midpoint; - } - } -} - void Command::printConflictingAccelerators() const { auto cmd = Application::Instance->commandManager().checkAcceleratorForConflicts(sAccel, this); diff --git a/src/Gui/Command.h b/src/Gui/Command.h index 50809a8f45..db158d0596 100644 --- a/src/Gui/Command.h +++ b/src/Gui/Command.h @@ -575,11 +575,6 @@ public: /// Obtain the current shortcut of this command virtual QString getShortcut() const; - /** @name arbitrary helper methods */ - //@{ - void adjustCameraPosition(); - //@} - /// Helper class to disable python console log class LogDisabler { public: