1
0
Fork 0

- cleanup of the day (more finegrained change history in my local cvs)

- <damp>ing coefficient is now 1.0 - 1.0 / pow(10, damp)
This commit is contained in:
mfranz 2006-07-05 22:55:33 +00:00
parent 80bada55cd
commit 42c3d8867f
8 changed files with 312 additions and 398 deletions

View file

@ -225,8 +225,7 @@ void HUD::draw3D()
}
void HUD::draw2D( GLfloat x_start, GLfloat y_start,
GLfloat x_end, GLfloat y_end )
void HUD::draw2D(GLfloat x_start, GLfloat y_start, GLfloat x_end, GLfloat y_end)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();

View file

@ -315,7 +315,7 @@ public:
_offset = n->getFloatValue("offset", offset);
_min = n->getFloatValue("min", min);
_max = n->getFloatValue("max", max);
_coeff = n->getFloatValue("damp", 0.0);
_coeff = 1.0 - 1.0 / powf(10, fabsf(n->getFloatValue("damp", 0.0)));
SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false);
if (p) {
const char *path = p->getStringValue();
@ -338,13 +338,14 @@ public:
_damped = f;
if (_coeff > 0.0f)
f = _damped = f * (1.0f - _coeff) + _damped * _coeff;
return f < _min ? _min : f > _max ? _max : f;
return clamp(f);
}
inline float isValid() const { return _valid; }
inline float min() const { return _min; }
inline float max() const { return _max; }
inline float factor() const { return _factor; }
float clamp(float v) const { return v < _min ? _min : v > _max ? _max : v; }
void set_min(float m, bool force = true) {
if (force || _min == -SGLimitsf::max())
@ -368,7 +369,7 @@ private:
class HUD::Item { // An Abstract Base Class (ABC)
class HUD::Item {
public:
Item(HUD *parent, const SGPropertyNode *, float x = 0.0f, float y = 0.0f);
virtual ~Item () {}
@ -376,7 +377,6 @@ public:
virtual bool isEnabled();
protected:
inline Rect get_location() const { return _scrn_pos; }
inline float get_span() const { return _scr_span; }
inline Point get_centroid() const { return _mid_span; }
@ -469,7 +469,7 @@ public:
protected:
inline unsigned int modulo() const { return _modulo; }
inline float factor() const { return scale_factor; }
inline float factor() const { return _display_factor; }
inline float range_to_show() const { return _range_shown; }
Input _input;
@ -478,7 +478,7 @@ protected:
private:
float _range_shown; // Width Units.
float scale_factor; // factor => screen units/range values.
float _display_factor; // factor => screen units/range values.
unsigned int _modulo; // Roll over point
};
@ -576,15 +576,14 @@ private:
Input _pitch;
Input _roll;
enum Type { PITCH, CLIMB_DIVE } _type;
unsigned int width_units;
float _width_units;
int div_units;
unsigned int minor_div;
unsigned int label_pos;
unsigned int _scr_hole;
float _vmax;
float _vmin;
float _compression;
bool _frl;
bool _frl; // fuselage reference line
bool _target_spot;
bool _velocity_vector;
bool _drift_marker;
@ -617,8 +616,7 @@ public:
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);

View file

@ -42,8 +42,8 @@ void HUD::Dial::draw(void)
float x, y;
float i;
y = (float)(scrn_rect.top);
x = (float)(scrn_rect.left);
y = scrn_rect.top;
x = scrn_rect.left;
glEnable(GL_POINT_SMOOTH);
glPointSize(3.0);

View file

@ -93,8 +93,8 @@ void HUD::Gauge::draw(void)
if (!option_noticks()) { // If not no ticks...:)
// Calculate x marker offsets
int last = (int)vmax + 1; // float_to_int(vmax)+1;
i = (int)vmin; //float_to_int(vmin);
int last = (int)vmax + 1;
i = (int)vmin;
for (; i < last; i++) {
// Calculate the location of this tick
@ -216,8 +216,8 @@ void HUD::Gauge::draw(void)
}
int last = (int)vmax + 1; //float_to_int(vmax)+1;
i = (int)vmin; //float_to_int(vmin);
int last = (int)vmax + 1;
i = (int)vmin;
for (; i <last ; i++) {
condition = true;
if (!modulo() && i < _input.min())

View file

@ -95,31 +95,32 @@ bool HUD::Item::isEnabled()
}
void HUD::Item::draw_line( float x1, float y1, float x2, float y2)
void HUD::Item::draw_line(float x1, float y1, float x2, float y2)
{
_hud->_line_list.add(LineSegment(x1, y1, x2, y2));
}
void HUD::Item::draw_stipple_line( float x1, float y1, float x2, float y2)
void HUD::Item::draw_stipple_line(float x1, float y1, float x2, float y2)
{
_hud->_stipple_line_list.add(LineSegment(x1, y1, x2, y2));
}
void HUD::Item::draw_text( float x, float y, char *msg, int digit)
void HUD::Item::draw_text(float x, float y, char *msg, int digit)
{
_hud->_text_list.add(HUDText(x, y, msg, digit));
}
void HUD::Item::draw_circle(float x1, float y1, float r) const
void HUD::Item::draw_circle(float xoffs, float yoffs, float r) const
{
glBegin(GL_LINE_LOOP);
for (int count = 0; count < 25; count++) {
float cosine = r * cos(count * 2 * SG_PI / 10.0);
float sine = r * sin(count * 2 * SG_PI / 10.0);
glVertex2f(cosine + x1, sine + y1);
for (int i = 0; i < 25; i++) {
float alpha = i * 2.0 * SG_PI / 10.0;
float x = r * cos(alpha);
float y = r * sin(alpha);
glVertex2f(x + xoffs, y + yoffs);
}
glEnd();
}

View file

@ -44,9 +44,8 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
Item(hud, n, x, y),
_pitch(n->getNode("pitch-input", false)),
_roll(n->getNode("roll-input", false)),
width_units(int(n->getFloatValue("display-span"))),
_width_units(int(n->getFloatValue("display-span"))),
div_units(int(fabs(n->getFloatValue("divisions")))),
minor_div(0 /* hud.cxx: static float minor_division = 0 */),
label_pos(n->getIntValue("lbl-pos")),
_scr_hole(n->getIntValue("screen-hole")),
_compression(n->getFloatValue("compression-factor")),
@ -56,7 +55,7 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
_drift_marker(n->getBoolValue("enable-drift-marker", false)),
_alpha_bracket(n->getBoolValue("enable-alpha-bracket", false)),
_energy_marker(n->getBoolValue("enable-energy-marker", false)),
_climb_dive_marker(n->getBoolValue("enable-climb-dive-marker", false)), // WTF FIXME
_climb_dive_marker(n->getBoolValue("enable-climb-dive-marker", false)),
_glide_slope_marker(n->getBoolValue("enable-glide-slope-marker",false)),
_glide_slope(n->getFloatValue("glide-slope", -4.0)),
_energy_worm(n->getBoolValue("enable-energy-marker", false)),
@ -68,10 +67,10 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
const char *t = n->getStringValue("type");
_type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
if (!width_units)
width_units = 45;
if (!_width_units)
_width_units = 45;
_vmax = width_units / 2;
_vmax = _width_units / 2;
_vmin = -_vmax;
}
@ -423,13 +422,13 @@ void HUD::Ladder::draw(void)
//****************************************************************
if (climb_dive_ladder) { // CONFORMAL_HUD
_vmin = pitch_value - (float)width_units;
_vmax = pitch_value + (float)width_units;
_vmin = pitch_value - _width_units;
_vmax = pitch_value + _width_units;
glTranslatef(vel_x, vel_y, 0);
} else { // pitch_ladder - Default Hud
_vmin = pitch_value - (float)width_units * 0.5f;
_vmax = pitch_value + (float)width_units * 0.5f;
_vmin = pitch_value - _width_units * 0.5f;
_vmax = pitch_value + _width_units * 0.5f;
}
glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
@ -467,8 +466,8 @@ void HUD::Ladder::draw(void)
if (!_scr_hole) {
x_end = half_span;
for (; i<last; i++) {
y = (((float)(i - pitch_value) * _compression) + .5f);
for (; i < last; i++) {
y = (i - pitch_value) * _compression + .5f;
if (!(i % div_units)) { // At integral multiple of div
snprintf(buf, BUFSIZE, "%d", i);
@ -505,16 +504,16 @@ void HUD::Ladder::draw(void)
} else { // if (_scr_hole)
// Draw ladder with space in the middle of the lines
float hole = (float)((_scr_hole) / 2.0f);
float hole = _scr_hole / 2.0f;
x_end = -half_span + hole;
x_ini2 = half_span - hole;
for (; i < last; i++) {
if (_type == PITCH)
y = (((float)(i - pitch_value) * _compression) + .5);
y = float(i - pitch_value) * _compression + .5;
else // _type == CLIMB_DIVE
y = (((float)(i - actslope) * _compression) + .5);
y = float(i - actslope) * _compression + .5;
if (!(i % div_units)) { // At integral multiple of div
snprintf(buf, BUFSIZE, "%d", i);
@ -676,7 +675,7 @@ void HUD::Ladder::draw(void)
glBegin(GL_POINTS);
for (int count = 0; count <= 200; count++) {
float temp = count * 3.142 * 3 / (200.0 * 2.0);
float temp = count * SG_PI * 3 / (200.0 * 2.0);
float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
x1 = x + r * cos(temp1);
y1 = y + r * sin(temp1);
@ -743,7 +742,7 @@ void HUD::Ladder::draw_nadir(float xfirst, float xlast, float yvalue)
ycent1 = ycentre;
for (int count = 1; count <= 400; count++) {
float temp = count * 2 * 3.142 / 400.0;
float temp = count * 2 * SG_PI / 400.0;
xcent2 = xcentre + r * cos(temp);
ycent2 = ycentre + r * sin(temp);
@ -765,7 +764,7 @@ void HUD::Ladder::draw_nadir(float xfirst, float xlast, float yvalue)
//line in the middle of circle
draw_line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
float theta = asin (2.5 / 7.5);
float theta = asin(2.5 / 7.5);
float theta1 = asin(5.0 / 7.5);
x1 = xcentre + r * cos(theta);

View file

@ -46,7 +46,7 @@ HUD::Scale::Scale( HUD *hud, const SGPropertyNode *n, float x, float y) :
else
_range_shown = _input.max() - _input.min();
scale_factor = (float)get_span() / _range_shown;
_display_factor = get_span() / _range_shown;
if (_range_shown < 0)
_range_shown = -_range_shown;

View file

@ -38,7 +38,8 @@ HUD::Tape::Tape(HUD *hud, const SGPropertyNode *n, float x, float y) :
{
_half_width_units = range_to_show() / 2.0;
const char *s = n->getStringValue("pointer-type");
const char *s;
s = n->getStringValue("pointer-type");
_pointer_type = strcmp(s, "moving") ? FIXED : MOVING; // "fixed", "moving"
s = n->getStringValue("tick-type");
@ -62,17 +63,15 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
float text_x = 0.0, text_y = 0.0;
int lenstr;
float height, width;
int i, last;
const int BUFSIZE = 80;
char buf[BUFSIZE];
bool condition;
int disp_val = 0;
int oddtype, k; //odd or even values for ticks
Point mid_scr = get_centroid();
float cur_value = _input.getFloatValue();
if ((int)_input.max() & 1)
if (int(floor(_input.max() + 0.5)) & 1)
oddtype = 1; //draw ticks at odd values
else
oddtype = 0; //draw ticks at even values
@ -88,8 +87,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
vmin = _input.min();
vmax = _input.max();
} else {
// default to fixed
} 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;
@ -103,6 +101,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
text_y = mid_scr.y;
}
// Draw the basic markings for the scale...
if (option_vert()) { // Vertical scale
@ -138,10 +137,8 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
//First draw capping lines and pointers
if (option_left()) { // Calculate x marker offset
if (_draw_cap_right) {
// Cap right side
if (_draw_cap_right)
draw_line(marker_xe, scrn_rect.top, marker_xe, marker_ye);
}
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
@ -153,20 +150,16 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// draw pointer
if (_pointer) {
if (_pointer_type == MOVING) {
if (_zoom == 0) {
if (!_zoom) {
//Code for Moving Type Pointer
float ycentre, ypoint, xpoint;
float range, wth;
if (cur_value > _input.max())
cur_value = _input.max();
if (cur_value < _input.min())
cur_value = _input.min();
if (_input.min() >= 0.0)
ycentre = scrn_rect.top;
else if (_input.max() + _input.min() == 0.0)
ycentre = mid_scr.y;
else if (oddtype == 1)
else if (oddtype)
ycentre = scrn_rect.top + (1.0 - _input.min()) * scrn_rect.bottom
/ (_input.max() - _input.min());
else
@ -176,7 +169,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
range = scrn_rect.bottom;
wth = scrn_rect.left + scrn_rect.right;
if (oddtype == 1)
if (oddtype)
ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
else
ypoint = ycentre + (cur_value * range / _val_span);
@ -186,7 +179,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
draw_line(xpoint, ypoint, xpoint - _marker_offset, ypoint);
draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
} //_zoom=0
} // !_zoom
} else {
// default to fixed
@ -197,13 +190,13 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
} //if pointer
} //end vertical/left
// begin vertical/right
//First draw capping lines and pointers
if (option_right()) { // We'll default this for now.
if (_draw_cap_left) {
// Cap left side
if (option_right()) {
if (_draw_cap_left)
draw_line(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
} //endif cap_left
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
// Indicator carrot
@ -215,29 +208,24 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// draw pointer
if (_pointer) {
if (_pointer_type == MOVING) {
if (_zoom == 0) {
if (!_zoom) {
//type-fixed & _zoom=1, behaviour to be defined
// Code for Moving Type Pointer
float ycentre, ypoint, xpoint;
float range;
if (cur_value > _input.max())
cur_value = _input.max();
if (cur_value < _input.min())
cur_value = _input.min();
if (_input.min() >= 0.0)
ycentre = scrn_rect.top;
else if (_input.max() + _input.min() == 0.0)
ycentre = mid_scr.y;
else if (oddtype == 1)
else if (oddtype)
ycentre = scrn_rect.top + (1.0 - _input.min()) * scrn_rect.bottom / (_input.max() - _input.min());
else
ycentre = scrn_rect.top + _input.min() * scrn_rect.bottom / (_input.max() - _input.min());
range = scrn_rect.bottom;
if (oddtype == 1)
if (oddtype)
ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
else
ypoint = ycentre + (cur_value * range / _val_span);
@ -258,78 +246,65 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
} //if pointer
} //end vertical/right
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if (option_both()) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// To keep this from confusing things they are now swapped.
if (option_both())
marker_ye = marker_xs, marker_xs = marker_xe, marker_xe = marker_ye;
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
// draw scale or tape
last = (int)vmax + 1; // N
i = (int)vmin; // N
if (_zoom == 1) {
if (_zoom) {
zoomed_scale((int)vmin, (int)vmax);
} else {
for (; i < last; i++) {
condition = true;
if (!modulo() && i < _input.min())
condition = false;
if (condition) { // Show a tick if necessary
for (int i = (int)vmin; i < (int)vmax + 1; i++) {
if (!modulo() && i < _input.min())
continue;
// Calculate the location of this tick
marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
// marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
marker_ys = scrn_rect.top + ((i - vmin) * factor());
// 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))) {
// Magic numbers!!!
if ((marker_ys < (scrn_rect.top + 4)) || (marker_ys > (height - 4)))
continue;
}
if (oddtype == 1)
if (oddtype)
k = i + 1; //enable ticks at odd values
else
k = i;
// Minor ticks
if (_minor_divs) {
// if ((i % _minor_divs) == 0) {
if (!(k % (int)_minor_divs)) {
if (((marker_ys - 5) > scrn_rect.top)
&& ((marker_ys + 5) < (height))) {
if (marker_ys < scrn_rect.top + 5 || (marker_ys + 5) > height)
continue;
//vertical/left OR vertical/right
if (option_both()) {
if (_tick_type == LINE) {
if (_tick_length == VARIABLE) {
draw_line(scrn_rect.left, marker_ys,
marker_xs, marker_ys);
draw_line(marker_xe, marker_ys,
width, marker_ys);
draw_line(scrn_rect.left, marker_ys, marker_xs, marker_ys);
draw_line(marker_xe, marker_ys, width, marker_ys);
} else {
draw_line(scrn_rect.left, marker_ys,
marker_xs, marker_ys);
draw_line(marker_xe, marker_ys,
width, marker_ys);
draw_line(scrn_rect.left, marker_ys, marker_xs, marker_ys);
draw_line(marker_xe, marker_ys, width, marker_ys);
}
} else if (_tick_type == CIRCLE) {
draw_bullet(scrn_rect.left,(float)marker_ys, 3.0);
draw_bullet(scrn_rect.left, marker_ys, 3.0);
} else {
// if neither line nor circle draw default as line
draw_line(scrn_rect.left, marker_ys,
marker_xs, marker_ys);
draw_line(marker_xe, marker_ys,
width, marker_ys);
draw_line(scrn_rect.left, marker_ys, marker_xs, marker_ys);
draw_line(marker_xe, marker_ys, width, marker_ys);
}
// glBegin(GL_LINES);
// glVertex2f(scrn_rect.left, marker_ys);
@ -337,54 +312,47 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// glVertex2f(marker_xe, marker_ys);
// glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
// glEnd();
// anything other than option_both
// anything other than huds_both
} else {
if (option_left()) {
if (_tick_type == LINE) {
if (_tick_length == VARIABLE) {
draw_line(marker_xs + 4, marker_ys,
marker_xe, marker_ys);
draw_line(marker_xs + 4, marker_ys, marker_xe, marker_ys);
} else {
draw_line(marker_xs, marker_ys,
marker_xe, marker_ys);
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
}
} else if (_tick_type == CIRCLE) {
draw_bullet((float)marker_xs + 4, (float)marker_ys, 3.0);
draw_bullet(marker_xs + 4, marker_ys, 3.0);
} else {
draw_line(marker_xs + 4, marker_ys,
marker_xe, marker_ys);
draw_line(marker_xs + 4, marker_ys, marker_xe, marker_ys);
}
} else {
if (_tick_type == LINE) {
if (_tick_length == VARIABLE) {
draw_line(marker_xs, marker_ys,
marker_xe - 4, marker_ys);
draw_line(marker_xs, marker_ys, marker_xe - 4, marker_ys);
} else {
draw_line(marker_xs, marker_ys,
marker_xe, marker_ys);
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
}
} else if (_tick_type == CIRCLE) {
draw_bullet((float)marker_xe - 4, (float)marker_ys, 3.0);
draw_bullet(marker_xe - 4, marker_ys, 3.0);
} else {
draw_line(marker_xs, marker_ys,
marker_xe - 4, marker_ys);
draw_line(marker_xs, marker_ys, marker_xe - 4, marker_ys);
}
}
} //end huds both
}
} //end draw minor ticks
} //end minor ticks
} // end huds both
} // end draw minor ticks
} // end minor ticks
// Major ticks
if (_major_divs) {
if (!(k % (int)_major_divs)) {
if (modulo()) {
disp_val = i % (int) modulo(); // ?????????
disp_val = i % (int) modulo();
if (disp_val < 0) {
while (disp_val < 0)
disp_val += modulo();
@ -393,16 +361,13 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
disp_val = i;
}
// FIXME what nonsense is this?!?
lenstr = snprintf(buf, BUFSIZE, "%d", int(disp_val * _input.factor()/*+.5*/)); // was data_scaling ... makes no sense at all
// (int)(disp_val * data_scaling() +.5));
/* if (((marker_ys - 8) > scrn_rect.top) &&
((marker_ys + 8) < (height))){ */
// option_both
// FIXME int lenstr??
lenstr = snprintf(buf, BUFSIZE, "%d", int(disp_val * _input.factor())); // was data_scaling ... makes no sense at all
if (option_both()) {
// draw_line(scrn_rect.left, marker_ys,
// drawOneLine(scrn_rect.left, marker_ys,
// marker_xs, marker_ys);
// draw_line(marker_xs, marker_ys,
// drawOneLine(marker_xs, marker_ys,
// scrn_rect.left + scrn_rect.right,
// marker_ys);
if (_tick_type == LINE) {
@ -413,7 +378,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
glEnd();
} else if (_tick_type == CIRCLE) {
draw_bullet(scrn_rect.left, (float)marker_ys, 5.0);
draw_bullet(scrn_rect.left, marker_ys, 5.0);
} else {
glBegin(GL_LINE_STRIP);
@ -432,27 +397,25 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
if (_tick_type == LINE)
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
else if (_tick_type == CIRCLE)
draw_bullet((float)marker_xs + 4, (float)marker_ys, 5.0);
draw_bullet(marker_xs + 4, marker_ys, 5.0);
else
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
if (!option_notext()) {
if (option_left()) {
draw_text(marker_xs - 8 * lenstr - 2,
marker_ys - 4, buf, 0);
} else {
draw_text(marker_xe + 3 * lenstr,
marker_ys - 4, buf, 0);
} //End if option_left
} //End if !option_notext
} //End if huds-both
if (option_left())
draw_text(marker_xs - 8 * lenstr - 2, marker_ys - 4, buf, 0);
else
draw_text(marker_xe + 3 * lenstr, marker_ys - 4, buf, 0);
}
} // End if huds-both
} // End if draw major ticks
} // End if major ticks
} // End condition
} // End for
} //end of zoom
} // end of zoom
// End if VERTICAL SCALE TYPE (tape loop yet to be closed)
} else {
// Horizontal scale by default
// left tick bar
@ -466,7 +429,7 @@ void HUD::Tape::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 + ((cur_value - vmin) * factor() /*+ .5f*/);
marker_xs = scrn_rect.left + ((cur_value - vmin) * factor());
// glBegin(GL_LINES);
// left tick bar
@ -479,7 +442,6 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// glEnd();
if (option_top()) {
// Bottom box line
if (_draw_cap_bottom)
draw_line(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
@ -493,14 +455,8 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// draw pointer
if (_pointer) {
if (_pointer_type == MOVING) {
if (_zoom == 0) {
if (!_zoom) {
//Code for Moving Type Pointer
// static float xcentre, xpoint, ypoint;
// static int range;
if (cur_value > _input.max())
cur_value = _input.max();
if (cur_value < _input.min())
cur_value = _input.min();
float xcentre = mid_scr.x;
float range = scrn_rect.right;
@ -521,7 +477,6 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
} //End Horizontal scale/top
if (option_bottom()) {
// Top box line
if (_draw_cap_top)
draw_line(scrn_rect.left, height, width, height);
@ -538,14 +493,8 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
// draw pointer
if (_pointer) {
if (_pointer_type == MOVING) {
if (_zoom == 0) {
if (!_zoom) {
//Code for Moving Type Pointer
// static float xcentre, xpoint, ypoint;
// static int range, hgt;
if (cur_value > _input.max())
cur_value = _input.max();
if (cur_value < _input.min())
cur_value = _input.min();
float xcentre = mid_scr.x ;
float range = scrn_rect.right;
@ -561,52 +510,39 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
marker_xs - scrn_rect.bottom / 4, height);
}
} //if pointer
}
} //end horizontal scale bottom
if (_zoom == 1) {
if (_zoom) {
zoomed_scale((int)vmin,(int)vmax);
} else {
//default to _zoom=0
last = (int)vmax + 1;
i = (int)vmin;
for (; i < last; i++) {
// for (i = (int)vmin; i <= (int)vmax; i++) {
// printf("<*> i = %d\n", i);
condition = true;
for (int i = (int)vmin; i < (int)vmax + 1; i++) {
if (!modulo() && i < _input.min())
condition = false;
continue;
// printf("<**> i = %d\n", i);
if (condition) {
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
marker_xs = scrn_rect.left + (i - vmin) * factor();
if (oddtype == 1)
k = i + 1; //enable ticks at odd values
if (oddtype)
k = i + 1;
else
k = i;
if (_minor_divs) {
// if ((i % (int)_minor_divs) == 0) {
//draw minor ticks
// draw minor ticks
if (!(k % (int)_minor_divs)) {
// 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 < scrn_rect.left + 5 || marker_xs + 5 > scrn_rect.left + scrn_rect.right)
continue;
if (option_both()) {
if (_tick_length == VARIABLE) {
draw_line(marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
draw_line(marker_xs, marker_ye + 4,
marker_xs, height);
draw_line(marker_xs, scrn_rect.top, marker_xs, marker_ys - 4);
draw_line(marker_xs, marker_ye + 4, marker_xs, height);
} else {
draw_line(marker_xs, scrn_rect.top,
marker_xs, marker_ys);
draw_line(marker_xs, marker_ye,
marker_xs, height);
draw_line(marker_xs, scrn_rect.top, marker_xs, marker_ys);
draw_line(marker_xs, marker_ye, marker_xs, height);
}
// glBegin(GL_LINES);
// glVertex2f(marker_xs, scrn_rect.top);
@ -617,7 +553,7 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
} else {
if (option_top()) {
//draw minor ticks
// draw minor ticks
if (_tick_length == VARIABLE)
draw_line(marker_xs, marker_ys, marker_xs, marker_ye - 4);
else
@ -629,19 +565,15 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
draw_line(marker_xs, marker_ys, marker_xs, marker_ye);
}
}
}
} //end draw minor ticks
} //end minor ticks
} // end draw minor ticks
} // end minor ticks
//major ticks
// major ticks
if (_major_divs) {
// printf("i = %d\n", i);
// if ((i % (int)_major_divs)==0) {
// draw major ticks
if (!(k % (int)_major_divs)) {
if (modulo()) {
disp_val = i % (int) modulo(); // ?????????
disp_val = i % (int) modulo();
if (disp_val < 0) {
while (disp_val<0)
disp_val += modulo();
@ -649,15 +581,12 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
} else {
disp_val = i;
}
// printf("disp_val = %d\n", disp_val);
// printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
lenstr = snprintf(buf, BUFSIZE, "%d",
// (int)(disp_val * data_scaling() +.5));
int(disp_val * _input.factor() /*+.5*/)); // was data_scaling() ... makes no sense at all
lenstr = snprintf(buf, BUFSIZE, "%d", int(disp_val * _input.factor())); // was data_scaling() ... makes no sense at all
// 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 > scrn_rect.left + 10 || marker_xs + 10 < scrn_rect.left + scrn_rect.right)
continue;
if (option_both()) {
// draw_line(marker_xs, scrn_rect.top,
// marker_xs, marker_ys);
@ -669,32 +598,25 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale)
glVertex2f(marker_xs, height);
glEnd();
if (!option_notext()) {
draw_text(marker_xs - 4 * lenstr,
marker_ys + 4, buf, 0);
}
if (!option_notext())
draw_text(marker_xs - 4 * lenstr, marker_ys + 4, buf, 0);
} else {
draw_line(marker_xs, marker_ys, marker_xs, marker_ye);
if (!option_notext()) {
if (option_top()) {
draw_text(marker_xs - 4 * lenstr,
height - 10, buf, 0);
} else {
draw_text(marker_xs - 4 * lenstr,
scrn_rect.top, buf, 0);
if (option_top())
draw_text(marker_xs - 4 * lenstr, height - 10, buf, 0);
else
draw_text(marker_xs - 4 * lenstr, scrn_rect.top, buf, 0);
}
}
}
}
} //end draw major ticks
} //endif major ticks
} //end condition
} //end for
} //end zoom
} //end horizontal/vertical scale
} //draw
} // end draw major ticks
} // endif major ticks
} // end for
} // end zoom
} // end horizontal/vertical scale
}
@ -718,11 +640,6 @@ void HUD::Tape::zoomed_scale(int first, int last)
float x, y, w, h, bottom;
float cur_value = _input.getFloatValue();
if (cur_value > _input.max())
cur_value = _input.max();
if (cur_value < _input.min())
cur_value = _input.min();
int a = 0;
while (first <= last) {
@ -759,7 +676,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
// begin
//this is for moving type pointer
static float ycent, ypoint, xpoint;
static float ycent, ypoint, xpoint; // FIXME really static?
static float wth;
ycent = mid_scr.y;
@ -798,7 +715,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes not sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes not sense at all
if (!option_notext())
draw_text(x, ycentre, buf, 0);
@ -816,12 +733,12 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xstart, yfirst, xstart - 5.0, yfirst);
draw_line(xstart, ysecond, xstart - 5.0, ysecond);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(x, yfirst, buf, 0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(x, ysecond, buf, 0);
@ -849,7 +766,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(w, ycentre, buf, 0);
@ -867,12 +784,12 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xstart, yfirst, xstart + 5.0, yfirst);
draw_line(xstart, ysecond, xstart + 5.0, ysecond);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(w, yfirst, buf, 0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor()));
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor()));
if (!option_notext())
draw_text(w, ysecond, buf, 0);
@ -923,7 +840,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
//Code for Moving Type Pointer
//begin
static float xcent, xpoint, ypoint;
static float xcent, xpoint, ypoint; // FIXME really static?
xcent = mid_scr.x;
@ -961,7 +878,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
ystart = h;
draw_line(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xcentre - 10.0, y, buf, 0);
@ -979,12 +896,12 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xfirst, ystart, xfirst, ystart - 5.0);
draw_line(xsecond, ystart, xsecond, ystart - 5.0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xfirst - 10.0, y, buf, 0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xsecond - 10.0, y, buf, 0);
@ -1013,7 +930,7 @@ void HUD::Tape::zoomed_scale(int first, int last)
//draw_line(xstart, yfirst, xstart - 5.0, yfirst);
draw_line(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xcentre - 10.0, h, buf, 0);
@ -1031,12 +948,12 @@ void HUD::Tape::zoomed_scale(int first, int last)
draw_line(xfirst, ystart, xfirst, ystart + 5.0);
draw_line(xsecond, ystart, xsecond, ystart + 5.0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xfirst - 10.0, h, buf, 0);
snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
if (!option_notext())
draw_text(xsecond - 10.0, h, buf, 0);