diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index 81fc6f5202..eff5b5a43d 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index 53d893f0ff..563b4db7f0 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -121,7 +121,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 4c57393cb4..543cd8c522 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -125,7 +125,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index dc66d74beb..bdb8d5e111 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -1387,55 +1387,6 @@ void NavigationStyle::syncModifierKeys(const SoEvent * const ev) } } -SbBool NavigationStyle::handleKeyboardEvent(const SoKeyboardEvent * const event, const SbVec2f & posn) -{ - SbBool processed = false; - const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; - switch (event->getKey()) { - case SoKeyboardEvent::LEFT_CONTROL: - case SoKeyboardEvent::RIGHT_CONTROL: - this->ctrldown = press; - break; - case SoKeyboardEvent::LEFT_SHIFT: - case SoKeyboardEvent::RIGHT_SHIFT: - this->shiftdown = press; - break; - case SoKeyboardEvent::LEFT_ALT: - case SoKeyboardEvent::RIGHT_ALT: - this->altdown = press; - break; - case SoKeyboardEvent::H: - processed = true; - viewer->saveHomePosition(); - break; - case SoKeyboardEvent::R: - processed = true; - viewer->resetToHomePosition(); - break; - case SoKeyboardEvent::S: - case SoKeyboardEvent::HOME: - case SoKeyboardEvent::LEFT_ARROW: - case SoKeyboardEvent::UP_ARROW: - case SoKeyboardEvent::RIGHT_ARROW: - case SoKeyboardEvent::DOWN_ARROW: - if (!this->isViewing()) - this->setViewing(true); - break; - case SoKeyboardEvent::PAGE_UP: - processed = true; - doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn); - break; - case SoKeyboardEvent::PAGE_DOWN: - processed = true; - doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn); - break; - default: - break; - } - - return processed; -} - // The viewer is a state machine, and all changes to the current state // are made through this call. void NavigationStyle::setViewingMode(const ViewerMode newmode) @@ -1664,6 +1615,61 @@ SbBool NavigationStyle::processMotionEvent(const SoMotion3Event * const ev) return true; } +SbBool NavigationStyle::processKeyboardEvent(const SoKeyboardEvent * const event) +{ + SbBool processed = false; + const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; + switch (event->getKey()) { + case SoKeyboardEvent::LEFT_CONTROL: + case SoKeyboardEvent::RIGHT_CONTROL: + this->ctrldown = press; + break; + case SoKeyboardEvent::LEFT_SHIFT: + case SoKeyboardEvent::RIGHT_SHIFT: + this->shiftdown = press; + break; + case SoKeyboardEvent::LEFT_ALT: + case SoKeyboardEvent::RIGHT_ALT: + this->altdown = press; + break; + case SoKeyboardEvent::H: + processed = true; + viewer->saveHomePosition(); + break; + case SoKeyboardEvent::R: + processed = true; + viewer->resetToHomePosition(); + break; + case SoKeyboardEvent::S: + case SoKeyboardEvent::HOME: + case SoKeyboardEvent::LEFT_ARROW: + case SoKeyboardEvent::UP_ARROW: + case SoKeyboardEvent::RIGHT_ARROW: + case SoKeyboardEvent::DOWN_ARROW: + if (!this->isViewing()) + this->setViewing(true); + break; + case SoKeyboardEvent::PAGE_UP: + { + processed = true; + const SbVec2f posn = normalizePixelPos(event->getPosition()); + doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn); + break; + } + case SoKeyboardEvent::PAGE_DOWN: + { + processed = true; + const SbVec2f posn = normalizePixelPos(event->getPosition()); + doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn); + break; + } + default: + break; + } + + return processed; +} + void NavigationStyle::setPopupMenuEnabled(const SbBool on) { this->menuenabled = on; diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 3ef16058d7..7a6fbfdb9d 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -152,6 +152,7 @@ public: int getViewingMode() const; virtual SbBool processEvent(const SoEvent * const ev); virtual SbBool processMotionEvent(const SoMotion3Event * const ev); + virtual SbBool processKeyboardEvent(const SoKeyboardEvent * const event); void setPopupMenuEnabled(const SbBool on); SbBool isPopupMenuEnabled(void) const; @@ -215,7 +216,6 @@ protected: void addToLog(const SbVec2s pos, const SbTime time); void syncModifierKeys(const SoEvent * const ev); - SbBool handleKeyboardEvent(const SoKeyboardEvent * const event, const SbVec2f & posn); protected: struct { // tracking mouse movement in a log diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/OpenCascadeNavigationStyle.cpp index 58501d9d7b..0b79107ea4 100644 --- a/src/Gui/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/OpenCascadeNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/OpenSCADNavigationStyle.cpp index 75b34dac11..629eb0be29 100644 --- a/src/Gui/OpenSCADNavigationStyle.cpp +++ b/src/Gui/OpenSCADNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/RevitNavigationStyle.cpp index 3408929108..99bf448e4c 100644 --- a/src/Gui/RevitNavigationStyle.cpp +++ b/src/Gui/RevitNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/TinkerCADNavigationStyle.cpp index 524d1eb210..14b540dd7a 100644 --- a/src/Gui/TinkerCADNavigationStyle.cpp +++ b/src/Gui/TinkerCADNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp index 606412fdd8..035aa118b0 100644 --- a/src/Gui/TouchpadNavigationStyle.cpp +++ b/src/Gui/TouchpadNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling