From c71ea4a493c347ba04d97b14e2dd8ef4bb47e07f Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 28 Nov 2020 22:12:25 +0100 Subject: [PATCH] Gui: [skip ci] in user settings offer combo box to choose between rotation modes --- src/Gui/DlgSettingsNavigation.cpp | 8 +++- src/Gui/DlgSettingsNavigation.ui | 79 ++++++++++++++++++++----------- src/Gui/NavigationStyle.cpp | 14 ++++-- src/Gui/View3DInventor.cpp | 15 ++++-- 4 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/Gui/DlgSettingsNavigation.cpp b/src/Gui/DlgSettingsNavigation.cpp index e85fc23a23..cd558d11b7 100644 --- a/src/Gui/DlgSettingsNavigation.cpp +++ b/src/Gui/DlgSettingsNavigation.cpp @@ -84,11 +84,13 @@ void DlgSettingsNavigation::saveSettings() index = ui->naviCubeCorner->currentIndex(); hGrp->SetInt("CornerNaviCube", index); + index = ui->comboRotationMode->currentIndex(); + hGrp->SetInt("RotationMode", index); + ui->checkBoxZoomAtCursor->onSave(); ui->checkBoxInvertZoom->onSave(); ui->checkBoxDisableTilt->onSave(); ui->spinBoxZoomStep->onSave(); - ui->checkBoxDragAtCursor->onSave(); ui->CheckBox_UseAutoRotation->onSave(); ui->qspinNewDocScale->onSave(); ui->prefStepByTurn->onSave(); @@ -113,7 +115,6 @@ void DlgSettingsNavigation::loadSettings() ui->checkBoxInvertZoom->onRestore(); ui->checkBoxDisableTilt->onRestore(); ui->spinBoxZoomStep->onRestore(); - ui->checkBoxDragAtCursor->onRestore(); ui->CheckBox_UseAutoRotation->onRestore(); ui->qspinNewDocScale->onRestore(); ui->prefStepByTurn->onRestore(); @@ -131,6 +132,9 @@ void DlgSettingsNavigation::loadSettings() index = hGrp->GetInt("CornerNaviCube", 1); ui->naviCubeCorner->setCurrentIndex(index); + index = hGrp->GetInt("RotationMode", 1); + ui->comboRotationMode->setCurrentIndex(index); + bool showNaviCube = hGrp->GetBool("ShowNaviCube", true); ui->groupBoxNaviCube->setChecked(showNaviCube); diff --git a/src/Gui/DlgSettingsNavigation.ui b/src/Gui/DlgSettingsNavigation.ui index 8e2c492dda..db674b9192 100644 --- a/src/Gui/DlgSettingsNavigation.ui +++ b/src/Gui/DlgSettingsNavigation.ui @@ -232,13 +232,57 @@ Turntable: the part will be rotated around the z-axis. + + + Rotation mode + + + + + + + + 120 + 0 + + + + + 16777215 + 16777215 + + + + Rotations in 3D will use current cursor position as center for rotation + + + 1 + + + + Window center + + + + + Drag at cursor + + + + + Object center + + + + + Default camera orientation - + @@ -257,14 +301,14 @@ Turntable: the part will be rotated around the z-axis. - + New document scale - + @@ -302,7 +346,7 @@ The value is the diameter of the sphere to fit on the screen. - + true @@ -324,7 +368,7 @@ The value is the diameter of the sphere to fit on the screen. - + Zoom operations will be performed at position of mouse pointer @@ -343,7 +387,7 @@ The value is the diameter of the sphere to fit on the screen. - + @@ -411,7 +455,7 @@ Zoom step of '1' means a factor of 7.5 for every zoom step. - + Direction of zoom operations will be inverted @@ -430,7 +474,7 @@ Zoom step of '1' means a factor of 7.5 for every zoom step. - + Prevents view tilting when pinch-zooming. @@ -451,25 +495,6 @@ Mouse tilting is not disabled by this setting. - - - - Rotations in 3D will use current cursor position as center for rotation - - - Rotate at cursor - - - false - - - DragAtCursor - - - View - - - diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 717c7b1d4f..eb0988a11c 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -238,9 +238,17 @@ void NavigationStyle::initialize() ("User parameter:BaseApp/Preferences/View")->GetBool("ZoomAtCursor",true); this->zoomStep = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/View")->GetFloat("ZoomStep",0.2f); - bool dragAtCursor = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/View")->GetBool("DragAtCursor", false); - setRotationCenterMode(dragAtCursor ? ScenePointAtCursor : WindowCenter); + long mode = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/View")->GetInt("RotationMode", 1); + if (mode == 0) { + setRotationCenterMode(NavigationStyle::WindowCenter); + } + else if (mode == 1) { + setRotationCenterMode(NavigationStyle::ScenePointAtCursor); + } + else if (mode == 2) { + setRotationCenterMode(NavigationStyle::BoundingBoxCenter); + } } void NavigationStyle::finalize() diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index b525d28ef5..beef0d3c73 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -357,10 +357,17 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M float val = rGrp.GetFloat("ZoomStep", 0.0f); _viewer->navigationStyle()->setZoomStep(val); } - else if (strcmp(Reason,"DragAtCursor") == 0) { - bool on = rGrp.GetBool("DragAtCursor", false); - _viewer->navigationStyle()->setRotationCenterMode(on ? NavigationStyle::ScenePointAtCursor - : NavigationStyle::WindowCenter); + else if (strcmp(Reason,"RotationMode") == 0) { + long mode = rGrp.GetInt("RotationMode", 1); + if (mode == 0) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::WindowCenter); + } + else if (mode == 1) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::ScenePointAtCursor); + } + else if (mode == 2) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::BoundingBoxCenter); + } } else if (strcmp(Reason,"EyeDistance") == 0) { _viewer->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0));