1
0
Fork 0

Panel code reorganization contributed by David Megginson:

I've reorganized the code in panel.cxx and panel.hxx so that it will
be a little easier to extend the panel later if someone wants to.
It's still basically Friedemann's code at the core, but I've
repackaged it into a saner class hierarchy and encapsulated as much as
I could (there are still a couple of circular dependencies that need
swatting).  If someone wants to modify it to use SSG or to add new
gauges, it should be a lot easier now.

There are no user-visible changes.
This commit is contained in:
curt 1999-12-23 17:37:18 +00:00
parent 46b65bcab2
commit 7da417530f
2 changed files with 672 additions and 733 deletions

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,8 @@
// //
// Written by Friedemann Reinhard, started June 1998. // Written by Friedemann Reinhard, started June 1998.
// //
// Major code reorganization by David Megginson, November 1999.
//
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
@ -18,7 +20,6 @@
// //
// $Id$ // $Id$
#define LETTER_OFFSET 0.03515625
#ifndef _PANEL_HXX #ifndef _PANEL_HXX
#define _PANEL_HXX #define _PANEL_HXX
@ -40,69 +41,77 @@
#include <GL/glut.h> #include <GL/glut.h>
#include <XGL/xgl.h> #include <XGL/xgl.h>
class FGInstrument; class FGInstrument; // FIXME: rearrange to avoid this?
/**
* Top-level class to hold an instance of a panel.
*/
class FGPanel{ class FGPanel{
private:
int height, width;
GLuint FontList;
GLubyte *background;
// FGInstrument **instr_list;
FGInstrument *test_instr[7];
void GetData(void);
public: public:
static FGPanel *OurPanel; static FGPanel *OurPanel; // current_panel would be better
FGPanel(void); // FIXME: a few other classes have a
// dependency on this information; it
// would be nice to fix that.
GLuint panel_tex_id[2];
float get_height(void){ FGPanel();
return height; virtual ~FGPanel ();
} virtual float get_height(void) { return height; }
virtual void ReInit( int x, int y, int finx, int finy);
virtual void Update(void);
void ReInit( int x, int y, int finx, int finy); private:
void Update(void);
void DrawLetter(void){
glBegin(GL_POLYGON);
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
glVertex2f(7.0, 0.0);
glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
glVertex2f(7.0, 9.0);
glTexCoord2f(0.0, 0.0390625);
glVertex2f(0.0, 9.0);
glEnd();
}
void DrawTestLetter(float X, float Y);
void InitLists(void);
void TexString(char *s, float XPos, float YPos, float size);
int height;
int width;
GLubyte *background;
GLubyte *imag;
int imag_width, imag_height;
GLubyte *img;
int img_width, img_height;
// The instruments on the panel.
FGInstrument * horizonIndicator;
FGInstrument * turnCoordinator;
FGInstrument * rpmIndicator;
FGInstrument * airspeedIndicator;
FGInstrument * verticalSpeedIndicator;
FGInstrument * altimeter;
FGInstrument * altimeter2;
}; };
class FGInstrument{
friend class FGPanel;
protected: /**
float XPos, YPos; * Abstract base class for all panel instruments.
*/
class FGInstrument{
public: public:
FGInstrument(void){ FGInstrument (void) {}
}
virtual ~FGInstrument (void) {} virtual ~FGInstrument (void) {}
virtual void Init(void) = 0; virtual void Init(void) = 0;
virtual void Render(void) = 0; virtual void Render(void) = 0;
protected:
float XPos;
float YPos;
}; };
class FGHorizon : public FGInstrument {
/**
* Instrument: the artificial horizon.
*/
class FGHorizon : public FGInstrument
{
public:
FGHorizon (float inXPos, float inYPos);
virtual ~FGHorizon (void);
virtual void Init (void);
virtual void Render (void);
private: private:
float texXPos; float texXPos;
float texYPos; float texYPos;
@ -112,24 +121,21 @@ class FGHorizon : public FGInstrument {
float vertices[180][2]; float vertices[180][2];
float normals[180][3]; float normals[180][3];
float texCoord[180][2]; float texCoord[180][2];
};
/**
* Instrument: the turn co-ordinator.
*/
class FGTurnCoordinator : public FGInstrument
{
public: public:
FGHorizon(void){ FGTurnCoordinator (float inXPos, float inYPos);
XPos = 0.0; YPos = 0.0; virtual FGTurnCoordinator::~FGTurnCoordinator (void);
Init();
}
FGHorizon(float inXPos, float inYPos){
XPos = inXPos; YPos = inYPos;
Init();
}
virtual void Init (void); virtual void Init (void);
virtual void Render(void); virtual void Render(void);
};
class FGTurnCoordinator : public FGInstrument {
private: private:
float PlaneTexXPos; float PlaneTexXPos;
float PlaneTexYPos; float PlaneTexYPos;
@ -143,48 +149,31 @@ class FGTurnCoordinator : public FGInstrument {
float BallTexYPos; float BallTexYPos;
float BallRadius; float BallRadius;
GLfloat vertices[72]; GLfloat vertices[72];
static GLfloat wingArea[];
static GLfloat elevatorArea[];
static GLfloat rudderArea[];
};
/**
* Abstract base class for gauges with needles and textured backgrounds.
*
* The airspeed indicator, vertical speed indicator, altimeter, and RPM
* gauge are all derived from this class.
*/
class FGTexInstrument : public FGInstrument
{
public: public:
FGTurnCoordinator(void){ FGTexInstrument (void);
XPos = 0.0; YPos = 0.0; virtual ~FGTexInstrument ();
Init();
}
FGTurnCoordinator(float inXPos, float inYPos){
XPos = inXPos; YPos = inYPos;
Init();
}
virtual void Init(void); virtual void Init(void);
virtual void Render(void); virtual void Render(void);
}; protected:
virtual void CreatePointer(void);
virtual void UpdatePointer(void);
virtual double getValue () const = 0;
class FGRpmGauge : public FGInstrument {
private:
GLuint list;
public:
FGRpmGauge(void){
XPos = 0.0; YPos = 0.0;
Init();
}
FGRpmGauge(float inXPos, float inYPos){
XPos = inXPos; YPos = inYPos;
Init();
}
virtual void Init(void);
virtual void Render(void);
};
// temporary class until I get the software-only routines for the
// instruments run
class FGTexInstrument : public FGInstrument {
private:
float radius; float radius;
float length; float length;
float width; float width;
@ -194,58 +183,83 @@ class FGTexInstrument : public FGInstrument {
float value2; float value2;
float alpha1; float alpha1;
float alpha2; float alpha2;
float teXpos; float textureXPos;
float texYpos; float textureYPos;
int variable;
GLfloat vertices[20]; GLfloat vertices[20];
public:
FGTexInstrument(void){
XPos = 0.0; YPos = 0.0;
Init();
}
FGTexInstrument(float inXPos, float inYPos, float inradius, float inlength, float inwidth, float inangle, float invalue1, float invalue2, float inalpha1, float inalpha2, float intexXPos, float intexYPos, int invariable){
XPos = inXPos; YPos = inYPos;
radius = inradius; angle = inangle;
length = inlength; width = inwidth;
value1 = invalue1; value2 = invalue2;
alpha1 = inalpha1; alpha2 = inalpha2;
teXpos = intexXPos; texYpos = intexYPos;
variable = invariable;
Init();
}
void CreatePointer(void);
void UpdatePointer(void);
void Init(void);
void Render(void);
}; };
typedef struct{
float XPos;
float YPos;
float radius;
float length;
float width;
float angle;
float tape[2];
float value1;
float value2;
float alpha1;
float alpha2;
float teXpos;
float texYpos;
int variable;
GLfloat vertices[20];
}Pointer;
/**
* Instrument: the airspeed indicator.
*/
class FGAirspeedIndicator : public FGTexInstrument
{
public:
FGAirspeedIndicator (int x, int y);
virtual ~FGAirspeedIndicator ();
protected:
double getValue () const;
};
/**
* Instrument: the vertical speed indicator.
*/
class FGVerticalSpeedIndicator : public FGTexInstrument
{
public:
FGVerticalSpeedIndicator (int x, int y);
virtual ~FGVerticalSpeedIndicator ();
protected:
double getValue () const;
};
/**
* Instrument: the altimeter (big hand?)
*/
class FGAltimeter : public FGTexInstrument
{
public:
FGAltimeter (int x, int y);
virtual ~FGAltimeter ();
protected:
double getValue () const;
};
/**
* Instrument: the altimeter (little hand?)
*/
class FGAltimeter2 : public FGTexInstrument
{
public:
FGAltimeter2 (int x, int y);
virtual ~FGAltimeter2 ();
protected:
double getValue () const;
};
/**
* Instrument: the RPM gauge (actually manifold pressure right now).
*/
class FGRPMIndicator : public FGTexInstrument
{
public:
FGRPMIndicator (int x, int y);
virtual ~FGRPMIndicator ();
protected:
double getValue () const;
};
// FIXME: move to FGPanel, somehow
void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos, GLfloat texYPos, GLfloat XPos, GLfloat YPos, int Texid, float ScaleFactor); void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos, GLfloat texYPos, GLfloat XPos, GLfloat YPos, int Texid, float ScaleFactor);
void DrawScale(float XPos, float YPos, float InnerRadius, float OuterRadius, float alpha1, float alpha2, int steps, float LineWidth, float red, float green, float blue, bool filled);
void DrawBeechcraftLogo(float XPos, float YPos, float Width, float Height);
void PrintMatrix( void);
#endif // _PANEL_HXX #endif // _PANEL_HXX