OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SphericalManipulator.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef __SphericalManipulator_h__
15 #define __SphericalManipulator_h__
16 
17 #include <osgGA/CameraManipulator>
18 #include <osg/Math>
19 #include <osg/Quat>
20 
21 namespace osgGA
22 {
23 
25 {
26  public:
28 
29  virtual const char* className() const { return "Spherical Manipulator"; }
30 
32  virtual void setByMatrix(const osg::Matrixd& matrix);
33 
35  virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
36 
38  virtual osg::Matrixd getMatrix() const;
39 
41  virtual osg::Matrixd getInverseMatrix() const;
42 
45 
47  virtual float getFusionDistanceValue() const { return _distance; }
48 
53  virtual void setNode(osg::Node*);
54 
56  virtual const osg::Node* getNode() const;
57 
59  virtual osg::Node* getNode();
60 
63  virtual void home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
64  virtual void home(double);
65 
67  virtual void init(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
68 
69  void zoomOn(const osg::BoundingSphere& bound);
70 
72  virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
73 
75  virtual void computeHomePosition();
76 
77  void computeViewPosition(const osg::BoundingSphere& bound,double& scale,double& distance,osg::Vec3d& center);
78 
79  void setCenter(const osg::Vec3d& center) {_center=center;}
80  const osg::Vec3d& getCenter() const {return _center;}
81 
82  bool setDistance(double distance);
83  double getDistance() const { return _distance; }
84 
85  double getHomeDistance() const { return _homeDistance; }
86 
87  void setHeading(double azimuth) { _heading = azimuth; }
88  double getHeading() const {return _heading;}
89 
90  void setElevation(double elevation) { _elevation = elevation; }
91  double getElevtion() const {return _elevation;}
92 
93 
95  double getMinimumZoomScale() const { return _minimumZoomScale; }
96 
99  void setMinimumZoomScale(double minimumZoomScale) {_minimumZoomScale=minimumZoomScale;}
100 
101 
104  void setScroolWheelZoomDelta(double zoomDelta) { _zoomDelta = zoomDelta; }
105 
107  double getScroolWheelZoomDelta() const { return _zoomDelta; }
108 
109 
111  virtual void getUsage(osg::ApplicationUsage& usage) const;
112 
114  {
115  ELEVATION_HEADING=0,
118  MAP
119  };
120 
121  RotationMode getRotationMode() const {return _rotationMode;}
122  void setRotationMode(RotationMode mode);
123 
125  bool getAllowThrow() const { return _allowThrow; }
127  void setAllowThrow(bool allowThrow) { _allowThrow = allowThrow; }
128 
129  protected:
130 
131  virtual ~SphericalManipulator();
132 
134  void flushMouseEventStack();
136  void addMouseEvent(const osgGA::GUIEventAdapter& ea);
137 
140  bool calcMovement();
141 
144  bool isMouseMoving();
145 
146  // Internal event stack comprising last two mouse events.
149 
151 
152  double _modelScale;
154 
155  bool _thrown;
157 
163 
168 
171  double _distance;
172  double _heading; // angle from x axis in xy plane
173  double _elevation; // angle from xy plane, positive upwards towards the z axis
175  double _zoomDelta;
176 };
177 }
178 #endif
void setAllowThrow(bool allowThrow)
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
void setElevation(double elevation)
virtual const char * className() const
void setCenter(const osg::Vec3d &center)
virtual float getFusionDistanceValue() const
#define OSGGA_EXPORT
Definition: Export.h:40
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
static Matrixd inverse(const Matrixd &matrix)
Definition: Matrixd.h:530
void setMinimumZoomScale(double minimumZoomScale)
osg::observer_ptr< osg::Node > _node
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t1
const osg::Vec3d & getCenter() const
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t0
Definition: Node.h:71
void setHeading(double azimuth)
void setScroolWheelZoomDelta(double zoomDelta)
RotationMode getRotationMode() const