OpenWalnut  1.4.0
WGENoOpManipulator.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGENOOPMANIPULATOR_H
26 #define WGENOOPMANIPULATOR_H
27 
28 #include <osg/Version>
29 
30 // OSG interface changed in 2.9.7, to make it compile also with those versions we do this:
31 // OSG_MIN_VERSION_REQUIRED(2, 9, 8) macro is not available in e.g. OSG 2.8.1, hence we use the old way
32 #if ( ( OPENSCENEGRAPH_MAJOR_VERSION > 2 ) || ( OPENSCENEGRAPH_MAJOR_VERSION == 2 && ( OPENSCENEGRAPH_MINOR_VERSION > 9 || \
33  ( OPENSCENEGRAPH_MINOR_VERSION == 9 && OPENSCENEGRAPH_PATCH_VERSION >= 8 ) ) ) )
34  #include <osgGA/CameraManipulator>
35  namespace osgGA
36  {
37  typedef CameraManipulator MatrixManipulator;
38  }
39 #else
40  #include <osgGA/MatrixManipulator>
41 #endif
42 
43 /**
44  * This is an OSG Manipulator implementation which does nothing. It is very useful for simple two-d views.
45  */
46 class WGENoOpManipulator: public osgGA::MatrixManipulator
47 {
48 public:
49  /**
50  * Convenience typedef for a boost::shared_ptr< WGENoOpManipulator >.
51  */
52  typedef osg::ref_ptr< WGENoOpManipulator > SPtr;
53 
54  /**
55  * Convenience typedef for a boost::shared_ptr< const WGENoOpManipulator >.
56  */
57  typedef osg::ref_ptr< const WGENoOpManipulator > ConstSPtr;
58 
59  /**
60  * Default constructor.
61  */
63 
64  /**
65  * Destructor.
66  */
67  virtual ~WGENoOpManipulator();
68 
69  /**
70  * Return the name of the object's class type.
71  *
72  * \return the name of the object's class type
73  */
74  virtual const char* className() const;
75 
76 
77  /**
78  * Set the position of the matrix manipulator using a 4x4 matrix.
79  *
80  * \param matrix a 4x4 matrix
81  */
82  virtual void setByMatrix( const osg::Matrixd& matrix );
83 
84  /**
85  * Set the position of the matrix manipulator using a 4x4 matrix.
86  *
87  * \param matrix a 4x4 matrix
88  */
89  virtual void setByInverseMatrix( const osg::Matrixd& matrix );
90 
91  /**
92  * Get the position of the manipulator as 4x4 matrix.
93  *
94  * \return the position of the manipulator as 4x4 matrix
95  */
96  virtual osg::Matrixd getMatrix() const;
97 
98  /**
99  * Get the position of the manipulator as a inverse matrix of the
100  * manipulator, typically used as a model view matrix.
101  *
102  * \return the position of the manipulator as a inverse matrix
103  */
104  virtual osg::Matrixd getInverseMatrix() const;
105 
106  /**
107  * Move the camera to the default position.
108  *
109  * \param us the action adapter used to request actions of the GUI
110  */
111  virtual void home( const osgGA::GUIEventAdapter& /*ea*/, osgGA::GUIActionAdapter& us ); // NOLINT We can not change the interface of OSG
112 
113  /**
114  * Start/restart the manipulator.
115  *
116  * \param us the action adapter used to request actions of the GUI
117  */
118  virtual void init( const osgGA::GUIEventAdapter& /*ea*/, osgGA::GUIActionAdapter& us ); // NOLINT We can not change the interface of OSG
119 
120  /**
121  * Handle events
122  *
123  * \param ea event class for storing keyboard, mouse and window events
124  * \param us the action adapter used to request actions of the GUI
125  * \return true if handled, false otherwise
126  */
127  virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
128 
129 protected:
130 private:
131 };
132 
133 #endif // WGENOOPMANIPULATOR_H
134 
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events.
virtual const char * className() const
Return the name of the object's class type.
WGENoOpManipulator()
Default constructor.
virtual void init(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Start/restart the manipulator.
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual void home(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Move the camera to the default position.
osg::ref_ptr< const WGENoOpManipulator > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WGENoOpManipulator >.
virtual osg::Matrixd getMatrix() const
Get the position of the manipulator as 4x4 matrix.
This is an OSG Manipulator implementation which does nothing.
osg::ref_ptr< WGENoOpManipulator > SPtr
Convenience typedef for a boost::shared_ptr< WGENoOpManipulator >.
virtual ~WGENoOpManipulator()
Destructor.
virtual osg::Matrixd getInverseMatrix() const
Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...