]> git.mxchange.org Git - flightgear.git/commitdiff
remove readRunway() and let the runway_instr class read the properties in
authormfranz <mfranz>
Wed, 14 Jun 2006 18:41:36 +0000 (18:41 +0000)
committermfranz <mfranz>
Wed, 14 Jun 2006 18:41:36 +0000 (18:41 +0000)
the constructor

src/Cockpit/hud.cxx
src/Cockpit/hud.hxx
src/Cockpit/hud_rwy.cxx

index 23a0c3adef4126ce5cbdec67dfa6284282005edd..323d12f9f3ec6e97ab0657770138353e0ca8e00d 100644 (file)
@@ -284,30 +284,6 @@ readCard(const SGPropertyNode * node)
 }// end readCard
 
 
-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)
 {
     static const SGPropertyNode *startup_units_node
@@ -354,7 +330,7 @@ int readInstrument(const SGPropertyNode * node)
         int nTbis = tbi_group->nChildren();
         for (int j = 0; j < nTbis; j++) {
             HIptr = static_cast<instr_item *>(new fgTBI_instr(tbi_group->getChild(j)));
-            HUD_deque.insert( HUD_deque.begin(), HIptr);
+            HUD_deque.insert(HUD_deque.begin(), HIptr);
         }
     }
 
@@ -362,13 +338,12 @@ int readInstrument(const SGPropertyNode * node)
     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);
+            HIptr = static_cast<instr_item *>(new runway_instr(rwy_group->getChild(j)));
+            HUD_deque.insert(HUD_deque.begin(), HIptr);
         }
     }
     return 0;
-}//end readinstrument
+} //end readinstrument
 
 
 int readHud( istream &input )
index fcf26b1d10f3556fb60511a49c25a0533abe53d9..5f859dd1015e57a17da37c22930d2cf657ecd568 100644 (file)
@@ -436,7 +436,7 @@ public:
                 FLTFNPTR       data_source,
                 float          data_scaling,
                 UINT           options,
-                bool           working  = true,
+                bool           working = true,
                 int            digit = 0);
 
     instr_item( const instr_item & image );
@@ -455,19 +455,23 @@ public:
     POINT   get_centroid    ( void ) { return mid_span;  }
     UINT    get_options     ( void ) { return opts;      }
     int     get_digits      ( void ) { return digits;         }
-
-    UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
-    UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
-    UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
+    inline int get_x() const { return scrn_pos.left; }
+    inline int get_y() const { return scrn_pos.top; }
+    inline int get_width() const { return scrn_pos.right; }
+    inline int get_height() const { return scrn_pos.bottom; }
+
+    UINT    huds_vert     (UINT options) { return (options & HUDS_VERT); }
+    UINT    huds_left     (UINT options) { return (options & HUDS_LEFT); }
+    UINT    huds_right    (UINT options) { return (options & HUDS_RIGHT); }
     UINT    huds_both     (UINT options) {
-        return( (options & HUDS_BOTH) == HUDS_BOTH );
+        return ((options & HUDS_BOTH) == HUDS_BOTH);
     }
-    UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
-    UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
-    UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
-    UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
+    UINT    huds_noticks  (UINT options) { return (options & HUDS_NOTICKS); }
+    UINT    huds_notext   (UINT options) { return (options & HUDS_NOTEXT); }
+    UINT    huds_top      (UINT options) { return (options & HUDS_TOP); }
+    UINT    huds_bottom   (UINT options) { return (options & HUDS_BOTTOM); }
 
-    virtual void display_enable( bool working ) { is_enabled = !! working;}
+    virtual void display_enable( bool working ) { is_enabled = working;}
 
     virtual void update( void );
     virtual void break_display ( bool bad );
@@ -624,45 +628,49 @@ public:
 
 
 //
