Gui: avoid code duplication in NavigationStyle and remove superfluous doZoom_wheel method
This commit is contained in:
@@ -319,12 +319,12 @@ public:
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_UP:
|
||||
if(!press){
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), ns.getDelta(), posn);
|
||||
}
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_DOWN:
|
||||
if(!press){
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), -ns.getDelta(), posn);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -345,13 +345,13 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_UP:
|
||||
if(press){
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn);
|
||||
}
|
||||
processed = true;
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_DOWN:
|
||||
if(press){
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn);
|
||||
}
|
||||
processed = true;
|
||||
break;
|
||||
|
||||
@@ -771,36 +771,17 @@ void NavigationStyle::zoomOut()
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), this->zoomStep);
|
||||
}
|
||||
|
||||
void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& pos)
|
||||
/*!
|
||||
* Returns the steps if the mouse wheel is rotated
|
||||
*/
|
||||
int NavigationStyle::getDelta() const
|
||||
{
|
||||
// SbBool zoomAtCur = this->zoomAtCursor;
|
||||
// if (zoomAtCur) {
|
||||
// const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
// float ratio = vp.getViewportAspectRatio();
|
||||
// SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
|
||||
// SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
|
||||
// panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, SbVec2f(0.5,0.5), pos);
|
||||
// }
|
||||
|
||||
float value = this->zoomStep;
|
||||
if (!forward)
|
||||
value = -value;
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
doZoom(camera, value, pos);
|
||||
|
||||
// if (zoomAtCur) {
|
||||
// const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
// float ratio = vp.getViewportAspectRatio();
|
||||
// SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
|
||||
// SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
|
||||
// panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, pos, SbVec2f(0.5,0.5));
|
||||
// }
|
||||
return 120;
|
||||
}
|
||||
|
||||
void NavigationStyle::doZoom_wheel(SoCamera* camera, int wheeldelta, const SbVec2f& pos)
|
||||
void NavigationStyle::doZoom(SoCamera* camera, int wheeldelta, const SbVec2f& pos)
|
||||
{
|
||||
float value =this->zoomStep * wheeldelta / float(120.0);
|
||||
float value = this->zoomStep * wheeldelta / float(getDelta());
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
doZoom(camera, value, pos);
|
||||
@@ -1483,7 +1464,7 @@ SbBool NavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
//handle mouse wheel zoom
|
||||
if(ev->isOfType(SoMouseWheelEvent::getClassTypeId())){
|
||||
doZoom_wheel(
|
||||
doZoom(
|
||||
viewer->getSoRenderManager()->getCamera(),
|
||||
static_cast<const SoMouseWheelEvent*>(ev)->getDelta(),
|
||||
posn
|
||||
|
||||
@@ -188,10 +188,10 @@ protected:
|
||||
const SbVec2f & current);
|
||||
void pan(SoCamera* camera);
|
||||
void panToCenter(const SbPlane & pplane, const SbVec2f & currpos);
|
||||
int getDelta() const;
|
||||
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, 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);
|
||||
|
||||
@@ -157,11 +157,11 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
this->setViewing(true);
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_UP:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), true, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn);
|
||||
processed = true;
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_DOWN:
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), false, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn);
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user