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; }
109 /** Whether or not resizing is supported. It might not be when
110 * using multiple displays.
112 bool getResizable() { return resizable; }
113 void setResizable(bool _resizable) { resizable = _resizable; }
116 osg::ref_ptr<osg::Node> _node;
117 fgIdleHandler idleHandler;
118 fgDrawHandler drawHandler;
119 fgWindowResizeHandler windowResizeHandler;
120 fgKeyHandler keyHandler;
121 fgMouseClickHandler mouseClickHandler;
122 fgMouseMotionHandler mouseMotionHandler;
123 int currentModifiers;
124 // work-around for OSG bug
126 typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
127 KeyMaskMap keyMaskMap;
128 std::map<int, int> numlockKeyMap;
131 void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);