-// fgRunway_instr        This class is responsible for rendering the active runway
-//                        in the hud (if visible).
+// fgRunway_instr   This class is responsible for rendering the active runway
+//                  in the hud (if visible).
 class runway_instr : public instr_item {
 private:
         void boundPoint(const sgdVec3& v, sgdVec3& m);
         bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
-        bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
+        bool drawLine(const sgdVec3& a1, const sgdVec3& a2,
+                const sgdVec3& p1, const sgdVec3& p2);
         void drawArrow();
         bool get_active_runway(FGRunway& rwy);
         void get_rwy_points(sgdVec3 *points);
         void setLineWidth(void);
 
-        sgdVec3 points3d[6],points2d[6];
-        double mm[16],pm[16], arrowScale, arrowRad, lnScale, scaleDist, default_pitch, default_heading;
+        sgdVec3 points3d[6], points2d[6];
+        double mm[16],pm[16], arrowScale, arrowRad, lnScale;
+        double scaleDist, default_pitch, default_heading;
         GLint view[4];
         FGRunway runway;
         FGViewer* cockpit_view;
-        unsigned short stippleOut,stippleCen;
-        bool drawIA,drawIAAlways;
+        unsigned short stippleOut, stippleCen;
+        bool drawIA, drawIAAlways;
         RECT location;
         POINT center;
 
 public:
-    runway_instr( int    x,
-                  int    y,
-                  int    width,
-                  int    height,
-                  float  scale_data,
-                  bool   working = true);
-
-    virtual void draw( void );       // Required method in base class
-        void setArrowRotationRadius(double radius);
-        void setArrowScale(double scale); // Scales the runway indication arrow
-        void setDrawArrow(bool draw);         // Draws arrow when runway is not visible in HUD if draw=true
-        void setDrawArrowAlways(bool draw); //Always draws arrow if draw=true;
-        void setLineScale(double scale); //Sets the maximum line scale
-        void setScaleDist(double dist_nm); //Sets the distance where to start scaling the lines
-        void setStippleOutline(unsigned short stipple); //Sets the stipple pattern of the outline of the runway
-        void setStippleCenterline(unsigned short stipple); //Sets the stipple patter of the center line of the runway
+    runway_instr(const SGPropertyNode *);
+
+    virtual void draw( void );
+    void setArrowRotationRadius(double radius);
+    // Scales the runway indication arrow
+    void setArrowScale(double scale);
+    // Draws arrow when runway is not visible in HUD if draw=true
+    void setDrawArrow(bool draw);
+    //Always draws arrow if draw=true;
+    void setDrawArrowAlways(bool draw);
+    //Sets the maximum line scale
+    void setLineScale(double scale);
+    //Sets the distance where to start scaling the lines
+    void setScaleDist(double dist_nm);
+    //Sets the stipple pattern of the outline of the runway
+    void setStippleOutline(unsigned short stipple);
+    //Sets the stipple patter of the center line of the runway
+    void setStippleCenterline(unsigned short stipple);
 };
 
 
index 1d20481b33d151eea4fc6ce5f8fdfae05dfe199f..b9e78eb93cfb66dcc9e2774ca0cfe851b1ee9949 100644 (file)
 #include SG_GLU_H
 #include <ATC/ATCutils.hxx>
 
