1 #ifndef FGMANIPULATOR_H
2 #define FGMANIPULATOR_H 1
5 #include <osgGA/MatrixManipulator>
9 class FGManipulator : public osgGA::MatrixManipulator {
12 idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
13 mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0)
15 virtual ~FGManipulator() {}
17 virtual const char* className() const {return "FGManipulator"; }
19 /** set the position of the matrix manipulator using a 4x4 Matrix.*/
20 virtual void setByMatrix(const osg::Matrixd& matrix);
22 virtual void setByInverseMatrix(const osg::Matrixd& matrix)
23 { setByMatrix(osg::Matrixd::inverse(matrix)); }
25 /** get the position of the manipulator as 4x4 Matrix.*/
26 virtual osg::Matrixd getMatrix() const;
28 /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
29 virtual osg::Matrixd getInverseMatrix() const;
31 virtual void setNode(osg::Node* node);
33 const osg::Node* getNode() const;
37 virtual void init(const osgGA::GUIEventAdapter& ea,
38 osgGA::GUIActionAdapter& us);
40 virtual bool handle(const osgGA::GUIEventAdapter& ea,
41 osgGA::GUIActionAdapter& us);
43 void setIdleHandler(fgIdleHandler idleHandler)
45 this->idleHandler = idleHandler;
48 fgIdleHandler getIdleHandler() const
53 void setDrawHandler(fgDrawHandler drawHandler)
55 this->drawHandler = drawHandler;
58 fgDrawHandler getDrawHandler() const
63 void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
65 this->windowResizeHandler = windowResizeHandler;
68 fgWindowResizeHandler getWindowResizeHandler() const
70 return windowResizeHandler;
73 void setKeyHandler(fgKeyHandler keyHandler)
75 this->keyHandler = keyHandler;
78 fgKeyHandler getKeyHandler() const
83 void setMouseClickHandler(fgMouseClickHandler mouseClickHandler)
85 this->mouseClickHandler = mouseClickHandler;
88 fgMouseClickHandler getMouseClickHandler()
90 return mouseClickHandler;
93 void setMouseMotionHandler(fgMouseMotionHandler mouseMotionHandler)
95 this->mouseMotionHandler = mouseMotionHandler;
98 fgMouseMotionHandler getMouseMotionHandler()
100 return mouseMotionHandler;
103 int getCurrentModifiers() const
105 return currentModifiers;
107 void setPosition(const osg::Vec3d position) { this->position = position; }
108 void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
111 osg::ref_ptr<osg::Node> _node;
112 fgIdleHandler idleHandler;
113 fgDrawHandler drawHandler;
114 fgWindowResizeHandler windowResizeHandler;
115 fgKeyHandler keyHandler;
116 fgMouseClickHandler mouseClickHandler;
117 fgMouseMotionHandler mouseMotionHandler;
118 int currentModifiers;
121 void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);