SphericalManipulator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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.
*/
#ifndef __SphericalManipulator_h__
#define __SphericalManipulator_h__
#include <osgGA/CameraManipulator>
#include <osg/Math>
#include <osg/Quat>
namespace osgGA
{
class OSGGA_EXPORT SphericalManipulator : public CameraManipulator
{
public:
SphericalManipulator();
virtual const char* className() const { return "Spherical Manipulator"; }
virtual void setByMatrix(const osg::Matrixd& matrix);
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
virtual osg::Matrixd getMatrix() const;
virtual osg::Matrixd getInverseMatrix() const;
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
virtual float getFusionDistanceValue() const { return _distance; }
virtual void setNode(osg::Node*);
virtual const osg::Node* getNode() const;
virtual osg::Node* getNode();
virtual void home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
virtual void home(double);
virtual void init(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
void zoomOn(const osg::BoundingSphere& bound);
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
virtual void computeHomePosition();
void computeViewPosition(const osg::BoundingSphere& bound,double& scale,double& distance,osg::Vec3d& center);
void setCenter(const osg::Vec3d& center) {_center=center;}
const osg::Vec3d& getCenter() const {return _center;}
bool setDistance(double distance);
double getDistance() const { return _distance; }
double getHomeDistance() const { return _homeDistance; }
void setHeading(double azimuth) { _heading = azimuth; }
double getHeading() const {return _heading;}
void setElevation(double elevation) { _elevation = elevation; }
double getElevtion() const {return _elevation;}
double getMinimumZoomScale() const { return _minimumZoomScale; }
void setMinimumZoomScale(double minimumZoomScale) {_minimumZoomScale=minimumZoomScale;}
void setScroolWheelZoomDelta(double zoomDelta) { _zoomDelta = zoomDelta; }
double getScroolWheelZoomDelta() const { return _zoomDelta; }
virtual void getUsage(osg::ApplicationUsage& usage) const;
enum RotationMode
{
ELEVATION_HEADING=0,
HEADING,
ELEVATION,
MAP
};
RotationMode getRotationMode() const {return _rotationMode;}
void setRotationMode(RotationMode mode);
bool getAllowThrow() const { return _allowThrow; }
void setAllowThrow(bool allowThrow) { _allowThrow = allowThrow; }
protected:
virtual ~SphericalManipulator();
void flushMouseEventStack();
void addMouseEvent(const osgGA::GUIEventAdapter& ea);
bool calcMovement();
bool isMouseMoving();
// Internal event stack comprising last two mouse events.
osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t1;
osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t0;
osg::observer_ptr<osg::Node> _node;
double _modelScale;
double _minimumZoomScale;
bool _thrown;
bool _allowThrow;
double _delta_frame_time;
double _last_frame_time;
RotationMode _rotationMode;
osg::Vec3d _center;
double _distance;
double _heading; // angle from x axis in xy plane
double _elevation; // angle from xy plane, positive upwards towards the z axis
double _homeDistance;
double _zoomDelta;
};
}
#endif
CameraManipulator
Math
Quat
osgGA::CameraManipulator::CameraManipulator
CameraManipulator()
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgGA::SphericalManipulator::getDistance
double getDistance() const
Definition SphericalManipulator:83
osgGA::SphericalManipulator::getElevtion
double getElevtion() const
Definition SphericalManipulator:91
osgGA::SphericalManipulator::setAllowThrow
void setAllowThrow(bool allowThrow)
Definition SphericalManipulator:127
osgGA::SphericalManipulator::init
virtual void init(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::SphericalManipulator::home
virtual void home(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::SphericalManipulator::_homeDistance
double _homeDistance
Definition SphericalManipulator:174
osgGA::SphericalManipulator::calcMovement
bool calcMovement()
osgGA::SphericalManipulator::_ga_t1
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t1
Definition SphericalManipulator:147
osgGA::SphericalManipulator::getFusionDistanceMode
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
Definition SphericalManipulator:44
osgGA::SphericalManipulator::computeViewPosition
void computeViewPosition(const osg::BoundingSphere &bound, double &scale, double &distance, osg::Vec3d &center)
osgGA::SphericalManipulator::home
virtual void home(double)
osgGA::SphericalManipulator::zoomOn
void zoomOn(const osg::BoundingSphere &bound)
osgGA::SphericalManipulator::_modelScale
double _modelScale
Definition SphericalManipulator:152
osgGA::SphericalManipulator::_elevation
double _elevation
Definition SphericalManipulator:173
osgGA::SphericalManipulator::_minimumZoomScale
double _minimumZoomScale
Definition SphericalManipulator:153
osgGA::SphericalManipulator::setNode
virtual void setNode(osg::Node *)
osgGA::SphericalManipulator::handle
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::SphericalManipulator::setElevation
void setElevation(double elevation)
Definition SphericalManipulator:90
osgGA::SphericalManipulator::flushMouseEventStack
void flushMouseEventStack()
osgGA::SphericalManipulator::setByInverseMatrix
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Definition SphericalManipulator:35
osgGA::SphericalManipulator::_last_frame_time
double _last_frame_time
Definition SphericalManipulator:167
osgGA::SphericalManipulator::_distance
double _distance
Definition SphericalManipulator:171
osgGA::SphericalManipulator::getInverseMatrix
virtual osg::Matrixd getInverseMatrix() const
osgGA::SphericalManipulator::getRotationMode
RotationMode getRotationMode() const
Definition SphericalManipulator:121
osgGA::SphericalManipulator::_delta_frame_time
double _delta_frame_time
Definition SphericalManipulator:162
osgGA::SphericalManipulator::SphericalManipulator
SphericalManipulator()
osgGA::SphericalManipulator::setMinimumZoomScale
void setMinimumZoomScale(double minimumZoomScale)
Definition SphericalManipulator:99
osgGA::SphericalManipulator::getCenter
const osg::Vec3d & getCenter() const
Definition SphericalManipulator:80
osgGA::SphericalManipulator::className
virtual const char * className() const
Definition SphericalManipulator:29
osgGA::SphericalManipulator::setCenter
void setCenter(const osg::Vec3d &center)
Definition SphericalManipulator:79
osgGA::SphericalManipulator::setHeading
void setHeading(double azimuth)
Definition SphericalManipulator:87
osgGA::SphericalManipulator::setRotationMode
void setRotationMode(RotationMode mode)
osgGA::SphericalManipulator::getMinimumZoomScale
double getMinimumZoomScale() const
Definition SphericalManipulator:95
osgGA::SphericalManipulator::setByMatrix
virtual void setByMatrix(const osg::Matrixd &matrix)
osgGA::SphericalManipulator::setScroolWheelZoomDelta
void setScroolWheelZoomDelta(double zoomDelta)
Definition SphericalManipulator:104
osgGA::SphericalManipulator::getAllowThrow
bool getAllowThrow() const
Definition SphericalManipulator:125
osgGA::SphericalManipulator::_center
osg::Vec3d _center
Definition SphericalManipulator:170
osgGA::SphericalManipulator::getNode
virtual const osg::Node * getNode() const
osgGA::SphericalManipulator::_ga_t0
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t0
Definition SphericalManipulator:148
osgGA::SphericalManipulator::RotationMode
RotationMode
Definition SphericalManipulator:114
osgGA::SphericalManipulator::ELEVATION_HEADING
@ ELEVATION_HEADING
Definition SphericalManipulator:115
osgGA::SphericalManipulator::HEADING
@ HEADING
Definition SphericalManipulator:116
osgGA::SphericalManipulator::ELEVATION
@ ELEVATION
Definition SphericalManipulator:117
osgGA::SphericalManipulator::MAP
@ MAP
Definition SphericalManipulator:118
osgGA::SphericalManipulator::_rotationMode
RotationMode _rotationMode
Definition SphericalManipulator:169
osgGA::SphericalManipulator::_thrown
bool _thrown
Definition SphericalManipulator:155
osgGA::SphericalManipulator::getScroolWheelZoomDelta
double getScroolWheelZoomDelta() const
Definition SphericalManipulator:107
osgGA::SphericalManipulator::_heading
double _heading
Definition SphericalManipulator:172
osgGA::SphericalManipulator::getMatrix
virtual osg::Matrixd getMatrix() const
osgGA::SphericalManipulator::getUsage
virtual void getUsage(osg::ApplicationUsage &usage) const
osgGA::SphericalManipulator::getFusionDistanceValue
virtual float getFusionDistanceValue() const
Definition SphericalManipulator:47
osgGA::SphericalManipulator::getHeading
double getHeading() const
Definition SphericalManipulator:88
osgGA::SphericalManipulator::getNode
virtual osg::Node * getNode()
osgGA::SphericalManipulator::addMouseEvent
void addMouseEvent(const osgGA::GUIEventAdapter &ea)
osgGA::SphericalManipulator::isMouseMoving
bool isMouseMoving()
osgGA::SphericalManipulator::computeHomePosition
virtual void computeHomePosition()
osgGA::SphericalManipulator::setDistance
bool setDistance(double distance)
osgGA::SphericalManipulator::~SphericalManipulator
virtual ~SphericalManipulator()
osgGA::SphericalManipulator::_node
osg::observer_ptr< osg::Node > _node
Definition SphericalManipulator:150
osgGA::SphericalManipulator::_zoomDelta
double _zoomDelta
Definition SphericalManipulator:175
osgGA::SphericalManipulator::getHomeDistance
double getHomeDistance() const
Definition SphericalManipulator:85
osgGA::SphericalManipulator::_allowThrow
bool _allowThrow
Definition SphericalManipulator:156
osgUtil::SceneView::FusionDistanceMode
FusionDistanceMode
Definition SceneView:339
osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE
@ USE_FUSION_DISTANCE_VALUE
Definition SceneView:341
osg::ApplicationUsage
Definition ApplicationUsage:26
osg::Matrixd
Definition Matrixd:27
osg::Matrixd::inverse
static Matrixd inverse(const Matrixd &matrix)
Definition Matrixd:536
osg::Node
Definition Node:72
osg::Vec3d
Definition Vec3d:30
osg::observer_ptr
Definition observer_ptr:39
osg::ref_ptr
Definition ref_ptr:32
osgGA
Definition Callback:21
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
OSGGA_EXPORT
#define OSGGA_EXPORT
Definition osgGA/Export:40