#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
-#include STL_STRING
-#include STL_FSTREAM
+#include <string>
+#include <fstream>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-
#include <math.h>
-
#include <stdlib.h>
#include <stdio.h> // char related functions
#include <string.h> // strcmp()
-#include SG_GLU_H
-
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props_io.hxx>
+
+#include <osg/GLU>
-#include <Aircraft/aircraft.hxx>
-//#include <Autopilot/xmlauto.hxx>
#include <GUI/new_gui.hxx> // FGFontCache
#include <Main/globals.hxx>
#include <Scenery/scenery.hxx>
+#include <Airports/runways.hxx>
+#include <Main/viewer.hxx>
#include "hud.hxx"
}
- 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"))
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();
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());
// 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;
}
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);
}
-int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
+int fgHUDInit2()
{
HUD_style = 2;
= 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);
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",