-runway_instr::runway_instr(int x,
-                           int y,
-                           int width,
-                           int height,
-                           float scale_data,
-                           bool working) :
-    instr_item(x, y, width, height, NULL, scale_data, 0, working)
+
+// int x, int y, int width, int height, float scale_data, bool working)
+
+runway_instr::runway_instr(const SGPropertyNode *node) :
+    instr_item(
+            node->getIntValue("x"),
+            node->getIntValue("y"),
+            node->getIntValue("width"),
+            node->getIntValue("height"),
+            NULL,
+            node->getDoubleValue("scale"),
+            0,
+            node->getBoolValue("working", true)),
+    arrowScale(node->getDoubleValue("arrow_scale", 1.0)),
+    arrowRad(node->getDoubleValue("arrow_radius")),
+    lnScale(node->getDoubleValue("line_scale", 1.0)),
+    scaleDist(node->getDoubleValue("scale_dist_nm")),
+    default_pitch(fgGetDouble("/sim/view[0]/config/pitch-pitch-deg", 0.0)),
+    default_heading(fgGetDouble("/sim/view[0]/config/pitch-heading-deg", 0.0)),
+    cockpit_view(globals->get_viewmgr()->get_view(0)),
+    stippleOut(node->getIntValue("outer_stipple", 0xFFFF)),
+    stippleCen(node->getIntValue("center_stipple", 0xFFFF)),
+    drawIA(arrowScale > 0 ? true : false),
+    drawIAAlways(arrowScale > 0 ? node->getBoolValue("arrow_always") : false)
 {
-    stippleOut=0xFFFF;
-    stippleCen=0xFFFF;
-    arrowScale = 1.0;
-    arrowRad = 0.0;
+    SG_LOG(SG_INPUT, SG_INFO, "Done reading runway instrument "
+            << node->getStringValue("name"));
+
     view[0] = 0;
     view[1] = 0;
     view[2] = 640;
     view[3] = 480;
-    center.x = view[2]>>1;
-    center.y = view[3]>>1;
-    location.left = center.x-(width>>1)+x;
-    location.right = center.x+(width>>1)+x;
-    location.bottom = center.y-(height>>1)+y;
-    location.top = center.y+(height>>1)+y;
-    cockpit_view = globals->get_viewmgr()->get_view(0);
-    default_heading = fgGetDouble("/sim/view[0]/config/pitch-heading-deg",0.0);
-    default_pitch = fgGetDouble("/sim/view[0]/config/pitch-pitch-deg",0.0);
+
+    center.x = view[2] >> 1;
+    center.y = view[3] >> 1;
+
+    location.left = center.x - (get_width() >> 1) + get_x();
+    location.right = center.x + (get_width() >>1) + get_x();
+    location.bottom = center.y - (get_height() >>1) + get_y();
+    location.top = center.y + (get_height() >> 1) + get_y();
 }
 
 
