]> git.mxchange.org Git - flightgear.git/commitdiff
fix <modulo> feature (required for the compass tape)
authormfranz <mfranz>
Thu, 6 Jul 2006 16:46:25 +0000 (16:46 +0000)
committermfranz <mfranz>
Thu, 6 Jul 2006 16:46:25 +0000 (16:46 +0000)
src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_gauge.cxx
src/Instrumentation/HUD/HUD_tape.cxx

index 678b197762d731c4175752a0c8194b9774aca8aa..42e334f12d2e7df376c59991802929a75ec911b7 100644 (file)
@@ -457,18 +457,17 @@ public:
     virtual void draw    ( void ) {}  // No-op here. Defined in derived classes.
 
 protected:
-    inline unsigned int modulo() const { return _modulo; }
     inline float factor() const { return _display_factor; }
     inline float range_to_show() const { return _range_shown; }
 
     Input _input;
-    float _major_divs;  // major division marker units
-    float _minor_divs;  // minor division marker units
+    float _major_divs;      // major division marker units
+    float _minor_divs;      // minor division marker units
+    unsigned int _modulo;   // Roll over point
 
 private:
     float _range_shown;     // Width Units.
     float _display_factor;  // factor => screen units/range values.
-    unsigned int _modulo;   // Roll over point
 };
 
 
index 5c9e99df0115c4a47ad8a37f80f12479bf0f57cd..f0b95fc24a7525a696bf0f60baaaf9d2a6285e09 100644 (file)
@@ -219,7 +219,7 @@ void HUD::Gauge::draw(void)
         i = (int)vmin;
         for (; i <last ; i++) {
             condition = true;
-            if (!modulo() && i < _input.min())
+            if (!_modulo && i < _input.min())
                     condition = false;
 
             if (condition) {
@@ -246,12 +246,12 @@ void HUD::Gauge::draw(void)
 
                 if (_major_divs) {
                     if (!(i % (int)_major_divs)) {
-                        if (modulo()) {
+                        if (_modulo) {
                             if (disp_val < 0) {
                                 while (disp_val < 0)
-                                    disp_val += modulo();
+                                    disp_val += _modulo;
                             }
-                            disp_val = i % (int)modulo();
+                            disp_val = i % (int)_modulo;
                         } else {
                             disp_val = i;
                         }
index 5c7e81e66ecd914ce4f0eee1216f213684bf29e0..ec77b3e5243ce2ff2b57c2e1e68b394c7b40e8c9 100644 (file)
@@ -274,7 +274,7 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
             for (int i = 0; ; i++) {
                 float v = vstart + i * _minor_divs;
 
-                if (!modulo() && (v < _input.min() || v > _input.max()))
+                if (!_modulo && (v < _input.min() || v > _input.max()))
                     continue;
 
                 float y = _y + (v - vmin) * factor();
@@ -342,7 +342,11 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
                     } // end huds both
 
                 } else { // major div
-                    lenstr = snprintf(buf, BUFSIZE, "%d", int(v));
+                    int display_value = int(v);
+                    if (_modulo)
+                        display_value %= _modulo;
+
+                    lenstr = snprintf(buf, BUFSIZE, "%d", display_value);
 
                     if (option_both()) {
                         // draw_line(_x, y, marker_xs, y);
@@ -501,7 +505,7 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
             for (int i = 0; ; i++) {
                 float v = vstart + i * _minor_divs;
 
-                if (!modulo() && (v < _input.min() || v > _input.max()))
+                if (!_modulo && (v < _input.min() || v > _input.max()))
                     continue;
 
                 float x = _x + (v - vmin) * factor();
@@ -543,7 +547,11 @@ void HUD::Tape::draw(void) //  (HUD_scale * pscale)
                     }
 
                 } else { // major divs
-                    lenstr = snprintf(buf, BUFSIZE, "%d", int(v));
+                    int display_value = int(v);
+                    if (_modulo)
+                        display_value %= _modulo;
+
+                    lenstr = snprintf(buf, BUFSIZE, "%d", display_value);
 
                     // Draw major ticks and text only if far enough from the edge.                     // FIXME
                     if (x < _x + 10 || x + 10 > _x + _w)