25 #include "WGEZoomTrackballManipulator.h"
26 #include "WGraphicsEngine.h"
29 TrackballManipulator(),
31 m_allowThrow( false ),
34 setTrackballSize( .3 );
39 m_zoom = 1.0 / matrix.getScale()[0];
42 TrackballManipulator::setByMatrix( osg::Matrixd::inverse( osg::Matrixd::scale( 1.0 /
m_zoom, 1.0 /
m_zoom, 1.0 /
m_zoom ) ) * matrix );
47 return osg::Matrixd::scale( 1.0 /
m_zoom, 1.0 /
m_zoom, 1.0 /
m_zoom ) * TrackballManipulator::getMatrix();
52 return TrackballManipulator::getMatrix();
57 return TrackballManipulator::getInverseMatrix() * osg::Matrixd::scale(
m_zoom,
m_zoom,
m_zoom );
63 TrackballManipulator::home( 0 );
68 double zoomDelta = 0.0;
70 if( ea.getKey() && ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN )
72 if( ea.getKey() == 45 )
76 if( ea.getKey() == 43 )
80 if( zoomDelta != 0.0 )
93 switch( ea.getScrollingMotion() )
95 case osgGA::GUIEventAdapter::SCROLL_UP:
98 case osgGA::GUIEventAdapter::SCROLL_DOWN:
101 case osgGA::GUIEventAdapter::SCROLL_2D:
102 zoomDelta = 0.05 / 120.0 * ea.getScrollingDeltaY();
114 if( zoomDelta != 0.0 )
116 m_zoom *= 1.0 + zoomDelta;
120 us.requestContinuousUpdate(
false );
135 else if( ea.getEventType() == osgGA::GUIEventAdapter::SCROLL || ea.getKey() == 45 || ea.getKey() == 43 )
137 return zoom( ea, us );
141 else if( ( ea.getEventType() == osgGA::GUIEventAdapter::DRAG ) || ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH ) )
143 if( ea.getButtonMask() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
147 else if( ( ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ) && (
m_paintMode == 1 ) )
153 return TrackballManipulator::handle( ea, us );
158 return TrackballManipulator::handle( ea, us );
void setPaintMode(int mode)
setter for paint mode when set to something different from 0, a left drag should move the scene ...
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events, return true if handled, false otherwise.
bool getThrow() const
Checks whether throwing is active.
static boost::shared_ptr< WGraphicsEngine > getGraphicsEngine()
Returns instance of the graphics engine.
double m_zoom
Zoom factor.
virtual osg::Matrixd getMatrixWithoutZoom() const
Get the manipulator only containing rotation and translation.
virtual void home(double currentTime)
Move the camera to the default position.
virtual osg::Matrixd getMatrix() const
Get the position of the manipulator as 4x4 matrix.
int m_paintMode
paint mode
bool m_allowThrow
Do we want the auto-rotation thingy?
WGEZoomTrackballManipulator()
Default constructor.
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the manipulator using a 4x4 matrix.
void setThrow(bool allowThrow=true)
En-/Disables throwing.
virtual osg::Matrixd getInverseMatrix() const
Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...
bool zoom(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handles events related to zooming.