X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fhud.cxx;h=043eeb8ee12cad7f6bb17a4f093ac5bc20bedf34;hb=75747d35167cdf4586d32fc82d8c7dddd6bfeee9;hp=4f7ddfdedc7a6b29d2f8775f944e4f93b9451446;hpb=2119db35c3f596268e2ee21d3cd8c359a85cd1ed;p=flightgear.git diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 4f7ddfded..043eeb8ee 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -21,7 +21,7 @@ // $Id$ #include -#include +#include #include STL_STRING #include STL_FSTREAM @@ -40,24 +40,22 @@ #include -#include #include #include // char related functions #include // strcmp() +#include SG_GLU_H + #include #include #include #include #include -#include +#include #include #include
#include
-#ifdef FG_NETWORK_OLK -#include -#endif #include #if defined ( __sun__ ) || defined ( __sgi ) @@ -242,11 +240,13 @@ readLadder(const SGPropertyNode * node) // The factor assumes a base of 55 degrees per 640 pixels. // Invert to convert the "compression" factor to a // pixels-per-degree number. - if( HUD_style == 1) + if(fgGetBool("/sim/hud/enable3d", true)) { -// if(factor == 0) + if (HUD_style == 1) + { factor = 1; - factor = (640./55.) / factor; + factor = (640./55.) / factor; + } } SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); @@ -455,6 +455,7 @@ readLabel(const SGPropertyNode * node) } } +#ifdef ENABLE_SP_FMDS if ( loadfn== "aux1" ) { load_fn = get_aux1; } else if ( loadfn == "aux2" ) { @@ -491,7 +492,9 @@ readLabel(const SGPropertyNode * node) load_fn = get_aux17; } else if ( loadfn == "aux18" ) { load_fn = get_aux18; - } else if ( loadfn == "ax" ) { + } else +#endif + if ( loadfn == "ax" ) { load_fn = get_Ax; } else if ( loadfn == "speed" ) { load_fn = get_speed; @@ -582,6 +585,29 @@ readTBI(const SGPropertyNode * node) return p; } //end readTBI +static instr_item * +readRunway(const SGPropertyNode * node) { + name = node->getStringValue("name"); + x = node->getIntValue("x"); + y = node->getIntValue("y"); + width = node->getIntValue("width"); + height = node->getIntValue("height"); + scaling = node->getDoubleValue("scale"); + working = node->getBoolValue("working",true); + runway_instr *ri = new runway_instr(x,y,width,height,scaling,working); + double scale = node->getDoubleValue("arrow_scale",1.0); + ri->setDrawArrow((scale>0)?true:false); + ri->setDrawArrowAlways((scale>0)?node->getBoolValue("arrow_always"):false); + ri->setStippleOutline(node->getIntValue("outer_stipple",0xFFFF)); + ri->setStippleCenterline(node->getIntValue("center_stipple",0xFFFF)); + ri->setArrowRotationRadius(node->getDoubleValue("arrow_radius")); + ri->setArrowScale(scale); + ri->setLineScale(node->getDoubleValue("line_scale",1.0)); + ri->setScaleDist(node->getDoubleValue("scale_dist_nm")); + SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); + return (instr_item *) ri; +} + int readInstrument(const SGPropertyNode * node) { @@ -640,6 +666,18 @@ int readInstrument(const SGPropertyNode * node) }//for - tbis } + + const SGPropertyNode * rwy_group = node->getNode("runways"); + if (rwy_group != 0) { + int nRwy = rwy_group->nChildren(); + for (int j = 0; j < nRwy; j++) { + SG_LOG( SG_COCKPIT, SG_DEBUG, + "************** Reading runway properties" ); + HIptr = readRunway(rwy_group->getChild(j)); + HUD_deque.insert( HUD_deque.begin(), HIptr); + + }//for - runways + } return 0; }//end readinstrument @@ -993,7 +1031,8 @@ static void set_hud_color(float r, float g, float b) { // void fgUpdateHUD( void ) { - if( HUD_style == 1) + static const SGPropertyNode *enable3d_node = fgGetNode("/sim/hud/enable3d"); + if( HUD_style == 1 && enable3d_node->getBoolValue() ) { fgUpdateHUDVirtual(); return; @@ -1096,8 +1135,18 @@ void drawHUD() glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); - static const SGPropertyNode * antialiased_node - = fgGetNode("/sim/hud/antialiased"); + static const SGPropertyNode *antialiased_node + = fgGetNode("/sim/hud/antialiased", true); + static const SGPropertyNode *heading_enabled + = fgGetNode("/autopilot/locks/heading", true); + static const SGPropertyNode *altitude_enabled + = 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_alt_text[256]; if( antialiased_node->getBoolValue() ) { glEnable(GL_LINE_SMOOTH); @@ -1163,43 +1212,59 @@ void drawHUD() HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) ); -#ifdef FG_NETWORK_OLK - if ( net_hud_display ) { - net_hud_update(); - } -#endif - int apY = 480 - 80; - // char scratch[128]; - // HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) ); - // apY -= 15; - FGAutopilot *AP = globals->get_autopilot(); - if( AP->get_HeadingEnabled() ) { - HUD_TextList.add( fgText( 40, apY, AP->get_TargetHeadingStr()) ); + + if (strcmp( heading_enabled->getStringValue(), "dg-heading-hold") == 0 ) { + snprintf( hud_hdg_text, 256, "hdg = %.1f\n", + fgGetDouble("/autopilot/settings/heading-bug-deg") ); + HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) ); apY -= 15; - } - if( AP->get_AltitudeEnabled() ) { - HUD_TextList.add( fgText( 40, apY, AP->get_TargetAltitudeStr()) ); + } else if ( strcmp(heading_enabled->getStringValue(), "true-heading-hold") == 0 ) { + snprintf( hud_hdg_text, 256, "hdg = %.1f\n", + fgGetDouble("/autopilot/settings/true-heading-deg") ); + HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) ); apY -= 15; - } - if( AP->get_HeadingMode() == FGAutopilot::FG_HEADING_WAYPOINT ) - { - if ( strlen( AP->get_TargetWP1Str() ) ) { - HUD_TextList.add( fgText( 40, apY, AP->get_TargetWP1Str() ) ); + + 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; } - if ( strlen( AP->get_TargetWP2Str() ) ) { - HUD_TextList.add( fgText( 40, apY, AP->get_TargetWP2Str() ) ); + 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; } - if ( strlen( AP->get_TargetWP3Str() ) ) { - HUD_TextList.add( fgText( 40, apY, AP->get_TargetWP3Str() ) ); - 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; } } + if ( strcmp( altitude_enabled->getStringValue(), "altitude-hold" ) == 0 ) { + snprintf( hud_alt_text, 256, "alt = %.0f\n", + fgGetDouble("/autopilot/settings/target-altitude-ft") ); + HUD_TextList.add( fgText( 40, apY, hud_alt_text ) ); + apY -= 15; + } else if ( strcmp( altitude_enabled->getStringValue(), "agl-hold" ) == 0 ){ + snprintf( hud_alt_text, 256, "agl = %.0f\n", + fgGetDouble("/autopilot/settings/target-agl-ft") ); + HUD_TextList.add( fgText( 40, apY, hud_alt_text ) ); + apY -= 15; + } + HUD_TextList.draw(); HUD_LineList.draw();