OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
osgGA::ViewManipulator Class Reference

#include "ViewManipulator.h"

Inheritance diagram for osgGA::ViewManipulator:

Classes

class  OrbitAnimationData
 

Public Member Functions

 ViewManipulator (int flags=DEFAULT_SETTINGS)
 Constructor.
 
 ViewManipulator (const ViewManipulator &om, const osg::CopyOp &copyOp=osg::CopyOp::SHALLOW_COPY)
 
virtual void setByMatrix (const osg::Matrixd &matrix)
 
virtual void setByInverseMatrix (const osg::Matrixd &matrix)
 
virtual osg::Matrixd getMatrix () const
 
virtual osg::Matrixd getInverseMatrix () const
 
virtual void setTransformation (const osg::Vec3d &eye, const osg::Quat &rotation)
 
virtual void setTransformation (const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up)
 
virtual void getTransformation (osg::Vec3d &eye, osg::Quat &rotation) const
 
virtual void getTransformation (osg::Vec3d &eye, osg::Vec3d &center, osg::Vec3d &up) const
 
void setHeading (double azimuth)
 
double getHeading () const
 Returns the heading in radians.
 
void setElevation (double elevation)
 
double getElevation () const
 Returns the elevation in radians.
 
virtual void setCenter (const osg::Vec3d &center)
 
const osg::Vec3d & getCenter () const
 
virtual void setRotation (const osg::Quat &rotation)
 
const osg::Quat & getRotation () const
 
virtual void setDistance (double distance)
 
double getDistance () const
 
virtual void setTrackballSize (const double &size)
 
double getTrackballSize () const
 
virtual void setWheelZoomFactor (double wheelZoomFactor)
 
double getWheelZoomFactor () const
 
virtual void setMinimumDistance (const double &minimumDistance, bool relativeToModelSize=false)
 
double getMinimumDistance (bool *relativeToModelSize=NULL) const
 
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode () const
 
virtual float getFusionDistanceValue () const
 
void setHandleMouseMovement (bool flag)
 

Protected Member Functions

