1 #ifndef FGMANIPULATOR_H
2 #define FGMANIPULATOR_H 1
6 #include <osgGA/MatrixManipulator>
10 class FGManipulator : public osgGA::MatrixManipulator {
14 virtual ~FGManipulator() {}
16 virtual const char* className() const {return "FGManipulator"; }
18 /** set the position of the matrix manipulator using a 4x4 Matrix.*/
19 virtual void setByMatrix(const osg::Matrixd& matrix);
21 virtual void setByInverseMatrix(const osg::Matrixd& matrix)
22 { setByMatrix(osg::Matrixd::inverse(matrix)); }
24 /** get the position of the manipulator as 4x4 Matrix.*/
25 virtual osg::Matrixd getMatrix() const;
27 /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
28 virtual osg::Matrixd getInverseMatrix() const;
30 virtual void setNode(osg::Node* node);
32 const osg::Node* getNode() const;
36 virtual void init(const osgGA::GUIEventAdapter& ea,
37 osgGA::GUIActionAdapter& us);
39 virtual bool handle(const osgGA::GUIEventAdapter& ea,
40 osgGA::GUIActionAdapter& us);
42 void setIdleHandler(fgIdleHandler idleHandler)
44 this->idleHandler = idleHandler;
47 fgIdleHandler getIdleHandler() const
52 void setDrawHandler(fgDrawHandler drawHandler)
54 this->drawHandler = drawHandler;
57 fgDrawHandler getDrawHandler() const
62 void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
64 this->windowResizeHandler = windowResizeHandler;
67 fgWindowResizeHandler getWindowResizeHandler() const
69 return windowResizeHandler;
72 void setKeyHandler(fgKeyHandler keyHandler)
74 this->keyHandler = keyHandler;
77 fgKeyHandler getKeyHandler() const
82 void setMouseClickHandler(fgMouseClickHandler mouseClickHandler)
84 this->mouseClickHandler = mouseClickHandler;
87 fgMouseClickHandler getMouseClickHandler()
89 return mouseClickHandler;
92 void setMouseMotionHandler(fgMouseMotionHandler mouseMotionHandler)
94 this->mouseMotionHandler = mouseMotionHandler;
97 fgMouseMotionHandler getMouseMotionHandler()
99 return mouseMotionHandler;
102 int getCurrentModifiers() const
104 return currentModifiers;
106 void setPosition(const osg::Vec3d position) { this->position = position; }
107 void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
110 osg::ref_ptr<osg::Node> _node;
111 fgIdleHandler idleHandler;
112 fgDrawHandler drawHandler;
113 fgWindowResizeHandler windowResizeHandler;
114 fgKeyHandler keyHandler;
115 fgMouseClickHandler mouseClickHandler;
116 fgMouseMotionHandler mouseMotionHandler;
117 int currentModifiers;
118 // work-around for OSG bug
120 typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
121 KeyMaskMap keyMaskMap;
124 void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);