inline bool option_top() const { return _options & TOP; }
inline bool option_bottom() const { return _options & BOTTOM; }
- void draw_line( float x1, float y1, float x2, float y2) {
- _hud->_line_list.add(LineSegment(x1, y1, x2, y2));
- }
-
- void draw_stipple_line( float x1, float y1, float x2, float y2) {
- _hud->_stipple_line_list.add(LineSegment(x1, y1, x2, y2));
- }
-
- void draw_text( float x, float y, char *msg, int digit) {
- _hud->_text_list.add(HUDText(x, y, msg, digit));
- }
-
- float text_width(char *str) const {
- assert(_hud->_font_renderer);
- float r, l;
- _hud->_font->getBBox(str, _hud->_font_size, 0, &l, &r, 0, 0);
- return r - l;
- }
-
- void draw_circle(float x1, float y1, 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);
- }
- glEnd();
- }
+ void draw_line( float x1, float y1, float x2, float y2);
+ void draw_stipple_line( float x1, float y1, float x2, float y2);
+ void draw_text( float x, float y, char *msg, int digit);
+ float text_width(char *str) const;
+ void draw_circle(float x1, float y1, float r) const;
+ void draw_bullet(float, float, float);
HUD *_hud;
string _name;
virtual void draw();
protected:
- void circle(float, float, float);
void fixed(float, float, float, float, float, float);
void zoomed_scale(int, int);
bool HUD::Item::isEnabled()
{
- if (!_condition)
- return true;
+ return _condition ? _condition->test() : true;
+}
+
+
+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)
+{
+ _hud->_stipple_line_list.add(LineSegment(x1, y1, x2, y2));
+}
+
+
+void HUD::Item::draw_text( float x, float y, char *msg, int digit)
+{
+ _hud->_text_list.add(HUDText(x, y, msg, digit));
+}
- return _condition->test();
+
+void HUD::Item::draw_circle(float x1, float y1, 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);
+ }
+ glEnd();
+}
+
+
+void HUD::Item::draw_bullet(float x, float y, float size)
+{
+ glEnable(GL_POINT_SMOOTH);
+ glPointSize(size);
+
+ glBegin(GL_POINTS);
+ glVertex2f(x, y);
+ glEnd();
+
+ glPointSize(1.0);
+ glDisable(GL_POINT_SMOOTH);
+}
+
+
+float HUD::Item::text_width(char *str) const
+{
+ assert(_hud->_font_renderer);
+ float r, l;
+ _hud->_font->getBBox(str, _hud->_font_size, 0, &l, &r, 0, 0);
+ return r - l;
}
width = scrn_rect.left + scrn_rect.right;
- // was: if (type != "gauge") { ... until end
- // if its not explicitly a gauge default to tape
if (_pointer) {
if (_pointer_type == MOVING) {
vmin = _input.min();
// minor and major ticks.
// draw scale or tape
-
-// last = float_to_int(vmax)+1;
-// i = float_to_int(vmin);
last = (int)vmax + 1; // N
i = (int)vmin; // N
}
} else if (_tick_type == CIRCLE) {
- circle(scrn_rect.left,(float)marker_ys, 3.0);
+ draw_bullet(scrn_rect.left,(float)marker_ys, 3.0);
} else {
// if neither line nor circle draw default as line
marker_xe, marker_ys);
}
} else if (_tick_type == CIRCLE) {
- circle((float)marker_xs + 4, (float)marker_ys, 3.0);
+ draw_bullet((float)marker_xs + 4, (float)marker_ys, 3.0);
} else {
draw_line(marker_xs + 4, marker_ys,
}
} else if (_tick_type == CIRCLE) {
- circle((float)marker_xe - 4, (float)marker_ys, 3.0);
+ draw_bullet((float)marker_xe - 4, (float)marker_ys, 3.0);
} else {
draw_line(marker_xs, marker_ys,
marker_xe - 4, marker_ys);
glEnd();
} else if (_tick_type == CIRCLE) {
- circle(scrn_rect.left, (float)marker_ys, 5.0);
+ draw_bullet(scrn_rect.left, (float)marker_ys, 5.0);
} else {
glBegin(GL_LINE_STRIP);
if (_tick_type == LINE)
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
else if (_tick_type == CIRCLE)
- circle((float)marker_xs + 4, (float)marker_ys, 5.0);
+ draw_bullet((float)marker_xs + 4, (float)marker_ys, 5.0);
else
draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
-void HUD::Tape::circle(float x, float y, float size)
-{
- glEnable(GL_POINT_SMOOTH);
- glPointSize(size);
-
- glBegin(GL_POINTS);
- glVertex2f(x, y);
- glEnd();
-
- glPointSize(1.0);
- glDisable(GL_POINT_SMOOTH);
-}
-
-
void HUD::Tape::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
{
glBegin(GL_LINE_STRIP);
for (i = 1; i < 5; i++) {
yfirst += factor;
ycentre += factor;
- circle(xstart - 2.5, yfirst, 3.0);
- circle(xstart - 2.5, ycentre, 3.0);
+ draw_bullet(xstart - 2.5, yfirst, 3.0);
+ draw_bullet(xstart - 2.5, ycentre, 3.0);
}
yfirst = mid_scr.y - hgt;
for (i = 1; i < 5; i++) {
yfirst += factor;
ycentre += factor;
- circle(xstart + 2.5, yfirst, 3.0);
- circle(xstart + 2.5, ycentre, 3.0);
+ draw_bullet(xstart + 2.5, yfirst, 3.0);
+ draw_bullet(xstart + 2.5, ycentre, 3.0);
}
yfirst = mid_scr.y - hgt;
for (i = 1; i < 5; i++) {
xfirst += factor;
xcentre += factor;
- circle(xfirst, ystart - 2.5, 3.0);
- circle(xcentre, ystart - 2.5, 3.0);
+ draw_bullet(xfirst, ystart - 2.5, 3.0);
+ draw_bullet(xcentre, ystart - 2.5, 3.0);
}
xfirst = mid_scr.x - hgt;
for (i = 1; i < 5; i++) {
xfirst += factor;
xcentre += factor;
- circle(xfirst, ystart + 2.5, 3.0);
- circle(xcentre, ystart + 2.5, 3.0);
+ draw_bullet(xfirst, ystart + 2.5, 3.0);
+ draw_bullet(xcentre, ystart + 2.5, 3.0);
}
xfirst = mid_scr.x - hgt;