From 06ef559d91d02d122cade98387658b0191bbe124 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 11 Mar 2009 10:50:03 +0000 Subject: [PATCH] From Martin Beckett, added get/setScrollWheelZoomDelta() support for controlling the mouse scroll wheel zoom delta. --- include/osgGA/TrackballManipulator | 8 ++++++++ src/osgGA/TrackballManipulator.cpp | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/osgGA/TrackballManipulator b/include/osgGA/TrackballManipulator index 73557505b..024c18da5 100644 --- a/include/osgGA/TrackballManipulator +++ b/include/osgGA/TrackballManipulator @@ -78,6 +78,13 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator /** get the minimum distance (as ratio) the eye point can be zoomed in */ double getMinimumZoomScale() const { return _minimumZoomScale; } + /** set the mouse scroll wheel zoom delta. + * Range -1.0 to +1.0, -ve value inverts wheel direction and zero switches off scroll wheel. */ + void setScroolWheelZoomDelta(double zoomDelta) { _zoomDelta = zoomDelta; } + + /** get the mouse scroll wheel zoom delta. */ + double getScroolWheelZoomDelta() const { return _zoomDelta; } + /** Set the center of the trackball. */ void setCenter(const osg::Vec3d& center) { _center = center; } @@ -139,6 +146,7 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator osg::Quat _rotation; double _distance; float _trackballSize; + float _zoomDelta; }; diff --git a/src/osgGA/TrackballManipulator.cpp b/src/osgGA/TrackballManipulator.cpp index 09f586c34..d5532bb9b 100644 --- a/src/osgGA/TrackballManipulator.cpp +++ b/src/osgGA/TrackballManipulator.cpp @@ -14,6 +14,7 @@ TrackballManipulator::TrackballManipulator() _distance = 1.0f; _trackballSize = 0.8f; + _zoomDelta = 0.1f; } @@ -245,7 +246,7 @@ void TrackballManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& bool TrackballManipulator::calcMovement() { - // mosue scroll is only a single event + // mouse scroll is only a single event if (_ga_t0.get()==NULL) return false; float dx=0.0f; @@ -254,7 +255,7 @@ bool TrackballManipulator::calcMovement() if (_ga_t0->getEventType()==GUIEventAdapter::SCROLL) { - dy = _ga_t0->getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_DOWN ? -0.1 : 0.1; + dy = _ga_t0->getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP ? _zoomDelta : -_zoomDelta; buttonMask=GUIEventAdapter::SCROLL; } else