]> git.mxchange.org Git - flightgear.git/blob - src/Main/FGManipulator.hxx
cosmetic changes *only*:
[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 #include <osgViewer/ViewerEventHandlers>
8
9 #include "fg_os.hxx"
10
11 class FGManipulator : public osgGA::MatrixManipulator {
12 public:
13     FGManipulator();
14     
15     virtual ~FGManipulator() {}
16     
17     virtual const char* className() const {return "FGManipulator"; }
18
19     /** set the position of the matrix manipulator using a 4x4 Matrix.*/
20     virtual void setByMatrix(const osg::Matrixd& matrix);
21
22     virtual void setByInverseMatrix(const osg::Matrixd& matrix)
23         { setByMatrix(osg::Matrixd::inverse(matrix)); }
24
25     /** get the position of the manipulator as 4x4 Matrix.*/
26     virtual osg::Matrixd getMatrix() const;
27
28     /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
29     virtual osg::Matrixd getInverseMatrix() const;
30
31     virtual void setNode(osg::Node* node);
32     
33     const osg::Node* getNode() const;
34
35     osg::Node* getNode();
36
37     virtual void init(const osgGA::GUIEventAdapter& ea,
38                       osgGA::GUIActionAdapter& us);
39
40     virtual bool handle(const osgGA::GUIEventAdapter& ea,
41                         osgGA::GUIActionAdapter& us);
42
43     void setIdleHandler(fgIdleHandler idleHandler)
44         {
45             this->idleHandler = idleHandler;
46         }
47
48     fgIdleHandler getIdleHandler() const
49         {
50             return idleHandler;
51         }
52
53     void setDrawHandler(fgDrawHandler drawHandler)
54         {
55             this->drawHandler = drawHandler;
56         }
57
58     fgDrawHandler getDrawHandler() const
59         {
60             return drawHandler;
61         }
62
63     void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
64         {
65             this->windowResizeHandler = windowResizeHandler;
66         }
67     
68     fgWindowResizeHandler getWindowResizeHandler() const
69         {
70             return windowResizeHandler;
71         }
72
73     void setKeyHandler(fgKeyHandler keyHandler)
74         {
75             this->keyHandler = keyHandler;
76         }
77
78     fgKeyHandler getKeyHandler() const
79         {
80             return keyHandler;
81         }
82
83     void setMouseClickHandler(fgMouseClickHandler mouseClickHandler)
84         {
85             this->mouseClickHandler = mouseClickHandler;
86         }
87     
88     fgMouseClickHandler getMouseClickHandler()
89         {
90             return mouseClickHandler;
91         }
92
93     void setMouseMotionHandler(fgMouseMotionHandler mouseMotionHandler)
94         {
95             this->mouseMotionHandler = mouseMotionHandler;
96         }
97     
98     fgMouseMotionHandler getMouseMotionHandler()
99         {
100             return mouseMotionHandler;
101         }
102
103     int getCurrentModifiers() const
104         {
105             return currentModifiers;
106         }
107
108     void setMouseWarped()
109         {
110             mouseWarped = true;
111         }
112
113     void setPosition(const osg::Vec3d position) { this->position = position; }
114     void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
115
116     /** Whether or not resizing is supported. It might not be when
117      * using multiple displays.
118      */
119     bool getResizable() { return resizable; }
120     void setResizable(bool _resizable) { resizable = _resizable; }
121
122 protected:
123     osg::ref_ptr<osg::Node> _node;
124     fgIdleHandler idleHandler;
125     fgDrawHandler drawHandler;
126     fgWindowResizeHandler windowResizeHandler;
127     fgKeyHandler keyHandler;
128     fgMouseClickHandler mouseClickHandler;
129     fgMouseMotionHandler mouseMotionHandler;
130     osg::ref_ptr<osgViewer::StatsHandler> statsHandler;
131     osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
132     int statsType;
133     int currentModifiers;
134     std::map<int, int> numlockKeyMap;
135     osg::Vec3d position;
136     osg::Quat attitude;
137     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
138     bool resizable;
139     bool mouseWarped;
140     // workaround for osgViewer double scroll events
141     bool scrollButtonPressed;
142     int release_keys[128];
143     void handleStats(osgGA::GUIActionAdapter& us);
144 };
145 #endif