]> git.mxchange.org Git - flightgear.git/commitdiff
get rid of struct Point and get_centroid(). Instruments may access *their*
authormfranz <mfranz>
Sat, 22 Jul 2006 10:09:36 +0000 (10:09 +0000)
committermfranz <mfranz>
Sat, 22 Jul 2006 10:09:36 +0000 (10:09 +0000)
properties directly. This is properly encapsulated already.

src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_gauge.cxx
src/Instrumentation/HUD/HUD_instrument.cxx
src/Instrumentation/HUD/HUD_ladder.cxx
src/Instrumentation/HUD/HUD_misc.cxx
src/Instrumentation/HUD/HUD_runway.cxx
src/Instrumentation/HUD/HUD_tape.cxx
src/Instrumentation/HUD/HUD_tbi.cxx

index b67aab7165e127d5fd428e5cb680f612f1f74bc0..b2d5a1e0da4c1d65be02fd675afc7fa00f484895 100644 (file)
@@ -200,10 +200,6 @@ public:
     void init();
     void update(double);
 
-    typedef struct {
-        float x, y;
-    } Point;
-
     // called from Main/renderer.cxx to draw 2D and 3D HUD
     void draw();
 
@@ -380,7 +376,6 @@ public:
 
 protected:
     inline float get_span()       const { return _scr_span; }
-    inline Point get_centroid()   const { return _mid_span; }
     inline int   get_digits()     const { return _digits; }
 
     inline bool option_vert()    const { return (_options & VERT) == VERT; }
@@ -403,12 +398,12 @@ protected:
     string      _name;
     int         _options;
     float       _x, _y, _w, _h;
+    float       _center_x, _center_y;
 
 private:
     SGCondition *_condition;
     float       _disp_factor;   // Multiply by to get numbers shown on scale.
     float       _scr_span;      // Working values for draw;
-    Point       _mid_span;
     int         _digits;
 };
 
@@ -633,7 +628,6 @@ private:
     bool   _draw_arrow;             // draw arrow when runway is not visible in HUD
     bool   _draw_arrow_always;      // always draws arrow
     float  _left, _right, _top, _bottom;
-    Point  _center;
 };
 
 
index f0b95fc24a7525a696bf0f60baaaf9d2a6285e09..b676484f5a1753448bf4bf7f097ea720d990e862 100644 (file)
@@ -51,7 +51,6 @@ void HUD::Gauge::draw(void)
     int disp_val = 0;
     float vmin = _input.min();
     float vmax = _input.max();
-    Point mid_scr = get_centroid();
     float cur_value = _input.getFloatValue();
 
     width = _x + _w;                                           // FIXME huh?
@@ -137,7 +136,7 @@ void HUD::Gauge::draw(void)
                             lenstr = text_width(buf);
 
                             if (option_left() && option_right()) {
-                                text_x = mid_scr.x - lenstr/2 ;
+                                text_x = _center_x - lenstr/2 ;
 
                             } else if (option_left()) {
                                 text_x = marker_xs - lenstr;
index e68781f7630232f5d084841404ef38655a1006c4..d7d1f7747566f62d69209a2b37659866ea381d1b 100644 (file)
@@ -84,8 +84,8 @@ HUD::Item::Item(HUD *hud, const SGPropertyNode *n, float x, float y) :
         _scr_span = _w;
     }
 
-    _mid_span.x = _x + _w / 2.0;
-    _mid_span.y = _y + _h / 2.0;
+    _center_x = _x + _w / 2.0;
+    _center_y = _y + _h / 2.0;
 }
 
 
index 81b95ad74bf09790baac6362d188d7312c3e7cea..fd132ec83c5dac8b1c19dff381832266bf179039 100644 (file)
@@ -96,8 +96,6 @@ void HUD::Ladder::draw(void)
     GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
     GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
 
-    Point centroid = get_centroid();
-
     float half_span = _w / 2.0;
     float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;         // FIXME rad/deg conversion
     alpha = get__aoa();
@@ -127,7 +125,7 @@ void HUD::Ladder::draw(void)
     //**************************************************************
     glPushMatrix();
     // define (0, 0) as center of screen
-    glTranslatef(centroid.x, centroid.y, 0);
+    glTranslatef(_center_x, _center_y, 0);
 
     // OBJECT STATIC RETICLE
     // TYPE FRL (FUSELAGE REFERENCE LINE)
