]> git.mxchange.org Git - flightgear.git/blob - src/Main/FGManipulator.hxx
remove redundant --airport-id option (OK'ed by Curt, no longer used by fgrun)
[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
107     void setMouseWarped()
108         {
109             mouseWarped = true;
110         }
111
112     void setPosition(const osg::Vec3d position) { this->position = position; }
113     void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
114
115     /** Whether or not resizing is supported. It might not be when
116      * using multiple displays.
117      */
118     bool getResizable() { return resizable; }
119     void setResizable(bool _resizable) { resizable = _resizable; }
120
121     bool getUseEventModifiers() { return useEventModifiers; }
122     void setUseEventModifiers(bool val) { useEventModifiers = val; }
123 protected:
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
133     int osgModifiers;
134     typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
135     KeyMaskMap keyMaskMap;
136     std::map<int, int> numlockKeyMap;
137     osg::Vec3d position;
138     osg::Quat attitude;
139     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
140     bool resizable;
141     bool mouseWarped;
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;
148 };
149 #endif