1
0
Fork 0

- fix more cases of scale tick aliasing to get smooth scale movements

- remove trailing spaces, fix indentation, unify coding style, ...
This commit is contained in:
mfranz 2006-06-12 23:27:55 +00:00
parent 365546444c
commit b674037a3c
2 changed files with 948 additions and 944 deletions

View file

@ -7,21 +7,19 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, digit) TextString( text, x , y ,digit ) //suma
#define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
//========== Top of hud_card class member definitions =============
//begin suma
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
//end suma
hud_card ::
hud_card( int x,
hud_card::hud_card(
int x,
int y,
UINT width,
UINT height,
@ -50,10 +48,9 @@ hud_card( int x,
string type_tick,//hud
string length_tick,//hud
bool working,
float rad,//suma
int divs, //suma
int zooms //suma
) : //suma
float rad,
int divs,
int zooms) :
instr_scale(x,y,width,height,
data_source, options,
value_span,
@ -75,16 +72,16 @@ hud_card( int x,
pointer_type (type_pointer),
tick_type (type_tick), //hud
tick_length (length_tick), //hud
Maj_div (major_divs), //suma
Min_div (minor_divs) //suma
Maj_div (major_divs),
Min_div (minor_divs)
{
half_width_units = range_to_show() / 2.0;
radius=rad; //suma
maxValue=max_value; //suma
minValue=min_value; //suma
divisions=divs; //suma
zoom = zooms; //suma
radius = rad;
maxValue = max_value;
minValue = min_value;
divisions = divs;
zoom = zooms;
// UINT options = get_options();
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
@ -96,11 +93,11 @@ hud_card( int x,
// huds_bottom = options & HUDS_BOTTOM;
}
hud_card ::
~hud_card() { }
hud_card ::
hud_card( const hud_card & image):
hud_card::~hud_card() { }
hud_card::hud_card(const hud_card & image) :
instr_scale((const instr_scale &) image),
val_span(image.val_span),
type(image.type),
@ -118,8 +115,8 @@ hud_card( const hud_card & image):
pointer_type (image.pointer_type),
tick_type(image.tick_type), //hud
tick_length(image.tick_length), //hud
Maj_div(image.Maj_div), //suma
Min_div(image.Min_div)//suma
Maj_div(image.Maj_div),
Min_div(image.Min_div)
{
// UINT options = get_options();
@ -132,8 +129,8 @@ hud_card( const hud_card & image):
// huds_bottom = options & HUDS_BOTTOM;
}
hud_card & hud_card ::
operator = (const hud_card & rhs )
hud_card & hud_card::operator=(const hud_card & rhs)
{
if (!(this == &rhs)) {
instr_scale::operator = (rhs);
@ -153,18 +150,16 @@ operator = (const hud_card & rhs )
pointer_type = rhs.pointer_type;
tick_type = rhs.tick_type;
tick_length = rhs.tick_length;
Maj_div = rhs.Maj_div; //suma
Min_div = rhs.Min_div; //suma
Maj_div = rhs.Maj_div;
Min_div = rhs.Min_div;
}
return *this;
}
void hud_card ::
draw( void ) // (HUD_scale * pscale )
{
void hud_card::draw(void) // (HUD_scale * pscale)
{
float vmin = 0.0, vmax = 0.0;
float marker_xs;
float marker_xe;
@ -193,7 +188,6 @@ draw( void ) // (HUD_scale * pscale )
height = scrn_rect.top + scrn_rect.bottom;
width = scrn_rect.left + scrn_rect.right;
//begin suma
// if type=gauge then display dial
if (type == "gauge") {
float x,y;
@ -245,16 +239,15 @@ draw( void ) // (HUD_scale * pscale )
else if (l<360)
textString(x-2.0, y, TextScale, 0);
}
} //end type=gauge
}
//end type=gauge
} else {
// if its not explicitly a gauge default to tape
if (pointer) {
if (pointer_type=="moving") {
vmin = minValue;
vmax = maxValue;
} else {
// default to fixed
vmin = cur_value - half_width_units; // width units == needle travel
@ -262,6 +255,7 @@ draw( void ) // (HUD_scale * pscale )
text_x = mid_scr.x;
text_y = mid_scr.y;
}
} else {
vmin = cur_value - half_width_units; // width units == needle travel
vmax = cur_value + half_width_units; // or picture unit span.
@ -278,6 +272,7 @@ draw( void ) // (HUD_scale * pscale )
width,
scrn_rect.top);
} // endif draw_tick_bottom
if (draw_tick_top) {
drawOneLine(scrn_rect.left, // Top tick bar
height,
@ -310,7 +305,6 @@ draw( void ) // (HUD_scale * pscale )
if (huds_left(options)) { // Calculate x marker offset
if (draw_cap_right) {
drawOneLine(marker_xe, scrn_rect.top,
marker_xe, marker_ye); // Cap right side
} //endif cap_right
@ -326,11 +320,14 @@ draw( void ) // (HUD_scale * pscale )
if (pointer) {
if (pointer_type=="moving") {
if (zoom == 0) {
//Code for Moving Type Pointer included by suma.
//Code for Moving Type Pointer
float ycentre, ypoint,xpoint;
int range,wth;
if(cur_value > maxValue) cur_value = maxValue;
if(cur_value < minValue) cur_value = minValue;
if (cur_value > maxValue)
cur_value = maxValue;
if (cur_value < minValue)
cur_value = minValue;
if (minValue >= 0.0)
ycentre = scrn_rect.top;
else if (maxValue + minValue == 0.0)
@ -340,25 +337,28 @@ draw( void ) // (HUD_scale * pscale )
ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
else
ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
range = scrn_rect.bottom;
wth = scrn_rect.left + scrn_rect.right;
if (oddtype == 1)
ypoint = ycentre + ((cur_value-1.0) * range / val_span);
else
ypoint = ycentre + (cur_value * range / val_span);
xpoint = wth + marker_offset;
drawOneLine(xpoint,ycentre,xpoint,ypoint);
drawOneLine(xpoint,ypoint,xpoint-marker_offset,ypoint);
drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint+5.0);
drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint-5.0);
} //zoom=0
} else {
// default to fixed
fixed(marker_offset+marker_xe, text_y + scrn_rect.right / 6,
marker_offset+marker_xs, text_y,marker_offset+marker_xe,
text_y - scrn_rect.right / 6);
}//end pointer type
} //if pointer
} //end vertical/left
@ -382,7 +382,7 @@ draw( void ) // (HUD_scale * pscale )
if (pointer_type == "moving") {
if (zoom == 0) {
//type-fixed & zoom=1, behaviour to be defined
// Code for Moving Type Pointer included by suma.
// Code for Moving Type Pointer
float ycentre, ypoint,xpoint;
int range;
@ -400,18 +400,21 @@ draw( void ) // (HUD_scale * pscale )
ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
else
ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
range = scrn_rect.bottom;
if (oddtype == 1)
ypoint = ycentre + ((cur_value-1.0) * range / val_span);
else
ypoint = ycentre + (cur_value * range / val_span);
xpoint = scrn_rect.left - marker_offset;
drawOneLine(xpoint,ycentre,xpoint,ypoint);
drawOneLine(xpoint,ypoint,xpoint+marker_offset,ypoint);
drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint+5.0);
drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint-5.0);
}
} else {
// default to fixed
fixed(-marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6,
@ -440,7 +443,7 @@ draw( void ) // (HUD_scale * pscale )
i = (int)vmin; // N
if (zoom == 1) {
zoomed_scale((int)vmin,(int)vmax); //suma
zoomed_scale((int)vmin, (int)vmax);
} else {
for (; i < last; i++) {
condition = true;
@ -452,14 +455,13 @@ draw( void ) // (HUD_scale * pscale )
if (condition) { // Show a tick if necessary
// Calculate the location of this tick
marker_ys = scrn_rect.top + (i - vmin) * factor()/*+.5f*/;
marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
// marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
// Block calculation artifact from drawing ticks below min coordinate.
// Calculation here accounts for text height.
if(( marker_ys < (scrn_rect.top + 4)) |
( marker_ys > (height - 4)))
{
if ((marker_ys < (scrn_rect.top + 4))
| (marker_ys > (height - 4))) {
// Magic numbers!!!
continue;
}
@ -473,8 +475,8 @@ draw( void ) // (HUD_scale * pscale )
if (div_min()) {
// if ((i%div_min()) == 0) {
if (!(k%(int)div_min())) {
if((( marker_ys - 5) > scrn_rect.top ) &&
(( marker_ys + 5) < (height))) {
if (((marker_ys - 5) > scrn_rect.top)
&& ((marker_ys + 5) < (height))) {
//vertical/left OR vertical/right
if (huds_both(options)) {
@ -490,8 +492,8 @@ draw( void ) // (HUD_scale * pscale )
drawOneLine(marker_xe, marker_ys,
width, marker_ys);
}
} else if(tick_type=="circle") // begin suma this func. is written below
circles(scrn_rect.left,(float)marker_ys,3.0); //end suma
} else if (tick_type == "circle")
circles(scrn_rect.left,(float)marker_ys,3.0);
else {
// if neither line nor circle draw default as line
@ -507,6 +509,7 @@ draw( void ) // (HUD_scale * pscale )
// glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
// glEnd();
// anything other than huds_both
} else {
if (huds_left(options)) {
if (tick_type=="line") {
@ -517,8 +520,8 @@ draw( void ) // (HUD_scale * pscale )
drawOneLine(marker_xs , marker_ys,
marker_xe, marker_ys);
}
} else if(tick_type=="circle") // begin suma
circles((float)marker_xs + 4, (float)marker_ys,3.0); //end suma
} else if (tick_type=="circle")
circles((float)marker_xs + 4, (float)marker_ys,3.0);
else {
drawOneLine(marker_xs + 4, marker_ys,
@ -533,8 +536,8 @@ draw( void ) // (HUD_scale * pscale )
drawOneLine(marker_xs, marker_ys,
marker_xe , marker_ys);
}
} else if(tick_type=="circle") //begin suma
circles((float)marker_xe - 4, (float)marker_ys,3.0); //end suma
} else if (tick_type=="circle")
circles((float)marker_xe - 4, (float)marker_ys,3.0);
else {
drawOneLine(marker_xs, marker_ys,
marker_xe - 4, marker_ys);
@ -547,7 +550,6 @@ draw( void ) // (HUD_scale * pscale )
// Major ticks
if (div_max()) {
if (!(k%(int)div_max())) {
if (modulo()) {
disp_val = i % (int) modulo(); // ?????????
@ -563,7 +565,7 @@ draw( void ) // (HUD_scale * pscale )
FloatToInt(disp_val * data_scaling()/*+.5*/));
// (int)(disp_val * data_scaling() +.5));
/* if (((marker_ys - 8) > scrn_rect.top) &&
( (marker_ys + 8) < (height))){ */ //suma
((marker_ys + 8) < (height))){ */
// huds_both
if (huds_both(options)) {
// drawOneLine(scrn_rect.left, marker_ys,
@ -577,9 +579,9 @@ draw( void ) // (HUD_scale * pscale )
glVertex2f(marker_xs, marker_ys);
glVertex2f(width, marker_ys);
glEnd();
} else if(tick_type=="circle") //begin suma
circles(scrn_rect.left, (float)marker_ys,5.0); //end suma
else {
} 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);
@ -591,17 +593,18 @@ draw( void ) // (HUD_scale * pscale )
textString (marker_xs + 2, marker_ys,
TextScale,0);
}
} else {
//begin suma
/* 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);//end suma
else {
} 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,
@ -620,6 +623,7 @@ draw( void ) // (HUD_scale * pscale )
} // End for
} //end of zoom
// End if VERTICAL SCALE TYPE (tape loop yet to be closed)
} else {
// Horizontal scale by default
// left tick bar
@ -637,8 +641,7 @@ draw( void ) // (HUD_scale * pscale )
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xe = width;
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
// glBegin(GL_LINES);
// left tick bar
@ -670,11 +673,14 @@ draw( void ) // (HUD_scale * pscale )
if (pointer) {
if (pointer_type == "moving") {
if (zoom == 0) {
//Code for Moving Type Pointer included by suma.
//Code for Moving Type Pointer
// static float xcentre,xpoint,ypoint;
// static int range;
if(cur_value > maxValue) cur_value = maxValue;
if(cur_value < minValue) cur_value = minValue;
if (cur_value > maxValue)
cur_value = maxValue;
if (cur_value < minValue)
cur_value = minValue;
float xcentre = mid_scr.x;
int range = scrn_rect.right;
float xpoint = xcentre + (cur_value * range / val_span);
@ -713,11 +719,14 @@ draw( void ) // (HUD_scale * pscale )
if (pointer) {
if (pointer_type =="moving") {
if (zoom == 0) {
//Code for Moving Type Pointer included by suma.
//Code for Moving Type Pointer
// static float xcentre,xpoint,ypoint;
// static int range,hgt;
if(cur_value > maxValue) cur_value = maxValue;
if(cur_value < minValue) cur_value = minValue;
if (cur_value > maxValue)
cur_value = maxValue;
if (cur_value < minValue)
cur_value = minValue;
float xcentre = mid_scr.x ;
int range = scrn_rect.right;
int hgt = scrn_rect.top + scrn_rect.bottom;
@ -747,7 +756,7 @@ draw( void ) // (HUD_scale * pscale )
// i = FloatToInt(vmin);
if (zoom == 1) {
zoomed_scale((int)vmin,(int)vmax); //suma
zoomed_scale((int)vmin,(int)vmax);
} else {
//default to zoom=0
last = (int)vmax + 1;
@ -764,7 +773,7 @@ draw( void ) // (HUD_scale * pscale )
// printf("<**> i = %d\n", i);
if (condition) {
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
if (oddtype == 1)
k = i+1; //enable ticks at odd values
@ -776,8 +785,8 @@ draw( void ) // (HUD_scale * pscale )
//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 (((marker_xs - 5) > scrn_rect.left)
&& ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
if (huds_both(options)) {
if (tick_length == "variable") {
@ -797,6 +806,7 @@ draw( void ) // (HUD_scale * pscale )
// glVertex2f(marker_xs, marker_ye + 4);
// glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
// glEnd();
} else {
if (huds_top(options)) {
//draw minor ticks
@ -804,6 +814,7 @@ draw( void ) // (HUD_scale * pscale )
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);
@ -813,11 +824,13 @@ draw( void ) // (HUD_scale * pscale )
}
} //end draw minor ticks
} //end minor ticks
//major ticks
if (div_max()) {
// printf("i = %d\n", i);
// if ((i%(int)div_max())==0) {
// draw major ticks
if (!(k%(int)div_max())) {
if (modulo()) {
disp_val = i % (int) modulo(); // ?????????
@ -833,9 +846,10 @@ draw( void ) // (HUD_scale * pscale )
lenstr = sprintf(TextScale, "%d",
// (int)(disp_val * data_scaling() +.5));
FloatToInt(disp_val * data_scaling()/*+.5*/));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
if (((marker_xs - 10)> scrn_rect.left)
&& ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
if (huds_both(options)) {
// drawOneLine(marker_xs, scrn_rect.top,
// marker_xs, marker_ys);
@ -846,23 +860,22 @@ draw( void ) // (HUD_scale * pscale )
glVertex2f(marker_xs, marker_ye);
glVertex2f(marker_xs, height);
glEnd();
if (!huds_notext(options)) {
textString(marker_xs - 4 * lenstr,
marker_ys + 4,
TextScale, 0 ); //suma
marker_ys + 4, TextScale, 0);
}
} else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
if (!huds_notext(options)) {
if (huds_top(options)) {
textString(marker_xs - 4 * lenstr,
height - 10,
TextScale, 0 ); //suma
height - 10, TextScale, 0);
} else {
textString(marker_xs - 4 * lenstr,
scrn_rect.top,
TextScale, 0 ); //suma
scrn_rect.top, TextScale, 0);
}
}
}
@ -877,10 +890,8 @@ draw( void ) // (HUD_scale * pscale )
} //draw
//begin suma
void hud_card ::
circles(float x,float y,float size)
void hud_card::circles(float x,float y,float size)
{
glEnable(GL_POINT_SMOOTH);
glPointSize(size);
@ -893,10 +904,8 @@ circles(float x,float y,float size)
glDisable(GL_POINT_SMOOTH);
}
//end suma
void hud_card ::
fixed(float x1, float y1, float x2, float y2, float x3, float y3)
void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
{
glBegin(GL_LINE_STRIP);
glVertex2f(x1, y1);
@ -906,10 +915,8 @@ fixed(float x1, float y1, float x2, float y2, float x3, float y3)
}
void hud_card ::
zoomed_scale(int first, int last)
void hud_card::zoomed_scale(int first, int last)
{
POINT mid_scr = get_centroid();
RECT scrn_rect = get_location();
UINT options = get_options();
@ -919,8 +926,10 @@ zoomed_scale(int first, int last)
float x,y,w,h,bottom;
float cur_value=get_value();
if(cur_value > maxValue) cur_value = maxValue;
if(cur_value < minValue) cur_value = minValue;
if (cur_value > maxValue)
cur_value = maxValue;
if (cur_value < minValue)
cur_value = minValue;
int a=0;
@ -933,9 +942,7 @@ zoomed_scale(int first, int last)
}
int centre =a/2;
if (huds_vert(options)) {
x=scrn_rect.left;
y=scrn_rect.top;
w=scrn_rect.left+scrn_rect.right;
@ -958,8 +965,6 @@ zoomed_scale(int first, int last)
int incr = incrs / 2;
float factors = hgt1 / incr;
// begin
//this is for moving type pointer
static float ycent, ypoint,xpoint;
@ -987,7 +992,6 @@ zoomed_scale(int first, int last)
ypoint = ycent - hgt - val;
}
if (cur_value > data[centre+1])
if (cur_value <= maxValue) {
float diff = maxValue - data[centre+1];
@ -1031,11 +1035,11 @@ zoomed_scale(int first, int last)
if (!huds_notext(options))
textString (x, ysecond, TextScale, 0);
yfirst -= factors;
ysecond += factors;
}
//to draw moving type pointer for left option
//begin
xpoint = wth + 10.0;
@ -1101,6 +1105,7 @@ zoomed_scale(int first, int last)
//end
}//end huds_right /left
//end of vertical scale
} else {
//horizontal scale
x=scrn_rect.left;
@ -1200,7 +1205,6 @@ zoomed_scale(int first, int last)
xfirst -= factors;
xsecond += factors;
}
//this is for moving pointer for top option
//begin
@ -1214,6 +1218,7 @@ zoomed_scale(int first, int last)
drawOneLine(xpoint,ypoint-10.0,xpoint-5.0,ypoint-5.0);
}
//end of top option
} else {
//else huds_bottom
ystart = (y + h) / 2;
@ -1265,11 +1270,8 @@ zoomed_scale(int first, int last)
drawOneLine(xpoint,ypoint+10.0,xpoint+5.0,ypoint+5.0);
drawOneLine(xpoint,ypoint+10.0,xpoint-5.0,ypoint+5.0);
}
//end
}//end hud_top or hud_bottom
} //end of horizontal/vertical scales
}//end draw

