]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/panel.hxx
da38c69cedf5710bfe8d0785643f3402e0cda778
[flightgear.git] / src / Cockpit / panel.hxx
1 //  panel.cxx - default, 2D single-engine prop instrument panel
2 //
3 //  Written by David Megginson, started January 2000.
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License as
7 //  published by the Free Software Foundation; either version 2 of the
8 //  License, or (at your option) any later version.
9 // 
10 //  This program is distributed in the hope that it will be useful, but
11 //  WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 //  General Public License for more details.
14 // 
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19 //  $Id$
20
21 #ifndef __PANEL_HXX
22 #define __PANEL_HXX
23
24 #ifndef __cplusplus                                                          
25 # error This library requires C++
26 #endif                                   
27
28
29 #ifdef HAVE_CONFIG_H
30 #  include <config.h>
31 #endif
32
33 #ifdef HAVE_WINDOWS_H          
34 #  include <windows.h>
35 #endif
36
37 #include <GL/glut.h>
38 #include <simgear/xgl/xgl.h>
39
40 #include <plib/ssg.h>
41
42 class FGPanelInstrument;
43
44
45 \f
46 ////////////////////////////////////////////////////////////////////////
47 // Instrument panel class.
48 ////////////////////////////////////////////////////////////////////////
49
50 class FGPanel
51 {
52 public:
53   FGPanel ();
54   virtual ~FGPanel ();
55
56                                 // Legacy interface from old panel.
57   static FGPanel * OurPanel;
58   virtual float get_height () const;
59   virtual void ReInit (int x, int y, int finx, int finy);
60   virtual void Update () const;
61
62 private:
63   int _x, _y, _w, _h;
64   int _panel_h;
65
66   ssgTexture * _bg;
67
68   const FGPanelInstrument * _airspeed;
69   const FGPanelInstrument * _horizon;
70   const FGPanelInstrument * _altimeter;
71   const FGPanelInstrument * _coordinator;
72   const FGPanelInstrument * _gyro;
73   const FGPanelInstrument * _vertical;
74   const FGPanelInstrument * _flaps;
75   const FGPanelInstrument * _rpm;
76 };
77
78
79 \f
80 ////////////////////////////////////////////////////////////////////////
81 // Instrument base class.
82 ////////////////////////////////////////////////////////////////////////
83
84 class FGPanelInstrument
85 {
86 public:
87   FGPanelInstrument ();
88   FGPanelInstrument (int x, int y, int w, int h);
89   virtual ~FGPanelInstrument ();
90
91   virtual void draw () const = 0;
92
93   virtual void setPosition(int x, int y);
94   virtual void setSize(int w, int h);
95
96   virtual int getXPos () const;
97   virtual int getYPos () const;
98
99 protected:
100   int _x, _y, _w, _h;
101 };
102
103
104 \f
105 ////////////////////////////////////////////////////////////////////////
106 // An instrument composed of layered textures.
107 ////////////////////////////////////////////////////////////////////////
108
109 class FGTexturedInstrument : public FGPanelInstrument
110 {
111 public:
112   static const int MAX_LAYERS = 8;
113   FGTexturedInstrument (int x, int y, int w, int h);
114   virtual ~FGTexturedInstrument ();
115
116   virtual void addLayer (int layer, const char * textureName);
117   virtual void addLayer (int layer, ssgTexture * texture);
118   virtual void setLayerCenter (int layer, int x, int y);
119   virtual void setLayerRot (int layer, double rotation) const;
120   virtual void setLayerOffset (int layer, int xoffset, int yoffset) const;
121   virtual bool hasLayer (int layer) const;
122
123   virtual void draw () const;
124 protected:
125   bool _layers[MAX_LAYERS];
126   mutable int _xcenter[MAX_LAYERS];
127   mutable int _ycenter[MAX_LAYERS];
128   mutable double _rotation[MAX_LAYERS];
129   mutable int _xoffset[MAX_LAYERS];
130   mutable int _yoffset[MAX_LAYERS];
131   ssgTexture * _textures[MAX_LAYERS];
132 };
133
134
135 \f
136 ////////////////////////////////////////////////////////////////////////
137 // Airspeed indicator.
138 ////////////////////////////////////////////////////////////////////////
139
140 class FGAirspeedIndicator : public FGTexturedInstrument
141 {
142 public:
143   FGAirspeedIndicator (int x, int y);
144   virtual ~FGAirspeedIndicator ();
145   virtual void draw () const;
146 };
147
148
149 \f
150 ////////////////////////////////////////////////////////////////////////
151 // Artificial Horizon.
152 ////////////////////////////////////////////////////////////////////////
153
154 class FGHorizon : public FGTexturedInstrument
155 {
156 public:
157   FGHorizon (int x, int y);
158   virtual ~FGHorizon ();
159   virtual void draw () const;
160 };
161
162
163 \f
164 ////////////////////////////////////////////////////////////////////////
165 // Altimeter.
166 ////////////////////////////////////////////////////////////////////////
167
168 class FGAltimeter : public FGTexturedInstrument
169 {
170 public:
171   FGAltimeter (int x, int y);
172   virtual ~FGAltimeter ();
173   virtual void draw () const;
174 };
175
176
177 \f
178 ////////////////////////////////////////////////////////////////////////
179 // Turn Co-ordinator.
180 ////////////////////////////////////////////////////////////////////////
181
182 class FGTurnCoordinator : public FGTexturedInstrument
183 {
184 public:
185   FGTurnCoordinator (int x, int y);
186   virtual ~FGTurnCoordinator ();
187   virtual void draw () const;
188 };
189
190
191 \f
192 ////////////////////////////////////////////////////////////////////////
193 // Gyro Compass.
194 ////////////////////////////////////////////////////////////////////////
195
196 class FGGyroCompass : public FGTexturedInstrument
197 {
198 public:
199   FGGyroCompass (int x, int y);
200   virtual ~FGGyroCompass ();
201   virtual void draw () const;
202 };
203
204
205 \f
206 ////////////////////////////////////////////////////////////////////////
207 // Vertical velocity indicator.
208 ////////////////////////////////////////////////////////////////////////
209
210 class FGVerticalVelocity : public FGTexturedInstrument
211 {
212 public:
213   FGVerticalVelocity (int x, int y);
214   virtual ~FGVerticalVelocity ();
215   virtual void draw () const;
216 };
217
218
219 \f
220 ////////////////////////////////////////////////////////////////////////
221 // RPM gauge.
222 ////////////////////////////////////////////////////////////////////////
223
224 class FGRPMGauge : public FGTexturedInstrument
225 {
226 public:
227   FGRPMGauge (int x, int y);
228   virtual ~FGRPMGauge ();
229   virtual void draw () const;
230 };
231
232
233 \f
234 ////////////////////////////////////////////////////////////////////////
235 // Flap position indicator.
236 ////////////////////////////////////////////////////////////////////////
237
238 class FGFlapIndicator : public FGTexturedInstrument
239 {
240 public:
241   FGFlapIndicator (int x, int y);
242   virtual ~FGFlapIndicator ();
243   virtual void draw () const;
244 };
245
246
247 \f
248 #endif // __PANEL_HXX
249
250 // end of panel.hxx
251
252