@@ -307,14 +305,14 @@ void HUD::Ladder::draw(void)
 #ifdef ENABLE_SP_FDM
     if (_alpha_bracket && ihook == 1) {
         glBegin(GL_LINE_STRIP);
-        glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * _compression);
+        glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
         glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
         glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
         glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
         glEnd();
 
         glBegin(GL_LINE_STRIP);
-        glVertex2f(vel_x + 20 , vel_y - (16 - alpha) * _compression);
+        glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
         glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
         glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
         glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
@@ -635,7 +633,7 @@ void HUD::Ladder::draw(void)
         // waypoint marker
         if (fabs(brg-psi) > 10.0) {
             glPushMatrix();
-            glTranslatef(centroid.x, centroid.y, 0);
+            glTranslatef(_center_x, _center_y, 0);
             glTranslatef(vel_x, vel_y, 0);
             glRotatef(brg - psi, 0.0, 0.0, -1.0);
             glBegin(GL_LINE_LOOP);
index ac7765592c9175a37686e8ca163e71a2feb7d231..fce0ada2d88d95d3158b226b5fb4eb00b4df6710 100644 (file)
@@ -46,9 +46,8 @@ void HUD::AimingReticle::draw(void)
     bool active = _active_condition ? _active_condition->test() : true;
     float diameter = _diameter.isValid() ? _diameter.getFloatValue() : 2.0f; // outer circle
 
-    Point centroid = get_centroid();
-    float x = centroid.x;
-    float y = centroid.y;
+    float x = _center_x;
+    float y = _center_y;
 
     if (active) { // stadiametric (4.2.4.4)
         draw_bullet(x, y, _bullet_size);
index bff02fb013b73bbd1ad9dade62940468f2039c2c..0f12f2952a7f38c1f87b4b7f26d41c1fb81d24e5 100644 (file)
@@ -60,13 +60,13 @@ HUD::Runway::Runway(HUD *hud, const SGPropertyNode *node, float x, float y) :
     _view[2] = 640;
     _view[3] = 480;
 
-    _center.x = _view[2] / 2;
-    _center.y = _view[3] / 2;
+    _center_x = _view[2] / 2;
+    _center_y = _view[3] / 2;
 
-    _left = _center.x - (_w / 2) + _x;
-    _right = _center.x + (_w / 2) + _x;
-    _bottom = _center.y - (_h / 2) + _y;
-    _top = _center.y + (_h / 2) + _y;
+    _left = _center_x - (_w / 2) + _x;
+    _right = _center_x + (_w / 2) + _x;
+    _bottom = _center_y - (_h / 2) + _y;
+    _top = _center_y + (_h / 2) + _y;
 }
 
 
index 7e8715798afb55b30f2878fae0f5d09dfedfbabc..8decc7bccfce9885da8023bdf54f97a1b513137a 100644 (file)
@@ -66,7 +66,6 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
     int oddtype;
 //    int k; //odd or even values for ticks            // FIXME odd scale
 
-    Point mid_scr = get_centroid();
     float cur_value = _input.getFloatValue();
 
     if (int(floor(_input.max() + 0.5)) & 1)
@@ -86,15 +85,15 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
         } else { // FIXED
             vmin = cur_value - _half_width_units; // width units == needle travel
             vmax = cur_value + _half_width_units; // or picture unit span.
-            text_x = mid_scr.x;
-            text_y = mid_scr.y;
+            text_x = _center_x;
+            text_y = _center_y;
         }
 
     } else {
         vmin = cur_value - _half_width_units; // width units == needle travel
         vmax = cur_value + _half_width_units; // or picture unit span.
-        text_x = mid_scr.x;
-        text_y = mid_scr.y;
+        text_x = _center_x;
+        text_y = _center_y;
     }
 
 
@@ -142,8 +141,8 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
 
             marker_xs = marker_xe - _w / 3.0;
 
