1
0
Fork 0

a) HUD - Here is the updated hud code with moving pointers, dials, turn/slip gauge, choice of circular ticks, two sizes for fonts, box for text labels etc. based partly on MIL-STD-1787b and our pilots requirements. Our pilots are not very enthusiastic about all symbols discussed in MIL-STD-1787b (I suppose it is very subjective) and so I did not have motivation to try all of them. Even now I plan to do simple symbols as seen on Russian aircraft since our Air Force pilots are familiar with them. That should be part of my next update. I have included a html document which is basically the old text file plus some snapshots with all possible hud symbols linked to corresponding xml templates. You have to just cut & paste the template, change names and positions to create additional symbols (if you have the real estate on the hud).

This commit is contained in:
curt 2001-09-19 22:23:25 +00:00
parent 45390e0655
commit 2154915465
13 changed files with 2381 additions and 681 deletions

View file

@ -3,7 +3,7 @@ noinst_LIBRARIES = libCockpit.a
libCockpit_a_SOURCES = \ libCockpit_a_SOURCES = \
cockpit.cxx cockpit.hxx \ cockpit.cxx cockpit.hxx \
hud.cxx hud.hxx hud_opts.hxx \ hud.cxx hud.hxx hud_opts.hxx \
hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \ hud_card.cxx hud_dnst.cxx hud_gaug.cxx hud_inst.cxx \
hud_labl.cxx hud_ladr.cxx \ hud_labl.cxx hud_ladr.cxx \
hud_lat.cxx hud_lon.cxx \ hud_lat.cxx hud_lon.cxx \
hud_scal.cxx hud_tbi.cxx \ hud_scal.cxx hud_tbi.cxx \

View file

@ -64,18 +64,12 @@ static pCockpit ac_cockpit;
float get_latitude( void ) float get_latitude( void )
{ {
double lat; return current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
lat = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
float flat = lat;
return(flat);
} }
float get_lat_min( void ) float get_lat_min( void )
{ {
double a, d; double a, d;
a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES; a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
if (a < 0.0) { if (a < 0.0) {
@ -83,18 +77,14 @@ float get_lat_min( void )
} }
d = (double) ( (int) a); d = (double) ( (int) a);
float lat_min = (a - d) * 60.0; float lat_min = (a - d) * 60.0;
return(lat_min );
return lat_min;
} }
float get_longitude( void ) float get_longitude( void )
{ {
double lon; return current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
lon = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
float flon = lon;
return(flon);
} }
@ -106,6 +96,7 @@ get_formated_gmt_time( void )
sprintf( buf, "%d/%d/%4d %d:%02d:%02d", sprintf( buf, "%d/%d/%4d %d:%02d:%02d",
p->tm_mon+1, p->tm_mday, 1900 + p->tm_year, p->tm_mon+1, p->tm_mday, 1900 + p->tm_year,
p->tm_hour, p->tm_min, p->tm_sec); p->tm_hour, p->tm_min, p->tm_sec);
return buf; return buf;
} }
@ -119,37 +110,34 @@ float get_long_min( void )
} }
d = (double) ( (int) a); d = (double) ( (int) a);
float lon_min = (a - d) * 60.0; float lon_min = (a - d) * 60.0;
return(lon_min);
return lon_min;
} }
float get_throttleval( void ) float get_throttleval( void )
{ {
float throttle = globals->get_controls()->get_throttle( 0 ); // Hack limiting to one engine
return (throttle); // Hack limiting to one engine return globals->get_controls()->get_throttle( 0 );
} }
float get_aileronval( void ) float get_aileronval( void )
{ {
float aileronval = globals->get_controls()->get_aileron(); return globals->get_controls()->get_aileron();
return (aileronval);
} }
float get_elevatorval( void ) float get_elevatorval( void )
{ {
float elevator_val = (float)globals->get_controls()->get_elevator(); return globals->get_controls()->get_elevator();
return elevator_val;
} }
float get_elev_trimval( void ) float get_elev_trimval( void )
{ {
float elevatorval = globals->get_controls()->get_elevator_trim(); return globals->get_controls()->get_elevator_trim();
return (elevatorval);
} }
float get_rudderval( void ) float get_rudderval( void )
{ {
float rudderval = globals->get_controls()->get_rudder(); return globals->get_controls()->get_rudder();
return (rudderval);
} }
float get_speed( void ) float get_speed( void )
@ -164,32 +152,27 @@ float get_speed( void )
float get_mach(void) float get_mach(void)
{ {
float mach=current_aircraft.fdm_state->get_Mach_number(); return current_aircraft.fdm_state->get_Mach_number();
return mach;
} }
float get_aoa( void ) float get_aoa( void )
{ {
float aoa = current_aircraft.fdm_state->get_Alpha() * SGD_RADIANS_TO_DEGREES; return current_aircraft.fdm_state->get_Alpha() * SGD_RADIANS_TO_DEGREES;
return( aoa );
} }
float get_roll( void ) float get_roll( void )
{ {
float roll = current_aircraft.fdm_state->get_Phi(); return current_aircraft.fdm_state->get_Phi();
return( roll );
} }
float get_pitch( void ) float get_pitch( void )
{ {
float pitch = current_aircraft.fdm_state->get_Theta(); return current_aircraft.fdm_state->get_Theta();
return( pitch );
} }
float get_heading( void ) float get_heading( void )
{ {
float heading = (current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES); return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES;
return( heading );
} }
float get_altitude( void ) float get_altitude( void )
@ -220,25 +203,23 @@ float get_agl( void )
agl = (current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER agl = (current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
- scenery.cur_elev); - scenery.cur_elev);
} }
return agl; return agl;
} }
float get_sideslip( void ) float get_sideslip( void )
{ {
float sideslip = current_aircraft.fdm_state->get_Beta(); return current_aircraft.fdm_state->get_Beta();
return( sideslip );
} }
float get_frame_rate( void ) float get_frame_rate( void )
{ {
float frame_rate = general.get_frame_rate(); return general.get_frame_rate();
return (frame_rate);
} }
float get_fov( void ) float get_fov( void )
{ {
float fov = globals->get_current_view()->get_fov(); return globals->get_current_view()->get_fov();
return (fov);
} }
float get_vfc_ratio( void ) float get_vfc_ratio( void )
@ -270,7 +251,8 @@ float get_climb_rate( void )
} else { } else {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0; climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0;
} }
return (climb_rate);
return climb_rate;
} }
@ -292,230 +274,230 @@ float get_view_direction( void )
// #ifdef FIGHTER_HUD // #ifdef FIGHTER_HUD
float get_Vx ( void ) float get_Vx ( void )
{ {
// CLO - 5 Jan 2000 - something needs to get addressed here // Curt dont comment this and return zero. - Ranga
// float Vxx = current_aircraft.fdm_state->get_V_north_rel_ground(); // Please remove comments from get_V_..() function in flight.hxx
float Vxx = 0; float Vxx = current_aircraft.fdm_state->get_V_north_rel_ground();
return (Vxx); return Vxx;
} }
float get_Vy ( void ) float get_Vy ( void )
{ {
// CLO - 5 Jan 2000 - something needs to get addressed here // Curt dont comment this and return zero. - Ranga
// float Vyy = current_aircraft.fdm_state->get_V_east_rel_ground(); // Please remove comments from get_V_..() function in flight.hxx
float Vyy = 0; float Vyy = current_aircraft.fdm_state->get_V_east_rel_ground();
return (Vyy); return Vyy;
} }
float get_Vz ( void ) float get_Vz ( void )
{ {
// CLO - 5 Jan 2000 - something needs to get addressed here // Curt dont comment this and return zero. - Ranga
// float Vzz = current_aircraft.fdm_state->get_V_down_rel_ground(); // Please remove comments from get_V_..() function in flight.hxx
float Vzz = 0; float Vzz = current_aircraft.fdm_state->get_V_down_rel_ground();
return (Vzz); return Vzz;
} }
float get_Ax ( void ) float get_Ax ( void )
{ {
float Ax = current_aircraft.fdm_state->get_V_dot_north(); float Ax = current_aircraft.fdm_state->get_V_dot_north();
return (Ax); return Ax;
} }
float get_Ay ( void ) float get_Ay ( void )
{ {
float Ay = current_aircraft.fdm_state->get_V_dot_east(); float Ay = current_aircraft.fdm_state->get_V_dot_east();
return (Ay); return Ay;
} }
float get_Az ( void ) float get_Az ( void )
{ {
float Az = current_aircraft.fdm_state->get_V_dot_down(); float Az = current_aircraft.fdm_state->get_V_dot_down();
return (Az); return Az;
} }
float get_anzg ( void ) float get_anzg ( void )
{ {
float anzg = current_aircraft.fdm_state->get_N_Z_cg(); float anzg = current_aircraft.fdm_state->get_N_Z_cg();
return (anzg); return anzg;
} }
int get_iaux1 (void) int get_iaux1 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux1(); return fdm->get_iaux(1);
} }
int get_iaux2 (void) int get_iaux2 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux2(); return fdm->get_iaux(2);
} }
int get_iaux3 (void) int get_iaux3 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux3(); return fdm->get_iaux(3);
} }
int get_iaux4 (void) int get_iaux4 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux4(); return fdm->get_iaux(4);
} }
int get_iaux5 (void) int get_iaux5 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux5(); return fdm->get_iaux(5);
} }
int get_iaux6 (void) int get_iaux6 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux6(); return fdm->get_iaux(6);
} }
int get_iaux7 (void) int get_iaux7 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux7(); return fdm->get_iaux(7);
} }
int get_iaux8 (void) int get_iaux8 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux8(); return fdm->get_iaux(8);
} }
int get_iaux9 (void) int get_iaux9 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux9(); return fdm->get_iaux(9);
} }
int get_iaux10 (void) int get_iaux10 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux10(); return fdm->get_iaux(10);
} }
int get_iaux11 (void) int get_iaux11 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux11(); return fdm->get_iaux(11);
} }
int get_iaux12 (void) int get_iaux12 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_iaux12(); return fdm->get_iaux(12);
} }
float get_aux1 (void) float get_aux1 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux1(); return fdm->get_daux(1);
} }
float get_aux2 (void) float get_aux2 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux2(); return fdm->get_daux(2);
} }
float get_aux3 (void) float get_aux3 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux3(); return fdm->get_daux(3);
} }
float get_aux4 (void) float get_aux4 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux4(); return fdm->get_daux(4);
} }
float get_aux5 (void) float get_aux5 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux5(); return fdm->get_daux(5);
} }
float get_aux6 (void) float get_aux6 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux6(); return fdm->get_daux(6);
} }
float get_aux7 (void) float get_aux7 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux7(); return fdm->get_daux(7);
} }
float get_aux8 (void) float get_aux8 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux8(); return fdm->get_daux(8);
} }
float get_aux9 (void) float get_aux9 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux9(); return fdm->get_faux(1);
} }
float get_aux10 (void) float get_aux10 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux10(); return fdm->get_faux(2);
} }
float get_aux11 (void) float get_aux11 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux11(); return fdm->get_faux(3);
} }
float get_aux12 (void) float get_aux12 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux12(); return fdm->get_faux(4);
} }
float get_aux13 (void) float get_aux13 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux13(); return fdm->get_faux(5);
} }
float get_aux14 (void) float get_aux14 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux14(); return fdm->get_faux(6);
} }
float get_aux15 (void) float get_aux15 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux15(); return fdm->get_faux(7);
} }
float get_aux16 (void) float get_aux16 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux16(); return fdm->get_faux(8);
} }
float get_aux17 (void) float get_aux17 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux17(); return fdm->get_faux(9);
} }
float get_aux18 (void) float get_aux18 (void)
{ {
FGADA *fdm = (FGADA *)current_aircraft.fdm_state; FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_aux18(); return fdm->get_faux(10);
} }
// #endif // #endif
// $$$ end - added, VS Renganathan 13 Oct 2K // $$$ end - added, VS Renganathan 13 Oct 2K

