OpenWalnut  1.5.0dev
WGEAdvancedManipulator.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2017 OpenWalnut Community
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 WGEADVANCEDMANIPULATOR_H
26 #define WGEADVANCEDMANIPULATOR_H
27 
28 #include <osgGA/TrackballManipulator>
29 
30 /**
31  * TrackballManipulator with added mouse wheel zoom. Home function
32  * will also choose appropriate zoom for ALL nodes in the scene graph.
33  * This means also for the deactivated ones.
34  */
35 class WGEAdvancedManipulator: public osgGA::TrackballManipulator
36 {
37 public:
38  /**
39  * Default constructor
40  */
42 
43  /**
44  * Set the position of the manipulator using a 4x4 matrix.
45  * \param matrix position of the manipulator
46  */
47  virtual void setByMatrix( const osg::Matrixd& matrix );
48 
49  /**
50  * Get the position of the manipulator as 4x4 matrix.
51  *
52  * \return the matrix representing the transformation
53  */
54  virtual osg::Matrixd getMatrix() const;
55 
56  /**
57  * Get the manipulator only containing rotation and translation.
58  *
59  * \return the matrix with translation and rotation.
60  */
61  virtual osg::Matrixd getMatrixWithoutZoom() const;
62 
63  /**
64  * Get the position of the manipulator as a inverse matrix of the
65  * manipulator, typically used as a model view matrix.
66  *
67  * \return the inverse matrix
68  */
69  virtual osg::Matrixd getInverseMatrix() const;
70 
71  /**
72  * Move the camera to the default position.
73  * \param currentTime Variable specified in osg class but not used.
74  */
75  virtual void home( double currentTime );
76 
77  /**
78  * Handle events, return true if handled, false otherwise.
79  * \param ea Event class for storing Keyboard, mouse and window events.
80  * \param us Interface by which GUIEventHandlers may request actions of the GUI system
81  *
82  * \return true if event was handled
83  */
84  virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
85 
86  /**
87  * Get zoom factor.
88  *
89  * \return the current zoom factor
90  */
91  double getZoom() const;
92 
93  /**
94  * Set zoom factor.
95  * \param zoom the zoom factor to be set.
96  */
97  void setZoom( double zoom );
98 
99  /**
100  * setter for paint mode
101  * when set to something different from 0, a left drag should move the scene
102  *
103  * \param mode the mode
104  */
105  void setPaintMode( int mode );
106 
107  /**
108  * En-/Disables throwing.
109  *
110  * \param allowThrow if true, throwing is enabled.
111  */
112  void setThrow( bool allowThrow = true );
113 
114  /**
115  * Checks whether throwing is active.
116  *
117  * \return true if active
118  */
119  bool getThrow() const;
120 
121 protected:
122 private:
123  /**
124  * Handles events related to zooming.
125  * \param ea Event class for storing Keyboard, mouse and window events.
126  * \param us Interface by which GUIEventHandlers may request actions of the GUI system
127  *
128  * \return true if event was handled
129  */
130  bool zoom( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
131 
132  double m_zoom; //!< Zoom factor.
133  bool m_allowThrow; //!< Do we want the auto-rotation thingy?
134 
135  int m_paintMode; //!<paint mode
136 };
137 
138 inline double WGEAdvancedManipulator::getZoom() const
139 {
140  return m_zoom;
141 }
142 
143 inline void WGEAdvancedManipulator::setZoom( double zoom )
144 {
145  m_zoom = zoom;
146 }
147 
148 #endif // WGEADVANCEDMANIPULATOR_H
TrackballManipulator with added mouse wheel zoom.
void setPaintMode(int mode)
setter for paint mode when set to something different from 0, a left drag should move the scene
bool getThrow() const
Checks whether throwing is active.
void setZoom(double zoom)
Set zoom factor.
double getZoom() const
Get zoom factor.
WGEAdvancedManipulator()
Default constructor.
void setThrow(bool allowThrow=true)
En-/Disables throwing.
bool zoom(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handles events related to zooming.
bool m_allowThrow
Do we want the auto-rotation thingy?
virtual osg::Matrixd getMatrix() const
Get the position of the manipulator as 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...
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events, return true if handled, false otherwise.
virtual osg::Matrixd getMatrixWithoutZoom() const
Get the manipulator only containing rotation and translation.
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the manipulator using a 4x4 matrix.
virtual void home(double currentTime)
Move the camera to the default position.