From c39a994c8220a4fa3214310e6675bf8f8d0fbb90 Mon Sep 17 00:00:00 2001 From: mfranz <mfranz> Date: Sun, 30 Sep 2007 10:06:28 +0000 Subject: [PATCH] don't draw minor ticks where major ticks are to be drawn (looks ugly on semitransparent huds) --- src/Cockpit/hud_card.cxx | 234 ++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 113 deletions(-) diff --git a/src/Cockpit/hud_card.cxx b/src/Cockpit/hud_card.cxx index 921c5990d..28522e9b8 100644 --- a/src/Cockpit/hud_card.cxx +++ b/src/Cockpit/hud_card.cxx @@ -370,8 +370,80 @@ void hud_card::draw(void) // (HUD_scale * pscale) else k = i; + bool major_tick_drawn = false; + + // Major ticks + if (div_max()) { + if (!(k % (int)div_max())) { + major_tick_drawn = true; + if (modulo()) { + disp_val = i % (int) modulo(); // ????????? + if (disp_val < 0) { + while (disp_val < 0) + disp_val += modulo(); + } + } else { + disp_val = i; + } + + lenstr = sprintf(TextScale, "%d", + float_to_int(disp_val * data_scaling()/*+.5*/)); + // (int)(disp_val * data_scaling() +.5)); + /* if (((marker_ys - 8) > scrn_rect.top) && + ((marker_ys + 8) < (height))){ */ + // huds_both + if (huds_both(options)) { + // drawOneLine(scrn_rect.left, marker_ys, + // marker_xs, marker_ys); + // drawOneLine(marker_xs, marker_ys, + // scrn_rect.left + scrn_rect.right, + // marker_ys); + if (tick_type == "line") { + glBegin(GL_LINE_STRIP); + glVertex2f(scrn_rect.left, marker_ys); + glVertex2f(marker_xs, marker_ys); + glVertex2f(width, marker_ys); + glEnd(); + + } else if (tick_type == "circle") { + circles(scrn_rect.left, (float)marker_ys, 5.0); + + } else { + glBegin(GL_LINE_STRIP); + glVertex2f(scrn_rect.left, marker_ys); + glVertex2f(marker_xs, marker_ys); + glVertex2f(width, marker_ys); + glEnd(); + } + + if (!huds_notext(options)) + textString (marker_xs + 2, marker_ys, TextScale, 0); + + } else { + /* Changes are made to draw a circle when tick_type="circle" */ + // anything other than huds_both + if (tick_type == "line") + drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys); + else if (tick_type == "circle") + circles((float)marker_xs + 4, (float)marker_ys, 5.0); + else + drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys); + + if (!huds_notext(options)) { + if (huds_left(options)) { + textString(marker_xs - 8 * lenstr - 2, + marker_ys - 4, TextScale, 0); + } else { + textString(marker_xe + 3 * lenstr, + marker_ys - 4, TextScale, 0); + } //End if huds_left + } //End if !huds_notext + } //End if huds-both + } // End if draw major ticks + } // End if major ticks + // Minor ticks - if (div_min()) { + if (div_min() && !major_tick_drawn) { // if ((i % div_min()) == 0) { if (!(k % (int)div_min())) { if (((marker_ys - 5) > scrn_rect.top) @@ -450,74 +522,6 @@ void hud_card::draw(void) // (HUD_scale * pscale) } //end draw minor ticks } //end minor ticks - // Major ticks - if (div_max()) { - if (!(k % (int)div_max())) { - if (modulo()) { - disp_val = i % (int) modulo(); // ????????? - if (disp_val < 0) { - while (disp_val < 0) - disp_val += modulo(); - } - } else { - disp_val = i; - } - - lenstr = sprintf(TextScale, "%d", - float_to_int(disp_val * data_scaling()/*+.5*/)); - // (int)(disp_val * data_scaling() +.5)); - /* if (((marker_ys - 8) > scrn_rect.top) && - ((marker_ys + 8) < (height))){ */ - // huds_both - if (huds_both(options)) { - // drawOneLine(scrn_rect.left, marker_ys, - // marker_xs, marker_ys); - // drawOneLine(marker_xs, marker_ys, - // scrn_rect.left + scrn_rect.right, - // marker_ys); - if (tick_type == "line") { - glBegin(GL_LINE_STRIP); - glVertex2f(scrn_rect.left, marker_ys); - glVertex2f(marker_xs, marker_ys); - glVertex2f(width, marker_ys); - glEnd(); - - } else if (tick_type == "circle") { - circles(scrn_rect.left, (float)marker_ys, 5.0); - - } else { - glBegin(GL_LINE_STRIP); - glVertex2f(scrn_rect.left, marker_ys); - glVertex2f(marker_xs, marker_ys); - glVertex2f(width, marker_ys); - glEnd(); - } - - if (!huds_notext(options)) - textString (marker_xs + 2, marker_ys, TextScale, 0); - - } else { - /* Changes are made to draw a circle when tick_type="circle" */ - // anything other than huds_both - if (tick_type == "line") - drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys); - else if (tick_type == "circle") - circles((float)marker_xs + 4, (float)marker_ys, 5.0); - else - drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys); - - if (!huds_notext(options)) { - if (huds_left(options)) { - textString(marker_xs - 8 * lenstr - 2, - marker_ys - 4, TextScale, 0); - } else { - textString(marker_xe + 3 * lenstr, - marker_ys - 4, TextScale, 0); - } //End if huds_left - } //End if !huds_notext - } //End if huds-both - } // End if draw major ticks - } // End if major ticks } // End condition } // End for } //end of zoom @@ -668,50 +672,7 @@ void hud_card::draw(void) // (HUD_scale * pscale) else k = i; - if (div_min()) { - // if ((i % (int)div_min()) == 0) { - //draw minor ticks - if (!(k % (int)div_min())) { - // draw in ticks only if they aren't too close to the edge. - if (((marker_xs - 5) > scrn_rect.left) - && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) { - - if (huds_both(options)) { - if (tick_length == "variable") { - drawOneLine(marker_xs, scrn_rect.top, - marker_xs, marker_ys - 4); - drawOneLine(marker_xs, marker_ye + 4, - marker_xs, height); - } else { - drawOneLine(marker_xs, scrn_rect.top, - marker_xs, marker_ys); - drawOneLine(marker_xs, marker_ye, - marker_xs, height); - } - // glBegin(GL_LINES); - // glVertex2f(marker_xs, scrn_rect.top); - // glVertex2f(marker_xs, marker_ys - 4); - // glVertex2f(marker_xs, marker_ye + 4); - // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom); - // glEnd(); - - } else { - if (huds_top(options)) { - //draw minor ticks - if (tick_length == "variable") - drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4); - else - drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye); - - } else if (tick_length == "variable") { - drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye); - } else { - drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye); - } - } - } - } //end draw minor ticks - } //end minor ticks + bool major_tick_drawn = false; //major ticks if (div_max()) { @@ -720,6 +681,7 @@ void hud_card::draw(void) // (HUD_scale * pscale) // draw major ticks if (!(k % (int)div_max())) { + major_tick_drawn = true; if (modulo()) { disp_val = i % (int) modulo(); // ????????? if (disp_val < 0) { @@ -770,6 +732,52 @@ void hud_card::draw(void) // (HUD_scale * pscale) } } //end draw major ticks } //endif major ticks + + if (div_min() && !major_tick_drawn) { + // if ((i % (int)div_min()) == 0) { + //draw minor ticks + if (!(k % (int)div_min())) { + // draw in ticks only if they aren't too close to the edge. + if (((marker_xs - 5) > scrn_rect.left) + && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) { + + if (huds_both(options)) { + if (tick_length == "variable") { + drawOneLine(marker_xs, scrn_rect.top, + marker_xs, marker_ys - 4); + drawOneLine(marker_xs, marker_ye + 4, + marker_xs, height); + } else { + drawOneLine(marker_xs, scrn_rect.top, + marker_xs, marker_ys); + drawOneLine(marker_xs, marker_ye, + marker_xs, height); + } + // glBegin(GL_LINES); + // glVertex2f(marker_xs, scrn_rect.top); + // glVertex2f(marker_xs, marker_ys - 4); + // glVertex2f(marker_xs, marker_ye + 4); + // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom); + // glEnd(); + + } else { + if (huds_top(options)) { + //draw minor ticks + if (tick_length == "variable") + drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4); + else + drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye); + + } else if (tick_length == "variable") { + drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye); + } else { + drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye); + } + } + } + } //end draw minor ticks + } //end minor ticks + } //end condition } //end for } //end zoom