View file

@ -52,7 +52,6 @@
#include <GUI/gui.h> #include <GUI/gui.h>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/viewmgr.hxx>
#ifdef FG_NETWORK_OLK #ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h> #include <NetworkOLK/network.h>
#endif #endif
@ -144,6 +143,19 @@ static bool glide;
static float glide_slope_val; static float glide_slope_val;
static bool worm_energy; static bool worm_energy;
static bool waypoint; static bool waypoint;
static string type_tick;//hud
static string length_tick;//hud
static bool label_box;//hud
static int digits; //suma
static float radius; //suma
static int divisions; //suma
static int zoom; //suma
static int zenith; //suma
static int nadir ; //suma
static int hat; //suma
static bool tsi; //suma
static float rad; //suma
static FLTFNPTR load_fn; static FLTFNPTR load_fn;
static fgLabelJust justification; static fgLabelJust justification;
@ -200,7 +212,8 @@ void drawOneLine( RECT &rect)
// //
/* textString - Bitmap font string */ /* textString - Bitmap font string */
void textString( int x, int y, char *msg, void *font ){ void textString( int x, int y, char *msg, void *font,int digit) //suma
{
if(*msg) if(*msg)
{ {
@ -293,6 +306,10 @@ readLadder(const SGPropertyNode * node)
worm_energy = node->getBoolValue("enable_energy_marker",false); worm_energy = node->getBoolValue("enable_energy_marker",false);
waypoint = node->getBoolValue("enable_waypoint_marker",false); waypoint = node->getBoolValue("enable_waypoint_marker",false);
working = node->getBoolValue("working"); working = node->getBoolValue("working");
zenith = node->getIntValue("zenith"); //suma
nadir = node->getIntValue("nadir"); //suma
hat = node->getIntValue("hat");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -304,7 +321,7 @@ readLadder(const SGPropertyNode * node)
screen_hole, lbl_pos, frl_spot, target, vel_vector, screen_hole, lbl_pos, frl_spot, target, vel_vector,
drift, alpha, energy, climb_dive, drift, alpha, energy, climb_dive,
glide, glide_slope_val, worm_energy, glide, glide_slope_val, worm_energy,
waypoint, working); waypoint, working, zenith, nadir, hat);
return p; return p;
@ -342,13 +359,17 @@ readCard(const SGPropertyNode * node)
marker_off = node->getFloatValue("marker_offset",0.0); marker_off = node->getFloatValue("marker_offset",0.0);
enable_pointer = node->getBoolValue("enable_pointer",true); enable_pointer = node->getBoolValue("enable_pointer",true);
type_pointer = node->getStringValue("pointer_type"); type_pointer = node->getStringValue("pointer_type");
type_tick = node->getStringValue("tick_type");//hud Can be 'circle' or 'line'
length_tick = node->getStringValue("tick_length");//hud For variable length
working = node->getBoolValue("working"); working = node->getBoolValue("working");
radius = node->getFloatValue("radius"); //suma
divisions = node->getIntValue("divisions"); //suma
zoom = node->getIntValue("zoom"); //suma
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
if(type=="guage") if(type=="gauge")
span_units = maxValue - minValue; span_units = maxValue - minValue;
if(loadfn=="anzg") if(loadfn=="anzg")
@ -412,7 +433,13 @@ readCard(const SGPropertyNode * node)
marker_off, marker_off,
enable_pointer, enable_pointer,
type_pointer, type_pointer,
working); type_tick,//hud
length_tick,//hud
working,
radius, //suma
divisions, //suma
zoom //suma
);
return p; return p;
}// end readCard }// end readCard
@ -438,7 +465,9 @@ readLabel(const SGPropertyNode * node)
blinking = node->getIntValue("blinking"); blinking = node->getIntValue("blinking");
latitude = node->getBoolValue("latitude",false); latitude = node->getBoolValue("latitude",false);
longitude = node->getBoolValue("longitude",false); longitude = node->getBoolValue("longitude",false);
label_box = node->getBoolValue("label_box",false);//hud
working = node->getBoolValue("working"); working = node->getBoolValue("working");
digits = node->getIntValue("digits"); //suma
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -480,26 +509,42 @@ readLabel(const SGPropertyNode * node)
} }
} }
if ( loadfn == "aux16" ) { if ( loadfn== "aux1" ) {
load_fn = get_aux16; load_fn = get_aux1;
} else if ( loadfn == "aux17" ) { } else if ( loadfn == "aux2" ) {
load_fn = get_aux17; load_fn = get_aux2;
} else if ( loadfn == "aux3" ) {
load_fn = get_aux3;
} else if ( loadfn == "aux4" ) {
load_fn = get_aux4;
} else if ( loadfn == "aux5" ) {
load_fn = get_aux5;
} else if ( loadfn == "aux6" ) {
load_fn = get_aux6;
} else if ( loadfn == "aux7" ) {
load_fn = get_aux7;
} else if ( loadfn == "aux8" ) {
load_fn = get_aux8;
} else if ( loadfn == "aux9" ) { } else if ( loadfn == "aux9" ) {
load_fn = get_aux9; load_fn = get_aux9;
} else if ( loadfn == "aux10" ) {
load_fn = get_aux10;
} else if ( loadfn == "aux11" ) { } else if ( loadfn == "aux11" ) {
load_fn = get_aux11; load_fn = get_aux11;
} else if ( loadfn == "aux12" ) { } else if ( loadfn == "aux12" ) {
load_fn = get_aux12; load_fn = get_aux12;
} else if ( loadfn == "aux10" ) {
load_fn = get_aux10;
} else if ( loadfn == "aux13" ) { } else if ( loadfn == "aux13" ) {
load_fn = get_aux13; load_fn = get_aux13;
} else if ( loadfn == "aux14" ) { } else if ( loadfn == "aux14" ) {
load_fn = get_aux14; load_fn = get_aux14;
} else if ( loadfn == "aux15" ) { } else if ( loadfn == "aux15" ) {
load_fn = get_aux15; load_fn = get_aux15;
} else if ( loadfn == "aux8" ) { } else if ( loadfn == "aux16" ) {
load_fn = get_aux8; load_fn = get_aux16;
} else if ( loadfn == "aux17" ) {
load_fn = get_aux17;
} else if ( loadfn == "aux18" ) {
load_fn = get_aux18;
} else if ( loadfn == "ax" ) { } else if ( loadfn == "ax" ) {
load_fn = get_Ax; load_fn = get_Ax;
} else if ( loadfn == "speed" ) { } else if ( loadfn == "speed" ) {
@ -524,9 +569,13 @@ readLabel(const SGPropertyNode * node)
load_fn = get_aoa; load_fn = get_aoa;
} else if ( loadfn == "latitude" ) { } else if ( loadfn == "latitude" ) {
load_fn = get_latitude; load_fn = get_latitude;
} else if ( loadfn == "anzg" ) {
load_fn = get_anzg;
} else if ( loadfn == "longitude" ) { } else if ( loadfn == "longitude" ) {
load_fn = get_longitude; load_fn = get_longitude;
} } else if (loadfn=="throttleval") {
load_fn = get_throttleval;
}
p = (instr_item *) new instr_label ( x, p = (instr_item *) new instr_label ( x,
y, y,
@ -543,7 +592,9 @@ readLabel(const SGPropertyNode * node)
blinking, blinking,
latitude, latitude,
longitude, longitude,
working); label_box, //hud
working,
digits); //suma
return p; return p;
} // end readLabel } // end readLabel
@ -563,6 +614,8 @@ readTBI(const SGPropertyNode * node)
maxSlipAngle = node->getFloatValue("maxSlipAngle"); maxSlipAngle = node->getFloatValue("maxSlipAngle");
gap_width = node->getIntValue("gap_width"); gap_width = node->getIntValue("gap_width");
working = node->getBoolValue("working"); working = node->getBoolValue("working");
tsi = node->getBoolValue("tsi"); //suma
rad = node->getFloatValue("rad"); //suma
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -576,7 +629,9 @@ readTBI(const SGPropertyNode * node)
maxBankAngle, maxBankAngle,
maxSlipAngle, maxSlipAngle,
gap_width, gap_width,
working); working,
tsi, //suma
rad); //suma
return p; return p;
} //end readTBI } //end readTBI
@ -680,13 +735,13 @@ int readHud( istream &input )
SGPropertyNode root2; SGPropertyNode root2;
try { try {
readProperties(path.str(), &root2); readProperties(path.str(), &root2);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
guiErrorMessage("Error reading HUD instrument: ", e); guiErrorMessage("Error reading HUD instrument: ", e);
continue; continue;
} }
readInstrument(&root2); readInstrument(&root2);
}//for loop(i) }//for loop(i)
return 0; return 0;
@ -1033,7 +1088,6 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
// glEnable(GL_BLEND); // glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE); glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE);
// glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glLineWidth(1.5); glLineWidth(1.5);
} else { } else {
glLineWidth(1.0); glLineWidth(1.0);
@ -1104,7 +1158,7 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
} }
char *gmt_str = get_formated_gmt_time(); char *gmt_str = get_formated_gmt_time();
HUD_TextList.add( fgText(40, 10, gmt_str) ); HUD_TextList.add( fgText(40, 10, gmt_str, 0) );
#ifdef FG_NETWORK_OLK #ifdef FG_NETWORK_OLK
if ( net_hud_display ) { if ( net_hud_display ) {

View file

@ -48,6 +48,7 @@
#include <vector> // STL vector #include <vector> // STL vector
#include <deque> // STL double ended queue #include <deque> // STL double ended queue
#include STL_FSTREAM
#include <simgear/constants.h> #include <simgear/constants.h>
@ -56,6 +57,8 @@
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
#include <Controls/controls.hxx> #include <Controls/controls.hxx>
#include <GUI/gui.h> #include <GUI/gui.h>
#include <Main/globals.hxx>
#include <Main/viewmgr.hxx>
#include "hud_opts.hxx" #include "hud_opts.hxx"
@ -218,6 +221,7 @@ extern float get_aux3(void);
extern float get_aux4(void); extern float get_aux4(void);
extern float get_aux5 (void); extern float get_aux5 (void);
extern float get_aux6 (void); extern float get_aux6 (void);
extern float get_aux7 (void);
extern float get_aux8(void); extern float get_aux8(void);
extern float get_aux9(void); extern float get_aux9(void);
extern float get_aux10(void); extern float get_aux10(void);
@ -240,7 +244,7 @@ enum hudinstype{ HUDno_instr,
HUDladder, HUDladder,
HUDcirc_ladder, HUDcirc_ladder,
HUDhorizon, HUDhorizon,
HUDguage, HUDgauge,
HUDdual_inst, HUDdual_inst,
HUDmoving_scale, HUDmoving_scale,
HUDtbi HUDtbi
@ -286,15 +290,19 @@ private:
float x, y; float x, y;
char msg[64]; char msg[64];
public: public:
fgText( float x = 0, float y = 0, char *c = NULL ) int digit; //suma
: x(x), y(y) {strncpy(msg,c,64-1);} fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
{
strcpy(msg,c);
digit=digits; //suma
}
fgText( const fgText & image ) fgText( const fgText & image )
: x(image.x), y(image.y) {strcpy(msg,image.msg);} : x(image.x), y(image.y),digit(image.digit) {strcpy(msg,image.msg);} //suma
fgText& operator = ( const fgText & image ) { fgText& operator = ( const fgText & image ) {
strcpy(msg,image.msg); x = image.x; y = image.y; strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma
return *this; return *this;
} }
~fgText() {msg[0]='\0';} ~fgText() {msg[0]='\0';}
@ -320,12 +328,57 @@ public:
} }
return 0 ; return 0 ;
} }
void Draw(fntRenderer *fnt) // this code is changed to display Numbers with big/small digits
{ // according to MIL Standards for example Altitude above 10000 ft
fnt->start2f( x, y ); // is shown as 10ooo. begin suma
fnt->puts ( msg ) ;
void Draw(fntRenderer *fnt,int digits) {
if(digits==1) {
int c=0,i=0;
char *t=msg;
int p=4;
if(t[0]=='-') //if negative value then increase the c and p values for '-' sign.
{
c++;
p++;
}
char *tmp=msg;
while(tmp[i]!='\0') {
if((tmp[i]>='0') && (tmp[i]<='9'))
c++;
i++;
}
if(c>p) {
fnt->setPointSize(8);
int p1=c-3;
char *tmp1=msg+p1;
int p2=p1*8;
fnt->start2f(x+p2,y);
fnt->puts(tmp1);
fnt->setPointSize(12);
char tmp2[p1+1];
strncpy(tmp2,msg,p1);
tmp2[p1]='\0';
fnt->start2f(x,y);
fnt->puts(tmp2);
} else {
fnt->setPointSize(12);
fnt->start2f( x, y );
fnt->puts(tmp);
}
} else {
//if digits not equal to 1
fnt->setPointSize(8);
fnt->start2f( x, y );
fnt->puts( msg ) ;
}
} }
//end suma
void Draw() void Draw()
{ {
@ -389,7 +442,7 @@ public:
Font->begin(); Font->begin();
for( ; curString != lastString; curString++ ) { for( ; curString != lastString; curString++ ) {
curString->Draw(Font); curString->Draw(Font,curString->digit); //suma
} }
Font->end(); Font->end();
@ -437,7 +490,8 @@ class instr_item { // An Abstract Base Class (ABC)
bool broken; bool broken;
UINT scr_span; // Working values for draw; UINT scr_span; // Working values for draw;
POINT mid_span; // POINT mid_span; //
int digits; //suma
public: public:
instr_item( int x, instr_item( int x,
int y, int y,
@ -446,7 +500,9 @@ class instr_item { // An Abstract Base Class (ABC)
FLTFNPTR data_source, FLTFNPTR data_source,
float data_scaling, float data_scaling,
UINT options, UINT options,
bool working = true); bool working = true,
int digit = 0); //suma
instr_item( const instr_item & image ); instr_item( const instr_item & image );
@ -463,6 +519,7 @@ class instr_item { // An Abstract Base Class (ABC)
UINT get_span ( void ) { return scr_span; } UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; } POINT get_centroid ( void ) { return mid_span; }
UINT get_options ( void ) { return opts; } UINT get_options ( void ) { return opts; }
int get_digits ( void ) { return digits; } //suma
UINT huds_vert (UINT options) { return( options & HUDS_VERT ); } UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
UINT huds_left (UINT options) { return( options & HUDS_LEFT ); } UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
@ -490,9 +547,9 @@ class instr_item { // An Abstract Base Class (ABC)
{ {
HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2)); HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
} }
void TextString( char *msg, float x, float y ) void TextString( char *msg, float x, float y,int digit ) //suma
{ {
HUD_TextList.add(fgText(x, y, msg)); HUD_TextList.add(fgText(x, y, msg,digit)); //suma
} }
int getStringWidth ( char *str ) int getStringWidth ( char *str )
{ {
@ -504,6 +561,18 @@ class instr_item { // An Abstract Base Class (ABC)
} }
return 0 ; return 0 ;
} }
//code to draw ticks as small circles
void drawOneCircle(float x1, float y1, float r)
{
glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
for(int count=0; count<25; count++) {
float cosine = r * cos(count * 2 * M_PI/10.0);
float sine = r * sin(count * 2 * M_PI/10.0);
glVertex2f(cosine+x1, sine+y1);
}
glEnd();
}
}; };
@ -532,6 +601,7 @@ class instr_label : public instr_item {
char format_buffer[80]; char format_buffer[80];
bool lat; bool lat;
bool lon; bool lon;
bool lbox;
public: public:
instr_label( int x, instr_label( int x,
@ -547,9 +617,11 @@ class instr_label : public instr_item {
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool latitude, bool latitude,
bool longitude, bool longitude,
bool working); bool label_box,
bool working,
int digit ); //suma);
~instr_label(); ~instr_label();
@ -573,19 +645,20 @@ class lat_label : public instr_item {
public: public:
lat_label( int x, lat_label( int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
const char *label_format, const char *label_format,
const char *pre_label_string, const char *pre_label_string,
const char *post_label_string, const char *post_label_string,
float scale_data, float scale_data,
UINT options, UINT options,
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool working); bool working,
int digits =0 );//suma
~lat_label(); ~lat_label();
@ -608,19 +681,21 @@ class lon_label : public instr_item {
public: public:
lon_label( int x, lon_label( int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
const char *label_format, const char *label_format,
const char *pre_label_string, const char *pre_label_string,
const char *post_label_string, const char *post_label_string,
float scale_data, float scale_data,
UINT options, UINT options,
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool working); bool working,
int digit=0); //suma
~lon_label(); ~lon_label();
@ -700,7 +775,16 @@ class hud_card : public instr_scale {
float marker_offset; float marker_offset;
bool pointer; bool pointer;
string pointer_type; string pointer_type;
string tick_type;
string tick_length;
float radius; //suma
float maxValue; //suma
float minValue; //suma
int divisions; //suma
int zoom; //suma
UINT Maj_div; //suma
UINT Min_div; //suma
public: public:
hud_card( int x, hud_card( int x,
@ -729,20 +813,29 @@ class hud_card : public instr_scale {
float marker_offset, float marker_offset,
bool pointer, bool pointer,
string pointer_type, string pointer_type,
bool working); string tick_type,
string tick_length,
bool working,
float radius, //suma
int divisions, //suma
int zoom); //suma
~hud_card(); ~hud_card();
hud_card( const hud_card & image); hud_card( const hud_card & image);
hud_card & operator = (const hud_card & rhs ); hud_card & operator = (const hud_card & rhs );
// virtual void display_enable( bool setting ); // virtual void display_enable( bool setting );
virtual void draw( void ); // Required method in base class virtual void draw( void ); // Required method in base class
void circles(float,float,float); // suma
void fixed(float,float,float,float,float,float); //suma
void zoomed_scale(int,int); //suma
}; };
typedef hud_card * pCardScale; typedef hud_card * pCardScale;
class guage_instr : public instr_scale { class gauge_instr : public instr_scale {
public: public:
guage_instr( int x, gauge_instr( int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
@ -757,13 +850,13 @@ class guage_instr : public instr_scale {
UINT modulus, UINT modulus,
bool working); bool working);
~guage_instr(); ~gauge_instr();
guage_instr( const guage_instr & image); gauge_instr( const gauge_instr & image);
guage_instr & operator = (const guage_instr & rhs ); gauge_instr & operator = (const gauge_instr & rhs );
virtual void draw( void ); // Required method in base class virtual void draw( void ); // Required method in base class
}; };
typedef guage_instr * pGuageInst; typedef gauge_instr * pGaugeInst;
// //
// dual_instr_item This class was created to form the base class // dual_instr_item This class was created to form the base class
// for both panel and HUD Turn Bank Indicators. // for both panel and HUD Turn Bank Indicators.
@ -791,11 +884,14 @@ class dual_instr_item : public instr_item {
virtual void draw ( void ) { } virtual void draw ( void ) { }
}; };
class fgTBI_instr : public dual_instr_item { class fgTBI_instr : public dual_instr_item
{
private: private:
UINT BankLimit; UINT BankLimit;
UINT SlewLimit; UINT SlewLimit;
UINT scr_hole; UINT scr_hole;
bool tsi; //suma
float rad; //suma
public: public:
fgTBI_instr( int x, fgTBI_instr( int x,
@ -807,7 +903,9 @@ class fgTBI_instr : public dual_instr_item {
float maxBankAngle, float maxBankAngle,
float maxSlipAngle, float maxSlipAngle,
UINT gap_width, UINT gap_width,
bool working); bool working,
bool tsi, //suma
float rad); //suma
fgTBI_instr( const fgTBI_instr & image); fgTBI_instr( const fgTBI_instr & image);
fgTBI_instr & operator = (const fgTBI_instr & rhs ); fgTBI_instr & operator = (const fgTBI_instr & rhs );
@ -844,6 +942,10 @@ class HudLadder : public dual_instr_item {
float glide_slope; float glide_slope;
bool energy_worm; bool energy_worm;
bool waypoint_marker; bool waypoint_marker;
int zenith; //suma
int nadir; //suma
int hat; //suma
fgTextList TextList; fgTextList TextList;
fgLineList LineList; fgLineList LineList;
@ -874,14 +976,20 @@ class HudLadder : public dual_instr_item {
float glide_slope, float glide_slope,
bool energy_worm, bool energy_worm,
bool waypoint_marker, bool waypoint_marker,
bool working); bool working,
int zenith, //suma
int nadir, //suma
int hat); //suma
~HudLadder(); ~HudLadder();
HudLadder( const HudLadder & image ); HudLadder( const HudLadder & image );
HudLadder & operator = ( const HudLadder & rhs ); HudLadder & operator = ( const HudLadder & rhs );
virtual void draw( void ); virtual void draw( void );
void drawZenith(float,float,float); //suma
void drawNadir(float, float, float); //suma
void Text( float x, float y, char *s) void Text( float x, float y, char *s)
{ {
TextList.add( fgText( x, y, s) ); TextList.add( fgText( x, y, s) );
@ -915,7 +1023,7 @@ extern void drawOneLine ( RECT &rect);
extern void textString ( int x, extern void textString ( int x,
int y, int y,
char *msg, char *msg,
void *font = GLUT_BITMAP_8_BY_13); void *font = GLUT_BITMAP_9_BY_15,int digit=0); //suma
extern void strokeString( int x, extern void strokeString( int x,
int y, int y,
char *msg, char *msg,

File diff suppressed because it is too large Load diff

380
src/Cockpit/hud_gaug.cxx Normal file
View file

@ -0,0 +1,380 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, font,digit ) TextString( text, x , y,digit ) //suma
#else
#define textString( x , y, text, font,digit ) puDrawString ( guiFnt, text, x, y ); //suma
#endif
//============== Top of gauge_instr class member definitions ==============
gauge_instr ::
gauge_instr( int x,
int y,
UINT width,
UINT height,
FLTFNPTR load_fn,
UINT options,
float disp_scale,
float maxValue,
float minValue,
UINT major_divs,
UINT minor_divs,
int dp_showing,
UINT modulus,
bool working) :
instr_scale( x, y, width, height,
load_fn, options,
(maxValue - minValue), // Always shows span?
maxValue, minValue,
disp_scale,
major_divs, minor_divs,
modulus, dp_showing,
working)
{
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
}
gauge_instr ::
~gauge_instr()
{
}
gauge_instr ::
gauge_instr( const gauge_instr & image):
instr_scale( (instr_scale &) image)
{
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
}
gauge_instr & gauge_instr ::
operator = (const gauge_instr & rhs )
{
if( !(this == &rhs)) {
instr_scale::operator = (rhs);
}
return *this;
}
// As implemented, draw only correctly draws a horizontal or vertical
// scale. It should contain a variation that permits clock type displays.
// Now is supports "tickless" displays such as control surface indicators.
// This routine should be worked over before using. Current value would be
// fetched and not used if not commented out. Clearly that is intollerable.
void gauge_instr :: draw (void)
{
int marker_xs, marker_xe;
int marker_ys, marker_ye;
int text_x, text_y;
int width, height, bottom_4;
int lenstr;
int i;
char TextScale[80];
bool condition;
int disp_val = 0;
float vmin = min_val();
float vmax = max_val();
POINT mid_scr = get_centroid();
float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom,
bottom_4 = scrn_rect.bottom / 4;
// Draw the basic markings for the scale...
if( huds_vert(options) ) { // Vertical scale
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
width,
scrn_rect.top);
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
marker_xs = scrn_rect.left;
marker_xe = width;
if( huds_left(options) ) { // Read left, so line down right side
drawOneLine( width,
scrn_rect.top,
width,
height);
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
}
if( huds_right(options) ) { // Read right, so down left sides
drawOneLine( scrn_rect.left,
scrn_rect.top,
scrn_rect.left,
height);
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
}
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if( huds_both(options) ) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
if( !huds_noticks(options)) { // If not no ticks...:)
// Calculate x marker offsets
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
// We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler.
if( div_min()) { // Minor tick marks
if( !(i%(int)div_min()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs - 3, marker_ys );
drawOneLine( marker_xe + 3, marker_ys,
width, marker_ys );
}
else {
if( huds_left(options) ) {
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
}
}
}
}
// Now we work on the major divisions. Since these are also labeled
// and no labels are drawn otherwise, we label inside this if
// statement.
if( div_max()) { // Major tick mark
if( !(i%(int)div_max()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
width, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
}
if( !huds_notext(options) ) {
disp_val = i;
sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/ ));
lenstr = getStringWidth( TextScale );
if( huds_left(options) && huds_right(options) ) {
text_x = mid_scr.x - lenstr/2 ;
}
else {
if( huds_left(options) ) {
text_x = marker_xs - lenstr;
}
else {
text_x = marker_xe - lenstr;
}
}
// Now we know where to put the text.
text_y = marker_ys;
textString( text_x, text_y, TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
}
}
} //
} //
} //
// Now that the scale is drawn, we draw in the pointer(s). Since labels
// have been drawn, text_x and text_y may be recycled. This is used
// with the marker start stops to produce a pointer for each side reading
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left;
if( huds_right(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, text_y + 5);
glVertex2f( marker_xe, text_y);
glVertex2f( scrn_rect.left, text_y - 5);
glEnd();
}
if( huds_left(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( width, text_y + 5);
glVertex2f( marker_xs, text_y);
glVertex2f( width, text_y - 5);
glEnd();
}
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar
scrn_rect.top,
scrn_rect.left,
height);
drawOneLine( width, // right tick bar
scrn_rect.top,
width,
height );
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
if( huds_top(options) ) {
drawOneLine( scrn_rect.left,
scrn_rect.top,
width,
scrn_rect.top); // Bottom box line
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
// Bottom arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - bottom_4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs + bottom_4, scrn_rect.top);
glEnd();
}
if( huds_bottom(options) ) {
// Top box line
drawOneLine( scrn_rect.left, height, width, height);
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
// Top arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + bottom_4, height);
glVertex2f( marker_xs, marker_ys );
glVertex2f( marker_xs - bottom_4, height);
glEnd();
}
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for( ; i <last ; i++ ) {
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
if( condition ) {
marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if( div_min()){
if( !(i%(int)div_min()) ) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs + 5) > scrn_rect.left ) ||
(( marker_xs - 5 )< (width))){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height);
}
else {
if( huds_top(options) ) {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
else {
drawOneLine( marker_xs, marker_ys + 4,
marker_xs, marker_ye);
}
}
}
}
}
if( div_max()) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while( disp_val < 0 ) {
disp_val += modulo();
}
}
disp_val = i % (int)modulo();
} else {
disp_val = i;
}
sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/* +.5*/ ));
lenstr = getStringWidth( TextScale);
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < width )){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys);
drawOneLine( marker_xs, marker_ye,
marker_xs, height);
if( !huds_notext(options) ) {
textString ( marker_xs - lenstr, marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 ,0); //suma
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if( !huds_notext(options) ) {
if( huds_top(options) ) {
textString ( marker_xs - lenstr,
height - 10,
TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
}
else {
textString( marker_xs - lenstr, scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
}
}
}
}
}
}
}
}
}
}

