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:
parent
46b65bcab2
commit
7da417530f
2 changed files with 672 additions and 733 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,8 @@
|
||||||
// panel.hxx -- instrument panel defines and prototypes
|
// panel.hxx -- instrument panel defines and prototypes
|
||||||
//
|
//
|
||||||
// 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
|
||||||
|
@ -18,7 +20,6 @@
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
#define LETTER_OFFSET 0.03515625
|
|
||||||
|
|
||||||
#ifndef _PANEL_HXX
|
#ifndef _PANEL_HXX
|
||||||
#define _PANEL_HXX
|
#define _PANEL_HXX
|
||||||
|
@ -40,212 +41,225 @@
|
||||||
#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:
|
public:
|
||||||
int height, width;
|
static FGPanel *OurPanel; // current_panel would be better
|
||||||
GLuint FontList;
|
|
||||||
|
// FIXME: a few other classes have a
|
||||||
GLubyte *background;
|
// dependency on this information; it
|
||||||
|
// would be nice to fix that.
|
||||||
// FGInstrument **instr_list;
|
GLuint panel_tex_id[2];
|
||||||
FGInstrument *test_instr[7];
|
|
||||||
|
FGPanel();
|
||||||
void GetData(void);
|
virtual ~FGPanel ();
|
||||||
|
virtual float get_height(void) { return height; }
|
||||||
public:
|
virtual void ReInit( int x, int y, int finx, int finy);
|
||||||
static FGPanel *OurPanel;
|
virtual void Update(void);
|
||||||
|
|
||||||
FGPanel(void);
|
private:
|
||||||
|
|
||||||
float get_height(void){
|
int height;
|
||||||
return height;
|
int width;
|
||||||
}
|
GLubyte *background;
|
||||||
|
GLubyte *imag;
|
||||||
void ReInit( int x, int y, int finx, int finy);
|
int imag_width, imag_height;
|
||||||
void Update(void);
|
GLubyte *img;
|
||||||
|
int img_width, img_height;
|
||||||
void DrawLetter(void){
|
// The instruments on the panel.
|
||||||
glBegin(GL_POLYGON);
|
FGInstrument * horizonIndicator;
|
||||||
glTexCoord2f(0.0, 0.0);
|
FGInstrument * turnCoordinator;
|
||||||
glVertex2f(0.0, 0.0);
|
FGInstrument * rpmIndicator;
|
||||||
glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
|
FGInstrument * airspeedIndicator;
|
||||||
glVertex2f(7.0, 0.0);
|
FGInstrument * verticalSpeedIndicator;
|
||||||
glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
|
FGInstrument * altimeter;
|
||||||
glVertex2f(7.0, 9.0);
|
FGInstrument * altimeter2;
|
||||||
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);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for all panel instruments.
|
||||||
|
*/
|
||||||
class FGInstrument{
|
class FGInstrument{
|
||||||
friend class FGPanel;
|
|
||||||
|
public:
|
||||||
protected:
|
FGInstrument (void) {}
|
||||||
float XPos, YPos;
|
virtual ~FGInstrument (void) {}
|
||||||
|
virtual void Init(void) = 0;
|
||||||
public:
|
virtual void Render(void) = 0;
|
||||||
FGInstrument(void){
|
|
||||||
}
|
protected:
|
||||||
|
float XPos;
|
||||||
virtual ~FGInstrument(void){}
|
float YPos;
|
||||||
|
|
||||||
virtual void Init(void) = 0;
|
|
||||||
virtual void Render(void) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGHorizon : public FGInstrument {
|
|
||||||
private:
|
/**
|
||||||
float texXPos;
|
* Instrument: the artificial horizon.
|
||||||
float texYPos;
|
*/
|
||||||
float radius;
|
class FGHorizon : public FGInstrument
|
||||||
float bottom; // tell the program the offset between midpoint and bottom
|
{
|
||||||
float top; // guess what ;-)
|
|
||||||
float vertices[180][2];
|
public:
|
||||||
float normals[180][3];
|
FGHorizon (float inXPos, float inYPos);
|
||||||
float texCoord[180][2];
|
virtual ~FGHorizon (void);
|
||||||
|
virtual void Init (void);
|
||||||
public:
|
virtual void Render (void);
|
||||||
FGHorizon(void){
|
|
||||||
XPos = 0.0; YPos = 0.0;
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
FGHorizon(float inXPos, float inYPos){
|
|
||||||
XPos = inXPos; YPos = inYPos;
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Init(void);
|
|
||||||
virtual void Render(void);
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
float texXPos;
|
||||||
|
float texYPos;
|
||||||
|
float radius;
|
||||||
|
float bottom; // tell the program the offset between midpoint and bottom
|
||||||
|
float top; // guess what ;-)
|
||||||
|
float vertices[180][2];
|
||||||
|
float normals[180][3];
|
||||||
|
float texCoord[180][2];
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGTurnCoordinator : public FGInstrument {
|
|
||||||
private:
|
/**
|
||||||
float PlaneTexXPos;
|
* Instrument: the turn co-ordinator.
|
||||||
float PlaneTexYPos;
|
*/
|
||||||
float alpha;
|
class FGTurnCoordinator : public FGInstrument
|
||||||
float PlaneAlpha;
|
{
|
||||||
float alphahist[2];
|
|
||||||
float rollhist[2];
|
public:
|
||||||
float BallXPos;
|
FGTurnCoordinator (float inXPos, float inYPos);
|
||||||
float BallYPos;
|
virtual FGTurnCoordinator::~FGTurnCoordinator (void);
|
||||||
float BallTexXPos;
|
virtual void Init (void);
|
||||||
float BallTexYPos;
|
virtual void Render(void);
|
||||||
float BallRadius;
|
|
||||||
GLfloat vertices[72];
|
private:
|
||||||
|
float PlaneTexXPos;
|
||||||
public:
|
float PlaneTexYPos;
|
||||||
FGTurnCoordinator(void){
|
float alpha;
|
||||||
XPos = 0.0; YPos = 0.0;
|
float PlaneAlpha;
|
||||||
Init();
|
float alphahist[2];
|
||||||
}
|
float rollhist[2];
|
||||||
|
float BallXPos;
|
||||||
FGTurnCoordinator(float inXPos, float inYPos){
|
float BallYPos;
|
||||||
XPos = inXPos; YPos = inYPos;
|
float BallTexXPos;
|
||||||
Init();
|
float BallTexYPos;
|
||||||
}
|
float BallRadius;
|
||||||
|
GLfloat vertices[72];
|
||||||
virtual void Init (void);
|
static GLfloat wingArea[];
|
||||||
virtual void Render(void);
|
static GLfloat elevatorArea[];
|
||||||
|
static GLfloat rudderArea[];
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGRpmGauge : public FGInstrument {
|
|
||||||
private:
|
/**
|
||||||
GLuint list;
|
* Abstract base class for gauges with needles and textured backgrounds.
|
||||||
|
*
|
||||||
public:
|
* The airspeed indicator, vertical speed indicator, altimeter, and RPM
|
||||||
FGRpmGauge(void){
|
* gauge are all derived from this class.
|
||||||
XPos = 0.0; YPos = 0.0;
|
*/
|
||||||
Init();
|
class FGTexInstrument : public FGInstrument
|
||||||
}
|
{
|
||||||
|
public:
|
||||||
FGRpmGauge(float inXPos, float inYPos){
|
FGTexInstrument (void);
|
||||||
XPos = inXPos; YPos = inYPos;
|
virtual ~FGTexInstrument ();
|
||||||
Init();
|
virtual void Init(void);
|
||||||
}
|
virtual void Render(void);
|
||||||
|
|
||||||
virtual void Init(void);
|
protected:
|
||||||
virtual void Render(void);
|
virtual void CreatePointer(void);
|
||||||
|
virtual void UpdatePointer(void);
|
||||||
|
virtual double getValue () const = 0;
|
||||||
|
|
||||||
|
float radius;
|
||||||
|
float length;
|
||||||
|
float width;
|
||||||
|
float angle;
|
||||||
|
float tape[2];
|
||||||
|
float value1;
|
||||||
|
float value2;
|
||||||
|
float alpha1;
|
||||||
|
float alpha2;
|
||||||
|
float textureXPos;
|
||||||
|
float textureYPos;
|
||||||
|
GLfloat vertices[20];
|
||||||
};
|
};
|
||||||
|
|
||||||
// temporary class until I get the software-only routines for the
|
|
||||||
// instruments run
|
|
||||||
|
|
||||||
class FGTexInstrument : public FGInstrument {
|
/**
|
||||||
|
* Instrument: the airspeed indicator.
|
||||||
private:
|
*/
|
||||||
float radius;
|
class FGAirspeedIndicator : public FGTexInstrument
|
||||||
float length;
|
{
|
||||||
float width;
|
public:
|
||||||
float angle;
|
FGAirspeedIndicator (int x, int y);
|
||||||
float tape[2];
|
virtual ~FGAirspeedIndicator ();
|
||||||
float value1;
|
|
||||||
float value2;
|
protected:
|
||||||
float alpha1;
|
double getValue () const;
|
||||||
float alpha2;
|
|
||||||
float teXpos;
|
|
||||||
float texYpos;
|
|
||||||
int variable;
|
|
||||||
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 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
|
||||||
|
|
Loading…
Reference in a new issue