-/**************************************************************************
- * hud.hxx -- hud defines and prototypes (initial draft)
- *
- * Written by Michele America, started September 1997.
- *
- * Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- * (Log is kept at end of this file)
- **************************************************************************/
+// hud.hxx -- hud defines and prototypes (initial draft)
+//
+// Written by Michele America, started September 1997.
+//
+// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+// (Log is kept at end of this file)
#ifndef _HUD_HXX
#define _HUD_HXX
-
#ifndef __cplusplus
# error This library requires C++
#endif
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
-#include <config.h>
+#include <GL/glut.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_VALUES_H
+# include <values.h> // for MAXINT
+#endif
#include <fg_typedefs.h>
#include <fg_constants.h>
-#include <Aircraft/aircraft.h>
-#include <Flight/flight.h>
-#include <Controls/controls.h>
+#include <Aircraft/aircraft.hxx>
+#include <FDM/flight.hxx>
+#include <Controls/controls.hxx>
-//using namespace std;
-
-#include <deque.h> // STL
+#include <deque> // STL double ended queue
+#ifdef NEEDNAMESPACESTD
+using namespace std;
+#endif
#ifndef WIN32
-
typedef struct {
int x, y;
} POINT;
-
+
typedef struct {
int top, bottom, left, right;
} RECT;
-
#endif
-
// View mode definitions
enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
// Hud general constants
#define DAY 1
#define NIGHT 2
-#define BRT_DARK 3
-#define BRT_MEDIUM 4
-#define BRT_LIGHT 5
-#define SIZE_SMALL 6
-#define SIZE_LARGE 7
+#define BRT_BLACK 3
+#define BRT_DARK 4
+#define BRT_MEDIUM 5
+#define BRT_LIGHT 6
+#define SIZE_SMALL 7
+#define SIZE_LARGE 8
// Label constants
#define SMALL 1
#define LABEL_COUNTER 1
#define LABEL_WARNING 2
+#define HUDS_AUTOTICKS 0x0001
+#define HUDS_VERT 0x0002
+#define HUDS_HORZ 0x0000
+#define HUDS_TOP 0x0004
+#define HUDS_BOTTOM 0x0008
+#define HUDS_LEFT HUDS_TOP
+#define HUDS_RIGHT HUDS_BOTTOM
+#define HUDS_BOTH (HUDS_LEFT | HUDS_RIGHT)
+#define HUDS_NOTICKS 0x0010
+#define HUDS_ARITHTIC 0x0020
+#define HUDS_DECITICS 0x0040
+#define HUDS_NOTEXT 0x0080
+
// Ladder orientaion
// #define HUD_VERTICAL 1
// #define HUD_HORIZONTAL 2
extern double get_pitch ( void );
extern double get_heading ( void );
extern double get_altitude ( void );
+extern double get_agl ( void );
extern double get_sideslip ( void );
extern double get_frame_rate ( void );
+extern double get_latitude ( void );
+extern double get_lat_min ( void );
+extern double get_longitude ( void );
+extern double get_long_min ( void );
extern double get_fov ( void );
+extern double get_vfc_ratio ( void );
+extern double get_vfc_tris_drawn ( void );
+extern double get_climb_rate ( void );
enum hudinstype{ HUDno_instr,
HUDscale,
HUDtbi
};
-enum ReadOriented{ ReadRIGHT, ReadLEFT, ReadTOP, ReadBOTTOM };
+typedef struct gltagRGBTRIPLE { // rgbt
+ GLfloat Blue;
+ GLfloat Green;
+ GLfloat Red;
+} glRGBTRIPLE;
class instr_item { // An Abstract Base Class (ABC)
private:
- static UINT instances; // More than 64K instruments? Nah!
- UINT handle;
- RECT scrn_pos; // Framing - affects scale dimensions
+ static UINT instances; // More than 64K instruments? Nah!
+ static int brightness;
+ static glRGBTRIPLE color;
+
+ UINT handle;
+ RECT scrn_pos; // Framing - affects scale dimensions
// and orientation. Vert vs Horz, etc.
- DBLFNPTR load_value_fn;
- ReadOriented oriented;
- bool is_enabled;
- bool broken;
- int brightness;
- UINT scr_span; // Working values for draw;
- POINT mid_span; //
+ DBLFNPTR load_value_fn;
+ double disp_factor; // Multiply by to get numbers shown on scale.
+ UINT opts;
+ bool is_enabled;
+ bool broken;
+ UINT scr_span; // Working values for draw;
+ POINT mid_span; //
public:
- instr_item( RECT scrn_pos,
+ instr_item( int x,
+ int y,
+ UINT height,
+ UINT width,
DBLFNPTR data_source,
- ReadOriented orient,
+ double data_scaling,
+ UINT options,
bool working = true);
instr_item( const instr_item & image );
RECT get_location ( void ) { return scrn_pos; }
bool is_broken ( void ) { return broken; }
bool enabled ( void ) { return is_enabled;}
- double get_value ( void ) { return load_value_fn();}
+ bool data_available ( void ) { return !!load_value_fn; }
+ double get_value ( void ) { return load_value_fn(); }
+ double data_scaling ( void ) { return disp_factor; }
UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; }
- ReadOriented get_orientation ( void ) { return oriented; }
+ UINT get_options ( void ) { return opts; }
virtual void display_enable( bool working ) { is_enabled = !! working;}
virtual void update( void );
virtual void break_display ( bool bad );
virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
+ void SetPosition ( int x, int y, UINT width, UINT height );
UINT get_Handle( void );
virtual void draw( void ) = 0; // Required method in derived classes
};
int blink;
public:
- instr_label( RECT the_box,
+ instr_label( int x,
+ int y,
+ UINT width,
+ UINT height,
DBLFNPTR data_source,
const char *label_format,
- const char *pre_label_string = 0,
- const char *post_label_string = 0,
- ReadOriented orientation = ReadTOP,
- fgLabelJust justification = CENTER_JUST,
- int font_size = SMALL,
- int blinking = NOBLINK,
- bool working = true);
+ const char *pre_label_string = 0,
+ const char *post_label_string = 0,
+ double scale_data = 1.0,
+ UINT options = HUDS_TOP,
+ fgLabelJust justification = CENTER_JUST,
+ int font_size = SMALL,
+ int blinking = NOBLINK,
+ bool working = true);
~instr_label();
instr_label( const instr_label & image);
instr_label & operator = (const instr_label & rhs );
-
virtual void draw( void ); // Required method in base class
};
class instr_scale : public instr_item {
private:
- int range_shown; // Width Units.
- int Maximum_value; // ceiling.
- int Minimum_value; // Representation floor.
+ double range_shown; // Width Units.
+ double Maximum_value; // ceiling.
+ double Minimum_value; // Representation floor.
+ double scale_factor; // factor => screen units/range values.
UINT Maj_div; // major division marker units
UINT Min_div; // minor division marker units
UINT Modulo; // Roll over point
- double scale_factor; // factor => screen units/range values.
+ int signif_digits; // digits to show to the right.
public:
- instr_scale( RECT the_box,
+ instr_scale( int x,
+ int y,
+ UINT width,
+ UINT height,
DBLFNPTR load_fn,
- ReadOriented orient,
- int show_range,
- int max_value,
- int min_value = 0,
- UINT major_divs = 10,
- UINT minor_divs = 5,
- UINT rollover = 0,
- bool working = true);
+ UINT options,
+ double show_range,
+ double max_value = 100.0,
+ double min_value = 0.0,
+ double disp_scaling = 1.0,
+ UINT major_divs = 10,
+ UINT minor_divs = 5,
+ UINT rollover = 0,
+ int dp_showing = 2,
+ bool working = true);
virtual ~instr_scale();
instr_scale( const instr_scale & image);
virtual void draw ( void ) {}; // No-op here. Defined in derived classes.
UINT div_min ( void ) { return Min_div;}
UINT div_max ( void ) { return Maj_div;}
- int min_val ( void ) { return Minimum_value;}
- int max_val ( void ) { return Maximum_value;}
+ double min_val ( void ) { return Minimum_value;}
+ double max_val ( void ) { return Maximum_value;}
UINT modulo ( void ) { return Modulo; }
double factor ( void ) { return scale_factor;}
double range_to_show( void ) { return range_shown;}
};
-// moving_scale_instr This class displays the indicated quantity on
+// hud_card_ This class displays the indicated quantity on
// a scale that moves past the pointer. It may be
// horizontal or vertical, read above(left) or below(right) of the base
// line.
-class moving_scale : public instr_scale {
+class hud_card : public instr_scale {
private:
double val_span;
double half_width_units;
public:
- moving_scale( RECT box,
- DBLFNPTR load_fn,
- ReadOriented readway,
- int maxValue,
- int minValue,
- UINT major_divs,
- UINT minor_divs,
- UINT modulator,
- double value_span,
- bool working = true);
-
- ~moving_scale();
- moving_scale( const moving_scale & image);
- moving_scale & operator = (const moving_scale & rhs );
+ hud_card( int x,
+ int y,
+ UINT width,
+ UINT height,
+ DBLFNPTR load_fn,
+ UINT options,
+ double maxValue = 100.0,
+ double minValue = 0.0,
+ double disp_scaling = 1.0,
+ UINT major_divs = 10,
+ UINT minor_divs = 5,
+ UINT modulator = 100,
+ int dp_showing = 2,
+ double value_span = 100.0,
+ bool working = true);
+
+ ~hud_card();
+ hud_card( const hud_card & image);
+ hud_card & operator = (const hud_card & rhs );
// virtual void display_enable( bool setting );
virtual void draw( void ); // Required method in base class
};
-typedef moving_scale * pMoveScale;
+typedef hud_card * pCardScale;
class guage_instr : public instr_scale {
private:
public:
- guage_instr( RECT box,
- DBLFNPTR load_fn,
- ReadOriented readway,
- int maxValue,
- int minValue,
- UINT major_divs,
- UINT minor_divs,
- UINT modulus,
- bool working = true);
+ guage_instr( int x,
+ int y,
+ UINT width,
+ UINT height,
+ DBLFNPTR load_fn,
+ UINT options,
+ double disp_scaling = 1.0,
+ double maxValue = 100,
+ double minValue = 0,
+ UINT major_divs = 50,
+ UINT minor_divs = 0,
+ int dp_showing = 2,
+ UINT modulus = 0,
+ bool working = true);
~guage_instr();
guage_instr( const guage_instr & image);
DBLFNPTR alt_data_source;
public:
- dual_instr_item ( RECT the_box,
- DBLFNPTR chn1_source,
- DBLFNPTR chn2_source,
- bool working = true,
- ReadOriented readway = ReadTOP);
+ dual_instr_item ( int x,
+ int y,
+ UINT width,
+ UINT height,
+ DBLFNPTR chn1_source,
+ DBLFNPTR chn2_source,
+ bool working = true,
+ UINT options = HUDS_TOP);
virtual ~dual_instr_item() {};
dual_instr_item( const dual_instr_item & image);
UINT scr_hole;
public:
- fgTBI_instr( RECT the_box,
+ fgTBI_instr( int x,
+ int y,
+ UINT width,
+ UINT height,
DBLFNPTR chn1_source = get_roll,
DBLFNPTR chn2_source = get_sideslip,
- UINT maxBankAngle = 45,
- UINT maxSlipAngle = 5,
- UINT gap_width = 5,
+ double maxBankAngle = 45.0,
+ double maxSlipAngle = 5.0,
+ UINT gap_width = 5.0,
bool working = true);
fgTBI_instr( const fgTBI_instr & image);
UINT minor_div;
UINT label_pos;
UINT scr_hole;
- int vmax;
- int vmin;
+ double vmax;
+ double vmin;
double factor;
public:
- HudLadder( RECT the_box,
+ HudLadder( int x,
+ int y,
+ UINT width,
+ UINT height,
DBLFNPTR ptch_source = get_roll,
DBLFNPTR roll_source = get_pitch,
- UINT span_units = 45,
- int division_units = 10,
- UINT minor_division = 0,
- UINT screen_hole = 70,
- UINT lbl_pos = 0,
+ double span_units = 45.0,
+ double division_units = 10.0,
+ double minor_division = 0.0,
+ UINT screen_hole = 70,
+ UINT lbl_pos = 0,
bool working = true );
~HudLadder();
//using namespace std;
//deque <instr_item> * Hdeque_ptr;
+extern void HUD_brightkey( bool incr_bright );
extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
+extern int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
extern void fgUpdateHUD( void );
+extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2);
+extern void drawOneLine ( RECT &rect);
+extern void textString ( int x,
+ int y,
+ char *msg,
+ void *font = GLUT_BITMAP_8_BY_13);
+extern void strokeString( int x,
+ int y,
+ char *msg,
+ void *font = GLUT_STROKE_ROMAN,
+ float theta = 0);
/*
bool AddHUDInstrument( instr_item *pBlackBox );
void DrawHUD ( void );
#endif // _HUD_H
-/* $Log$
-/* Revision 1.3 1998/05/13 18:27:55 curt
-/* Added an fov to hud display.
-/*
- * Revision 1.2 1998/05/11 18:13:12 curt
- * Complete C++ rewrite of all cockpit code by Charlie Hotchkiss.
- *
- * Revision 1.15 1998/02/23 19:07:57 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.14 1998/02/21 14:53:14 curt
- * Added Charlie's HUD changes.
- *
- * Revision 1.13 1998/02/20 00:16:22 curt
- * Thursday's tweaks.
- *
- * Revision 1.12 1998/02/19 13:05:52 curt
- * Incorporated some HUD tweaks from Michelle America.
- * Tweaked the sky's sunset/rise colors.
- * Other misc. tweaks.
- *
- * Revision 1.11 1998/02/16 13:38:42 curt
- * Integrated changes from Charlie Hotchkiss.
- *
- * Revision 1.11 1998/02/16 13:38:42 curt
- * Integrated changes from Charlie Hotchkiss.
- *
- * Revision 1.10 1998/02/12 21:59:42 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.8 1998/02/07 15:29:35 curt
- * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.7 1998/02/03 23:20:15 curt
- * Lots of little tweaks to fix various consistency problems discovered by
- * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
- * passed arguments along to the real printf(). Also incorporated HUD changes
- * by Michele America.
- *
- * Revision 1.6 1998/01/22 02:59:30 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.5 1998/01/19 19:27:01 curt
- * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
- * This should simplify things tremendously.
- *
- * Revision 1.4 1998/01/19 18:40:21 curt
- * Tons of little changes to clean up the code and to remove fatal errors
- * when building with the c++ compiler.
- *
- * Revision 1.3 1997/12/30 16:36:41 curt
- * Merged in Durk's changes ...
- *
- * Revision 1.2 1997/12/10 22:37:40 curt
- * Prepended "fg" on the name of all global structures that didn't have it yet.
- * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
- *
- * Revision 1.1 1997/08/29 18:03:22 curt
- * Initial revision.
- *
- */
+// $Log$
+// Revision 1.17 1999/02/01 21:33:28 curt
+// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
+// Jon accepted my offer to do this and thought it was a good idea.
+//
+// Revision 1.16 1998/10/17 01:33:59 curt
+// C++ ifying ...
+//
+// Revision 1.15 1998/10/16 23:27:27 curt
+// C++-ifying.
+//
+// Revision 1.14 1998/09/29 14:56:33 curt
+// c++-ified comments.
+//
+// Revision 1.13 1998/09/29 02:01:09 curt
+// Added a "rate of climb" indicator.
+//
+// Revision 1.12 1998/08/24 20:05:17 curt
+// Added a second minimalistic HUD.
+// Added code to display the number of triangles rendered.
+//
+// Revision 1.11 1998/07/24 21:36:55 curt
+// Ran dos2unix to get rid of extraneous ^M's. Tweaked parameter in
+// ImageGetRawData() to match usage.
+//
+// Revision 1.10 1998/07/13 21:28:02 curt
+// Converted the aoa scale to a radio altimeter.
+//
+// Revision 1.9 1998/07/13 21:00:48 curt
+// Integrated Charlies latest HUD updates.
+// Wrote access functions for current fgOPTIONS.
+//
+// Revision 1.8 1998/07/03 13:16:29 curt
+// Added Charlie Hotchkiss's HUD updates and improvementes.
+//
+// Revision 1.6 1998/06/03 00:43:28 curt
+// No .h when including stl stuff.
+//
+// Revision 1.5 1998/05/17 16:58:13 curt
+// Added a View Frustum Culling ratio display to the hud.
+//
+// Revision 1.4 1998/05/16 13:04:15 curt
+// New updates from Charlie Hotchkiss.
+//
+// Revision 1.3 1998/05/13 18:27:55 curt
+// Added an fov to hud display.
+//
+// Revision 1.2 1998/05/11 18:13:12 curt
+// Complete C++ rewrite of all cockpit code by Charlie Hotchkiss.
+//
+// Revision 1.15 1998/02/23 19:07:57 curt
+// Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+// calculation code between sun display, and other FG sections that use this
+// for things like lighting.
+//
+// Revision 1.14 1998/02/21 14:53:14 curt
+// Added Charlie's HUD changes.
+//
+// Revision 1.13 1998/02/20 00:16:22 curt
+// Thursday's tweaks.
+//
+// Revision 1.12 1998/02/19 13:05:52 curt
+// Incorporated some HUD tweaks from Michelle America.
+// Tweaked the sky's sunset/rise colors.
+// Other misc. tweaks.
+//
+// Revision 1.11 1998/02/16 13:38:42 curt
+// Integrated changes from Charlie Hotchkiss.
+//
+// Revision 1.11 1998/02/16 13:38:42 curt
+// Integrated changes from Charlie Hotchkiss.
+//
+// Revision 1.10 1998/02/12 21:59:42 curt
+// Incorporated code changes contributed by Charlie Hotchkiss
+// <chotchkiss@namg.us.anritsu.com>
+//
+// Revision 1.8 1998/02/07 15:29:35 curt
+// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+// <chotchkiss@namg.us.anritsu.com>
+//
+// Revision 1.7 1998/02/03 23:20:15 curt
+// Lots of little tweaks to fix various consistency problems discovered by
+// Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+// passed arguments along to the real printf(). Also incorporated HUD changes
+// by Michele America.
+//
+// Revision 1.6 1998/01/22 02:59:30 curt
+// Changed #ifdef FILE_H to #ifdef _FILE_H
+//
+// Revision 1.5 1998/01/19 19:27:01 curt
+// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+// This should simplify things tremendously.
+//
+// Revision 1.4 1998/01/19 18:40:21 curt
+// Tons of little changes to clean up the code and to remove fatal errors
+// when building with the c++ compiler.
+//
+// Revision 1.3 1997/12/30 16:36:41 curt
+// Merged in Durk's changes ...
+//
+// Revision 1.2 1997/12/10 22:37:40 curt
+// Prepended "fg" on the name of all global structures that didn't have it yet.
+// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
+//
+// Revision 1.1 1997/08/29 18:03:22 curt
+// Initial revision.
+//