Gui: use SoMouseWheelEvent in navigation styles
This commit is contained in:
@@ -266,14 +266,6 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -310,14 +310,6 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -301,16 +301,6 @@ public:
|
||||
return transit<NS::AwaitingReleaseState>();
|
||||
}
|
||||
|
||||
//wheel events
|
||||
if(ev.isMouseButtonEvent() && ev.asMouseButtonEvent()->getButton() == SoMouseButtonEvent::BUTTON4){
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
ev.flags->processed = true;
|
||||
}
|
||||
if(ev.isMouseButtonEvent() && ev.asMouseButtonEvent()->getButton() == SoMouseButtonEvent::BUTTON5){
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
ev.flags->processed = true;
|
||||
}
|
||||
|
||||
//touchscreen gestures
|
||||
if(ev.isGestureActive()){
|
||||
ev.flags->processed = true;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#endif
|
||||
|
||||
#include <Inventor/sensors/SoTimerSensor.h>
|
||||
#include "SoMouseWheelEvent.h"
|
||||
|
||||
#include <App/Application.h>
|
||||
#include "NavigationStyle.h"
|
||||
@@ -284,14 +285,6 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -396,7 +389,9 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// If not handled in this class, pass on upwards in the inheritance
|
||||
// hierarchy.
|
||||
if ((curmode == NavigationStyle::SELECTION ||
|
||||
if (ev->isOfType(SoMouseWheelEvent::getClassTypeId()))
|
||||
processed = inherited::processSoEvent(ev);
|
||||
else if ((curmode == NavigationStyle::SELECTION ||
|
||||
newmode == NavigationStyle::SELECTION ||
|
||||
viewer->isEditing()) && !processed)
|
||||
processed = inherited::processSoEvent(ev);
|
||||
|
||||
@@ -423,14 +423,6 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4: //(wheel?)
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5: //(wheel?)
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "Application.h"
|
||||
#include "MenuManager.h"
|
||||
#include "MouseSelection.h"
|
||||
#include "SoMouseWheelEvent.h"
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
@@ -797,6 +798,13 @@ void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& po
|
||||
// }
|
||||
}
|
||||
|
||||
void NavigationStyle::doZoom_wheel(SoCamera* camera, int wheeldelta, const SbVec2f& pos)
|
||||
{
|
||||
float value =this->zoomStep * wheeldelta / float(120.0);
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
doZoom(camera, value, pos);
|
||||
}
|
||||
|
||||
/*!
|
||||
*\brief NavigationStyle::doZoom Zooms in or out by specified factor, keeping the point on screen specified by parameter pos fixed
|
||||
@@ -1466,7 +1474,27 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev)
|
||||
|
||||
SbBool NavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
{
|
||||
return viewer->processSoEventBase(ev);
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
|
||||
bool processed = false;
|
||||
|
||||
//handle mouse wheel zoom
|
||||
if(ev->isOfType(SoMouseWheelEvent::getClassTypeId())){
|
||||
doZoom_wheel(
|
||||
viewer->getSoRenderManager()->getCamera(),
|
||||
static_cast<const SoMouseWheelEvent*>(ev)->getDelta(),
|
||||
posn
|
||||
);
|
||||
processed = true;
|
||||
}
|
||||
|
||||
if (! processed)
|
||||
return viewer->processSoEventBase(ev);
|
||||
else
|
||||
return processed;
|
||||
}
|
||||
|
||||
void NavigationStyle::syncWithEvent(const SoEvent * const ev)
|
||||
|
||||
@@ -191,6 +191,7 @@ protected:
|
||||
void zoom(SoCamera * camera, float diffvalue);
|
||||
void zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos);
|
||||
void doZoom(SoCamera * camera, SbBool forward, const SbVec2f& pos);
|
||||
void doZoom_wheel(SoCamera * camera, int wheeldelta, const SbVec2f& pos);
|
||||
void doZoom(SoCamera * camera, float logzoomfactor, const SbVec2f& pos);
|
||||
void doRotate(SoCamera * camera, float angle, const SbVec2f& pos);
|
||||
void spin(const SbVec2f & pointerpos);
|
||||
|
||||
@@ -258,11 +258,6 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), button == SoMouseButtonEvent::BUTTON4, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -266,14 +266,6 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -248,14 +248,6 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
this->button2down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user