Gui: Pass wheel event to viewprovider
===================================== https://forum.freecadweb.org/viewtopic.php?p=578857#p578857
This commit is contained in:
committed by
abdullahtahiriyo
parent
33577a087f
commit
85cf3ca514
@@ -1493,14 +1493,17 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev)
|
||||
SbBool NavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
{
|
||||
bool processed = false;
|
||||
bool offeredtoViewerEventBase = false;
|
||||
|
||||
//handle mouse wheel zoom
|
||||
if (ev->isOfType(SoMouseWheelEvent::getClassTypeId())) {
|
||||
const SoMouseWheelEvent * const event = static_cast<const SoMouseWheelEvent *>(ev);
|
||||
processed = processWheelEvent(event);
|
||||
viewer->processSoEventBase(ev);
|
||||
offeredtoViewerEventBase = true;
|
||||
}
|
||||
|
||||
if (!processed) {
|
||||
if (!processed && !offeredtoViewerEventBase) {
|
||||
processed = viewer->processSoEventBase(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Matrix.h>
|
||||
|
||||
#include "SoMouseWheelEvent.h"
|
||||
#include "ViewProvider.h"
|
||||
#include "ActionFunction.h"
|
||||
#include "Application.h"
|
||||
@@ -217,7 +218,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
|
||||
// Therefore, we shall ignore ESC while any mouse button is
|
||||
// pressed, until this Coin bug is fixed.
|
||||
if (!press) {
|
||||
// react only on key release
|
||||
// react only on key release
|
||||
// Let first selection mode terminate
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
|
||||
@@ -229,7 +230,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Gui::TimerFunction* func = new Gui::TimerFunction();
|
||||
func->setAutoDelete(true);
|
||||
func->setFunction(boost::bind(&Document::resetEdit, doc));
|
||||
@@ -258,6 +259,12 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
|
||||
if (self->mouseButtonPressed(button,press,ev->getPosition(),viewer))
|
||||
node->setHandled();
|
||||
}
|
||||
else if (ev->getTypeId().isDerivedFrom(SoMouseWheelEvent::getClassTypeId())) {
|
||||
const SoMouseWheelEvent * const event = (const SoMouseWheelEvent *) ev;
|
||||
|
||||
if (self->mouseWheelEvent(event->getDelta(), event->getPosition(), viewer))
|
||||
node->setHandled();
|
||||
}
|
||||
// Mouse Movement handling
|
||||
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
||||
if (self->mouseMove(ev->getPosition(),viewer))
|
||||
@@ -670,6 +677,14 @@ bool ViewProvider::mouseButtonPressed(int button, bool pressed,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ViewProvider::mouseWheelEvent(int delta, const SbVec2s &cursorPos, const View3DInventorViewer* viewer)
|
||||
{
|
||||
(void) delta;
|
||||
(void) cursorPos;
|
||||
(void) viewer;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewProvider::setupContextMenu(QMenu* menu, QObject* receiver, const char* method)
|
||||
{
|
||||
auto vector = getExtensionsDerivedFromType<Gui::ViewProviderExtension>();
|
||||
|
||||
@@ -468,6 +468,8 @@ public:
|
||||
/// is called when the Provider is in edit and the mouse is clicked
|
||||
virtual bool mouseButtonPressed(int button, bool pressed, const SbVec2s &cursorPos,
|
||||
const View3DInventorViewer* viewer);
|
||||
|
||||
virtual bool mouseWheelEvent(int delta, const SbVec2s &cursorPos, const View3DInventorViewer* viewer);
|
||||
/// set up the context-menu with the supported edit modes
|
||||
virtual void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user