-            // draw_line(marker_xs, mid_scr.y, marker_xe, mid_scr.y + _w / 6);
-            // draw_line(marker_xs, mid_scr.y, marker_xe, mid_scr.y - _w / 6);
+            // draw_line(marker_xs, _center_y, marker_xe, _center_y + _w / 6);
+            // draw_line(marker_xs, _center_y, marker_xe, _center_y - _w / 6);
 
             // draw pointer
             if (_pointer) {
@@ -156,7 +155,7 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
                         if (_input.min() >= 0.0)
                             ycentre = _y;
                         else if (_input.max() + _input.min() == 0.0)
-                            ycentre = mid_scr.y;
+                            ycentre = _center_y;
                         else if (oddtype)
                             ycentre = _y + (1.0 - _input.min()) * _h
                                     / (_input.max() - _input.min());
@@ -198,8 +197,8 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
 
             marker_xe = _x + _w / 3.0;
             // Indicator carrot
-            // draw_line(_x, mid_scr.y +  _w / 6, marker_xe, mid_scr.y);
-            // draw_line(_x, mid_scr.y -  _w / 6, marker_xe, mid_scr.y);
+            // draw_line(_x, _center_y +  _w / 6, marker_xe, _center_y);
+            // draw_line(_x, _center_y -  _w / 6, marker_xe, _center_y);
 
             // draw pointer
             if (_pointer) {
@@ -213,7 +212,7 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
                         if (_input.min() >= 0.0)
                             ycentre = _y;
                         else if (_input.max() + _input.min() == 0.0)
-                            ycentre = mid_scr.y;
+                            ycentre = _center_y;
                         else if (oddtype)
                             ycentre = _y + (1.0 - _input.min()) * _h / (_input.max() - _input.min());
                         else
@@ -408,15 +407,15 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
             // Tick point adjust
             marker_ye  = _y + _h / 2;
             // Bottom arrow
-            // draw_line(mid_scr.x, marker_ye, mid_scr.x - _h / 4, _y);
-            // draw_line(mid_scr.x, marker_ye, mid_scr.x + _h / 4, _y);
+            // draw_line(_center_x, marker_ye, _center_x - _h / 4, _y);
+            // draw_line(_center_x, marker_ye, _center_x + _h / 4, _y);
             // draw pointer
             if (_pointer) {
                 if (_pointer_type == MOVING) {
                     if (!_zoom) {
                         //Code for Moving Type Pointer
 
-                        float xcentre = mid_scr.x;
+                        float xcentre = _center_x;
                         float range = _w;
                         float xpoint = xcentre + (cur_value * range / _val_span);
                         float ypoint = _y - _marker_offset;
@@ -441,8 +440,8 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
             // Tick point adjust
             marker_ys = top - _h / 2;
             // Top arrow
-            // draw_line(mid_scr.x + _h / 4, _y + _h, mid_scr.x, marker_ys);
-            // draw_line(mid_scr.x - _h / 4, _y + _h, mid_scr.x , marker_ys);
+            // draw_line(_center_x + _h / 4, _y + _h, _center_x, marker_ys);
+            // draw_line(_center_x - _h / 4, _y + _h, _center_x , marker_ys);
 
             // draw pointer
             if (_pointer) {
@@ -450,7 +449,7 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
                     if (!_zoom) {
                         //Code for Moving Type Pointer
 
-                        float xcentre = mid_scr.x ;
+                        float xcentre = _center_x;
                         float range = _w;
                         float hgt = _y + _h;
                         float xpoint = xcentre + (cur_value * range / _val_span);
@@ -582,7 +581,6 @@ void HUD::Tape::fixed(float x1, float y1, float x2, float y2, float x3, float y3
 
 void HUD::Tape::zoomed_scale(int first, int last)
 {
-    Point mid_scr = get_centroid();
     const int BUFSIZE = 80;
     char buf[BUFSIZE];
     int data[80];
@@ -594,7 +592,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
     while (first <= last) {
         if ((first % (int)_major_divs) == 0) {
             data[a] = first;
-            a++ ;
+            a++;
         }
         first++;
     }
@@ -610,9 +608,9 @@ void HUD::Tape::zoomed_scale(int first, int last)
         float xstart, yfirst, ycentre, ysecond;
 
         float hgt = bottom * 20.0 / 100.0;  // 60% of height should be zoomed
-        yfirst = mid_scr.y - hgt;
-        ycentre = mid_scr.y;
-        ysecond = mid_scr.y + hgt;
+        yfirst = _center_y - hgt;
+        ycentre = _center_y;
+        ysecond = _center_y + hgt;
         float range = hgt * 2;
 
         int i;
@@ -628,7 +626,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
         static float ycent, ypoint, xpoint;                                    // FIXME really static?
         static float wth;
 
-        ycent = mid_scr.y;
+        ycent = _center_y;
         wth = _x + _w;
 
         if (cur_value <= data[centre + 1])
@@ -676,7 +674,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
                 draw_bullet(xstart - 2.5, ycentre, 3.0);
             }
 
-            yfirst = mid_scr.y - hgt;
+            yfirst = _center_y - hgt;
 
             for (i = 0; i <= incr; i++) {
                 draw_line(xstart, yfirst, xstart - 5.0, yfirst);
@@ -727,7 +725,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
                 draw_bullet(xstart + 2.5, ycentre, 3.0);
             }
 
-            yfirst = mid_scr.y - hgt;
+            yfirst = _center_y - hgt;
 
             for (i = 0; i <= incr; i++) {
                 draw_line(xstart, yfirst, xstart + 5.0, yfirst);
@@ -773,9 +771,9 @@ void HUD::Tape::zoomed_scale(int first, int last)
         float ystart, xfirst, xcentre, xsecond;
 
         float hgt = bottom * 20.0 / 100.0;  // 60% of height should be zoomed
-        xfirst = mid_scr.x - hgt;
-        xcentre = mid_scr.x;
-        xsecond = mid_scr.x + hgt;
+        xfirst = _center_x - hgt;
+        xcentre = _center_x;
+        xsecond = _center_x + hgt;
         float range = hgt * 2;
 
         int i;
@@ -791,7 +789,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
         //begin
         static float xcent, xpoint, ypoint;                            // FIXME really static?
 
-        xcent = mid_scr.x;
+        xcent = _center_x;
 
         if (cur_value <= data[centre + 1])
             if (cur_value > data[centre]) {
@@ -839,7 +837,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
                 draw_bullet(xcentre, ystart - 2.5, 3.0);
             }
 
-            xfirst = mid_scr.x - hgt;
+            xfirst = _center_x - hgt;
 
             for (i = 0; i <= incr; i++) {
                 draw_line(xfirst, ystart, xfirst,  ystart - 5.0);
@@ -891,7 +889,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
                 draw_bullet(xcentre, ystart + 2.5, 3.0);
             }
 
-            xfirst = mid_scr.x - hgt;
+            xfirst = _center_x - hgt;
 
             for (i = 0; i <= incr; i++) {
                 draw_line(xfirst, ystart, xfirst, ystart + 5.0);
index eb4c1d5a2574b44abbea779eb71ffe597b0f2d24..4782f2b598bae894a324e9bd1702ac50f720f752 100644 (file)
@@ -48,17 +48,13 @@ void HUD::TurnBankIndicator::draw(void)
     float sideslip = _sideslip.getFloatValue();
 
     float span = get_span();
-    Point centroid = get_centroid();
-
-    float cen_x = centroid.x;
-    float cen_y = centroid.y;
 
     float tee_height = _h;
     float tee = -tee_height;
     float ss_const = 2 * sideslip * span / 40.0;  // sideslip angle pixels per deg (width represents 40 deg)
 
     glPushMatrix();
-    glTranslatef(cen_x, cen_y, 0.0);
+    glTranslatef(_center_x, _center_y, 0.0);
     glRotatef(-bank, 0.0, 0.0, 1.0);
 
     if (!_bank_scale) {
@@ -91,10 +87,10 @@ void HUD::TurnBankIndicator::draw(void)
 
 
     } else { // draw MIL-STD 1878B/4.2.2.4 bank scale
-        draw_line(cen_x - 1.0, _y, cen_x + 1.0, _y);
-        draw_line(cen_x - 1.0, _y, cen_x - 1.0, _y + 10.0);
-        draw_line(cen_x + 1.0, _y, cen_x + 1.0, _y + 10.0);
-        draw_line(cen_x - 1.0, _y + 10.0, cen_x + 1.0, _y + 10.0);
+        draw_line(_center_x - 1.0, _y, _center_x + 1.0, _y);
+        draw_line(_center_x - 1.0, _y, _center_x - 1.0, _y + 10.0);
+        draw_line(_center_x + 1.0, _y, _center_x + 1.0, _y + 10.0);
+        draw_line(_center_x - 1.0, _y + 10.0, _center_x + 1.0, _y + 10.0);
 
         float x1, y1, x2, y2, x3, y3, x4, y4, x5, y5;
         float xc, yc;