View file

@ -4,7 +4,8 @@
UINT instr_item :: instances = 0; // Initial value of zero UINT instr_item :: instances = 0; // Initial value of zero
int instr_item :: brightness = BRT_MEDIUM; int instr_item :: brightness = BRT_MEDIUM;
glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0}; //glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0};
// constructor ( No default provided ) // constructor ( No default provided )
instr_item :: instr_item ::
@ -15,13 +16,15 @@ instr_item ::
FLTFNPTR data_source, FLTFNPTR data_source,
float data_scaling, float data_scaling,
UINT options, UINT options,
bool working) : bool working,
int digit) : //suma
handle ( ++instances ), handle ( ++instances ),
load_value_fn ( data_source ), load_value_fn ( data_source ),
disp_factor ( data_scaling ), disp_factor ( data_scaling ),
opts ( options ), opts ( options ),
is_enabled ( working ), is_enabled ( working ),
broken ( FALSE ) broken ( FALSE ),
digits ( digit ) //suma
{ {
scrn_pos.left = x; scrn_pos.left = x;
scrn_pos.top = y; scrn_pos.top = y;

View file

@ -3,9 +3,9 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( text, x , y ) #define textString( x , y, text, font,digit ) TextString( text, x , y,digit ) //suma
#else #else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y ); #define textString( x , y, text, font,digit ) puDrawString ( guiFnt, text, x, y ); //suma
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -23,11 +23,13 @@ instr_label ::
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool latitude, bool latitude,
bool longitude, bool longitude,
bool working): bool label_box,//hud
bool working,
int digit): //suma
instr_item( x, y, width, height, instr_item( x, y, width, height,
data_source,scale_data,options, working ), data_source,scale_data,options, working, digit), //suma
pformat ( label_format ), pformat ( label_format ),
pre_str ( pre_label_string ), pre_str ( pre_label_string ),
post_str ( post_label_string ), post_str ( post_label_string ),
@ -35,7 +37,8 @@ instr_label ::
fontSize ( font_size ), fontSize ( font_size ),
blink ( blinking ), blink ( blinking ),
lat ( latitude ), lat ( latitude ),
lon ( longitude ) lon ( longitude ),
lbox ( label_box ) //hud
{ {
if( pre_str != NULL) { if( pre_str != NULL) {
@ -70,7 +73,8 @@ instr_label :: instr_label( const instr_label & image) :
post_str ( image.post_str ), post_str ( image.post_str ),
blink ( image.blink ), blink ( image.blink ),
lat ( image.lat ), lat ( image.lat ),
lon ( image.lon ) lon ( image.lon ),
lbox (image.lbox ) //hud
{ {
if( pre_str != NULL) { if( pre_str != NULL) {
@ -101,6 +105,7 @@ instr_label & instr_label ::operator = (const instr_label & rhs )
post_str = rhs.post_str; post_str = rhs.post_str;
lat = rhs.lat; lat = rhs.lat;
lon = rhs.lon; lon = rhs.lon;
lbox = rhs.lbox; //hud
strcpy(format_buffer,rhs.format_buffer); strcpy(format_buffer,rhs.format_buffer);
@ -128,10 +133,38 @@ draw( void ) // Required method in base class
if(lon) if(lon)
sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) ); sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
else else
sprintf( label_buffer, format_buffer, get_value() ); {
} if(lbox)//hud
{// Box for label
float x = scrn_rect.left;
float y = scrn_rect.top;
float w = scrn_rect.right;
float h = HUD_TextSize;
glPushMatrix();
glLoadIdentity();
glBegin(GL_LINES);
glVertex2f( x - 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y + h + 2.0);
glEnd();
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0xAAAA );
glBegin(GL_LINES);
glVertex2f( x + w + 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y - 2.0);
glEnd();
glDisable(GL_LINE_STIPPLE);
glPopMatrix();
}//hud
sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
}
}
else { else {
sprintf( label_buffer, format_buffer ); // sprintf( label_buffer, format_buffer );
} }
lenstr = getStringWidth( label_buffer ); lenstr = getStringWidth( label_buffer );
@ -143,7 +176,7 @@ draw( void ) // Required method in base class
fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer ); fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" ); fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
#endif #endif
// lenstr = strlen( label_buffer ); lenstr = strlen( label_buffer );
if( justify == RIGHT_JUST ) { if( justify == RIGHT_JUST ) {
posincr = scrn_rect.right - lenstr; posincr = scrn_rect.right - lenstr;
@ -156,12 +189,12 @@ draw( void ) // Required method in base class
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13 ,get_digits()); //suma
} }
else { else {
if( fontSize == LARGE ) { if( fontSize == LARGE ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_9_BY_15); label_buffer, GLUT_BITMAP_9_BY_15 ,get_digits()); //suma
} }
} }
} }

