From 27de3f76f4c400ba00e1178b175b1173f07b0217 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 21 May 2012 18:27:30 +0200 Subject: [PATCH] 0000712: Cad Navigation Zoom with Ctrl + causes shapes to pan off screen --- src/Gui/CommandView.cpp | 16 +++------------- src/Gui/NavigationStyle.cpp | 10 ++++++++++ src/Gui/NavigationStyle.h | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 712131d68..33da94c7c 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -59,6 +59,7 @@ #include "DemoMode.h" #include "TextureMapping.h" #include "Utilities.h" +#include "NavigationStyle.h" #include #include @@ -1817,13 +1818,7 @@ void StdViewZoomIn::activated(int iMsg) View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); if ( view ) { View3DInventorViewer* viewer = view->getViewer(); - - // send an event to the GL widget to use the internal View3DInventorViewer::zoom() method - // do only one step to zoom in - SoMouseButtonEvent e; - e.setButton(SoMouseButtonEvent::BUTTON5); - e.setState(SoMouseButtonEvent::DOWN); - viewer->sendSoEvent(&e); + viewer->navigationStyle()->zoomIn(); } } @@ -1857,12 +1852,7 @@ void StdViewZoomOut::activated(int iMsg) View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); if (view) { View3DInventorViewer* viewer = view->getViewer(); - // send an event to the GL widget to use the internal View3DInventorViewer::zoom() method - // do only one step to zoom out - SoMouseButtonEvent e; - e.setButton(SoMouseButtonEvent::BUTTON4); - e.setState(SoMouseButtonEvent::DOWN); - viewer->sendSoEvent(&e); + viewer->navigationStyle()->zoomOut(); } } diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 192cb7ae5..30f5ecf40 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -721,6 +721,16 @@ void NavigationStyle::zoomByCursor(const SbVec2f & thispos, const SbVec2f & prev zoom(viewer->getCamera(), (thispos[1] - prevpos[1]) * 10.0f/*20.0f*/); } +void NavigationStyle::zoomIn() +{ + zoom(viewer->getCamera(), -this->zoomStep); +} + +void NavigationStyle::zoomOut() +{ + zoom(viewer->getCamera(), this->zoomStep); +} + void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& pos) { SbBool zoomAtCur = this->zoomAtCursor; diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 7644a7340..b6d4e20e6 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -115,6 +115,8 @@ public: void setZoomStep(float); void setZoomAtCursor(SbBool); SbBool isZoomAtCursor() const; + void zoomIn(); + void zoomOut(); void updateAnimation(); void redraw();