From befd78afd174de2b73981d54ebfffe856892adb8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Nov 2021 21:37:19 +0100 Subject: [PATCH] Gui: move handling of SoMouseWheelEvent to its own handler function --- src/Gui/GestureNavigationStyle.cpp | 1 + src/Gui/NavigationStyle.cpp | 32 ++++++++++++++++++------------ src/Gui/NavigationStyle.h | 2 ++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 7d0732ae54..946efb1dcf 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -72,6 +72,7 @@ #include "GestureNavigationStyle.h" #include +#include #include #include "View3DInventorViewer.h" #include "Application.h" diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index c75ad3869a..fb971292e1 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -1495,24 +1495,19 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) SbBool NavigationStyle::processSoEvent(const SoEvent * const ev) { - const SbVec2s pos(ev->getPosition()); - const SbVec2f posn = normalizePixelPos(pos); bool processed = false; //handle mouse wheel zoom - if(ev->isOfType(SoMouseWheelEvent::getClassTypeId())){ - doZoom( - viewer->getSoRenderManager()->getCamera(), - static_cast(ev)->getDelta(), - posn - ); - processed = true; + if (ev->isOfType(SoMouseWheelEvent::getClassTypeId())) { + const SoMouseWheelEvent * const event = static_cast(ev); + processed = processWheelEvent(event); } - if (! processed) - return viewer->processSoEventBase(ev); - else - return processed; + if (!processed) { + processed = viewer->processSoEventBase(ev); + } + + return processed; } void NavigationStyle::syncWithEvent(const SoEvent * const ev) @@ -1692,6 +1687,17 @@ SbBool NavigationStyle::processClickEvent(const SoMouseButtonEvent * const event return processed; } +SbBool NavigationStyle::processWheelEvent(const SoMouseWheelEvent * const event) +{ + const SbVec2s pos(event->getPosition()); + const SbVec2f posn = normalizePixelPos(pos); + + //handle mouse wheel zoom + doZoom(viewer->getSoRenderManager()->getCamera(), + event->getDelta(), posn); + return true; +} + void NavigationStyle::setPopupMenuEnabled(const SbBool on) { this->menuenabled = on; diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index f35e61f37a..7f493ec55a 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -41,6 +41,7 @@ // forward declarations class SoEvent; +class SoMouseWheelEvent; class SoMotion3Event; class SoQtViewer; class SoCamera; @@ -154,6 +155,7 @@ public: virtual SbBool processMotionEvent(const SoMotion3Event * const ev); virtual SbBool processKeyboardEvent(const SoKeyboardEvent * const event); virtual SbBool processClickEvent(const SoMouseButtonEvent * const event); + virtual SbBool processWheelEvent(const SoMouseWheelEvent * const event); void setPopupMenuEnabled(const SbBool on); SbBool isPopupMenuEnabled() const;