OpenWalnut  1.5.0dev
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 <memory>
29 
30 #include <osg/Version>
31 
32 // OSG interface changed in 2.9.7, to make it compile also with those versions we do this:
33 // OSG_MIN_VERSION_REQUIRED(2, 9, 8) macro is not available in e.g. OSG 2.8.1, hence we use the old way
34 #if( ( OPENSCENEGRAPH_MAJOR_VERSION > 2 ) || ( OPENSCENEGRAPH_MAJOR_VERSION == 2 && ( OPENSCENEGRAPH_MINOR_VERSION > 9 || \
35  ( OPENSCENEGRAPH_MINOR_VERSION == 9 && OPENSCENEGRAPH_PATCH_VERSION >= 8 ) ) ) )
36  #include <osgGA/CameraManipulator>
37  namespace osgGA
38  {
39  typedef CameraManipulator MatrixManipulator;
40  }
41 #else
42  #include <osgGA/MatrixManipulator>
43 #endif
44 
45 /**
46  * This is an OSG Manipulator implementation which does nothing. It is very useful for simple two-d views.
47  */
48 class WGENoOpManipulator: public osgGA::MatrixManipulator
49 {
50 public:
51  /**
52  * Convenience typedef for a std::shared_ptr< WGENoOpManipulator >.
53  */
54  typedef osg::ref_ptr< WGENoOpManipulator > SPtr;
55 
56  /**
57  * Convenience typedef for a std::shared_ptr< const WGENoOpManipulator >.
58  */
59  typedef osg::ref_ptr< const WGENoOpManipulator > ConstSPtr;
60 
61  /**
62  * Default constructor.
63  */
65 
66  /**
67  * Destructor.
68  */
69  virtual ~WGENoOpManipulator();
70 
71  /**
72  * Return the name of the object's class type.
73  *
74  * \return the name of the object's class type
75  */
76  virtual const char* className() const;
77 
78 
79  /**
80  * Set the position of the matrix manipulator using a 4x4 matrix.
81  *
82  * \param matrix a 4x4 matrix
83  */
84  virtual void setByMatrix( const osg::Matrixd& matrix );
85 
86  /**
87  * Set the position of the matrix manipulator using a 4x4 matrix.
88  *
89  * \param matrix a 4x4 matrix
90  */
91  virtual void setByInverseMatrix( const osg::Matrixd& matrix );
92 
93  /**
94  * Get the position of the manipulator as 4x4 matrix.
95  *
96  * \return the position of the manipulator as 4x4 matrix
97  */
98  virtual osg::Matrixd getMatrix() const;
99 
100  /**
101  * Get the position of the manipulator as a inverse matrix of the
102  * manipulator, typically used as a model view matrix.
103  *
104  * \return the position of the manipulator as a inverse matrix
105  */
106  virtual osg::Matrixd getInverseMatrix() const;
107 
108  /**
109  * Move the camera to the default position.
110  *
111  * \param us the action adapter used to request actions of the GUI
112  */
113  virtual void home( const osgGA::GUIEventAdapter& /*ea*/, osgGA::GUIActionAdapter& us ); // NOLINT We can not change the interface of OSG
114 
115  /**
116  * Start/restart the manipulator.
117  *
118  * \param us the action adapter used to request actions of the GUI
119  */
120  virtual void init( const osgGA::GUIEventAdapter& /*ea*/, osgGA::GUIActionAdapter& us ); // NOLINT We can not change the interface of OSG
121 
122  /**
123  * Handle events
124  *
125  * \param ea event class for storing keyboard, mouse and window events
126  * \param us the action adapter used to request actions of the GUI
127  * \return true if handled, false otherwise
128  */
129  virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
130 
131 protected:
132 private:
133 };
134 
135 #endif // WGENOOPMANIPULATOR_H
136 
This is an OSG Manipulator implementation which does nothing.
virtual const char * className() const
Return the name of the object's class type.
WGENoOpManipulator()
Default constructor.
virtual osg::Matrixd getMatrix() const
Get the position of the manipulator as 4x4 matrix.
virtual void home(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Move the camera to the default position.
virtual ~WGENoOpManipulator()
Destructor.
osg::ref_ptr< const WGENoOpManipulator > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGENoOpManipulator >.
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual void init(const osgGA::GUIEventAdapter &, osgGA::GUIActionAdapter &us)
Start/restart the manipulator.
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events.
osg::ref_ptr< WGENoOpManipulator > SPtr
Convenience typedef for a std::shared_ptr< WGENoOpManipulator >.
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 matrix.
virtual osg::Matrixd getInverseMatrix() const
Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...