]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/cockpit.cxx
- modified FGBinding to keep a local copy of the argument property
[flightgear.git] / src / Cockpit / cockpit.cxx
index 5cdaee5b087d1b018866b9c70e6389ff4b2fd391..b88c5e93e5d3df82256528815438ffe5a1954ee4 100644 (file)
@@ -30,7 +30,6 @@
 #endif
 
 #include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
 
 #include <stdlib.h>
 #include <stdio.h>
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/math/fg_random.h>
 #include <simgear/math/polar3d.hxx>
+#include <simgear/misc/props.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Include/general.hxx>
 #include <FDM/ADA.hxx>
 #include <Main/globals.hxx>
-#include <Main/options.hxx>
+#include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 #include <Time/fg_timer.hxx>
 #include <GUI/gui.h>
@@ -66,7 +65,7 @@ float get_latitude( void )
 {
     double lat;
 
-    lat = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
+    lat = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
 
     float flat = lat;
     return(flat);
@@ -77,7 +76,7 @@ float get_lat_min( void )
 {
     double      a, d;
 
-    a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;    
+    a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;    
     if (a < 0.0) {
         a = -a;
     }
@@ -91,7 +90,7 @@ float get_longitude( void )
 {
     double lon;
 
-    lon = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
+    lon = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
 
     float flon = lon;
     return(flon);
@@ -113,7 +112,7 @@ get_formated_gmt_time( void )
 float get_long_min( void )
 {
     double  a, d;
-    a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;   
+    a = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;   
     if (a < 0.0) {
         a = -a;
     }
@@ -154,10 +153,12 @@ float get_rudderval( void )
 
 float get_speed( void )
 {
-    // Make an explicit function call.
+    static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
+
     float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
-       * globals->get_options()->get_speed_up();
-    return( speed );
+       * speedup_node->getIntValue();
+
+    return speed;
 }
 
 float get_mach(void)
@@ -168,7 +169,7 @@ float get_mach(void)
 
 float get_aoa( void )
 {
-    float aoa = current_aircraft.fdm_state->get_Alpha() * RAD_TO_DEG;
+    float aoa = current_aircraft.fdm_state->get_Alpha() * SGD_RADIANS_TO_DEGREES;
     return( aoa );
 }
 
@@ -186,25 +187,24 @@ float get_pitch( void )
 
 float get_heading( void )
 {
-    float heading = (current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG);
+    float heading = (current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES);
     return( heading );
 }
 
 float get_altitude( void )
 {
-//  FGState *f;
-    // double rough_elev;
+    static const SGPropertyNode *startup_units_node
+        = fgGetNode("/sim/startup/units");
 
-//  current_aircraft.fdm_state
-    // rough_elev = mesh_altitude(f->get_Longitude() * RAD_TO_ARCSEC,
-    //                         f->get_Latitude()  * RAD_TO_ARCSEC);
     float altitude;
 
-    if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
+    if ( startup_units_node->getStringValue() == "feet" ) {
         altitude = current_aircraft.fdm_state->get_Altitude();
     } else {
-        altitude = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER);
+        altitude = (current_aircraft.fdm_state->get_Altitude()
+                    * SG_FEET_TO_METER);
     }
+
     return altitude;
 }
 
@@ -212,11 +212,11 @@ float get_agl( void )
 {
     float agl;
 
-    if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
+    if ( fgGetString("/sim/startup/units") == "feet" ) {
         agl = (current_aircraft.fdm_state->get_Altitude()
-               - scenery.cur_elev * METER_TO_FEET);
+               - scenery.cur_elev * SG_METER_TO_FEET);
     } else {
-        agl = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
+        agl = (current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
                - scenery.cur_elev);
     }
     return agl;
@@ -236,7 +236,7 @@ float get_frame_rate( void )
 
 float get_fov( void )
 {
-    float fov = globals->get_options()->get_fov(); 
+    float fov = globals->get_current_view()->get_fov(); 
     return (fov);
 }
 
@@ -264,10 +264,10 @@ float get_vfc_tris_culled   ( void )
 float get_climb_rate( void )
 {
     float climb_rate;
-    if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
+    if ( fgGetString("/sim/startup/units") == "feet" ) {
         climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
     } else {
-        climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * FEET_TO_METER * 60.0;
+        climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0;
     }
     return (climb_rate);
 }
@@ -275,9 +275,9 @@ float get_climb_rate( void )
 
 float get_view_direction( void )
 {
-    double view_off = FG_2PI - globals->get_current_view()->get_view_offset();
+    double view_off = SGD_2PI - globals->get_current_view()->get_view_offset();
     double view = ( current_aircraft.fdm_state->get_Psi() + view_off)
-       * RAD_TO_DEG;
+       * SGD_RADIANS_TO_DEGREES;
     
     if(view > 360.)
         view -= 360.;
@@ -288,22 +288,28 @@ float get_view_direction( void )
 }
 
 // $$$ begin - added, VS Renganathan 13 Oct 2K
-#ifdef FIGHTER_HUD
+// #ifdef FIGHTER_HUD
 float get_Vx   ( void )
 {
-    float Vxx = current_aircraft.fdm_state->get_V_north_rel_ground();
+    // CLO - 5 Jan 2000 - something needs to get addressed here
+    // float Vxx = current_aircraft.fdm_state->get_V_north_rel_ground();
+    float Vxx = 0;
     return (Vxx);
 }
 
 float get_Vy   ( void )
 {
-    float Vyy = current_aircraft.fdm_state->get_V_east_rel_ground();
+    // CLO - 5 Jan 2000 - something needs to get addressed here
+    // float Vyy = current_aircraft.fdm_state->get_V_east_rel_ground();
+    float Vyy = 0;
     return (Vyy);
 }
 
 float get_Vz   ( void )
 {
-    float Vzz = current_aircraft.fdm_state->get_V_down_rel_ground();
+    // CLO - 5 Jan 2000 - something needs to get addressed here
+    // float Vzz = current_aircraft.fdm_state->get_V_down_rel_ground();
+    float Vzz = 0;
     return (Vzz);
 }
 
@@ -510,7 +516,7 @@ float get_aux18 (void)
     FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
     return fdm->get_aux18();
 }
-#endif
+// #endif
 // $$$ end - added, VS Renganathan 13 Oct 2K
 
 
@@ -667,7 +673,7 @@ char *coord_format_latlon(double latitude, double longitude)
 
 bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
 {
-    FG_LOG( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem" );
+    SG_LOG( SG_COCKPIT, SG_INFO, "Initializing cockpit subsystem" );
 
     //  cockpit->code = 1;  /* It will be aircraft dependent */
     //  cockpit->status = 0;
@@ -687,7 +693,7 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
     // Have to set the LatLon display type
     fgLatLonFormat = toDM;
     
-    FG_LOG( FG_COCKPIT, FG_INFO,
+    SG_LOG( SG_COCKPIT, SG_INFO,
         "  Code " << ac_cockpit->code() << " Status " 
         << ac_cockpit->status() );
 
@@ -696,16 +702,22 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
 
 void fgCockpitUpdate( void ) {
 
-    FG_LOG( FG_COCKPIT, FG_DEBUG,
-        "Cockpit: code " << ac_cockpit->code() << " status " 
-        << ac_cockpit->status() );
+    SG_LOG( SG_COCKPIT, SG_DEBUG,
+            "Cockpit: code " << ac_cockpit->code() << " status " 
+            << ac_cockpit->status() );
+
+    static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize");
+    static const SGPropertyNode * ysize_node = fgGetNode("/sim/startup/ysize");
+    static const SGPropertyNode * hud_visibility_node
+        = fgGetNode("/sim/hud/visibility");
 
-       int iwidth   = globals->get_current_view()->get_winWidth();
-       int iheight  = globals->get_current_view()->get_winHeight();
-       float width  = iwidth;
-       float height = iheight;
+    int iwidth   = xsize_node->getIntValue();
+    int iheight  = ysize_node->getIntValue();
+    float width  = iwidth;
+    // float height = iheight;
 
-    if ( globals->get_options()->get_hud_status() ) {
+                               // FIXME: inefficient
+    if ( hud_visibility_node->getBoolValue() ) {
         // This will check the global hud linked list pointer.
         // If these is anything to draw it will.
         fgUpdateHUD();
@@ -721,34 +733,30 @@ void fgCockpitUpdate( void ) {
 //      sprintf(buf,"%-4.1f  %7.0f  %7.0f", fps, tris, culled);
         sprintf(buf,"%-5.1f", fps);
 
-        glMatrixMode(GL_PROJECTION);
+        glMatrixMode( GL_PROJECTION );
         glPushMatrix();
         glLoadIdentity();
-        gluOrtho2D(0, width, 0, height);
-        glMatrixMode(GL_MODELVIEW);
+        gluOrtho2D( 0, iwidth, 0, iheight );
+        glMatrixMode( GL_MODELVIEW );
         glPushMatrix();
         glLoadIdentity();
 
-        glDisable(GL_DEPTH_TEST);
-        glDisable(GL_LIGHTING);
+        glDisable( GL_DEPTH_TEST );
+        glDisable( GL_LIGHTING );
         
-        glColor3f (0.9, 0.4, 0.2);
+        glColor3f( 0.9, 0.4, 0.2 );
 
         guiFnt.drawString( buf,
-                          // width/2 - guiFnt.getStringWidth(buf)/2,
                           int(width - guiFnt.getStringWidth(buf) - 10),
                            10 );
-        glEnable(GL_DEPTH_TEST);
-        glEnable(GL_LIGHTING);
-        glMatrixMode(GL_PROJECTION);
+        glEnable( GL_DEPTH_TEST );
+        glEnable( GL_LIGHTING );
+        glMatrixMode( GL_PROJECTION );
         glPopMatrix();
-        glMatrixMode(GL_MODELVIEW);
+        glMatrixMode( GL_MODELVIEW );
         glPopMatrix();
     }
 #endif // #ifdef DISPLAY_COUNTER
     
-    xglViewport( 0, 0, iwidth, iheight );
-
-    if (current_panel != 0)
-      current_panel->update();
+    glViewport( 0, 0, iwidth, iheight );
 }