]> git.mxchange.org Git - flightgear.git/blob - src/Main/FGManipulator.hxx
Modified Files:
[flightgear.git] / src / Main / FGManipulator.hxx
1 #ifndef FGMANIPULATOR_H
2 #define FGMANIPULATOR_H 1
3
4 #include <osg/Quat>
5 #include <osgGA/MatrixManipulator>
6
7 #include "fg_os.hxx"
8
9 class FGManipulator : public osgGA::MatrixManipulator {
10 public:
11     FGManipulator() :
12         idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
13         mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0)
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     void setPosition(const osg::Vec3d position) { this->position = position; }
108     void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
109
110 protected:
111     osg::ref_ptr<osg::Node> _node;
112     fgIdleHandler idleHandler;
113     fgDrawHandler drawHandler;
114     fgWindowResizeHandler windowResizeHandler;
115     fgKeyHandler keyHandler;
116     fgMouseClickHandler mouseClickHandler;
117     fgMouseMotionHandler mouseMotionHandler;
118     int currentModifiers;
119     osg::Vec3d position;
120     osg::Quat attitude;
121     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
122
123 };
124 #endif