OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WGE2DManipulator Class Reference

A manipulator which changes the view of a 2D scene. More...

#include <WGE2DManipulator.h>

+ Inheritance diagram for WGE2DManipulator:
+ Collaboration diagram for WGE2DManipulator:

Public Member Functions

 WGE2DManipulator ()
 Constructor. More...
 
virtual const char * className () const
 Return the name of the object's class type. More...
 
virtual void setByMatrix (const osg::Matrixd &matrix)
 Set the position of the matrix manipulator using a 4x4 matrix. More...
 
virtual void setByInverseMatrix (const osg::Matrixd &matrix)
 Set the position of the matrix manipulator using a 4x4 matrix. More...
 
virtual osg::Matrixd getMatrix () const
 Get the position of the manipulator as 4x4 matrix. More...
 
virtual osg::Matrixd getInverseMatrix () const
 Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix. More...
 
virtual void home (const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
 Move the camera to the default position. More...
 
virtual void init (const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
 Start/restart the manipulator. More...
 
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
 Handle events. More...
 
virtual void getUsage (osg::ApplicationUsage &usage) const
 Get the keyboard and mouse usage of this manipulator. More...
 

Protected Member Functions

virtual ~WGE2DManipulator ()
 Destructor. More...
 
void flushMouseEventStack ()
 Reset the internal GUIEvent stack. More...
 
void addMouseEvent (const osgGA::GUIEventAdapter &ea)
 Add the current mouse GUIEvent to the internal stack. More...
 
bool calcMovement ()
 Calculate the movement of the camera for the given mouse movement. More...
 

Protected Attributes

osg::ref_ptr< const osgGA::GUIEventAdapter > m_ga_t1
 The older event from the internal event stack. More...
 
osg::ref_ptr< const osgGA::GUIEventAdapter > m_ga_t0
 The newer event from the internal event stack. More...
 

Private Member Functions

bool zoom (const osgGA::GUIEventAdapter &ea)
 Handles events related to zooming. More...
 

Private Attributes

double m_positionX
 The x-position of the viewing window's lower left corner. More...
 
double m_positionY
 The y-position of the viewing window's lower left corner. More...
 
double m_zoom
 zoom factor More...
 

Detailed Description

A manipulator which changes the view of a 2D scene.

Does things like panning and zooming.

Definition at line 49 of file WGE2DManipulator.h.

Constructor & Destructor Documentation

◆ WGE2DManipulator()

WGE2DManipulator::WGE2DManipulator ( )

Constructor.

Definition at line 28 of file WGE2DManipulator.cpp.

◆ ~WGE2DManipulator()

WGE2DManipulator::~WGE2DManipulator ( )
protectedvirtual

Destructor.

Note, is protected so that objects cannot be deleted other than by being dereferenced and the reference count being zero (see osg::Referenced), preventing the deletion of objects which are still in use.

Definition at line 137 of file WGE2DManipulator.cpp.

Member Function Documentation

◆ addMouseEvent()

void WGE2DManipulator::addMouseEvent ( const osgGA::GUIEventAdapter &  ea)
protected

Add the current mouse GUIEvent to the internal stack.

Parameters
eathe current event class with a mouse event

Definition at line 147 of file WGE2DManipulator.cpp.

References m_ga_t0, and m_ga_t1.

Referenced by handle().

+ Here is the caller graph for this function:

◆ calcMovement()

bool WGE2DManipulator::calcMovement ( )
protected

Calculate the movement of the camera for the given mouse movement.

Returns
true is camera has moved and a redraw is required

Definition at line 153 of file WGE2DManipulator.cpp.

References m_ga_t0, m_ga_t1, m_positionX, m_positionY, and m_zoom.

Referenced by handle().

+ Here is the caller graph for this function:

◆ className()

const char * WGE2DManipulator::className ( ) const
virtual

Return the name of the object's class type.

Returns
the name of the object's class type

Definition at line 35 of file WGE2DManipulator.cpp.

◆ flushMouseEventStack()

void WGE2DManipulator::flushMouseEventStack ( )
protected

Reset the internal GUIEvent stack.

Definition at line 141 of file WGE2DManipulator.cpp.

References m_ga_t0, and m_ga_t1.

Referenced by home(), and init().

+ Here is the caller graph for this function:

◆ getInverseMatrix()

osg::Matrixd WGE2DManipulator::getInverseMatrix ( ) const
virtual

Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.

Returns
the position of the manipulator as a inverse matrix

Definition at line 59 of file WGE2DManipulator.cpp.

References m_positionX, m_positionY, and m_zoom.

◆ getMatrix()

osg::Matrixd WGE2DManipulator::getMatrix ( ) const
virtual

Get the position of the manipulator as 4x4 matrix.

Returns
the position of the manipulator as 4x4 matrix

Definition at line 54 of file WGE2DManipulator.cpp.

References m_positionX, m_positionY, and m_zoom.

◆ getUsage()

void WGE2DManipulator::getUsage ( osg::ApplicationUsage &  usage) const
virtual

Get the keyboard and mouse usage of this manipulator.

Parameters
usagethe application usage

Definition at line 132 of file WGE2DManipulator.cpp.

◆ handle()

bool WGE2DManipulator::handle ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  us 
)
virtual

Handle events.

Parameters
eaevent class for storing keyboard, mouse and window events
usthe action adapter used to request actions of the GUI
Returns
true if handled, false otherwise

Definition at line 81 of file WGE2DManipulator.cpp.

References addMouseEvent(), calcMovement(), home(), and zoom().

+ Here is the call graph for this function:

◆ home()

void WGE2DManipulator::home ( const osgGA::GUIEventAdapter &  ,
osgGA::GUIActionAdapter &  us 
)
virtual

Move the camera to the default position.

Parameters
usthe action adapter used to request actions of the GUI

Definition at line 64 of file WGE2DManipulator.cpp.

References flushMouseEventStack(), m_positionX, m_positionY, and m_zoom.

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void WGE2DManipulator::init ( const osgGA::GUIEventAdapter &  ,
osgGA::GUIActionAdapter &  us 
)
virtual

Start/restart the manipulator.

Parameters
usthe action adapter used to request actions of the GUI

Definition at line 74 of file WGE2DManipulator.cpp.

References flushMouseEventStack().

+ Here is the call graph for this function:

◆ setByInverseMatrix()

void WGE2DManipulator::setByInverseMatrix ( const osg::Matrixd &  matrix)
virtual

Set the position of the matrix manipulator using a 4x4 matrix.

Parameters
matrixa 4x4 matrix

Definition at line 47 of file WGE2DManipulator.cpp.

References m_positionX, m_positionY, and m_zoom.

◆ setByMatrix()

void WGE2DManipulator::setByMatrix ( const osg::Matrixd &  matrix)
virtual

Set the position of the matrix manipulator using a 4x4 matrix.

Parameters
matrixa 4x4 matrix

Definition at line 40 of file WGE2DManipulator.cpp.

References m_positionX, m_positionY, and m_zoom.

◆ zoom()

bool WGE2DManipulator::zoom ( const osgGA::GUIEventAdapter &  ea)
private

Handles events related to zooming.

Parameters
eaevent class for storing keyboard, mouse and window events
Returns
true if event was handled

Definition at line 172 of file WGE2DManipulator.cpp.

References m_zoom.

Referenced by handle().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ga_t0

osg::ref_ptr< const osgGA::GUIEventAdapter > WGE2DManipulator::m_ga_t0
protected

The newer event from the internal event stack.

Definition at line 160 of file WGE2DManipulator.h.

Referenced by addMouseEvent(), calcMovement(), and flushMouseEventStack().

◆ m_ga_t1

osg::ref_ptr< const osgGA::GUIEventAdapter > WGE2DManipulator::m_ga_t1
protected

The older event from the internal event stack.

Definition at line 155 of file WGE2DManipulator.h.

Referenced by addMouseEvent(), calcMovement(), and flushMouseEventStack().

◆ m_positionX

double WGE2DManipulator::m_positionX
private

The x-position of the viewing window's lower left corner.

Definition at line 175 of file WGE2DManipulator.h.

Referenced by calcMovement(), getInverseMatrix(), getMatrix(), home(), setByInverseMatrix(), and setByMatrix().

◆ m_positionY

double WGE2DManipulator::m_positionY
private

The y-position of the viewing window's lower left corner.

Definition at line 180 of file WGE2DManipulator.h.

Referenced by calcMovement(), getInverseMatrix(), getMatrix(), home(), setByInverseMatrix(), and setByMatrix().

◆ m_zoom

double WGE2DManipulator::m_zoom
private

zoom factor

Definition at line 185 of file WGE2DManipulator.h.

Referenced by calcMovement(), getInverseMatrix(), getMatrix(), home(), setByInverseMatrix(), setByMatrix(), and zoom().


The documentation for this class was generated from the following files: