OrbitManipulator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* OrbitManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
* while some pieces of code were taken from OSG.
* Thanks to company Cadwork (www.cadwork.ch) and
* Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
*/
#ifndef OSGGA_ORBIT_MANIPULATOR
#define OSGGA_ORBIT_MANIPULATOR 1
#include <osgGA/StandardManipulator>
namespace osgGA {
class OSGGA_EXPORT OrbitManipulator : public StandardManipulator
{
typedef StandardManipulator inherited;
public:
OrbitManipulator( int flags = DEFAULT_SETTINGS );
OrbitManipulator( const OrbitManipulator& om,
const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
META_Object( osgGA, OrbitManipulator );
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;
void setElevation( double elevation );
double getElevation() const;
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 );
inline double getTrackballSize() const;
virtual void setWheelZoomFactor( double wheelZoomFactor );
inline 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;
protected:
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 );
osg::Vec3d _center;
osg::Quat _rotation;
double _distance;
double _trackballSize;
double _wheelZoomFactor;
double _minimumDistance;
static int _minimumDistanceFlagIndex;
class OrbitAnimationData : public AnimationData {
public:
osg::Vec3d _movement;
void start( const osg::Vec3d& movement, const double startTime );
};
virtual void allocAnimationData() { _animationData = new OrbitAnimationData(); }
};
//
// inline functions
//
inline double OrbitManipulator::getTrackballSize() const { return _trackballSize; }
inline double OrbitManipulator::getWheelZoomFactor() const { return _wheelZoomFactor; }
}
#endif /* OSGGA_ORBIT_MANIPULATOR */
StandardManipulator
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgGA::OrbitManipulator::OrbitAnimationData
Definition OrbitManipulator:106
osgGA::OrbitManipulator::OrbitAnimationData::_movement
osg::Vec3d _movement
Definition OrbitManipulator:108
osgGA::OrbitManipulator::OrbitAnimationData::start
void start(const osg::Vec3d &movement, const double startTime)
osgGA::OrbitManipulator::applyAnimationStep
virtual void applyAnimationStep(const double currentProgress, const double prevProgress)
osgGA::OrbitManipulator::performMovementLeftMouseButton
virtual bool performMovementLeftMouseButton(const double eventTimeDelta, const double dx, const double dy)
osgGA::OrbitManipulator::performMovementRightMouseButton
virtual bool performMovementRightMouseButton(const double eventTimeDelta, const double dx, const double dy)
osgGA::OrbitManipulator::getDistance
double getDistance() const
osgGA::OrbitManipulator::setTrackballSize
virtual void setTrackballSize(const double &size)
osgGA::OrbitManipulator::getFusionDistanceValue
virtual float getFusionDistanceValue() const
osgGA::OrbitManipulator::getRotation
const osg::Quat & getRotation() const
osgGA::OrbitManipulator::setByMatrix
virtual void setByMatrix(const osg::Matrixd &matrix)
osgGA::OrbitManipulator::setWheelZoomFactor
virtual void setWheelZoomFactor(double wheelZoomFactor)
osgGA::OrbitManipulator::META_Object
META_Object(osgGA, OrbitManipulator)
osgGA::OrbitManipulator::rotateWithFixedVertical
virtual void rotateWithFixedVertical(const float dx, const float dy, const osg::Vec3f &up)
osgGA::OrbitManipulator::performMovementMiddleMouseButton
virtual bool performMovementMiddleMouseButton(const double eventTimeDelta, const double dx, const double dy)
osgGA::OrbitManipulator::tb_project_to_sphere
float tb_project_to_sphere(float r, float x, float y)
osgGA::OrbitManipulator::_distance
double _distance
Definition OrbitManipulator:98
osgGA::OrbitManipulator::getMinimumDistance
double getMinimumDistance(bool *relativeToModelSize=NULL) const
osgGA::OrbitManipulator::setRotation
virtual void setRotation(const osg::Quat &rotation)
osgGA::OrbitManipulator::getHeading
double getHeading() const
osgGA::OrbitManipulator::_minimumDistanceFlagIndex
static int _minimumDistanceFlagIndex
Definition OrbitManipulator:104
osgGA::OrbitManipulator::getTransformation
virtual void getTransformation(osg::Vec3d &eye, osg::Vec3d &center, osg::Vec3d &up) const
osgGA::OrbitManipulator::setCenter
virtual void setCenter(const osg::Vec3d &center)
osgGA::OrbitManipulator::getWheelZoomFactor
double getWheelZoomFactor() const
Definition OrbitManipulator:122
osgGA::OrbitManipulator::getMatrix
virtual osg::Matrixd getMatrix() const
osgGA::OrbitManipulator::setMinimumDistance
virtual void setMinimumDistance(const double &minimumDistance, bool relativeToModelSize=false)
osgGA::OrbitManipulator::_trackballSize
double _trackballSize
Definition OrbitManipulator:100
osgGA::OrbitManipulator::rotateTrackball
virtual void rotateTrackball(const float px0, const float py0, const float px1, const float py1, const float scale)
osgGA::OrbitManipulator::getTransformation
virtual void getTransformation(osg::Vec3d &eye, osg::Quat &rotation) const
osgGA::OrbitManipulator::performMouseDeltaMovement
virtual bool performMouseDeltaMovement(const float dx, const float dy)
osgGA::OrbitManipulator::trackball
void trackball(osg::Vec3d &axis, float &angle, float p1x, float p1y, float p2x, float p2y)
osgGA::OrbitManipulator::_minimumDistance
double _minimumDistance
Definition OrbitManipulator:103
osgGA::OrbitManipulator::handleMouseWheel
virtual bool handleMouseWheel(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::OrbitManipulator::allocAnimationData
virtual void allocAnimationData()
Definition OrbitManipulator:111
osgGA::OrbitManipulator::setElevation
void setElevation(double elevation)
osgGA::OrbitManipulator::getElevation
double getElevation() const
osgGA::OrbitManipulator::setTransformation
virtual void setTransformation(const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up)
osgGA::OrbitManipulator::getFusionDistanceMode
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
osgGA::OrbitManipulator::getTrackballSize
double getTrackballSize() const
Definition OrbitManipulator:120
osgGA::OrbitManipulator::setDistance
virtual void setDistance(double distance)
osgGA::OrbitManipulator::panModel
virtual void panModel(const float dx, const float dy, const float dz=0.f)
osgGA::OrbitManipulator::setHeading
void setHeading(double azimuth)
osgGA::OrbitManipulator::rotateWithFixedVertical
virtual void rotateWithFixedVertical(const float dx, const float dy)
osgGA::OrbitManipulator::setTransformation
virtual void setTransformation(const osg::Vec3d &eye, const osg::Quat &rotation)
osgGA::OrbitManipulator::startAnimationByMousePointerIntersection
virtual bool startAnimationByMousePointerIntersection(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::OrbitManipulator::OrbitManipulator
OrbitManipulator(const OrbitManipulator &om, const osg::CopyOp &copyOp=osg::CopyOp::SHALLOW_COPY)
osgGA::OrbitManipulator::zoomModel
virtual void zoomModel(const float dy, bool pushForwardIfNeeded=true)
osgGA::OrbitManipulator::getInverseMatrix
virtual osg::Matrixd getInverseMatrix() const
osgGA::OrbitManipulator::_center
osg::Vec3d _center
Definition OrbitManipulator:96
osgGA::OrbitManipulator::getCenter
const osg::Vec3d & getCenter() const
osgGA::OrbitManipulator::OrbitManipulator
OrbitManipulator(int flags=DEFAULT_SETTINGS)
osgGA::OrbitManipulator::_rotation
osg::Quat _rotation
Definition OrbitManipulator:97
osgGA::OrbitManipulator::setByInverseMatrix
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
osgGA::OrbitManipulator::_wheelZoomFactor
double _wheelZoomFactor
Definition OrbitManipulator:101
osgGA::StandardManipulator::AnimationData::AnimationData
AnimationData()
osgGA::StandardManipulator::StandardManipulator
StandardManipulator(int flags=DEFAULT_SETTINGS)
osgGA::StandardManipulator::DEFAULT_SETTINGS
@ DEFAULT_SETTINGS
Definition StandardManipulator:43
osgGA::StandardManipulator::_animationData
osg::ref_ptr< AnimationData > _animationData
Definition StandardManipulator:159
osgUtil::SceneView::FusionDistanceMode
FusionDistanceMode
Definition SceneView:339
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Matrixd
Definition Matrixd:27
osg::Quat
Definition Quat:30
osg::Vec3d
Definition Vec3d:30
osg::Vec3f
Definition Vec3f:29
osgGA
Definition Callback:21
OSGGA_EXPORT
#define OSGGA_EXPORT
Definition osgGA/Export:40
NULL
#define NULL
Definition osg/Export:55