diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp
index aeb875c80..d40ab1acc 100644
--- a/src/Gui/BlenderNavigationStyle.cpp
+++ b/src/Gui/BlenderNavigationStyle.cpp
@@ -257,17 +257,11 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
this->button3down = press;
break;
case SoMouseButtonEvent::BUTTON4:
- if (this->invertZoom)
- zoom(viewer->getCamera(), -0.05f);
- else
- zoom(viewer->getCamera(), 0.05f);
+ doZoom(viewer->getCamera(), TRUE, posn);
processed = TRUE;
break;
case SoMouseButtonEvent::BUTTON5:
- if (this->invertZoom)
- zoom(viewer->getCamera(), 0.05f);
- else
- zoom(viewer->getCamera(), -0.05f);
+ doZoom(viewer->getCamera(), FALSE, posn);
processed = TRUE;
break;
default:
diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp
index 965ace1bf..99f0d5919 100644
--- a/src/Gui/CADNavigationStyle.cpp
+++ b/src/Gui/CADNavigationStyle.cpp
@@ -286,17 +286,11 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
this->button3down = press;
break;
case SoMouseButtonEvent::BUTTON4:
- if (this->invertZoom)
- zoom(viewer->getCamera(), -0.05f);
- else
- zoom(viewer->getCamera(), 0.05f);
+ doZoom(viewer->getCamera(), TRUE, posn);
processed = TRUE;
break;
case SoMouseButtonEvent::BUTTON5:
- if (this->invertZoom)
- zoom(viewer->getCamera(), 0.05f);
- else
- zoom(viewer->getCamera(), -0.05f);
+ doZoom(viewer->getCamera(), FALSE, posn);
processed = TRUE;
break;
default:
diff --git a/src/Gui/DlgSettings3DView.ui b/src/Gui/DlgSettings3DView.ui
index 7cad6e9aa..66b80e72c 100644
--- a/src/Gui/DlgSettings3DView.ui
+++ b/src/Gui/DlgSettings3DView.ui
@@ -7,7 +7,7 @@
0
0
477
- 442
+ 495
@@ -25,7 +25,7 @@
3D View settings
-
+
-
@@ -130,6 +130,65 @@
-
+
+
-
+
+
+ Zoom at cursor
+
+
+ ZoomAtCursor
+
+
+ View
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Zoom step
+
+
+
+ -
+
+
+ 0.010000000000000
+
+
+ 1.000000000000000
+
+
+ 0.050000000000000
+
+
+ 0.050000000000000
+
+
+ ZoomStep
+
+
+ View
+
+
+
+
+
+ -
Invert zoom
@@ -142,7 +201,7 @@
- -
+
-
Enable anti-aliasing (slower)
@@ -155,7 +214,7 @@
- -
+
-
QFrame::HLine
@@ -168,7 +227,7 @@
- -
+
-
6
@@ -210,7 +269,7 @@
- -
+
-
11
@@ -399,6 +458,8 @@
comboNavigationStyle
mouseButton
comboOrbitStyle
+ checkBoxZoomAtCursor
+ spinBoxZoomStep
checkBoxInvertZoom
checkBoxAntiAliasing
FloatSpinBox_EyeDistance
diff --git a/src/Gui/DlgSettings3DViewImp.cpp b/src/Gui/DlgSettings3DViewImp.cpp
index 6b6ed6a86..604c35081 100644
--- a/src/Gui/DlgSettings3DViewImp.cpp
+++ b/src/Gui/DlgSettings3DViewImp.cpp
@@ -72,7 +72,9 @@ void DlgSettings3DViewImp::saveSettings()
int index = comboOrbitStyle->currentIndex();
hGrp->SetInt("OrbitStyle", index);
+ checkBoxZoomAtCursor->onSave();
checkBoxInvertZoom->onSave();
+ spinBoxZoomStep->onSave();
checkBoxAntiAliasing->onSave();
CheckBox_CornerCoordSystem->onSave();
CheckBox_ShowFPS->onSave();
@@ -87,7 +89,9 @@ void DlgSettings3DViewImp::saveSettings()
void DlgSettings3DViewImp::loadSettings()
{
+ checkBoxZoomAtCursor->onRestore();
checkBoxInvertZoom->onRestore();
+ spinBoxZoomStep->onRestore();
checkBoxAntiAliasing->onRestore();
CheckBox_CornerCoordSystem->onRestore();
CheckBox_ShowFPS->onRestore();
diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp
index 42993e755..5fb72f989 100644
--- a/src/Gui/InventorNavigationStyle.cpp
+++ b/src/Gui/InventorNavigationStyle.cpp
@@ -251,17 +251,11 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
this->button3down = press;
break;
case SoMouseButtonEvent::BUTTON4:
- if (this->invertZoom)
- zoom(viewer->getCamera(), -0.05f);
- else
- zoom(viewer->getCamera(), 0.05f);
+ doZoom(viewer->getCamera(), TRUE, posn);
processed = TRUE;
break;
case SoMouseButtonEvent::BUTTON5:
- if (this->invertZoom)
- zoom(viewer->getCamera(), 0.05f);
- else
- zoom(viewer->getCamera(), -0.05f);
+ doZoom(viewer->getCamera(), FALSE, posn);
processed = TRUE;
break;
default:
diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp
index c5283e00f..c8193993f 100644
--- a/src/Gui/NavigationStyle.cpp
+++ b/src/Gui/NavigationStyle.cpp
@@ -215,6 +215,10 @@ void NavigationStyle::initialize()
this->altdown = FALSE;
this->invertZoom = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetBool("InvertZoom",false);
+ this->zoomAtCursor = App::GetApplication().GetParameterGroupByPath
+ ("User parameter:BaseApp/Preferences/View")->GetBool("ZoomAtCursor",false);
+ this->zoomStep = App::GetApplication().GetParameterGroupByPath
+ ("User parameter:BaseApp/Preferences/View")->GetFloat("ZoomSetp",0.05f);
}
void NavigationStyle::finalize()
@@ -709,6 +713,33 @@ void NavigationStyle::zoomByCursor(const SbVec2f & thispos, const SbVec2f & prev
zoom(viewer->getCamera(), (thispos[1] - prevpos[1]) * 10.0f/*20.0f*/);
}
+void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& pos)
+{
+ SbBool zoomAtCur = this->zoomAtCursor;
+ if (zoomAtCur) {
+ const SbViewportRegion & vp = viewer->getViewportRegion();
+ float ratio = vp.getViewportAspectRatio();
+ SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
+ SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
+ panCamera(viewer->getCamera(), ratio, panplane, SbVec2f(0.5,0.5), pos);
+ }
+
+ float value = this->zoomStep;
+ if (!forward)
+ value = -value;
+ if (this->invertZoom)
+ value = -value;
+ zoom(camera, value);
+
+ if (zoomAtCur) {
+ const SbViewportRegion & vp = viewer->getViewportRegion();
+ float ratio = vp.getViewportAspectRatio();
+ SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
+ SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
+ panCamera(viewer->getCamera(), ratio, panplane, pos, SbVec2f(0.5,0.5));
+ }
+}
+
/** Uses the sphere sheet projector to map the mouseposition onto
* a 3D point and find a rotation from this and the last calculated point.
*/
@@ -884,6 +915,21 @@ SbBool NavigationStyle::isZoomInverted() const
return this->invertZoom;
}
+void NavigationStyle::setZoomStep(float val)
+{
+ this->zoomStep = val;
+}
+
+void NavigationStyle::setZoomAtCursor(SbBool on)
+{
+ this->zoomAtCursor = on;
+}
+
+SbBool NavigationStyle::isZoomAtCursor() const
+{
+ return this->zoomAtCursor;
+}
+
void NavigationStyle::startSelection(AbstractMouseSelection* mouse)
{
if (!mouse)
diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h
index 5b7087ef1..846e65f86 100644
--- a/src/Gui/NavigationStyle.h
+++ b/src/Gui/NavigationStyle.h
@@ -111,6 +111,9 @@ public:
void setZoomInverted(SbBool);
SbBool isZoomInverted() const;
+ void setZoomStep(float);
+ void setZoomAtCursor(SbBool);
+ SbBool isZoomAtCursor() const;
void updateAnimation();
void redraw();
@@ -162,6 +165,7 @@ protected:
void panToCenter(const SbPlane & pplane, const SbVec2f & currpos);
void zoom(SoCamera * camera, float diffvalue);
void zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos);
+ void doZoom(SoCamera * camera, SbBool forward, const SbVec2f& pos);
void spin(const SbVec2f & pointerpos);
SbBool doSpin();
@@ -191,6 +195,8 @@ protected:
SbBool ctrldown, shiftdown, altdown;
SbBool button1down, button2down, button3down;
SbBool invertZoom;
+ SbBool zoomAtCursor;
+ float zoomStep;
/** @name Mouse model */
//@{
diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp
index e192e11d6..530b0650d 100644
--- a/src/Gui/TouchpadNavigationStyle.cpp
+++ b/src/Gui/TouchpadNavigationStyle.cpp
@@ -154,17 +154,11 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
this->setViewing(true);
break;
case SoKeyboardEvent::PAGE_UP:
- if (this->invertZoom)
- zoom(viewer->getCamera(), 0.05f);
- else
- zoom(viewer->getCamera(), -0.05f);
+ doZoom(viewer->getCamera(), TRUE, posn);
processed = TRUE;
break;
case SoKeyboardEvent::PAGE_DOWN:
- if (this->invertZoom)
- zoom(viewer->getCamera(), -0.05f);
- else
- zoom(viewer->getCamera(), 0.05f);
+ doZoom(viewer->getCamera(), FALSE, posn);
processed = TRUE;
break;
default:
diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp
index 0b9f870bf..262916d1e 100644
--- a/src/Gui/View3DInventor.cpp
+++ b/src/Gui/View3DInventor.cpp
@@ -276,6 +276,14 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
bool on = rGrp.GetBool("InvertZoom", false);
_viewer->navigationStyle()->setZoomInverted(on);
}
+ else if (strcmp(Reason,"ZoomAtCursor") == 0) {
+ bool on = rGrp.GetBool("ZoomAtCursor", false);
+ _viewer->navigationStyle()->setZoomAtCursor(on);
+ }
+ else if (strcmp(Reason,"ZoomSetp") == 0) {
+ float val = rGrp.GetFloat("ZoomSetp", 0.0f);
+ _viewer->navigationStyle()->setZoomStep(val);
+ }
else if (strcmp(Reason,"EyeDistance") == 0) {
_viewer->setStereoOffset(rGrp.GetFloat("EyeDistance",65.0));
}