Gui: [skip ci] in user settings offer combo box to choose between rotation modes

This commit is contained in:
wmayer
2020-11-28 22:12:25 +01:00
parent eafcb59baf
commit c71ea4a493
4 changed files with 80 additions and 36 deletions

View File

@@ -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);

View File

@@ -232,13 +232,57 @@ Turntable: the part will be rotated around the z-axis.</string>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelRotationMode">
<property name="text">
<string>Rotation mode</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="comboRotationMode">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Rotations in 3D will use current cursor position as center for rotation</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Window center</string>
</property>
</item>
<item>
<property name="text">
<string>Drag at cursor</string>
</property>
</item>
<item>
<property name="text">
<string>Object center</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="newDocViewLabel">
<property name="text">
<string>Default camera orientation</string>
</property>
</widget>
</item>
<item row="2" column="3">
<item row="3" column="3">
<widget class="QComboBox" name="comboNewDocView">
<property name="minimumSize">
<size>
@@ -257,14 +301,14 @@ Turntable: the part will be rotated around the z-axis.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>New document scale</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="4" column="3">
<widget class="PrefUnitSpinBox" name="qspinNewDocScale" native="true">
<property name="minimumSize">
<size>
@@ -302,7 +346,7 @@ The value is the diameter of the sphere to fit on the screen.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="Gui::PrefCheckBox" name="CheckBox_UseAutoRotation">
<property name="enabled">
<bool>true</bool>
@@ -324,7 +368,7 @@ The value is the diameter of the sphere to fit on the screen.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxZoomAtCursor">
<property name="toolTip">
<string>Zoom operations will be performed at position of mouse pointer</string>
@@ -343,7 +387,7 @@ The value is the diameter of the sphere to fit on the screen.</string>
</property>
</widget>
</item>
<item row="5" column="3">
<item row="6" column="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
@@ -411,7 +455,7 @@ Zoom step of '1' means a factor of 7.5 for every zoom step. </string>
</item>
</layout>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxInvertZoom">
<property name="toolTip">
<string>Direction of zoom operations will be inverted</string>
@@ -430,7 +474,7 @@ Zoom step of '1' means a factor of 7.5 for every zoom step. </string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxDisableTilt">
<property name="toolTip">
<string>Prevents view tilting when pinch-zooming.
@@ -451,25 +495,6 @@ Mouse tilting is not disabled by this setting.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxDragAtCursor">
<property name="toolTip">
<string>Rotations in 3D will use current cursor position as center for rotation</string>
</property>
<property name="text">
<string>Rotate at cursor</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>DragAtCursor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@@ -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()

View File

@@ -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));