-void runway_instr::draw() {
+
+void runway_instr::draw()
+{
     if (!is_broken() && get_active_runway(runway)) {
         glPushAttrib(GL_LINE_STIPPLE | GL_LINE_STIPPLE_PATTERN | GL_LINE_WIDTH);
-        float modelView[4][4],projMat[4][4];
+        float modelView[4][4], projMat[4][4];
         bool anyLines;
         //Get the current view
         FGViewer* curr_view = globals->get_viewmgr()->get_current_view();
@@ -77,8 +94,8 @@ void runway_instr::draw() {
         double po = curr_view->getPitchOffset_deg();
         double ho = curr_view->getHeadingOffset_deg();
 
-        double yaw = -(cockpit_view->getHeadingOffset_deg()-default_heading)*SG_DEGREES_TO_RADIANS;
-        double pitch = (cockpit_view->getPitchOffset_deg()-default_pitch)*SG_DEGREES_TO_RADIANS;
+        double yaw = -(cockpit_view->getHeadingOffset_deg() - default_heading) * SG_DEGREES_TO_RADIANS;
+        double pitch = (cockpit_view->getPitchOffset_deg() - default_pitch) * SG_DEGREES_TO_RADIANS;
         //double roll = fgGetDouble("/sim/view[0]/config/roll-offset-deg",0.0) //TODO: adjust for default roll offset
         double sPitch = sin(pitch), cPitch = cos(pitch),
                sYaw = sin(yaw), cYaw = cos(yaw);
@@ -98,41 +115,46 @@ void runway_instr::draw() {
         ssgGetModelviewMatrix(modelView);
         //Create a rotation matrix to correct for any offsets (other than default offsets) to the model view matrix
         sgMat4 xy; //rotation about the Rxy, negate the sin's on Ry
-        xy[0][0]=cYaw;         xy[1][0]=0.0f;   xy[2][0]=-sYaw;        xy[3][0]=0.0f;
-        xy[0][1]=sPitch*-sYaw; xy[1][1]=cPitch; xy[2][1]=-sPitch*cYaw; xy[3][1]=0.0f;
-        xy[0][2]=cPitch*sYaw;  xy[1][2]=sPitch; xy[2][2]=cPitch*cYaw;  xy[3][2]=0.0f;
-        xy[0][3]=0.0f;         xy[1][3]=0.0f;   xy[2][3]=0.0f;         xy[3][3]=1.0f;
+        xy[0][0] = cYaw;         xy[1][0] = 0.0f;   xy[2][0] = -sYaw;        xy[3][0] = 0.0f;
+        xy[0][1] = sPitch*-sYaw; xy[1][1] = cPitch; xy[2][1] = -sPitch*cYaw; xy[3][1] = 0.0f;
+        xy[0][2] = cPitch*sYaw;  xy[1][2] = sPitch; xy[2][2] = cPitch*cYaw;  xy[3][2] = 0.0f;
+        xy[0][3] = 0.0f;         xy[1][3] = 0.0f;   xy[2][3] = 0.0f;         xy[3][3] = 1.0f;
         //Re-center the model view
         sgPostMultMat4(modelView,xy);
         //copy float matrices to double
-        for (int i=0; i<4; i++) {
-            for (int j=0; j<4; j++) {
-                int idx = (i*4)+j;
+        for (int i = 0; i < 4; i++) {
+            for (int j = 0; j < 4; j++) {
+                int idx = (i * 4) + j;
                 mm[idx] = (double)modelView[i][j];
                 pm[idx] = (double)projMat[i][j];
             }
         }
+
         //Calculate the 2D points via gluProject
         int result = GL_TRUE;
-        for (int i=0; i<6; i++) {
-            result = gluProject(points3d[i][0],points3d[i][1],points3d[i][2],mm,pm,view,&points2d[i][0],&points2d[i][1],&points2d[i][2]);
+        for (int i = 0; i < 6; i++) {
+            result = gluProject(points3d[i][0], points3d[i][1], points3d[i][2], mm,
+                    pm, view, &points2d[i][0], &points2d[i][1], &points2d[i][2]);
         }
         //set the line width based on our distance from the runway
         setLineWidth();
         //Draw the runway lines on the HUD
         glEnable(GL_LINE_STIPPLE);
-        glLineStipple(1,stippleOut);
+        glLineStipple(1, stippleOut);
         anyLines =
-        drawLine(points3d[0],points3d[1],points2d[0],points2d[1]) | //draw top
-        drawLine(points3d[2],points3d[1],points2d[2],points2d[1]) | //draw right
-        drawLine(points3d[2],points3d[3],points2d[2],points2d[3]) | //draw bottom
-        drawLine(points3d[3],points3d[0],points2d[3],points2d[0]);  //draw left
-        glLineStipple(1,stippleCen);
-        anyLines |= drawLine(points3d[5],points3d[4],points2d[5],points2d[4]); //draw center
+                drawLine(points3d[0], points3d[1], points2d[0], points2d[1]) | //draw top
+                drawLine(points3d[2], points3d[1], points2d[2], points2d[1]) | //draw right
+                drawLine(points3d[2], points3d[3], points2d[2], points2d[3]) | //draw bottom
+                drawLine(points3d[3], points3d[0], points2d[3], points2d[0]);  //draw left
+
+        glLineStipple(1, stippleCen);
+        anyLines |= drawLine(points3d[5], points3d[4], points2d[5], points2d[4]); //draw center
+
         //Check to see if arrow needs drawn
         if ((!anyLines && drawIA) || drawIAAlways) {
             drawArrow(); //draw indication arrow
         }
+
         //Restore the current view and any offsets
         if (curr_view_id != 0) {
             globals->get_viewmgr()->set_view(curr_view_id);
@@ -149,15 +171,17 @@ void runway_instr::draw() {
 }
 
 
-bool runway_instr::get_active_runway(FGRunway& runway) {
-  FGEnvironment stationweather =
-      ((FGEnvironmentMgr *)globals->get_subsystem("environment"))->getEnvironment();
-  double hdg = stationweather.get_wind_from_heading_deg();
-  return globals->get_runways()->search( fgGetString("/sim/presets/airport-id"), int(hdg), &runway);
+bool runway_instr::get_active_runway(FGRunway& runway)
+{
+    FGEnvironment stationweather =
+            ((FGEnvironmentMgr *)globals->get_subsystem("environment"))->getEnvironment();
+    double hdg = stationweather.get_wind_from_heading_deg();
+    return globals->get_runways()->search(fgGetString("/sim/presets/airport-id"), int(hdg), &runway);
 }
 
 
-void runway_instr::get_rwy_points(sgdVec3 *points3d) {
+void runway_instr::get_rwy_points(sgdVec3 *points3d)
+{
     static Point3D center = globals->get_scenery()->get_center();
 
     //Get the current tile center
@@ -165,28 +189,28 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d) {
     Point3D tileCenter = currentCenter;
     if (center != currentCenter) //if changing tiles
         tileCenter = center; //use last center
-    double alt = current_aircraft.fdm_state->get_Runway_altitude()*SG_FEET_TO_METER;
-    double length = (runway._length/2.0)*SG_FEET_TO_METER;
-    double width = (runway._width/2.0)*SG_FEET_TO_METER;
-    double frontLat,frontLon,backLat,backLon,az,tempLat,tempLon;
+    double alt = current_aircraft.fdm_state->get_Runway_altitude() * SG_FEET_TO_METER;
+    double length = (runway._length / 2.0) * SG_FEET_TO_METER;
+    double width = (runway._width / 2.0) * SG_FEET_TO_METER;
+    double frontLat, frontLon, backLat, backLon,az, tempLat, tempLon;
 
-    geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading,length,&backLat,&backLon,&az);
-    sgGeodToCart(backLat*SG_DEGREES_TO_RADIANS,backLon*SG_DEGREES_TO_RADIANS,alt,points3d[4]);
+    geo_direct_wgs_84(alt, runway._lat, runway._lon, runway._heading, length, &backLat, &backLon, &az);
+    sgGeodToCart(backLat * SG_DEGREES_TO_RADIANS, backLon * SG_DEGREES_TO_RADIANS, alt, points3d[4]);
 
-    geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading+180,length,&frontLat,&frontLon,&az);
-    sgGeodToCart(frontLat*SG_DEGREES_TO_RADIANS,frontLon*SG_DEGREES_TO_RADIANS,alt,points3d[5]);
+    geo_direct_wgs_84(alt, runway._lat, runway._lon, runway._heading + 180, length, &frontLat, &frontLon, &az);
+    sgGeodToCart(frontLat * SG_DEGREES_TO_RADIANS, frontLon * SG_DEGREES_TO_RADIANS, alt, points3d[5]);
 
-    geo_direct_wgs_84(alt,backLat,backLon,runway._heading+90,width,&tempLat,&tempLon,&az);
-    sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[0]);
+    geo_direct_wgs_84(alt, backLat, backLon, runway._heading + 90, width, &tempLat, &tempLon, &az);
+    sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[0]);
 
-    geo_direct_wgs_84(alt,backLat,backLon,runway._heading-90,width,&tempLat,&tempLon,&az);
-    sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[1]);
+    geo_direct_wgs_84(alt, backLat, backLon, runway._heading - 90, width, &tempLat, &tempLon, &az);
+    sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[1]);
 
-    geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading-90,width,&tempLat,&tempLon,&az);
-    sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[2]);
+    geo_direct_wgs_84(alt, frontLat, frontLon, runway._heading - 90, width, &tempLat, &tempLon, &az);
+    sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[2]);
 
-    geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading+90,width,&tempLat,&tempLon,&az);
-    sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[3]);
+    geo_direct_wgs_84(alt, frontLat, frontLon, runway._heading + 90, width, &tempLat, &tempLon, &az);
+    sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[3]);
 
     for (int i = 0; i < 6; i++) {
         points3d[i][0] -= tileCenter.x();
@@ -197,14 +221,17 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d) {
 }
 
 
-bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) {
+bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2)
+{
     sgdVec3 p1, p2;
     sgdCopyVec3(p1, point1);
     sgdCopyVec3(p2, point2);
-    bool p1Inside = (p1[0]>=location.left && p1[0]<=location.right && p1[1]>=location.bottom && p1[1]<=location.top);
+    bool p1Inside = (p1[0] >= location.left && p1[0] <= location.right
+            && p1[1] >= location.bottom && p1[1] <= location.top);
     bool p1Insight = (p1[2] >= 0.0 && p1[2] < 1.0);
     bool p1Valid = p1Insight && p1Inside;
-    bool p2Inside = (p2[0]>=location.left && p2[0]<=location.right && p2[1]>=location.bottom && p2[1]<=location.top);
+    bool p2Inside = (p2[0] >= location.left && p2[0] <= location.right
+            && p2[1] >= location.bottom && p2[1] <= location.top);
     bool p2Insight = (p2[2] >= 0.0 && p2[2] < 1.0);
     bool p2Valid = p2Insight && p2Inside;
 
@@ -215,41 +242,43 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
         glEnd();
 
     } else if (p1Valid) { //p1 is valid and p2 is not, calculate a new valid point
-        sgdVec3 vec = {a2[0]-a1[0], a2[1]-a1[1], a2[2]-a1[2]};
+        sgdVec3 vec = {a2[0] - a1[0], a2[1] - a1[1], a2[2] - a1[2]};
         //create the unit vector
-        sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
+        sgdScaleVec3(vec, 1.0 / sgdLengthVec3(vec));
         sgdVec3 newPt;
-        sgdCopyVec3(newPt,a1);
-        sgdAddVec3(newPt,vec);
-        if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p2[0],&p2[1],&p2[2]) && (p2[2]>0&&p2[2]<1.0) ) {
-            boundPoint(p1,p2);
+        sgdCopyVec3(newPt, a1);
+        sgdAddVec3(newPt, vec);
+        if (gluProject(newPt[0], newPt[1], newPt[2], mm, pm, view, &p2[0], &p2[1], &p2[2])
+                && (p2[2] > 0 && p2[2] < 1.0)) {
+            boundPoint(p1, p2);
             glBegin(GL_LINES);
-            glVertex2d(p1[0],p1[1]);
-            glVertex2d(p2[0],p2[1]);
+            glVertex2d(p1[0], p1[1]);
+            glVertex2d(p2[0], p2[1]);
             glEnd();
         }
 
     } else if (p2Valid) { //p2 is valid and p1 is not, calculate a new valid point
-        sgdVec3 vec = {a1[0]-a2[0], a1[1]-a2[1], a1[2]-a2[2]};
+        sgdVec3 vec = {a1[0] - a2[0], a1[1] - a2[1], a1[2] - a2[2]};
         //create the unit vector
-        sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
+        sgdScaleVec3(vec, 1.0 / sgdLengthVec3(vec));
         sgdVec3 newPt;
-        sgdCopyVec3(newPt,a2);
-        sgdAddVec3(newPt,vec);
-        if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p1[0],&p1[1],&p1[2]) && (p1[2]>0&&p1[2]<1.0)) {
-            boundPoint(p2,p1);
+        sgdCopyVec3(newPt, a2);
+        sgdAddVec3(newPt, vec);
+        if (gluProject(newPt[0], newPt[1], newPt[2], mm, pm, view, &p1[0], &p1[1], &p1[2])
+                && (p1[2] > 0 && p1[2] < 1.0)) {
+            boundPoint(p2, p1);
             glBegin(GL_LINES);
-            glVertex2d(p2[0],p2[1]);
-            glVertex2d(p1[0],p1[1]);
+            glVertex2d(p2[0], p2[1]);
+            glVertex2d(p1[0], p1[1]);
             glEnd();
         }
 
     } else if (p1Insight && p2Insight) { //both points are insight, but not inside
-        bool v = boundOutsidePoints(p1,p2);
+        bool v = boundOutsidePoints(p1, p2);
         if (v) {
             glBegin(GL_LINES);
-                glVertex2d(p1[0],p1[1]);
-                glVertex2d(p2[0],p2[1]);
+                glVertex2d(p1[0], p1[1]);
+                glVertex2d(p2[0], p2[1]);
             glEnd();
         }
         return v;
@@ -259,7 +288,8 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
 }
 
 
