]> git.mxchange.org Git - flightgear.git/blob - src/Main/FGManipulator.hxx
set /sim/fg-current to current working directory; getcwd() is defined in
[flightgear.git] / src / Main / FGManipulator.hxx
1 #ifndef FGMANIPULATOR_H
2 #define FGMANIPULATOR_H 1
3
4 #include <map>
5 #include <osg/Quat>
6 #include <osgGA/MatrixManipulator>
7
8 #include "fg_os.hxx"
9
10 class FGManipulator : public osgGA::MatrixManipulator {
11 public:
12     FGManipulator();
13     
14     virtual ~FGManipulator() {}
15     
16     virtual const char* className() const {return "FGManipulator"; }
17
18     /** set the position of the matrix manipulator using a 4x4 Matrix.*/
19     virtual void setByMatrix(const osg::Matrixd& matrix);
20
21     virtual void setByInverseMatrix(const osg::Matrixd& matrix)
22         { setByMatrix(osg::Matrixd::inverse(matrix)); }
23
24     /** get the position of the manipulator as 4x4 Matrix.*/
25     virtual osg::Matrixd getMatrix() const;
26
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;
29
30     virtual void setNode(osg::Node* node);
31     
32     const osg::Node* getNode() const;
33
34     osg::Node* getNode();
35
36     virtual void init(const osgGA::GUIEventAdapter& ea,
37                       osgGA::GUIActionAdapter& us);
38
39     virtual bool handle(const osgGA::GUIEventAdapter& ea,
40                         osgGA::GUIActionAdapter& us);
41
42     void setIdleHandler(fgIdleHandler idleHandler)
43         {
44             this->idleHandler = idleHandler;
45         }
46
47     fgIdleHandler getIdleHandler() const
48         {
49             return idleHandler;
50         }
51
52     void setDrawHandler(fgDrawHandler drawHandler)
53         {
54             this->drawHandler = drawHandler;
55         }
56
57     fgDrawHandler getDrawHandler() const
58         {
59             return drawHandler;
60         }
61
62     void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
63         {
64             this->windowResizeHandler = windowResizeHandler;
65         }
66     
67     fgWindowResizeHandler getWindowResizeHandler() const
68         {
69             return windowResizeHandler;
70         }
71
72     void setKeyHandler(fgKeyHandler keyHandler)
73         {
74             this->keyHandler = keyHandler;
75         }
76
77     fgKeyHandler getKeyHandler() const
78         {
79             return keyHandler;
80         }
81
82     void setMouseClickHandler(fgMouseClickHandler mouseClickHandler)
83         {
84             this->mouseClickHandler = mouseClickHandler;
85         }
86     
87     fgMouseClickHandler getMouseClickHandler()
88         {
89             return mouseClickHandler;
90         }
91
92     void setMouseMotionHandler(fgMouseMotionHandler mouseMotionHandler)
93         {
94             this->mouseMotionHandler = mouseMotionHandler;
95         }
96     
97     fgMouseMotionHandler getMouseMotionHandler()
98         {
99             return mouseMotionHandler;
100         }
101
102     int getCurrentModifiers() const
103         {
104             return currentModifiers;
105         }
106     void setPosition(const osg::Vec3d position) { this->position = position; }
107     void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
108
109 protected:
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
119     int osgModifiers;
120     typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
121     KeyMaskMap keyMaskMap;
122     osg::Vec3d position;
123     osg::Quat attitude;
124     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
125
126 };
127 #endif