OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OrbitManipulator.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 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  * OrbitManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
14  * while some pieces of code were taken from OSG.
15  * Thanks to company Cadwork (www.cadwork.ch) and
16  * Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
17 */
18 
19 #ifndef OSGGA_ORBIT_MANIPULATOR
20 #define OSGGA_ORBIT_MANIPULATOR 1
21 
22 #include <osgGA/StandardManipulator>
23 
24 
25 namespace osgGA {
26 
27 
32 {
34 
35  public:
36 
37  OrbitManipulator( int flags = DEFAULT_SETTINGS );
39  const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
40 
42 
43  virtual void setByMatrix( const osg::Matrixd& matrix );
44  virtual void setByInverseMatrix( const osg::Matrixd& matrix );
45  virtual osg::Matrixd getMatrix() const;
46  virtual osg::Matrixd getInverseMatrix() const;
47 
48  virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation );
49  virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up );
50  virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const;
51  virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const;
52 
53  void setHeading( double azimuth );
54  double getHeading() const;
55  void setElevation( double elevation );
56  double getElevation() const;
57 
58  virtual void setCenter( const osg::Vec3d& center );
59  const osg::Vec3d& getCenter() const;
60  virtual void setRotation( const osg::Quat& rotation );
61  const osg::Quat& getRotation() const;
62  virtual void setDistance( double distance );
63  double getDistance() const;
64 
65  virtual void setTrackballSize( const double& size );
66  inline double getTrackballSize() const;
67  virtual void setWheelZoomFactor( double wheelZoomFactor );
68  inline double getWheelZoomFactor() const;
69 
70  virtual void setMinimumDistance( const double& minimumDistance, bool relativeToModelSize = false );
71  double getMinimumDistance( bool *relativeToModelSize = NULL ) const;
72 
73  virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const;
74  virtual float getFusionDistanceValue() const;
75 
76  protected:
77 
78  virtual bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
79 
80  virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
81  virtual bool performMovementMiddleMouseButton( const double eventTimeDelta, const double dx, const double dy );
82  virtual bool performMovementRightMouseButton( const double eventTimeDelta, const double dx, const double dy );
83  virtual bool performMouseDeltaMovement( const float dx, const float dy );
84  virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
85 
86  virtual void rotateTrackball( const float px0, const float py0,
87  const float px1, const float py1, const float scale );
88  virtual void rotateWithFixedVertical( const float dx, const float dy );
89  virtual void rotateWithFixedVertical( const float dx, const float dy, const osg::Vec3f& up );
90  virtual void panModel( const float dx, const float dy, const float dz = 0.f );
91  virtual void zoomModel( const float dy, bool pushForwardIfNeeded = true );
92  void trackball( osg::Vec3d& axis, float& angle, float p1x, float p1y, float p2x, float p2y );
93  float tb_project_to_sphere( float r, float x, float y );
94  virtual bool startAnimationByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
95 
98  double _distance;
99 
102 
105 
107  public:
109  void start( const osg::Vec3d& movement, const double startTime );
110  };
111  virtual void allocAnimationData() { _animationData = new OrbitAnimationData(); }
112 };
113 
114 
115 //
116 // inline functions
117 //
118 
120 inline double OrbitManipulator::getTrackballSize() const { return _trackballSize; }
123 
124 
125 }
126 
127 #endif /* OSGGA_ORBIT_MANIPULATOR */
#define NULL
Definition: Export.h:59
double getTrackballSize() const
static int _minimumDistanceFlagIndex
double getWheelZoomFactor() const
#define OSGGA_EXPORT
Definition: Export.h:40
#define META_Object(library, name)
Definition: Object.h:42
virtual void allocAnimationData()
Definition: Quat.h:29