View file

@ -29,7 +29,11 @@ HudLadder :: HudLadder( string name,
float glide_slope_val, float glide_slope_val,
bool worm_energy, bool worm_energy,
bool waypoint, bool waypoint,
bool working) : bool working,
int zenithsymbol, //suma
int nadirsymbol, //suma
int hat_marker): //suma
dual_instr_item( x, y, width, height, dual_instr_item( x, y, width, height,
ptch_source, ptch_source,
roll_source, roll_source,
@ -58,8 +62,14 @@ HudLadder :: HudLadder( string name,
{ {
if( !width_units ) {
width_units = 45; zenith= zenithsymbol; //suma
nadir=nadirsymbol; //suma
hat= hat_marker; //suma
if( !width_units )
{
width_units = 45;
} }
} }
@ -152,11 +162,11 @@ void HudLadder :: draw( void )
pla = get_throttleval(); pla = get_throttleval();
int lgear,wown,wowm,ilcanclaw,ihook; int lgear,wown,wowm,ilcanclaw,ihook;
ilcanclaw = get_iaux1(); ilcanclaw = get_iaux2();
lgear = get_iaux2(); lgear = get_iaux3();
wown = get_iaux3(); wown = get_iaux4();
wowm = get_iaux4(); wowm = get_iaux5();
ihook = get_iaux5(); ihook = get_iaux6();
float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES; float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
@ -166,7 +176,8 @@ void HudLadder :: draw( void )
clip_plane = true; clip_plane = true;
} }
else else
if(hudladder_type=="Pitch Ladder") { // hudladder_type=="Pitch Ladder"
{
pitch_ladder = true; pitch_ladder = true;
climb_dive_ladder = false; climb_dive_ladder = false;
clip_plane = false; clip_plane = false;
@ -239,11 +250,13 @@ void HudLadder :: draw( void )
actslope = atan(up_vel/ground_vel)*SGD_RADIANS_TO_DEGREES; actslope = atan(up_vel/ground_vel)*SGD_RADIANS_TO_DEGREES;
} }
xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*(640.0/45.0)); xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*
(factor/globals->get_current_view()->get_win_ratio()));
drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi); drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
yvvr = ((actslope - pitch_value)*factor); yvvr = ((actslope - pitch_value)*factor);
vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor; vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*(640/45.0); vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*
(factor/globals->get_current_view()->get_win_ratio());
// printf("%f %f %f %f\n",vel_x,vel_y,drift,psi); // printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
//**************************************************************** //****************************************************************
// OBJECT MOVING RETICLE // OBJECT MOVING RETICLE
@ -446,7 +459,8 @@ void HudLadder :: draw( void )
//**************************************************************** //****************************************************************
if(climb_dive_ladder) {// CONFORMAL_HUD if(climb_dive_ladder)
{ // CONFORMAL_HUD
vmin = pitch_value - (float)width_units; vmin = pitch_value - (float)width_units;
vmax = pitch_value + (float)width_units; vmax = pitch_value + (float)width_units;
@ -455,7 +469,8 @@ void HudLadder :: draw( void )
} }
else else
if (pitch_ladder) {//Default Hud // pitch_ladder - Default Hud
{
vmin = pitch_value - (float)width_units * 0.5f; vmin = pitch_value - (float)width_units * 0.5f;
vmax = pitch_value + (float)width_units * 0.5f; vmax = pitch_value + (float)width_units * 0.5f;
@ -465,8 +480,8 @@ void HudLadder :: draw( void )
glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0); glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
// FRL marker not rotated - this line shifted below // FRL marker not rotated - this line shifted below
if( div_units ) { if( div_units )
{
char TextLadder[8] ; char TextLadder[8] ;
float label_length ; float label_length ;
float label_height ; float label_height ;
@ -475,34 +490,34 @@ void HudLadder :: draw( void )
float bot ; float bot ;
float top ; float top ;
float text_offset = 4.0f ; float text_offset = 4.0f ;
float zero_offset = 0.0; float zero_offset = 0.0;
if ( climb_dive_ladder ) { if ( climb_dive_ladder ) {
zero_offset = 50.0f ; zero_offset = 50.0f ; // horizon line is wider by this much (hard coded ??)
} else { } else {
if ( pitch_ladder ) {
zero_offset = 10.0f ; zero_offset = 10.0f ;
} }
}
fntFont *font = HUDtext->getFont(); fntFont *font = HUDtext->getFont();
float pointsize = HUDtext->getPointSize(); float pointsize = HUDtext->getPointSize();
float italic = HUDtext->getSlant(); float italic = HUDtext->getSlant();
TextList.setFont( HUDtext ); TextList.setFont( HUDtext );
TextList.erase(); TextList.erase();
LineList.erase(); LineList.erase();
StippleLineList.erase(); StippleLineList.erase();
int last = FloatToInt(vmax)+1; int last = FloatToInt(vmax)+1;
int i = FloatToInt(vmin); int i = FloatToInt(vmin);
if( !scr_hole ) { if( !scr_hole ) {
x_end = half_span; x_end = half_span;
for( ; i<last ; i++ ) { for( ; i<last ; i++ )
{
y = (((float)(i - pitch_value) * factor) + .5f); y = (((float)(i - pitch_value) * factor) + .5f);
if( !(i % div_units )) { // At integral multiple of div if( !(i % div_units )) // At integral multiple of div
{
sprintf( TextLadder, "%d", i ); sprintf( TextLadder, "%d", i );
font->getBBox ( TextLadder, pointsize, italic, font->getBBox ( TextLadder, pointsize, italic,
@ -513,15 +528,30 @@ void HudLadder :: draw( void )
x_ini = -half_span; x_ini = -half_span;
if( i >= 0 ) { if( i >= 0 )
{
// Make zero point wider on left // Make zero point wider on left
if( i == 0 ) if( i == 0 )
x_ini -= zero_offset; x_ini -= zero_offset;
// Zero or above draw solid lines
Line(x_ini, y, x_end, y); // Zero or above draw solid lines
Line(x_ini, y, x_end, y);
if(i == 90)
if(zenith == 1)
{
drawZenith(x_ini, x_end,y);
}
} else { } else {
// Below zero draw dashed lines. // Below zero draw dashed lines.
StippleLine(x_ini, y, x_end, y); StippleLine(x_ini, y, x_end, y);
if(i == -90)
if(nadir ==1)
{
drawNadir(x_ini, x_end,y);
}
} }
// Calculate the position of the left text and write it. // Calculate the position of the left text and write it.
@ -536,7 +566,8 @@ void HudLadder :: draw( void )
x_end = -half_span + hole; x_end = -half_span + hole;
x_ini2= half_span - hole; x_ini2= half_span - hole;
for( ; i<last ; i++ ) { for( ; i<last ; i++ )
{
if(hudladder_type=="Pitch Ladder") if(hudladder_type=="Pitch Ladder")
y = (((float)(i - pitch_value) * factor) + .5); y = (((float)(i - pitch_value) * factor) + .5);
@ -559,30 +590,48 @@ void HudLadder :: draw( void )
x_ini = -half_span; x_ini = -half_span;
x_end2= half_span; x_end2= half_span;
if( i >= 0 ) { if( i >= 0 )
{
// Make zero point wider on left // Make zero point wider on left
if( i == 0 ) { if( i == 0 )
x_ini -= zero_offset; {
x_end2 +=zero_offset; x_ini -= zero_offset;
} else { x_end2 +=zero_offset;
if(climb_dive_ladder){ }
// Zero or above draw solid lines //draw climb bar vertical lines
Line(x_end, y-5.0, x_end, y); if(climb_dive_ladder)
Line(x_ini2, y-5.0, x_ini2, y); {
} // Zero or above draw solid lines
Line(x_end, y-5.0, x_end, y);
Line(x_ini2, y-5.0, x_ini2, y);
} }
// draw pitch / climb bar
Line(x_ini, y, x_end, y); Line(x_ini, y, x_end, y);
Line(x_ini2, y, x_end2, y); Line(x_ini2, y, x_end2, y);
} else { if(i == 90)
// Below zero draw dashed lines. if(zenith == 1)
if(climb_dive_ladder) { {
Line(x_end, y+5.0, x_end, y); drawZenith(x_ini2, x_end,y);
Line(x_ini2, y+5.0, x_ini2, y); }
}
else // i < 0
{
// draw dive bar vertical lines
if(climb_dive_ladder)
{
Line(x_end, y+5.0, x_end, y);
Line(x_ini2, y+5.0, x_ini2, y);
} }
StippleLine(x_ini, y, x_end, y); // draw pitch / dive bars
StippleLine(x_ini, y, x_end, y);
StippleLine(x_ini2, y, x_end2, y); StippleLine(x_ini2, y, x_end2, y);
if(i == -90)
if(nadir == 1)
{
drawNadir(x_ini2, x_end,y);
}
} }
// Now calculate the location of the left side label using // Now calculate the location of the left side label using
@ -627,8 +676,8 @@ void HudLadder :: draw( void )
fromwp_lon = get_longitude()*SGD_DEGREES_TO_RADIANS; fromwp_lon = get_longitude()*SGD_DEGREES_TO_RADIANS;
fromwp_lat = get_latitude()*SGD_DEGREES_TO_RADIANS; fromwp_lat = get_latitude()*SGD_DEGREES_TO_RADIANS;
towp_lon = get_aux5()*SGD_DEGREES_TO_RADIANS; towp_lon = get_aux2()*SGD_DEGREES_TO_RADIANS;
towp_lat = get_aux6()*SGD_DEGREES_TO_RADIANS; towp_lat = get_aux1()*SGD_DEGREES_TO_RADIANS;
dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon))); dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon)));
delx= towp_lat - fromwp_lat; delx= towp_lat - fromwp_lat;
@ -651,7 +700,9 @@ void HudLadder :: draw( void )
// OBJECT MOVING RETICLE // OBJECT MOVING RETICLE
// TYPE ARROW // TYPE ARROW
// waypoint marker // waypoint marker
if (fabs(brg-psi) > 10.0) {
if (fabs(brg-psi) > 10.0)
{
glPushMatrix(); glPushMatrix();
glTranslatef( centroid.x, centroid.y, 0); glTranslatef( centroid.x, centroid.y, 0);
glTranslatef( vel_x, vel_y, 0); glTranslatef( vel_x, vel_y, 0);
@ -666,9 +717,13 @@ void HudLadder :: draw( void )
glVertex2f(2.5,20.0); glVertex2f(2.5,20.0);
glEnd(); glEnd();
glPopMatrix(); glPopMatrix();
} }
// waypoint marker on heading scale
if (fabs(brg-psi) < 12.0) { // waypoint marker on heading scale
if (fabs(brg-psi) < 12.0)
{
if(hat ==0)
{
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(((brg-psi)*60/25)+320,240.0); glVertex2f(((brg-psi)*60/25)+320,240.0);
glVertex2f(((brg-psi)*60/25)+326,240.0-4); glVertex2f(((brg-psi)*60/25)+326,240.0-4);
@ -678,7 +733,155 @@ void HudLadder :: draw( void )
glVertex2f(((brg-psi)*60/25)+317,240.0-4); glVertex2f(((brg-psi)*60/25)+317,240.0-4);
glVertex2f(((brg-psi)*60/25)+314,240.0-4); glVertex2f(((brg-psi)*60/25)+314,240.0-4);
glEnd(); glEnd();
} } else {//if hat=0
//*************************************************************
}// if waypoint_marker float x= (brg-psi)*60/25 + 320, y=240.0, r=5.0;
float x1,y1;
glEnable(GL_POINT_SMOOTH);
glBegin(GL_POINTS);
for(int count=0; count<=200; count++)
{
float temp = count * 3.142 * 3 / (200.0*2.0);
float temp1 = temp-(45.0*SGD_DEGREES_TO_RADIANS);
x1 = x + r * cos(temp1);
y1 = y + r * sin(temp1);
glVertex2f(x1, y1);
}
glEnd();
glDisable(GL_POINT_SMOOTH);
} //hat=0
} //brg<12
} // if waypoint_marker
}//draw }//draw
/******************************************************************/
//begin suma
// draws the zenith symbol for highest possible climb angle (i,e 90 degree climb angle)
void HudLadder ::
drawZenith(float xfirst,float xlast,float yvalue )
{
float xcentre = (xfirst + xlast)/2.0;
float ycentre = yvalue;
Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre+1.3);
Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre-1.3);
Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre+1.3);
Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre-1.3);
Line(xcentre, ycentre+9.0, xcentre-1.3, ycentre+3.0);
Line(xcentre, ycentre+9.0, xcentre+1.3, ycentre+3.0);
Line(xcentre-3.9, ycentre+3.9, xcentre-3.0, ycentre+1.3);
Line(xcentre-3.9, ycentre+3.9, xcentre-1.3, ycentre+3.0);
Line(xcentre+3.9, ycentre+3.9, xcentre+1.3, ycentre+3.0);
Line(xcentre+3.9, ycentre+3.9, xcentre+3.0, ycentre+1.3);
Line(xcentre-3.9, ycentre-3.9, xcentre-3.0, ycentre-1.3);
Line(xcentre-3.9, ycentre-3.9, xcentre-1.3, ycentre-2.6);
Line(xcentre+3.9, ycentre-3.9, xcentre+3.0, ycentre-1.3);
Line(xcentre+3.9, ycentre-3.9, xcentre+1.3, ycentre-2.6);
Line(xcentre-1.3, ycentre-2.6, xcentre, ycentre-27.0);
Line(xcentre+1.3, ycentre-2.6, xcentre, ycentre-27.0);
}
//end suma
//begin suma
// draws the nadir symbol for lowest possible dive angle (i,e 90 degree dive angle)
void HudLadder ::
drawNadir(float xfirst, float xlast, float yvalue)
{
float xcentre = (xfirst + xlast)/2.0;
float ycentre = yvalue;
float r = 7.5;
float ang,temp;
float x1,y1,x2,y2,xcent,ycent;
// to draw a circle
float xcent1, xcent2, ycent1, ycent2;
xcent1 = xcentre + r * cos(0.0);
ycent1 = ycentre + r * sin(0.0);
for(int count=1; count<=400; count++)
{
float temp = count * 2 * 3.142 / 400.0;
xcent2 = xcentre + r * cos(temp);
ycent2 = ycentre + r * sin(temp);
Line(xcent1, ycent1, xcent2, ycent2);
xcent1 = xcent2;
ycent1 = ycent2;
}
xcent2 = xcentre + r * cos(0.0);
ycent2 = ycentre + r * sin(0.0);
drawOneLine(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
//end circle
Line(xcentre, ycentre+7.5, xcentre, ycentre+22.5); //to draw a line above the circle
Line(xcentre-7.5, ycentre, xcentre+7.5,ycentre); //line in the middle of circle
float theta = asin (2.5/7.5);
float theta1 = asin(5.0/7.5);
x1 = xcentre + r * cos(theta);
y1 = ycentre + 2.5;
x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
y2 = ycentre + 2.5;
Line(x1,y1,x2,y2);
x1 = xcentre + r * cos(theta1);
y1 = ycentre + 5.0;
x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS)-theta1);
y2 = ycentre + 5.0;
Line(x1,y1,x2,y2);
x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) +theta);
y1 = ycentre - 2.5;
x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta);
y2 = ycentre - 2.5;
Line(x1,y1,x2,y2);
x1 = xcentre + r * cos((180.0* SGD_DEGREES_TO_RADIANS) +theta1);
y1 = ycentre - 5.0;
x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta1);
y2 = ycentre - 5.0;
Line(x1,y1,x2,y2);
}

