X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fhud.cxx;h=57c2264e81527c9702b157825269b79735e5a274;hb=8e5f3ac8a333a971d7f8104a387426c3bc47a014;hp=564b536dc90a09cd2a794feb8bfbac9784fa7b1f;hpb=18bece731a894f004357d38e5d692fb997b6c268;p=flightgear.git diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 564b536dc..57c2264e8 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -23,38 +23,30 @@ #include #include -#include STL_STRING -#include STL_FSTREAM +#include +#include #ifdef HAVE_CONFIG_H # include #endif -#ifdef HAVE_WINDOWS_H -# include -#endif - -#ifdef __BORLANDC__ -# define exception c_exception -#endif - #include - #include #include // char related functions #include // strcmp() -#include SG_GLU_H - #include #include #include +#include + +#include -#include -//#include #include // FGFontCache #include
#include +#include +#include
#include "hud.hxx" @@ -188,7 +180,7 @@ int readHud( istream &input ) } - SG_LOG(SG_INPUT, SG_INFO, "Read properties for " << + SG_LOG(SG_INPUT, SG_DEBUG, "Read properties for " << root.getStringValue("name")); if (!root.getNode("depreciated")) @@ -197,7 +189,7 @@ int readHud( istream &input ) HUD_deque.erase( HUD_deque.begin(), HUD_deque.end()); - SG_LOG(SG_INPUT, SG_INFO, "Reading Hud instruments"); + SG_LOG(SG_INPUT, SG_DEBUG, "Reading Hud instruments"); const SGPropertyNode * instrument_group = root.getChild("instruments"); int nInstruments = instrument_group->nChildren(); @@ -209,7 +201,7 @@ int readHud( istream &input ) SGPath path( globals->get_fg_root() ); path.append(node->getStringValue("path")); - SG_LOG(SG_INPUT, SG_INFO, "Reading Instrument " + SG_LOG(SG_INPUT, SG_DEBUG, "Reading Instrument " << node->getName() << " from " << path.str()); @@ -236,7 +228,7 @@ int readHud( istream &input ) // display for a Piper Cub doesn't show the speed range of a North American // mustange and the engine readouts of a B36! // -int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) +int fgHUDInit() { HUD_style = 1; @@ -268,9 +260,11 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) } FGFontCache *fc = globals->get_fontcache(); - HUD_Font = fc->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf")); + const char* fileName = fgGetString("/sim/hud/font/name", "Helvetica.txf"); + HUD_Font = fc->getTexFont(fileName); if (!HUD_Font) - throw sg_throwable(string("/sim/hud/font/name is not a texture font")); + throw sg_io_exception("/sim/hud/font/name is not a texture font", + sg_location(fileName)); HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10); @@ -286,7 +280,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) } -int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ ) +int fgHUDInit2() { HUD_style = 2; @@ -433,9 +427,9 @@ void drawHUD(osg::State* state) = fgGetNode("/autopilot/locks/altitude", true); static char hud_hdg_text[256]; - static char hud_wp0_text[256]; - static char hud_wp1_text[256]; - static char hud_wp2_text[256]; + static char hud_gps_text0[256]; + static char hud_gps_text1[256]; + static char hud_gps_text2[256]; static char hud_alt_text[256]; glEnable(GL_BLEND); @@ -472,32 +466,42 @@ void drawHUD(osg::State* state) fgGetDouble("/autopilot/settings/true-heading-deg") ); HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) ); apY -= 15; - - string wp0_id = fgGetString( "/autopilot/route-manager/wp[0]/id" ); - if ( wp0_id.length() > 0 ) { - snprintf( hud_wp0_text, 256, "%5s %6.1fnm %s", wp0_id.c_str(), - fgGetDouble( "/autopilot/route-manager/wp[0]/dist" ), - fgGetString( "/autopilot/route-manager/wp[0]/eta" ) ); - HUD_TextList.add( fgText( 40, apY, hud_wp0_text ) ); - apY -= 15; - } - string wp1_id = fgGetString( "/autopilot/route-manager/wp[1]/id" ); - if ( wp1_id.length() > 0 ) { - snprintf( hud_wp1_text, 256, "%5s %6.1fnm %s", wp1_id.c_str(), - fgGetDouble( "/autopilot/route-manager/wp[1]/dist" ), - fgGetString( "/autopilot/route-manager/wp[1]/eta" ) ); - HUD_TextList.add( fgText( 40, apY, hud_wp1_text ) ); - apY -= 15; - } - string wp2_id = fgGetString( "/autopilot/route-manager/wp-last/id" ); - if ( wp2_id.length() > 0 ) { - snprintf( hud_wp2_text, 256, "%5s %6.1fnm %s", wp2_id.c_str(), - fgGetDouble( "/autopilot/route-manager/wp-last/dist" ), - fgGetString( "/autopilot/route-manager/wp-last/eta" ) ); - HUD_TextList.add( fgText( 40, apY, hud_wp2_text ) ); - apY -= 15; - } } + + // GPS current waypoint information + SGPropertyNode_ptr gps = fgGetNode("/instrumentation/gps", true); + SGPropertyNode_ptr curWp = gps->getChild("wp")->getChild("wp",1); + + if ((gps->getDoubleValue("raim") > 0.5) && curWp) { + // GPS is receiving a valid signal + snprintf(hud_gps_text0, 256, "WPT:%5s BRG:%03.0f %5.1fnm", + curWp->getStringValue("ID"), + curWp->getDoubleValue("bearing-mag-deg"), + curWp->getDoubleValue("distance-nm")); + HUD_TextList.add( fgText( 40, apY, hud_gps_text0 ) ); + apY -= 15; + + // curWp->getStringValue("TTW") + snprintf(hud_gps_text2, 256, "ETA %s", curWp->getStringValue("TTW")); + HUD_TextList.add( fgText( 40, apY, hud_gps_text2 ) ); + apY -= 15; + + double courseError = curWp->getDoubleValue("course-error-nm"); + if (fabs(courseError) >= 0.01) { + // generate an arrow indicatinng if the pilot should turn left or right + char dir = (courseError < 0.0) ? '<' : '>'; + snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f XTRK:%c%4.2fnm", + gps->getDoubleValue("indicated-track-magnetic-deg"), dir, fabs(courseError)); + } else { // on course, don't bother showing the XTRK error + snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f", + gps->getDoubleValue("indicated-track-magnetic-deg")); + } + + HUD_TextList.add( fgText( 40, apY, hud_gps_text1) ); + apY -= 15; + } // of valid GPS output + + //////////////////// if ( strcmp( altitude_enabled->getStringValue(), "altitude-hold" ) == 0 ) { snprintf( hud_alt_text, 256, "alt = %.0f\n",