From 8f3c1f30e11925da9a683768e09091eb53ed69b3 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 13 Jul 1998 21:00:45 +0000 Subject: [PATCH] Integrated Charlies latest HUD updates. Wrote access functions for current fgOPTIONS. --- Cockpit/cockpit.cxx | 37 ++++--- Cockpit/cockpit.hxx | 29 ++--- Cockpit/hud.cxx | 248 +++++++++++++++++++++++++++++++------------ Cockpit/hud.hxx | 57 ++++++---- Cockpit/hud_card.cxx | 32 +++--- Cockpit/hud_guag.cxx | 22 ++-- Cockpit/hud_inst.cxx | 14 ++- Cockpit/hud_labl.cxx | 12 ++- Cockpit/hud_scal.cxx | 4 +- Cockpit/panel.cxx | 23 ++-- 10 files changed, 304 insertions(+), 174 deletions(-) diff --git a/Cockpit/cockpit.cxx b/Cockpit/cockpit.cxx index ccb5227f0..165da001e 100644 --- a/Cockpit/cockpit.cxx +++ b/Cockpit/cockpit.cxx @@ -215,29 +215,25 @@ double get_sideslip( void ) double get_frame_rate( void ) { - fgGENERAL *g; + fgGENERAL *pgeneral; - g = &general; + pgeneral = &general; - return g->frame_rate; + return pgeneral->frame_rate; } double get_fov( void ) { - fgOPTIONS *o; - - o = ¤t_options; - - return o->fov; + return (current_options.get_fov()); } double get_vfc_ratio( void ) { - fgVIEW *v; + fgVIEW *pview; - v = ¤t_view; + pview = ¤t_view; - return v->vfc_ratio; + return pview->vfc_ratio; } bool fgCockpitInit( fgAIRCRAFT *cur_aircraft ) @@ -270,32 +266,35 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft ) void fgCockpitUpdate( void ) { - fgOPTIONS *o; - fgVIEW *v; + fgVIEW *pview; - o = ¤t_options; - v = ¤t_view; + pview = ¤t_view; fgPrintf( FG_COCKPIT, FG_DEBUG, "Cockpit: code %d status %d\n", ac_cockpit->code(), ac_cockpit->status() ); - if ( o->hud_status ) { + if ( current_options.get_hud_status() ) { // This will check the global hud linked list pointer. // If these is anything to draw it will. fgUpdateHUD(); } - if ( o->panel_status && (fabs(v->view_offset) < 0.2) ) { + if ( current_options.get_panel_status() && + (fabs(pview->view_offset) < 0.2) ) { fgPanelUpdate(); } } /* $Log$ -/* Revision 1.10 1998/07/08 14:41:08 curt -/* Renamed polar3d.h to polar3d.hxx +/* Revision 1.11 1998/07/13 21:00:45 curt +/* Integrated Charlies latest HUD updates. +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.10 1998/07/08 14:41:08 curt + * Renamed polar3d.h to polar3d.hxx + * * Revision 1.9 1998/06/27 16:47:53 curt * Incorporated Friedemann Reinhard's * first pass at an isntrument panel. diff --git a/Cockpit/cockpit.hxx b/Cockpit/cockpit.hxx index 7abbc0230..5f6ac4b8b 100644 --- a/Cockpit/cockpit.hxx +++ b/Cockpit/cockpit.hxx @@ -28,25 +28,14 @@ #define _COCKPIT_HXX -#include "hud.hxx" -#include "panel.hxx" - - -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif -//typedef struct { -// int code; -// Hptr hud; -// // As above. -// // PANEL *panel; -// int status; -//}fgCOCKPIT, *pfgCockpit; +#include "hud.hxx" +#include "panel.hxx" -// And in the future (near future i hope). -// #include // Class fg_Cockpit This class is a holder for the heads up display // and is initialized with a class fg_Cockpit { @@ -71,10 +60,14 @@ void fgCockpitUpdate( void ); /* $Log$ -/* Revision 1.3 1998/06/27 16:47:54 curt -/* Incorporated Friedemann Reinhard's -/* first pass at an isntrument panel. +/* Revision 1.4 1998/07/13 21:00:46 curt +/* Integrated Charlies latest HUD updates. +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.3 1998/06/27 16:47:54 curt + * Incorporated Friedemann Reinhard's + * first pass at an isntrument panel. + * * Revision 1.2 1998/05/11 18:13:10 curt * Complete C++ rewrite of all cockpit code by Charlie Hotchkiss. * diff --git a/Cockpit/hud.cxx b/Cockpit/hud.cxx index 2d158e2e4..62a9a8041 100644 --- a/Cockpit/hud.cxx +++ b/Cockpit/hud.cxx @@ -43,6 +43,7 @@ #include #include #include +#include
#include #include #include @@ -169,17 +170,17 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) do { switch ( index ) { case 0: // TBI - HIptr = (instr_item *) new fgTBI_instr( 300, 100, 60, 10 ); + HIptr = (instr_item *) new fgTBI_instr( 270, 100, 60, 10 ); break; case 1: // Artificial Horizon - HIptr = (instr_item *) new HudLadder( 270, 195, 120, 180 ); + HIptr = (instr_item *) new HudLadder( 240, 195, 120, 180 ); break; case 2: // KIAS - HIptr = (instr_item *) new hud_card( 160, + HIptr = (instr_item *) new hud_card( 130, 170, - 35, + 28, 200, get_speed, HUDS_LEFT | HUDS_VERT, @@ -194,39 +195,39 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) break; case 3: // Angle of Attack - HIptr = (instr_item *) new hud_card( 450, + HIptr = (instr_item *) new hud_card( 420, 195, - 30, + 25, 150, get_aoa, HUDS_LEFT | HUDS_VERT, 50, -40, 1.0, - 5, 1, + 2, 1, 0, 1, - 21.0, + 5.0, true); break; case 4: // GYRO COMPASS HIptr = (instr_item *) new hud_card( 200, 375, - 260, - 32, + 200, + 28, get_heading, HUDS_TOP, 360, 0, - 1.0, - 10, 5, + 1.0, + 5, 1, 360, - 0, - 50, + 0, + 25, true); break; case 5: // AMSL - HIptr = (instr_item *) new hud_card( 490, + HIptr = (instr_item *) new hud_card( 460, 170, 35, 200, @@ -241,8 +242,56 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) true); break; - case 6: // Digital KIAS - HIptr = (instr_item *) new instr_label ( 160, + case 6: + HIptr = (instr_item *) new guage_instr( 250, // x + 350, // y + 100, // width + 20, // height + get_aileronval, // data source + HUDS_BOTTOM | HUDS_NOTEXT, + 100.0, + +1.0, + -1.0); + break; + + case 7: + HIptr = (instr_item *) new guage_instr( 170, // x + 225, // y + 20, // width + 100, // height + get_elevatorval, // data source + HUDS_RIGHT | HUDS_VERT | HUDS_NOTEXT, + -100.0, // Scale data + +1.0, // Data Range + -1.0); + break; + + case 8: + HIptr = (instr_item *) new guage_instr( 250, // x + 200, // y + 100, // width + 20, // height + get_rudderval, // data source + HUDS_TOP | HUDS_NOTEXT, + 100.0, + +1.0, + -1.0); + break; + + case 9: + HIptr = (instr_item *) new guage_instr( 100, // x + 190, + 20, + 160, // height + get_throttleval, // data source + HUDS_VERT | HUDS_RIGHT | HUDS_NOTEXT, + 100.0, + 1.0, + 0.0); + break; + + case 10: // Digital KIAS + HIptr = (instr_item *) new instr_label ( 110, 150, 40, 30, @@ -250,6 +299,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.0f", NULL, " Kts", + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -257,8 +307,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 7: // Digital Altimeter - HIptr = (instr_item *) new instr_label ( 160, + case 11: // Digital Altimeter + HIptr = (instr_item *) new instr_label ( 110, 135, 40, 10, @@ -266,6 +316,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "MSL %5.0f", NULL, " m", + 1.0, HUDS_TOP, LEFT_JUST, SMALL, @@ -273,8 +324,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 8: // Roll indication diagnostic - HIptr = (instr_item *) new instr_label ( 160, + case 12: // Roll indication diagnostic + HIptr = (instr_item *) new instr_label ( 110, 120, 40, 10, @@ -282,6 +333,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.2f", " Roll", " Deg", + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -289,7 +341,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 9: // Angle of attack diagnostic + case 13: // Angle of attack diagnostic HIptr = (instr_item *) new instr_label ( 440, 150, 60, @@ -298,6 +350,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) " %5.2f", "AOA", " Deg", + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -305,15 +358,16 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 10: + case 14: HIptr = (instr_item *) new instr_label ( 440, 135, 60, 10, get_heading, - " %5.0f", + " %5.1f", "Heading ", " Deg", + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -321,7 +375,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 11: + case 15: HIptr = (instr_item *) new instr_label ( 440, 120, 60, @@ -330,6 +384,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.2f", "Sideslip ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -337,7 +392,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 12: + case 16: HIptr = (instr_item *) new instr_label( 440, 100, 60, @@ -346,6 +401,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.2f", "Throttle ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -353,7 +409,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 13: + case 17: HIptr = (instr_item *) new instr_label( 440, 85, 60, @@ -362,6 +418,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.2f", "Elevator ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -369,7 +426,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 14: + case 18: HIptr = (instr_item *) new instr_label( 440, 60, 60, @@ -378,6 +435,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%5.2f", "Aileron ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -386,7 +444,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) break; - case 15: + case 19: HIptr = (instr_item *) new instr_label( 10, 10, 60, @@ -395,6 +453,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%.1f", "Frame rate = ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -402,7 +461,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 16: + case 20: HIptr = (instr_item *) new instr_label( 10, 25, 90, @@ -411,6 +470,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%.2f", "VFC Ratio = ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, @@ -418,7 +478,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); break; - case 17: + case 21: HIptr = (instr_item *) new instr_label( 10, 40, 90, @@ -427,47 +487,13 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) "%.1f", "FOV = ", NULL, + 1.0, HUDS_TOP, RIGHT_JUST, SMALL, 0, TRUE ); break; - case 18: - HIptr = (instr_item *) new guage_instr( 50, // x - 200, // y - 100, // width - 20, // height - get_aileronval, // data source - HUDS_BOTTOM, - 100.0, - +1.0, - -1.0); - break; - - case 19: - HIptr = (instr_item *) new guage_instr( 90, // x - 225, // y - 20, // width - 100, // height - get_elevatorval, // data source - HUDS_BOTH | HUDS_VERT, - 100.0, // Scale data - +1.0, // Data Range - -1.0); - break; - - case 20: - HIptr = (instr_item *) new guage_instr( 50, // x - 350, // y - 100, // width - 20, // height - get_rudderval, // data source - HUDS_TOP, - 100.0, - +1.0, - -1.0); - break; default: HIptr = 0;; @@ -482,6 +508,79 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) return 0; // For now. Later we may use this for an error code. } +int global_day_night_switch = DAY; + +void HUD_brightkey( bool incr_bright ) +{ +instr_item *pHUDInstr = HUD_deque[0]; +int brightness = pHUDInstr->get_brightness(); + + if( current_options.get_hud_status() ) { + if( incr_bright ) { + switch (brightness) { + case BRT_LIGHT: + current_options.set_hud_status(0); + break; + + case BRT_MEDIUM: + brightness = BRT_LIGHT; + break; + + case BRT_DARK: + brightness = BRT_MEDIUM; + break; + + case BRT_BLACK: + brightness = BRT_DARK; + break; + + default: + brightness = BRT_BLACK; + } + } + else { + switch (brightness) { + case BRT_LIGHT: + brightness = BRT_MEDIUM; + break; + + case BRT_MEDIUM: + brightness = BRT_DARK; + break; + + case BRT_DARK: + brightness = BRT_BLACK; + break; + + case BRT_BLACK: + default: + current_options.set_hud_status(0); + } + } + } + else { + current_options.set_hud_status(1); + if( incr_bright ) { + if( DAY == global_day_night_switch ) { + brightness = BRT_BLACK; + } + else { + brightness = BRT_DARK; + global_day_night_switch = DAY; + } + } + else { + if( NIGHT == global_day_night_switch ) { + brightness = BRT_DARK; + } + else { + brightness = BRT_MEDIUM; + global_day_night_switch = NIGHT; + } + } + } + pHUDInstr->SetBrightness( brightness ); +} // fgUpdateHUD // @@ -489,8 +588,6 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) // the HUD object with requests for redraw. Kinda. It will when this is // all C++. // -int global_day_night_switch = DAY; - void fgUpdateHUD( void ) { int i; int brightness; @@ -543,6 +640,13 @@ void fgUpdateHUD( void ) { case BRT_DARK: glColor3f (0.0, 0.5, 0.0); + break; + + case BRT_BLACK: + glColor3f( 0.0, 0.0, 0.0); + break; + + default:; } } else { @@ -582,9 +686,13 @@ void fgUpdateHUD( void ) { } /* $Log$ -/* Revision 1.15 1998/07/08 14:41:08 curt -/* Renamed polar3d.h to polar3d.hxx +/* Revision 1.16 1998/07/13 21:00:47 curt +/* Integrated Charlies latest HUD updates. +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.15 1998/07/08 14:41:08 curt + * Renamed polar3d.h to polar3d.hxx + * * Revision 1.14 1998/07/06 21:31:20 curt * Removed an extraneous ^M. * diff --git a/Cockpit/hud.hxx b/Cockpit/hud.hxx index c05260aa0..e1d1150c3 100644 --- a/Cockpit/hud.hxx +++ b/Cockpit/hud.hxx @@ -79,11 +79,12 @@ 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 @@ -185,19 +186,28 @@ enum hudinstype{ HUDno_instr, HUDtbi }; +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; - UINT opts; - 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( int x, @@ -205,6 +215,7 @@ class instr_item { // An Abstract Base Class (ABC) UINT height, UINT width, DBLFNPTR data_source, + double data_scaling, UINT options, bool working = true); @@ -217,7 +228,9 @@ class instr_item { // An Abstract Base Class (ABC) 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; } UINT get_options ( void ) { return opts; } @@ -259,6 +272,7 @@ class instr_label : public instr_item { const char *label_format, 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, @@ -269,7 +283,6 @@ class instr_label : public instr_item { instr_label( const instr_label & image); instr_label & operator = (const instr_label & rhs ); - virtual void draw( void ); // Required method in base class }; @@ -289,7 +302,6 @@ class instr_scale : public instr_item { double scale_factor; // factor => screen units/range values. UINT Maj_div; // major division marker units UINT Min_div; // minor division marker units - double disp_factor; // Multiply by to get numbers shown on scale. UINT Modulo; // Roll over point int signif_digits; // digits to show to the right. @@ -480,6 +492,7 @@ class HudLadder : public dual_instr_item { //using namespace std; //deque * Hdeque_ptr; +extern void HUD_brightkey( bool incr_bright ); extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ); extern void fgUpdateHUD( void ); @@ -509,9 +522,13 @@ void fgHUDSetTimeMode( Hptr hud, int time_of_day ); #endif // _HUD_H /* $Log$ -/* Revision 1.8 1998/07/03 13:16:29 curt -/* Added Charlie Hotchkiss's HUD updates and improvementes. +/* 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. * diff --git a/Cockpit/hud_card.cxx b/Cockpit/hud_card.cxx index c7ba3133a..55f8d1df0 100644 --- a/Cockpit/hud_card.cxx +++ b/Cockpit/hud_card.cxx @@ -1,4 +1,4 @@ -#ifdef HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif @@ -78,7 +78,7 @@ draw( void ) // (HUD_scale * pscale ) int marker_xe; int marker_ys; int marker_ye; - register i; + /* register */ int i; char TextScale[80]; bool condition; int disp_val; @@ -170,8 +170,8 @@ draw( void ) // (HUD_scale * pscale ) } if( div_min()) { if( (i%div_min()) == 0) { - if((( marker_ys + 5) > scrn_rect.top ) || - (( marker_ys - 5) < (scrn_rect.top + scrn_rect.bottom))){ + if((( marker_ys - 5) > scrn_rect.top ) && + (( marker_ys + 5) < (scrn_rect.top + scrn_rect.bottom))){ if( (options & HUDS_BOTH) == HUDS_BOTH ) { drawOneLine( scrn_rect.left, marker_ys, marker_xs, marker_ys ); @@ -204,9 +204,9 @@ draw( void ) // (HUD_scale * pscale ) else { disp_val = i; } - sprintf( TextScale, "%d", disp_val ); - if(( (marker_ys - 5 ) > scrn_rect.top ) || - ( (marker_ys + 5) < (scrn_rect.top + scrn_rect.bottom))){ + sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5)); + if(( (marker_ys - 8 ) > scrn_rect.top ) && + ( (marker_ys + 8) < (scrn_rect.top + scrn_rect.bottom))){ if( (options & HUDS_BOTH) == HUDS_BOTH) { drawOneLine( scrn_rect.left, marker_ys, marker_xs, marker_ys); @@ -232,7 +232,7 @@ draw( void ) // (HUD_scale * pscale ) TextScale, GLUT_BITMAP_8_BY_13 ); } } - } + } } // Else read oriented right } // End if modulo division by major interval is zero } // End if major interval divisor non-zero @@ -291,20 +291,23 @@ draw( void ) // (HUD_scale * pscale ) // marker_ye = marker_xe; // } + // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax); for( i = (int)vmin; i <= (int)vmax; i++ ) { + // printf("<*> i = %d\n", i); condition = true; if( !modulo()) { if( i < min_val()) { condition = false; } } + // printf("<**> i = %d\n", i); if( condition ) { marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5); if( div_min()){ if( (i%(int)div_min()) == 0 ) { // draw in ticks only if they aren't too close to the edge. - if((( marker_xs + 5) > scrn_rect.left ) || - (( marker_xs - 5 )< (scrn_rect.left + scrn_rect.right))){ + if((( marker_xs - 5) > scrn_rect.left ) && + (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){ if( (options & HUDS_BOTH) == HUDS_BOTH ) { drawOneLine( marker_xs, scrn_rect.top, @@ -325,7 +328,9 @@ draw( void ) // (HUD_scale * pscale ) } } } + // printf("<***> i = %d\n", i); if( div_max()) { + // printf("i = %d\n", i); if( (i%(int)div_max())==0 ) { if(modulo()) { if( disp_val < 0) { @@ -338,7 +343,9 @@ draw( void ) // (HUD_scale * pscale ) else { disp_val = i; } - sprintf( TextScale, "%d", disp_val ); + // printf("disp_val = %d\n", disp_val); + // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5)); + sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5)); // Draw major ticks and text only if far enough from the edge. if(( (marker_xs - 10)> scrn_rect.left ) && ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){ @@ -372,7 +379,8 @@ draw( void ) // (HUD_scale * pscale ) } } } - } + } + // printf("<****> i = %d\n", i); } } } diff --git a/Cockpit/hud_guag.cxx b/Cockpit/hud_guag.cxx index 7cc985bc2..c1c3dbf7d 100644 --- a/Cockpit/hud_guag.cxx +++ b/Cockpit/hud_guag.cxx @@ -1,4 +1,4 @@ -#ifdef HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include #endif @@ -180,7 +180,7 @@ void guage_instr :: draw (void) if( !(options & HUDS_NOTEXT)) { disp_val = i; - sprintf( TextScale, "%d", disp_val ); + sprintf( TextScale, "%d",disp_val * (int)(data_scaling() +.5)); if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) { text_x = mid_scr.x - 2 - ((3 * strlen( TextScale ))>>1); @@ -209,16 +209,16 @@ void guage_instr :: draw (void) // text_x = marker_xs - scrn_rect.left; if( options & HUDS_RIGHT ) { - drawOneLine(scrn_rect.left, text_y, - marker_xe, text_y + 5); - drawOneLine(scrn_rect.left, text_y, - marker_xe, text_y - 5); + drawOneLine(scrn_rect.left, text_y + 5, + marker_xe, text_y); + drawOneLine(scrn_rect.left, text_y - 5, + marker_xe, text_y); } if( options & HUDS_LEFT ) { - drawOneLine(scrn_rect.left + scrn_rect.right, text_y, - marker_xs, text_y + 5); - drawOneLine(scrn_rect.left + scrn_rect.right, text_y, - marker_xs, text_y - 5); + drawOneLine(scrn_rect.left + scrn_rect.right, text_y + 5, + marker_xs, text_y); + drawOneLine(scrn_rect.left + scrn_rect.right, text_y - 5, + marker_xs, text_y); } } // End if VERTICAL SCALE TYPE else { // Horizontal scale by default @@ -315,7 +315,7 @@ void guage_instr :: draw (void) else { disp_val = i; } - sprintf( TextScale, "%d", disp_val ); + sprintf( TextScale, "%d", (int)(disp_val * data_scaling() +.5)); // Draw major ticks and text only if far enough from the edge. if(( (marker_xs - 10)> scrn_rect.left ) && ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){ diff --git a/Cockpit/hud_inst.cxx b/Cockpit/hud_inst.cxx index 7d9fbe02c..f13102fb6 100644 --- a/Cockpit/hud_inst.cxx +++ b/Cockpit/hud_inst.cxx @@ -7,6 +7,7 @@ #ifdef HAVE_WINDOWS_H # include #endif + #include #include #include @@ -22,7 +23,9 @@ #include "hud.hxx" -UINT instr_item :: instances; // Initial value of zero +UINT instr_item :: instances = 0; // Initial value of zero +int instr_item :: brightness = BRT_MEDIUM; +glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0}; // constructor ( No default provided ) instr_item :: @@ -31,14 +34,15 @@ instr_item :: UINT width, UINT height, DBLFNPTR data_source, + double data_scaling, UINT options, bool working) : handle ( ++instances ), load_value_fn ( data_source ), + disp_factor ( data_scaling ), opts ( options ), is_enabled ( working ), - broken ( FALSE ), - brightness ( BRT_MEDIUM ) + broken ( FALSE ) { scrn_pos.left = x; scrn_pos.top = y; @@ -76,10 +80,10 @@ instr_item :: handle ( ++instances ), scrn_pos ( image.scrn_pos ), load_value_fn( image.load_value_fn), + disp_factor ( image.disp_factor ), opts ( image.opts ), is_enabled ( image.is_enabled ), broken ( image.broken ), - brightness ( image.brightness ), scr_span ( image.scr_span ), mid_span ( image.mid_span ) { @@ -92,10 +96,10 @@ instr_item & instr_item :: operator = ( const instr_item & rhs ) if( !(this == &rhs )) { // Not an identity assignment scrn_pos = rhs.scrn_pos; load_value_fn = rhs.load_value_fn; + disp_factor = rhs.disp_factor; opts = rhs.opts; is_enabled = rhs.is_enabled; broken = rhs.broken; - brightness = rhs.brightness; } return *this; } diff --git a/Cockpit/hud_labl.cxx b/Cockpit/hud_labl.cxx index 214bea8d6..38665b83d 100644 --- a/Cockpit/hud_labl.cxx +++ b/Cockpit/hud_labl.cxx @@ -30,13 +30,14 @@ instr_label :: const char *label_format, const char *pre_label_string, const char *post_label_string, + double scale_data, UINT options, fgLabelJust justification, int font_size, int blinking, bool working ): instr_item( x, y, width, height, - data_source, options, working ), + data_source, scale_data,options, working ), pformat ( label_format ), pre_str ( pre_label_string ), post_str ( post_label_string ), @@ -78,7 +79,6 @@ instr_label & instr_label ::operator = (const instr_label & rhs ) return *this; } - // // draw Draws a label anywhere in the HUD // @@ -106,7 +106,13 @@ draw( void ) // Required method in base class } } // else do nothing if both pre and post strings are nulls. Interesting. - sprintf( label_buffer, format_buffer, get_value() ); + if( data_available() ) { + sprintf( label_buffer, format_buffer, get_value() ); + } + else { + sprintf( label_buffer, format_buffer ); + } + #ifdef DEBUGHUD fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); diff --git a/Cockpit/hud_scal.cxx b/Cockpit/hud_scal.cxx index 57fc3ebd9..f2c3fe3b0 100644 --- a/Cockpit/hud_scal.cxx +++ b/Cockpit/hud_scal.cxx @@ -47,11 +47,11 @@ instr_scale ( int x, UINT rollover, int dp_showing, bool working ) : - instr_item( x, y, width, height, load_fn, options, working), + instr_item( x, y, width, height, + load_fn, disp_scale, options, working), range_shown ( show_range ), Maximum_value( maxValue ), Minimum_value( minValue ), - scale_factor ( disp_scale ), Maj_div ( major_divs ), Min_div ( minor_divs ), Modulo ( rollover ), diff --git a/Cockpit/panel.cxx b/Cockpit/panel.cxx index b1b241e23..dc47ff57f 100644 --- a/Cockpit/panel.cxx +++ b/Cockpit/panel.cxx @@ -45,6 +45,7 @@ #include "panel.hxx" + // Intriquing. Needs documentation. #define IMAGIC 0x01da #define IMAGIC_SWAP 0xda01 @@ -77,13 +78,7 @@ static GLuint panel_tex_id; static GLubyte tex[512][256][4]; -static double get_speed( void ) -{ - fgFLIGHT *f; - - f = current_aircraft.flight; - return( FG_V_equiv_kts ); // Make an explicit function call. -} +extern double get_speed( void ); /* image.c ,temporary hack, I know*/ @@ -291,12 +286,9 @@ static IMAGE *ImageLoad(char *fileName) void fgPanelInit ( void ) { - fgOPTIONS *o; char tpath[256]; int x, y; - o = ¤t_options; - #ifdef GL_VERSION_1_1 xglGenTextures(1, &panel_tex_id); xglBindTexture(GL_TEXTURE_2D, panel_tex_id); @@ -315,8 +307,7 @@ void fgPanelInit ( void ) { xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /* load in the texture data */ - tpath[0] = '\0'; - strcat(tpath, o->fg_root); + current_options.get_fg_root(tpath); strcat(tpath, "/Textures/"); strcat(tpath, "panel1.rgb"); @@ -425,9 +416,13 @@ void fgPanelUpdate ( void ) { /* $Log$ -/* Revision 1.2 1998/07/03 11:55:37 curt -/* A few small rearrangements and tweaks. +/* Revision 1.3 1998/07/13 21:00:52 curt +/* Integrated Charlies latest HUD updates. +/* Wrote access functions for current fgOPTIONS. /* + * Revision 1.2 1998/07/03 11:55:37 curt + * A few small rearrangements and tweaks. + * * Revision 1.1 1998/06/27 16:47:54 curt * Incorporated Friedemann Reinhard's * first pass at an isntrument panel. -- 2.39.2