virtual bool handleMouseWheel (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
 
virtual bool performMovementLeftMouseButton (const double eventTimeDelta, const double dx, const double dy)
 
virtual bool performMovementMiddleMouseButton (const double eventTimeDelta, const double dx, const double dy)
 
virtual bool performMovementRightMouseButton (const double eventTimeDelta, const double dx, const double dy)
 
virtual bool performMouseDeltaMovement (const float dx, const float dy)
 
virtual void applyAnimationStep (const double currentProgress, const double prevProgress)
 
virtual void rotateTrackball (const float px0, const float py0, const float px1, const float py1, const float scale)
 
virtual void rotateWithFixedVertical (const float dx, const float dy)
 
virtual void rotateWithFixedVertical (const float dx, const float dy, const osg::Vec3f &up)
 
virtual void panModel (const float dx, const float dy, const float dz=0.f)
 
virtual void zoomModel (const float dy, bool pushForwardIfNeeded=true)
 
void trackball (osg::Vec3d &axis, float &angle, float p1x, float p1y, float p2x, float p2y)
 
float tb_project_to_sphere (float r, float x, float y)
 
virtual bool startAnimationByMousePointerIntersection (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
 
virtual void allocAnimationData ()
 

Protected Attributes

osg::Vec3d _center
 
osg::Quat _rotation
 
double _distance
 
double _trackballSize
 
double _wheelZoomFactor
 
double _minimumDistance
 
bool handleMouseMovement
 

Static Protected Attributes

static int _minimumDistanceFlagIndex = allocateRelativeFlag()
 

Detailed Description

ViewManipulator is base class for camera control based on focal center, distance from the center, and orientation of distance vector to the eye. This is the base class for trackball style manipulators.

Constructor & Destructor Documentation

◆ ViewManipulator() [1/2]

ViewManipulator::ViewManipulator ( int flags = DEFAULT_SETTINGS)

Constructor.

◆ ViewManipulator() [2/2]

osgGA::ViewManipulator::ViewManipulator ( const ViewManipulator & om,
const osg::CopyOp & copyOp = osg::CopyOp::SHALLOW_COPY )

Member Function Documentation

◆ allocAnimationData()

virtual void osgGA::ViewManipulator::allocAnimationData ( )
inlineprotectedvirtual

◆ applyAnimationStep()

void ViewManipulator::applyAnimationStep ( const double currentProgress,
const double prevProgress )
protectedvirtual

◆ getCenter()

const Vec3d & ViewManipulator::getCenter ( ) const

Get the center of the manipulator.

◆ getDistance()

double ViewManipulator::getDistance ( ) const

Get the distance of the camera to the center.

◆ getElevation()

double ViewManipulator::getElevation ( ) const

Returns the elevation in radians.

See also
setElevation

◆ getFusionDistanceMode()

osgUtil::SceneView::FusionDistanceMode ViewManipulator::getFusionDistanceMode ( ) const
virtual

Get the FusionDistanceMode. Used by SceneView for setting up stereo convergence.

◆ getFusionDistanceValue()

float ViewManipulator::getFusionDistanceValue ( ) const
virtual

Get the FusionDistanceValue. Used by SceneView for setting up stereo convergence.

◆ getHeading()

double ViewManipulator::getHeading ( ) const

Returns the heading in radians.

See also
setHeading

◆ getInverseMatrix()

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

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

◆ getMatrix()

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

Get the position of the manipulator as 4x4 matrix.

◆ getMinimumDistance()

double ViewManipulator::getMinimumDistance ( bool * relativeToModelSize = NULL) const

Get the minimum distance of the eye point from the center before the center is pushed forward.

◆ getRotation()

const Quat & ViewManipulator::getRotation ( ) const

Get the rotation of the manipulator.

◆ getTrackballSize()

double osgGA::ViewManipulator::getTrackballSize ( ) const
inline

Get the size of the trackball relative to the model size.

◆ getTransformation() [1/2]

void ViewManipulator::getTransformation ( osg::Vec3d & eye,
osg::Quat & rotation ) const
virtual

◆ getTransformation() [2/2]

void ViewManipulator::getTransformation ( osg::Vec3d & eye,
osg::Vec3d & center,
osg::Vec3d & up ) const
virtual

◆ getWheelZoomFactor()

double osgGA::ViewManipulator::getWheelZoomFactor ( ) const
inline

Get the mouse wheel zoom factor.

◆ handleMouseWheel()

bool ViewManipulator::handleMouseWheel ( const osgGA::GUIEventAdapter & ea,
osgGA::GUIActionAdapter & us )
protectedvirtual

◆ panModel()

void ViewManipulator::panModel ( const float dx,
const float dy,
const float dz = 0.f )
protectedvirtual

Moves camera in x,y,z directions given in camera local coordinates.

◆ performMouseDeltaMovement()

bool ViewManipulator::performMouseDeltaMovement ( const float dx,
const float dy )
protectedvirtual

◆ performMovementLeftMouseButton()

bool ViewManipulator::performMovementLeftMouseButton ( const double eventTimeDelta,
const double dx,
const double dy )
protectedvirtual

◆ performMovementMiddleMouseButton()

bool ViewManipulator::performMovementMiddleMouseButton ( const double eventTimeDelta,
const double dx,
const double dy )
protectedvirtual

◆ performMovementRightMouseButton()

bool ViewManipulator::performMovementRightMouseButton ( const double eventTimeDelta,
const double dx,
const double dy )
protectedvirtual

◆ rotateTrackball()

void ViewManipulator::rotateTrackball ( const float px0,
const float py0,
const float px1,
const float py1,
const float scale )
protectedvirtual

Performs trackball rotation based on two points given, for example, by mouse pointer on the screen.

Scale parameter is useful, for example, when manipulator is thrown. It scales the amount of rotation based, for example, on the current frame time.

◆ rotateWithFixedVertical() [1/2]

void ViewManipulator::rotateWithFixedVertical ( const float dx,
const float dy )
protectedvirtual

Performs rotation horizontally by dx parameter and vertically by dy parameter, while keeping UP vector.

◆ rotateWithFixedVertical() [2/2]

virtual void osgGA::ViewManipulator::rotateWithFixedVertical ( const float dx,
const float dy,
const osg::Vec3f & up )
protectedvirtual

◆ setByInverseMatrix()

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

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

◆ setByMatrix()

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

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

◆ setCenter()

void ViewManipulator::setCenter ( const osg::Vec3d & center)
virtual

Set the center of the manipulator.

◆ setDistance()

void ViewManipulator::setDistance ( double distance)
virtual

Set the distance of camera to the center.

◆ setElevation()

void ViewManipulator::setElevation ( double elevation)

Sets the transformation by elevation. Elevation is given as an angle in radians from xy plane. Its meaning is similar to latitude used in cartography and navigation. Positive number is going to the north direction, negative to the south.

◆ setHandleMouseMovement()

void osgGA::ViewManipulator::setHandleMouseMovement ( bool flag)
inline

◆ setHeading()

void ViewManipulator::setHeading ( double azimuth)

Sets the transformation by heading. Heading is given as an angle in radians giving a azimuth in xy plane. Its meaning is similar to longitude used in cartography and navigation. Positive number is going to the east direction.

◆ setMinimumDistance()

void ViewManipulator::setMinimumDistance ( const double & minimumDistance,
bool relativeToModelSize = false )
virtual

Set the minimum distance of the eye point from the center before the center is pushed forward.

◆ setRotation()

void ViewManipulator::setRotation ( const osg::Quat & rotation)
virtual

Set the rotation of the manipulator.

◆ setTrackballSize()

void ViewManipulator::setTrackballSize ( const double & size)
virtual

Set the size of the trackball. Value is relative to the model size.

◆ setTransformation() [1/2]

void ViewManipulator::setTransformation ( const osg::Vec3d & eye,
const osg::Quat & rotation )
virtual

◆ setTransformation() [2/2]

void ViewManipulator::setTransformation ( const osg::Vec3d & eye,
const osg::Vec3d & center,
const osg::Vec3d & up )
virtual

◆ setWheelZoomFactor()

void ViewManipulator::setWheelZoomFactor ( double wheelZoomFactor)
virtual

Set the mouse wheel zoom factor. The amount of camera movement on each mouse wheel event is computed as the current distance to the center multiplied by this factor. For example, value of 0.1 will short distance to center by 10% on each wheel up event. Use negative value for reverse mouse wheel direction.

◆ startAnimationByMousePointerIntersection()

bool ViewManipulator::startAnimationByMousePointerIntersection ( const osgGA::GUIEventAdapter & ea,
osgGA::GUIActionAdapter & us )
protectedvirtual

◆ tb_project_to_sphere()

float ViewManipulator::tb_project_to_sphere ( float r,
float x,
float y )
protected

Helper trackball method that projects an x,y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the center of the sphere.

◆ trackball()

void ViewManipulator::trackball ( osg::Vec3d & axis,
float & angle,
float p1x,
float p1y,
float p2x,
float p2y )
protected

Simulate a track-ball. Project the points onto the virtual trackball, then figure out the axis of rotation, which is the cross product of P1 P2 and O P1 (O is the center of the ball, 0,0,0) Note: This is a deformed trackball– is a trackball in the center, but is deformed into a hyperbolic sheet of rotation away from the center. This particular function was chosen after trying out several variations.

It is assumed that the arguments to this routine are in the range (-1.0 ... 1.0)

◆ zoomModel()

void ViewManipulator::zoomModel ( const float dy,
bool pushForwardIfNeeded = true )
protectedvirtual

Changes the distance of camera to the focal center. If pushForwardIfNeeded is true and minimumDistance is reached, the focal center is moved forward. Otherwise, distance is limited to its minimum value.

See also
ViewManipulator::setMinimumDistance

Member Data Documentation

◆ _center

osg::Vec3d osgGA::ViewManipulator::_center
protected

◆ _distance

double osgGA::ViewManipulator::_distance
protected

◆ _minimumDistance

double osgGA::ViewManipulator::_minimumDistance
protected

◆ _minimumDistanceFlagIndex

int ViewManipulator::_minimumDistanceFlagIndex = allocateRelativeFlag()
staticprotected

◆ _rotation

osg::Quat osgGA::ViewManipulator::_rotation
protected

◆ _trackballSize

double osgGA::ViewManipulator::_trackballSize
protected

◆ _wheelZoomFactor

double osgGA::ViewManipulator::_wheelZoomFactor
protected

◆ handleMouseMovement

bool osgGA::ViewManipulator::handleMouseMovement
protected

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