-void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
+void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m)
+{
     double y = v[1];
     if (m[1] < v[1])
         y = location.bottom;
@@ -267,40 +297,41 @@ void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
         y = location.top;
 
     if (m[0] == v[0]) {
-        m[1]=y;
+        m[1] = y;
         return;  //prevent divide by zero
     }
 
-    double slope = (m[1]-v[1])/(m[0]-v[0]);
-    m[0] = (y-v[1])/slope + v[0];
+    double slope = (m[1] - v[1]) / (m[0] - v[0]);
+    m[0] = (y - v[1]) / slope + v[0];
     m[1] = y;
 
     if (m[0] < location.left) {
         m[0] = location.left;
-        m[1] = slope * (location.left-v[0])+v[1];
+        m[1] = slope * (location.left - v[0]) + v[1];
 
     } else if (m[0] > location.right) {
         m[0] = location.right;
-        m[1] = slope * (location.right-v[0])+v[1];
+        m[1] = slope * (location.right - v[0]) + v[1];
     }
 }
 
 
-bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
-    bool pointsInvalid = (v[1]>location.top && m[1]>location.top) ||
-                         (v[1]<location.bottom && m[1]<location.bottom) ||
-                         (v[0]>location.right && m[0]>location.right) ||
-                         (v[0]<location.left && m[0]<location.left);
+bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m)
+{
+    bool pointsInvalid = (v[1] > location.top && m[1] > location.top) ||
+                         (v[1] < location.bottom && m[1] < location.bottom) ||
+                         (v[0] > location.right && m[0] > location.right) ||
+                         (v[0] < location.left && m[0] < location.left);
     if (pointsInvalid)
         return false;
 
     if (m[0] == v[0]) {//x's are equal, vertical line
-        if (m[1]>v[1]) {
-            m[1]=location.top;
-            v[1]=location.bottom;
+        if (m[1] > v[1]) {
+            m[1] = location.top;
+            v[1] = location.bottom;
         } else {
-            v[1]=location.top;
-            m[1]=location.bottom;
+            v[1] = location.top;
+            m[1] = location.bottom;
         }
         return true;
     }
@@ -316,8 +347,8 @@ bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
         return true;
     }
 
-    double slope = (m[1]-v[1])/(m[0]-v[0]);
-    double b = v[1]-(slope*v[0]);
+    double slope = (m[1] - v[1]) / (m[0] - v[0]);
+    double b = v[1] - (slope * v[0]);
     double y1 = slope * location.left + b;
     double y2 = slope * location.right + b;
     double x1 = (location.bottom - b) / slope;
@@ -360,48 +391,51 @@ bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
     return (counter == 2);
 }
 
