25 #include "WGE2DManipulator.h"
29 : m_positionX( -64.0 ),
37 return "WGE2DManipulator";
44 m_zoom = 1.0 / matrix.getScale().x();
51 m_zoom = matrix.getScale().x();
78 us.requestContinuousUpdate(
false );
84 switch( ea.getEventType() )
86 case( osgGA::GUIEventAdapter::PUSH ):
92 case( osgGA::GUIEventAdapter::DRAG ):
102 case( osgGA::GUIEventAdapter::SCROLL ):
112 case( osgGA::GUIEventAdapter::KEYDOWN ):
114 if( ea.getKey() == osgGA::GUIEventAdapter::KEY_Space )
134 usage.addKeyboardMouseBinding(
"Space",
"Reset the view to home" );
155 bool changed =
false;
159 unsigned int buttonMask =
m_ga_t0->getButtonMask();
160 if( buttonMask == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON
161 || buttonMask == ( osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON | osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON ) )
174 bool changed =
false;
177 switch( ea.getScrollingMotion() )
179 case osgGA::GUIEventAdapter::SCROLL_UP:
182 case osgGA::GUIEventAdapter::SCROLL_DOWN:
185 case osgGA::GUIEventAdapter::SCROLL_2D:
186 zoomDelta = -0.05 / 120.0 * ea.getScrollingDeltaY();
196 if( zoomDelta != 0.0 )
198 m_zoom *= 1.0 + zoomDelta;
bool calcMovement()
Calculate the movement of the camera for the given mouse movement.
virtual const char * className() const
Return the name of the object's class type.
bool zoom(const osgGA::GUIEventAdapter &ea)
Handles events related to zooming.
void flushMouseEventStack()
Reset the internal GUIEvent stack.
osg::ref_ptr< const osgGA::GUIEventAdapter > m_ga_t0
The newer event from the internal event stack.
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual void getUsage(osg::ApplicationUsage &usage) const
Get the keyboard and mouse usage of this manipulator.
void addMouseEvent(const osgGA::GUIEventAdapter &ea)
Add the current mouse GUIEvent to the internal stack.
virtual void home(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Move the camera to the default position.
virtual osg::Matrixd getMatrix() const
Get the position of the manipulator as 4x4 matrix.
WGE2DManipulator()
Constructor.
double m_positionX
The x-position of the viewing window's lower left corner.
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual ~WGE2DManipulator()
Destructor.
virtual osg::Matrixd getInverseMatrix() const
Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...
osg::ref_ptr< const osgGA::GUIEventAdapter > m_ga_t1
The older event from the internal event stack.
virtual void init(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Start/restart the manipulator.
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events.
double m_positionY
The y-position of the viewing window's lower left corner.