1 // panel.hxx - default, 2D single-engine prop instrument panel
3 // Written by David Megginson, started January 2000.
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.
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.
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.
25 # error This library requires C++
45 class FGPanelInstrument;
49 ////////////////////////////////////////////////////////////////////////
50 // Instrument panel class.
51 ////////////////////////////////////////////////////////////////////////
57 typedef vector<FGPanelInstrument *> instrument_list_type;
62 // Legacy interface from old panel.
63 static FGPanel * OurPanel;
64 virtual float get_height () const;
65 virtual void ReInit (int x, int y, int finx, int finy);
66 virtual void Update () const;
74 instrument_list_type _instruments;
79 ////////////////////////////////////////////////////////////////////////
80 // Instrument base class.
81 ////////////////////////////////////////////////////////////////////////
83 class FGPanelInstrument
87 FGPanelInstrument (int x, int y, int w, int h);
88 virtual ~FGPanelInstrument ();
90 virtual void draw () const = 0;
92 virtual void setPosition(int x, int y);
93 virtual void setSize(int w, int h);
95 virtual int getXPos () const;
96 virtual int getYPos () const;
104 ////////////////////////////////////////////////////////////////////////
105 // A single layer of an instrument.
106 ////////////////////////////////////////////////////////////////////////
109 * A single layer of a multi-layered instrument.
111 * Each layer can be subject to a series of transformations based
112 * on current FGFS instrument readings: for example, a texture
113 * representing a needle can rotate to show the airspeed.
115 class FGInstrumentLayer
124 typedef double (*transform_func)();
127 FGInstrumentLayer ();
128 FGInstrumentLayer (int w, int h, int z);
129 virtual ~FGInstrumentLayer ();
131 virtual void draw () const = 0;
132 virtual void transform () const;
134 virtual void addTransformation (transform_type type, transform_func func,
135 double min, double max,
136 double factor = 1.0, double offset = 0.0);
149 typedef vector<transformation *> transformation_list;
150 transformation_list _transformations;
155 ////////////////////////////////////////////////////////////////////////
156 // An instrument composed of layered textures.
157 ////////////////////////////////////////////////////////////////////////
161 * An instrument constructed of multiple layers.
163 * Each individual layer can be rotated or shifted to correspond
164 * to internal FGFS instrument readings.
166 class FGLayeredInstrument : public FGPanelInstrument
169 typedef vector<FGInstrumentLayer *> layer_list;
170 FGLayeredInstrument (int x, int y, int w, int h);
171 virtual ~FGLayeredInstrument ();
173 virtual void draw () const;
175 virtual void addLayer (FGInstrumentLayer *layer);
176 virtual void addLayer (int i, const char *textureName);
177 virtual void addTransformation (int layer,
178 FGInstrumentLayer::transform_type type,
179 FGInstrumentLayer::transform_func func,
180 double min, double max,
181 double factor = 1.0, double offset = 0.0);
182 virtual void addTransformation (int layer,
183 FGInstrumentLayer::transform_type type,
185 addTransformation(layer, type, 0, 0.0, 0.0, 1.0, offset);
194 ////////////////////////////////////////////////////////////////////////
195 // A textured layer of an instrument.
196 ////////////////////////////////////////////////////////////////////////
199 * A textured layer of an instrument.
201 * This is a type of layer designed to hold a texture; normally,
202 * the texture's background should be transparent so that
203 * other layers or the panel background show through.
205 class FGTexturedInstrumentLayer : public FGInstrumentLayer
208 FGTexturedInstrumentLayer (const char * textureName,
209 int w, int h, int z);
210 FGTexturedInstrumentLayer (ssgTexture * texture,
211 int w, int h, int z);
212 virtual ~FGTexturedInstrumentLayer ();
214 virtual void draw () const;
216 virtual void setTexture (const char *textureName);
217 virtual void setTexture (ssgTexture * texture) { _texture = texture; }
220 ssgTexture * _texture;
225 ////////////////////////////////////////////////////////////////////////
226 // A text layer of an instrument.
227 ////////////////////////////////////////////////////////////////////////
229 class FGCharInstrumentLayer : public FGInstrumentLayer
232 typedef char * (*text_func)(char *);
233 FGCharInstrumentLayer (text_func func,
234 int w, int h, int z);
235 virtual ~FGCharInstrumentLayer ();
237 virtual void draw () const;
238 virtual void setColor (float r, float g, float b);
239 virtual void setPointSize (float size);
240 virtual void setFont (fntFont * font);
245 // FIXME: need only one globally
246 mutable fntRenderer _renderer;
247 mutable char _buf[1024];
252 #endif // __PANEL_HXX