-void runway_instr::drawArrow() {
+void runway_instr::drawArrow()
+{
     Point3D ac(0.0), rwy(0.0);
     ac.setlat(current_aircraft.fdm_state->get_Latitude_deg());
     ac.setlon(current_aircraft.fdm_state->get_Longitude_deg());
     rwy.setlat(runway._lat);
     rwy.setlon(runway._lon);
-    float theta = GetHeadingFromTo(ac,rwy);
+    float theta = GetHeadingFromTo(ac, rwy);
     theta -= fgGetDouble("/orientation/heading-deg");
     theta = -theta;
     glMatrixMode(GL_MODELVIEW);
     glPushMatrix();
-    glTranslated((location.right+location.left)/2.0,(location.top+location.bottom)/2.0,0.0);
-    glRotated(theta,0.0,0.0,1.0);
-    glTranslated(0.0,arrowRad,0.0);
-    glScaled(arrowScale,arrowScale,0.0);
+    glTranslated((location.right + location.left) / 2.0,(location.top + location.bottom) / 2.0, 0.0);
+    glRotated(theta, 0.0, 0.0, 1.0);
+    glTranslated(0.0, arrowRad, 0.0);
+    glScaled(arrowScale, arrowScale, 0.0);
 
     glBegin(GL_TRIANGLES);
-    glVertex2d(-5.0,12.5);
-    glVertex2d(0.0,25.0);
-    glVertex2d(5.0,12.5);
+    glVertex2d(-5.0, 12.5);
+    glVertex2d(0.0, 25.0);
+    glVertex2d(5.0, 12.5);
     glEnd();
 
     glBegin(GL_QUADS);
-    glVertex2d(-2.5,0.0);
-    glVertex2d(-2.5,12.5);
-    glVertex2d(2.5,12.5);
-    glVertex2d(2.5,0.0);
+    glVertex2d(-2.5, 0.0);
+    glVertex2d(-2.5, 12.5);
+    glVertex2d(2.5, 12.5);
+    glVertex2d(2.5, 0.0);
     glEnd();
     glPopMatrix();
 }
 
-void runway_instr::setLineWidth() {
+void runway_instr::setLineWidth()
+{
     //Calculate the distance from the runway, A
     double course, distance;
-    calc_gc_course_dist(Point3D(runway._lon*SGD_DEGREES_TO_RADIANS, runway._lat*SGD_DEGREES_TO_RADIANS, 0.0),
-        Point3D(current_aircraft.fdm_state->get_Longitude(),current_aircraft.fdm_state->get_Latitude(), 0.0 ),
-        &course, &distance);
+    calc_gc_course_dist(Point3D(runway._lon * SGD_DEGREES_TO_RADIANS,
+            runway._lat * SGD_DEGREES_TO_RADIANS, 0.0),
+            Point3D(current_aircraft.fdm_state->get_Longitude(),
+            current_aircraft.fdm_state->get_Latitude(), 0.0 ),
+            &course, &distance);
     distance *= SG_METER_TO_NM;
     //Get altitude above runway, B
     double alt_nm = get_agl();
-    static const SGPropertyNode *startup_units_node
-    = fgGetNode("/sim/startup/units");
+    static const SGPropertyNode *startup_units_node = fgGetNode("/sim/startup/units");
 
     if (!strcmp(startup_units_node->getStringValue(), "feet"))
         alt_nm *= SG_FEET_TO_METER*SG_METER_TO_NM;
@@ -409,11 +443,11 @@ void runway_instr::setLineWidth() {
         alt_nm *= SG_METER_TO_NM;
 
     //Calculate distance away from runway, C = v(A²+B²)
-    distance = sqrt(alt_nm*alt_nm + distance*distance);
+    distance = sqrt(alt_nm * alt_nm + distance*distance);
     if (distance < scaleDist)
-        glLineWidth( 1.0+( (lnScale-1)*( (scaleDist-distance)/scaleDist)));
+        glLineWidth(1.0 + ((lnScale - 1) * ((scaleDist - distance) / scaleDist)));
     else
-        glLineWidth( 1.0 );
+        glLineWidth(1.0);
 
 }