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;
107 void setMouseWarped()
112 void setPosition(const osg::Vec3d position) { this->position = position; }
113 void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
115 /** Whether or not resizing is supported. It might not be when
116 * using multiple displays.
118 bool getResizable() { return resizable; }
119 void setResizable(bool _resizable) { resizable = _resizable; }
121 bool getUseEventModifiers() { return useEventModifiers; }
122 void setUseEventModifiers(bool val) { useEventModifiers = val; }
124 osg::ref_ptr<osg::Node> _node;
125 fgIdleHandler idleHandler;
126 fgDrawHandler drawHandler;
127 fgWindowResizeHandler windowResizeHandler;
128 fgKeyHandler keyHandler;
129 fgMouseClickHandler mouseClickHandler;
130 fgMouseMotionHandler mouseMotionHandler;
131 int currentModifiers;
132 // work-around for OSG bug
134 typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
135 KeyMaskMap keyMaskMap;
136 std::map<int, int> numlockKeyMap;
139 void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
142 // workaround for osgViewer double scroll events
143 bool scrollButtonPressed;
144 int release_keys[128];
145 // When the viewer is embedded, the host toolkit may deliver a
146 // valid event mask but not control keys.
147 bool useEventModifiers;