View file

@ -3,9 +3,9 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( text, x , y ) #define textString( x , y, text, font,digit ) TextString( text, x , y,digit ) //suma
#else #else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y ); #define textString( x , y, text, font,digit ) puDrawString ( guiFnt, text, x, y ); //suma
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -23,9 +23,10 @@ lat_label ::
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool working ): bool working ,
int digit): //suma
instr_item( x, y, width, height, instr_item( x, y, width, height,
data_source, scale_data,options, working ), data_source, scale_data,options, working,digit), //suma
pformat ( label_format ), pformat ( label_format ),
pre_str ( pre_label_string ), pre_str ( pre_label_string ),
post_str ( post_label_string ), post_str ( post_label_string ),
@ -137,12 +138,12 @@ draw( void ) // Required method in base class
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13, get_digits()); //suma
} }
else { else {
if( fontSize == LARGE ) { if( fontSize == LARGE ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_9_BY_15); label_buffer, GLUT_BITMAP_9_BY_15,get_digits()); //suma
} }
} }
} }

View file

@ -3,9 +3,9 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( text, x , y ) #define textString( x , y, text, font,digit ) TextString( text, x , y,digit ) //suma
#else #else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y ); #define textString( x , y, text, font,digit ) puDrawString ( guiFnt, text, x, y ); //suma
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -25,9 +25,10 @@ lon_label ::
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool working ): bool working,
int digit): //suma
instr_item( x, y, width, height, instr_item( x, y, width, height,
data_source, scale_data,options, working ), data_source, scale_data,options, working,digit ), //suma
pformat ( label_format ), pformat ( label_format ),
pre_str ( pre_label_string ), pre_str ( pre_label_string ),
post_str ( post_label_string ), post_str ( post_label_string ),
@ -140,12 +141,12 @@ draw( void ) // Required method in base class
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13, get_digits()); //suma
} }
else { else {
if( fontSize == LARGE ) { if( fontSize == LARGE ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_9_BY_15); label_buffer, GLUT_BITMAP_9_BY_15, get_digits()); //suma
} }
} }
} }