View file

@ -3,15 +3,15 @@
#ifdef USE_HUD_TextList
#define textString( x , y, text, digit ) TextString( text, x , y,digit ) //suma
#define textString( x , y, text, digit ) TextString( text, x , y,digit )
#else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y )
#endif
//============== Top of gauge_instr class member definitions ==============
gauge_instr ::
gauge_instr( int x,
gauge_instr::gauge_instr(
int x,
int y,
UINT width,
UINT height,
@ -45,13 +45,13 @@ gauge_instr( int x,
// huds_bottom = options & HUDS_BOTTOM;
}
gauge_instr ::
~gauge_instr()
gauge_instr::~gauge_instr()
{
}
gauge_instr ::
gauge_instr( const gauge_instr & image):
gauge_instr::gauge_instr( const gauge_instr & image) :
instr_scale( (instr_scale &) image)
{
// UINT options = get_options();
@ -65,8 +65,8 @@ gauge_instr( const gauge_instr & image):
// huds_bottom = options & HUDS_BOTTOM;
}
gauge_instr & gauge_instr ::
operator = (const gauge_instr & rhs )
gauge_instr & gauge_instr::operator=(const gauge_instr & rhs)
{
if (!(this == &rhs)) {
instr_scale::operator = (rhs);
@ -74,6 +74,7 @@ operator = (const gauge_instr & rhs )
return *this;
}
// As implemented, draw only correctly draws a horizontal or vertical
// scale. It should contain a variation that permits clock type displays.
// Now is supports "tickless" displays such as control surface indicators.
@ -82,8 +83,8 @@ operator = (const gauge_instr & rhs )
void gauge_instr::draw (void)
{
int marker_xs, marker_xe;
int marker_ys, marker_ye;
float marker_xs, marker_xe;
float marker_ys, marker_ye;
int text_x, text_y;
int width, height, bottom_4;
int lenstr;
@ -123,7 +124,7 @@ void gauge_instr :: draw (void)
width,
height);
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick xs
}
if ( huds_right(options) ) { // Read right, so down left sides
@ -132,7 +133,7 @@ void gauge_instr :: draw (void)
scrn_rect.left,
height);
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick xe
}
// At this point marker x_start and x_end values are transposed.
@ -154,7 +155,7 @@ void gauge_instr :: draw (void)
// for ( i = (int)vmin; i <= (int)vmax; i++ ) {
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/;
// We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler.
@ -206,15 +207,15 @@ void gauge_instr :: draw (void)
}
else {
if ( huds_left(options) ) {
text_x = marker_xs - lenstr;
text_x = FloatToInt(marker_xs - lenstr);
}
else {
text_x = marker_xe - lenstr;
text_x = FloatToInt(marker_xe - lenstr);
}
}
// Now we know where to put the text.
text_y = marker_ys;
textString( text_x, text_y, TextScale, 0 ); //suma
text_y = FloatToInt(marker_ys);
textString( text_x, text_y, TextScale, 0 );
}
}
} //
@ -230,19 +231,20 @@ void gauge_instr :: draw (void)
if ( huds_right(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, text_y + 5);
glVertex2f( marker_xe, text_y);
glVertex2f( FloatToInt(marker_xe), text_y);
glVertex2f( scrn_rect.left, text_y - 5);
glEnd();
}
if ( huds_left(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( width, text_y + 5);
glVertex2f( marker_xs, text_y);
glVertex2f( FloatToInt(marker_xs), text_y);
glVertex2f( width, text_y - 5);
glEnd();
}
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
// End if VERTICAL SCALE TYPE
} else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar
scrn_rect.top,
scrn_rect.left,
@ -255,7 +257,7 @@ void gauge_instr :: draw (void)
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/;
if ( huds_top(options) ) {
drawOneLine( scrn_rect.left,
@ -263,7 +265,7 @@ void gauge_instr :: draw (void)
width,
scrn_rect.top); // Bottom box line
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust
// Bottom arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - bottom_4, scrn_rect.top);
@ -275,7 +277,7 @@ void gauge_instr :: draw (void)
// Top box line
drawOneLine( scrn_rect.left, height, width, height);
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
marker_ys = height - scrn_rect.bottom / 2.0;
// Top arrow
glBegin(GL_LINE_STRIP);
@ -296,7 +298,7 @@ void gauge_instr :: draw (void)
}
}
if ( condition ) {
marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
marker_xs = scrn_rect.left + (i - vmin) * factor()/* +.5f*/;
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if ( div_min()){
if ( !(i%(int)div_min()) ) {
@ -350,7 +352,7 @@ void gauge_instr :: draw (void)
if ( !huds_notext(options) ) {
textString ( marker_xs - lenstr, marker_ys + 4,
TextScale ,0); //suma
TextScale ,0);
}
}
else {
@ -361,11 +363,11 @@ void gauge_instr :: draw (void)
if ( huds_top(options) ) {
textString ( marker_xs - lenstr,
height - 10,
TextScale, 0 ); //suma
TextScale, 0 );
}
else {
textString( marker_xs - lenstr, scrn_rect.top,
TextScale, 0 ); //suma
TextScale, 0 );
}
}
}