View file

@ -12,7 +12,7 @@
// markers) or just over the middle line. // markers) or just over the middle line.
// //
// 2. This class was not intended to be instanciated. See moving_scale // 2. This class was not intended to be instanciated. See moving_scale
// and guage_instr classes. // and gauge_instr classes.
//============================================================================ //============================================================================
instr_scale :: instr_scale ::
instr_scale ( int x, instr_scale ( int x,

View file

@ -1,5 +1,6 @@
#include "hud.hxx" #include "hud.hxx"
#include<math.h>
//============ Top of fgTBI_instr class member definitions ============== //============ Top of fgTBI_instr class member definitions ==============
@ -14,7 +15,9 @@ fgTBI_instr( int x,
float maxBankAngle, float maxBankAngle,
float maxSlipAngle, float maxSlipAngle,
UINT gap_width, UINT gap_width,
bool working ) : bool working,
bool tsivalue, //suma
float radius) : //suma
dual_instr_item( x, y, width, height, dual_instr_item( x, y, width, height,
chn1_source, chn1_source,
chn2_source, chn2_source,
@ -24,6 +27,8 @@ fgTBI_instr( int x,
SlewLimit ((int)(maxSlipAngle)), SlewLimit ((int)(maxSlipAngle)),
scr_hole (gap_width ) scr_hole (gap_width )
{ {
tsi=tsivalue; //suma
rad=radius; //suma
} }
fgTBI_instr :: ~fgTBI_instr() {} fgTBI_instr :: ~fgTBI_instr() {}
@ -65,27 +70,35 @@ operator = (const fgTBI_instr & rhs )
RECT My_box = get_location(); RECT My_box = get_location();
POINT centroid = get_centroid(); POINT centroid = get_centroid();
int tee_height = My_box.bottom; int tee_height = My_box.bottom;
bank_angle = current_ch2(); // Roll limit +/- 30 degrees bank_angle = current_ch2(); // Roll limit +/- 30 degrees
if( bank_angle < -SGD_PI_2/3 ) { if( bank_angle < -SGD_PI_2/3 )
{
bank_angle = -SGD_PI_2/3; bank_angle = -SGD_PI_2/3;
} else if( bank_angle > SGD_PI_2/3 ) { }
else if( bank_angle > SGD_PI_2/3 )
{
bank_angle = SGD_PI_2/3; bank_angle = SGD_PI_2/3;
} }
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
if( sideslip_angle < -SGD_PI/9 ) {
if( sideslip_angle < -SGD_PI/9 )
{
sideslip_angle = -SGD_PI/9; sideslip_angle = -SGD_PI/9;
} else if( sideslip_angle > SGD_PI/9 ) { }
else if( sideslip_angle > SGD_PI/9 )
{
sideslip_angle = SGD_PI/9; sideslip_angle = SGD_PI/9;
} }
cen_x = centroid.x; cen_x = centroid.x;
cen_y = centroid.y; cen_y = centroid.y;
bank = bank_angle * SGD_RADIANS_TO_DEGREES; bank = bank_angle * SGD_RADIANS_TO_DEGREES;
tee = -tee_height; tee = -tee_height;
fspan = span; fspan = span;
hole = scr_hole; hole = scr_hole;
ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
@ -93,36 +106,194 @@ operator = (const fgTBI_instr & rhs )
// printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan); // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
// printf("ss_const: %f hole: %f\n", ss_const, hole); // printf("ss_const: %f hole: %f\n", ss_const, hole);
glPushMatrix(); glPushMatrix();
glTranslatef(cen_x, cen_y, zero); glTranslatef(cen_x, cen_y, zero);
glRotatef(-bank, zero, zero, 1.0); glRotatef(-bank, zero, zero, 1.0);
glBegin(GL_LINES); if(!tsi)
{
glBegin(GL_LINES);
if( !scr_hole )
{
glVertex2f( -fspan, zero );
glVertex2f( fspan, zero );
}
else
{
glVertex2f( -fspan, zero );
glVertex2f( -hole, zero );
glVertex2f( hole, zero );
glVertex2f( fspan, zero );
}
// draw teemarks
glVertex2f( hole, zero );
glVertex2f( hole, tee );
glVertex2f( -hole, zero );
glVertex2f( -hole, tee );
glEnd();
if( !scr_hole ) glBegin(GL_LINE_LOOP);
{ glVertex2f( ss_const, -hole);
glVertex2f( -fspan, zero ); glVertex2f( ss_const + hole, zero);
glVertex2f( fspan, zero ); glVertex2f( ss_const, hole);
} else { glVertex2f( ss_const - hole, zero);
glVertex2f( -fspan, zero ); glEnd();
glVertex2f( -hole, zero );
glVertex2f( hole, zero );
glVertex2f( fspan, zero );
}
// draw teemarks
glVertex2f( hole, zero );
glVertex2f( hole, tee );
glVertex2f( -hole, zero );
glVertex2f( -hole, tee );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f( ss_const, -hole);
glVertex2f( ss_const + hole, zero);
glVertex2f( ss_const, hole);
glVertex2f( ss_const - hole, zero);
glEnd();
glPopMatrix();
}
else //if tsi enabled
{
float factor = My_box.right / 6.0;
drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top);
drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0);
drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5;
float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0;
xc = My_box.left + My_box.right/ 2.0 ;
yc = My_box.top + r;
//first n last lines
x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
//second n fifth lines
x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
//third n fourth lines
x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
//to draw marker
float valbank, valsideslip, sideslip;
r = rad + 5.0; //5 is added to get a gap
// upper polygon
bank_angle = current_ch2();
bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
if(bank > BankLimit)
bank = BankLimit;
if(bank < -1.0*BankLimit)
bank = -1.0*BankLimit;
valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
if(sideslip > SlewLimit)
sideslip = SlewLimit;
if(sideslip < -1.0*SlewLimit)
sideslip = -1.0*SlewLimit;
valsideslip = sideslip * 15.0 / SlewLimit;
//values 270, 225 and 315 are angles in degrees...
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1, y1, x2, y2);
drawOneLine(x2, y2, x3, y3);
drawOneLine(x3, y3, x1, y1);
//lower polygon...
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
drawOneLine(x2, y2, x3, y3);
drawOneLine(x3, y3, x5, y5);
drawOneLine(x5, y5, x4, y4);
drawOneLine(x4, y4, x2, y2);
}
glPopMatrix();
} }