2006-02-18 13:58:09 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2001-09-19 22:23:25 +00:00
|
|
|
#include <plib/sg.h>
|
1998-07-03 13:16:27 +00:00
|
|
|
#include "hud.hxx"
|
1999-05-12 02:04:38 +00:00
|
|
|
|
|
|
|
#ifdef USE_HUD_TextList
|
2006-06-14 23:27:55 +00:00
|
|
|
#define textString(x, y, text, digit) TextString(text, x , y , digit)
|
1999-06-01 21:17:10 +00:00
|
|
|
#else
|
2006-06-12 23:27:55 +00:00
|
|
|
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
|
1999-05-12 02:04:38 +00:00
|
|
|
#endif
|
|
|
|
|
2006-06-15 18:09:15 +00:00
|
|
|
FLTFNPTR get_func(const char *name); // FIXME
|
2001-01-05 16:44:48 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
hud_card::hud_card(const SGPropertyNode *node) :
|
|
|
|
instr_scale(
|
|
|
|
node->getIntValue("x"),
|
|
|
|
node->getIntValue("y"),
|
|
|
|
node->getIntValue("width"),
|
|
|
|
node->getIntValue("height"),
|
|
|
|
0 /*data_source*/, // FIXME
|
|
|
|
node->getIntValue("options"),
|
|
|
|
node->getFloatValue("value_span"),
|
|
|
|
node->getFloatValue("maxValue"),
|
|
|
|
node->getFloatValue("minValue"),
|
|
|
|
node->getFloatValue("disp_scaling"),
|
|
|
|
node->getIntValue("major_divs"),
|
|
|
|
node->getIntValue("minor_divs"),
|
|
|
|
node->getIntValue("modulator"),
|
2006-06-15 18:09:15 +00:00
|
|
|
node->getBoolValue("working", true)),
|
2006-06-14 23:27:55 +00:00
|
|
|
val_span(node->getFloatValue("value_span")), // FIXME
|
|
|
|
type(node->getStringValue("type")),
|
|
|
|
draw_tick_bottom(node->getBoolValue("tick_bottom", false)),
|
|
|
|
draw_tick_top(node->getBoolValue("tick_top", false)),
|
|
|
|
draw_tick_right(node->getBoolValue("tick_right", false)),
|
|
|
|
draw_tick_left(node->getBoolValue("tick_left", false)),
|
|
|
|
draw_cap_bottom(node->getBoolValue("cap_bottom", false)),
|
|
|
|
draw_cap_top(node->getBoolValue("cap_top", false)),
|
|
|
|
draw_cap_right(node->getBoolValue("cap_right", false)),
|
|
|
|
draw_cap_left(node->getBoolValue("cap_left", false)),
|
|
|
|
marker_offset(node->getFloatValue("marker_offset", 0.0)),
|
|
|
|
pointer(node->getBoolValue("enable_pointer", true)),
|
|
|
|
pointer_type(node->getStringValue("pointer_type")),
|
|
|
|
tick_type(node->getStringValue("tick_type")), // 'circle' or 'line'
|
|
|
|
tick_length(node->getStringValue("tick_length")), // for variable length
|
|
|
|
radius(node->getFloatValue("radius")),
|
|
|
|
maxValue(node->getFloatValue("maxValue")), // FIXME dup
|
|
|
|
minValue(node->getFloatValue("minValue")), // FIXME dup
|
|
|
|
divisions(node->getIntValue("divisions")),
|
|
|
|
zoom(node->getIntValue("zoom")),
|
|
|
|
Maj_div(node->getIntValue("major_divs")), // FIXME dup
|
|
|
|
Min_div(node->getIntValue("minor_divs")) // FIXME dup
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 23:27:55 +00:00
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "Done reading dial/tape instrument "
|
|
|
|
<< node->getStringValue("name", "[unnamed]"));
|
|
|
|
|
2006-06-15 18:09:15 +00:00
|
|
|
set_data_source(get_func(node->getStringValue("loadfn")));
|
2006-06-14 23:27:55 +00:00
|
|
|
half_width_units = range_to_show() / 2.0;
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
void hud_card::draw(void) // (HUD_scale * pscale)
|
|
|
|
{
|
2001-06-12 23:37:29 +00:00
|
|
|
float vmin = 0.0, vmax = 0.0;
|
2006-06-12 22:27:10 +00:00
|
|
|
float marker_xs;
|
|
|
|
float marker_xe;
|
|
|
|
float marker_ys;
|
|
|
|
float marker_ye;
|
2001-06-12 23:37:29 +00:00
|
|
|
int text_x = 0, text_y = 0;
|
|
|
|
int lenstr;
|
|
|
|
int height, width;
|
|
|
|
int i, last;
|
|
|
|
char TextScale[80];
|
|
|
|
bool condition;
|
|
|
|
int disp_val = 0;
|
2001-09-19 22:23:25 +00:00
|
|
|
int oddtype, k; //odd or even values for ticks
|
2001-06-12 23:37:29 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
POINT mid_scr = get_centroid();
|
|
|
|
float cur_value = get_value();
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!((int)maxValue % 2))
|
2006-06-12 23:27:55 +00:00
|
|
|
oddtype = 0; //draw ticks at even values
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
2006-06-12 23:27:55 +00:00
|
|
|
oddtype = 1; //draw ticks at odd values
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
RECT scrn_rect = get_location();
|
|
|
|
UINT options = get_options();
|
2001-06-12 23:37:29 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
height = scrn_rect.top + scrn_rect.bottom;
|
2001-06-12 23:37:29 +00:00
|
|
|
width = scrn_rect.left + scrn_rect.right;
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// if type=gauge then display dial
|
2006-06-12 23:27:55 +00:00
|
|
|
if (type == "gauge") {
|
2006-06-14 23:27:55 +00:00
|
|
|
float x, y;
|
2001-09-20 22:10:45 +00:00
|
|
|
float i;
|
2006-06-12 23:27:55 +00:00
|
|
|
y = (float)(scrn_rect.top);
|
|
|
|
x = (float)(scrn_rect.left);
|
2001-09-20 22:10:45 +00:00
|
|
|
glEnable(GL_POINT_SMOOTH);
|
|
|
|
glPointSize(3.0);
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
float incr = 360.0 / divisions;
|
|
|
|
for (i = 0.0; i < 360.0; i += incr) {
|
|
|
|
float i1 = i * SGD_DEGREES_TO_RADIANS;
|
2006-06-14 23:27:55 +00:00
|
|
|
float x1 = x + radius * cos(i1);
|
|
|
|
float y1 = y + radius * sin(i1);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
glBegin(GL_POINTS);
|
2006-06-12 23:27:55 +00:00
|
|
|
glVertex2f(x1, y1);
|
2001-09-20 22:10:45 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
glPointSize(1.0);
|
|
|
|
glDisable(GL_POINT_SMOOTH);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (data_available()) {
|
|
|
|
float offset = 90.0 * SGD_DEGREES_TO_RADIANS;
|
|
|
|
float r1 = 10.0; //size of carrot
|
|
|
|
float theta = get_value();
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float theta1 = -theta * SGD_DEGREES_TO_RADIANS + offset;
|
|
|
|
float x1 = x + radius * cos(theta1);
|
|
|
|
float y1 = y + radius * sin(theta1);
|
|
|
|
float x2 = x1 - r1 * cos(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
|
|
|
|
float y2 = y1 - r1 * sin(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
|
|
|
|
float x3 = x1 - r1 * cos(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
|
|
|
|
float y3 = y1 - r1 * sin(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
// draw carrot
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(x1, y1, x2, y2);
|
|
|
|
drawOneLine(x1, y1, x3, y3);
|
|
|
|
sprintf(TextScale,"%3.1f\n", theta);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// draw value
|
2002-02-08 17:19:21 +00:00
|
|
|
int l = abs((int)theta);
|
|
|
|
if (l) {
|
2006-06-12 23:27:55 +00:00
|
|
|
if (l < 10)
|
|
|
|
textString(x, y, TextScale, 0);
|
|
|
|
else if (l < 100)
|
2006-06-14 23:27:55 +00:00
|
|
|
textString(x - 1.0, y, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
else if (l<360)
|
2006-06-14 23:27:55 +00:00
|
|
|
textString(x - 2.0, y, TextScale, 0);
|
2002-02-08 17:19:21 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
}
|
|
|
|
//end type=gauge
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
|
|
|
// if its not explicitly a gauge default to tape
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (pointer_type == "moving") {
|
2001-09-20 22:10:45 +00:00
|
|
|
vmin = minValue;
|
|
|
|
vmax = maxValue;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
|
|
|
// default to fixed
|
2006-06-14 23:27:55 +00:00
|
|
|
vmin = cur_value - half_width_units; // width units == needle travel
|
|
|
|
vmax = cur_value + half_width_units; // or picture unit span.
|
2001-09-19 22:23:25 +00:00
|
|
|
text_x = mid_scr.x;
|
|
|
|
text_y = mid_scr.y;
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
2006-06-14 23:27:55 +00:00
|
|
|
vmin = cur_value - half_width_units; // width units == needle travel
|
|
|
|
vmax = cur_value + half_width_units; // or picture unit span.
|
2001-06-12 23:37:29 +00:00
|
|
|
text_x = mid_scr.x;
|
|
|
|
text_y = mid_scr.y;
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// Draw the basic markings for the scale...
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (huds_vert(options)) { // Vertical scale
|
2006-06-14 23:27:55 +00:00
|
|
|
// Bottom tick bar
|
|
|
|
if (draw_tick_bottom)
|
|
|
|
drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
|
|
|
|
|
|
|
|
// Top tick bar
|
|
|
|
if (draw_tick_top)
|
|
|
|
drawOneLine(scrn_rect.left, height, width, height);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
marker_xs = scrn_rect.left; // x start
|
2006-06-12 23:27:55 +00:00
|
|
|
marker_xe = width; // x extent
|
2001-09-20 22:10:45 +00:00
|
|
|
marker_ye = height;
|
1999-05-12 02:04:38 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// glBegin(GL_LINES);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// Bottom tick bar
|
2006-06-12 23:27:55 +00:00
|
|
|
// glVertex2f(marker_xs, scrn_rect.top);
|
|
|
|
// glVertex2f(marker_xe, scrn_rect.top);
|
2001-01-05 16:44:48 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// Top tick bar
|
2006-06-12 23:27:55 +00:00
|
|
|
// glVertex2f(marker_xs, marker_ye);
|
|
|
|
// glVertex2f(marker_xe, marker_ye);
|
2001-09-20 22:10:45 +00:00
|
|
|
// glEnd();
|
2001-01-05 16:44:48 +00:00
|
|
|
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// We do not use else in the following so that combining the
|
|
|
|
// two options produces a "caged" display with double
|
|
|
|
// carrots. The same is done for horizontal card indicators.
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// begin vertical/left
|
|
|
|
//First draw capping lines and pointers
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_left(options)) { // Calculate x marker offset
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
if (draw_cap_right) {
|
2006-06-14 23:27:55 +00:00
|
|
|
// Cap right side
|
|
|
|
drawOneLine(marker_xe, scrn_rect.top, marker_xe, marker_ye);
|
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
|
|
|
|
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(marker_xs, mid_scr.y,
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xe, mid_scr.y + scrn_rect.right / 6);
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(marker_xs, mid_scr.y,
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xe, mid_scr.y - scrn_rect.right / 6);
|
|
|
|
|
|
|
|
// draw pointer
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (pointer_type == "moving") {
|
2006-06-12 23:27:55 +00:00
|
|
|
if (zoom == 0) {
|
|
|
|
//Code for Moving Type Pointer
|
2006-06-14 23:27:55 +00:00
|
|
|
float ycentre, ypoint, xpoint;
|
|
|
|
int range, wth;
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > maxValue)
|
|
|
|
cur_value = maxValue;
|
|
|
|
if (cur_value < minValue)
|
|
|
|
cur_value = minValue;
|
|
|
|
|
|
|
|
if (minValue >= 0.0)
|
2001-09-20 22:10:45 +00:00
|
|
|
ycentre = scrn_rect.top;
|
|
|
|
else if (maxValue + minValue == 0.0)
|
|
|
|
ycentre = mid_scr.y;
|
2006-06-14 23:27:55 +00:00
|
|
|
else if (oddtype == 1)
|
|
|
|
ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom
|
|
|
|
/ (maxValue - minValue);
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
2006-06-14 23:27:55 +00:00
|
|
|
ycentre = scrn_rect.top + minValue * scrn_rect.bottom
|
|
|
|
/ (maxValue - minValue);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
range = scrn_rect.bottom;
|
2006-06-14 23:27:55 +00:00
|
|
|
wth = scrn_rect.left + scrn_rect.right;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
if (oddtype == 1)
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
|
|
|
ypoint = ycentre + (cur_value * range / val_span);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xpoint = wth + marker_offset;
|
2006-06-14 23:27:55 +00:00
|
|
|
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);
|
2006-06-12 23:27:55 +00:00
|
|
|
} //zoom=0
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
|
|
|
// default to fixed
|
2006-06-14 23:27:55 +00:00
|
|
|
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);
|
2001-09-20 22:10:45 +00:00
|
|
|
}//end pointer type
|
2006-06-12 23:27:55 +00:00
|
|
|
} //if pointer
|
|
|
|
} //end vertical/left
|
2001-09-20 22:10:45 +00:00
|
|
|
|
|
|
|
// begin vertical/right
|
|
|
|
//First draw capping lines and pointers
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_right(options)) { // We'll default this for now.
|
2001-09-20 22:10:45 +00:00
|
|
|
if (draw_cap_left) {
|
2006-06-14 23:27:55 +00:00
|
|
|
// Cap left side
|
|
|
|
drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
|
2001-09-20 22:10:45 +00:00
|
|
|
} //endif cap_left
|
|
|
|
|
|
|
|
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
|
|
|
|
// Indicator carrot
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
|
|
|
|
// marker_xe, mid_scr.y);
|
|
|
|
// drawOneLine(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xe, mid_scr.y);
|
|
|
|
|
|
|
|
// draw pointer
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer) {
|
|
|
|
if (pointer_type == "moving") {
|
|
|
|
if (zoom == 0) {
|
2001-09-20 22:10:45 +00:00
|
|
|
//type-fixed & zoom=1, behaviour to be defined
|
2006-06-12 23:27:55 +00:00
|
|
|
// Code for Moving Type Pointer
|
2006-06-14 23:27:55 +00:00
|
|
|
float ycentre, ypoint, xpoint;
|
2002-05-10 23:35:06 +00:00
|
|
|
int range;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (cur_value > maxValue)
|
2002-02-08 17:19:21 +00:00
|
|
|
cur_value = maxValue;
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value < minValue)
|
2002-02-08 17:19:21 +00:00
|
|
|
cur_value = minValue;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (minValue >= 0.0)
|
2001-09-20 22:10:45 +00:00
|
|
|
ycentre = scrn_rect.top;
|
|
|
|
else if (maxValue + minValue == 0.0)
|
|
|
|
ycentre = mid_scr.y;
|
2006-06-14 23:27:55 +00:00
|
|
|
else if (oddtype == 1)
|
|
|
|
ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom / (maxValue - minValue);
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
2006-06-14 23:27:55 +00:00
|
|
|
ycentre = scrn_rect.top + minValue * scrn_rect.bottom / (maxValue - minValue);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
range = scrn_rect.bottom;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
if (oddtype == 1)
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
|
|
|
ypoint = ycentre + (cur_value * range / val_span);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xpoint = scrn_rect.left - marker_offset;
|
2006-06-14 23:27:55 +00:00
|
|
|
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);
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
|
|
|
// default to fixed
|
2006-06-14 23:27:55 +00:00
|
|
|
fixed(-marker_offset + scrn_rect.left, text_y + scrn_rect.right / 6,
|
|
|
|
-marker_offset + marker_xe, text_y,-marker_offset + scrn_rect.left,
|
|
|
|
text_y - scrn_rect.right / 6);
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
|
|
|
} //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.
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_both(options)) {
|
2001-09-20 22:10:45 +00:00
|
|
|
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.
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// draw scale or tape
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2002-02-08 17:19:21 +00:00
|
|
|
// last = FloatToInt(vmax)+1;
|
|
|
|
// i = FloatToInt(vmin);
|
|
|
|
last = (int)vmax + 1; // N
|
|
|
|
i = (int)vmin; // N
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (zoom == 1) {
|
|
|
|
zoomed_scale((int)vmin, (int)vmax);
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
2006-06-12 23:27:55 +00:00
|
|
|
for (; i < last; i++) {
|
2001-09-20 22:10:45 +00:00
|
|
|
condition = true;
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!modulo() && i < min_val())
|
|
|
|
condition = false;
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (condition) { // Show a tick if necessary
|
2001-09-20 22:10:45 +00:00
|
|
|
// Calculate the location of this tick
|
2006-06-12 23:27:55 +00:00
|
|
|
marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
|
2001-09-20 22:10:45 +00:00
|
|
|
// 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.
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if ((marker_ys < (scrn_rect.top + 4))
|
2006-06-14 23:27:55 +00:00
|
|
|
|| (marker_ys > (height - 4))) {
|
2002-02-08 17:19:21 +00:00
|
|
|
// Magic numbers!!!
|
|
|
|
continue;
|
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (oddtype == 1)
|
2006-06-14 23:27:55 +00:00
|
|
|
k = i + 1; //enable ticks at odd values
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
|
|
|
k = i;
|
|
|
|
|
|
|
|
// Minor ticks
|
2006-06-12 23:27:55 +00:00
|
|
|
if (div_min()) {
|
2006-06-14 23:27:55 +00:00
|
|
|
// if ((i % div_min()) == 0) {
|
|
|
|
if (!(k % (int)div_min())) {
|
2006-06-12 23:27:55 +00:00
|
|
|
if (((marker_ys - 5) > scrn_rect.top)
|
|
|
|
&& ((marker_ys + 5) < (height))) {
|
|
|
|
|
|
|
|
//vertical/left OR vertical/right
|
|
|
|
if (huds_both(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (tick_type == "line") {
|
|
|
|
if (tick_length == "variable") {
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(scrn_rect.left, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, marker_ys);
|
|
|
|
drawOneLine(marker_xe, marker_ys,
|
|
|
|
width, marker_ys);
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(scrn_rect.left, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, marker_ys);
|
|
|
|
drawOneLine(marker_xe, marker_ys,
|
|
|
|
width, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
} else if (tick_type == "circle") {
|
|
|
|
circles(scrn_rect.left,(float)marker_ys, 3.0);
|
|
|
|
|
|
|
|
} else {
|
2006-06-12 23:27:55 +00:00
|
|
|
// if neither line nor circle draw default as line
|
|
|
|
drawOneLine(scrn_rect.left, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, marker_ys);
|
|
|
|
drawOneLine(marker_xe, marker_ys,
|
|
|
|
width, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
// glBegin(GL_LINES);
|
|
|
|
// glVertex2f(scrn_rect.left, marker_ys);
|
|
|
|
// glVertex2f(marker_xs, marker_ys);
|
|
|
|
// glVertex2f(marker_xe, marker_ys);
|
|
|
|
// glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
|
|
|
|
// glEnd();
|
|
|
|
// anything other than huds_both
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (huds_left(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (tick_type == "line") {
|
|
|
|
if (tick_length == "variable") {
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs + 4, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xe, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys,
|
|
|
|
marker_xe, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
} else if (tick_type == "circle") {
|
|
|
|
circles((float)marker_xs + 4, (float)marker_ys, 3.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
} else {
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs + 4, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xe, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (tick_type == "line") {
|
|
|
|
if (tick_length == "variable") {
|
|
|
|
drawOneLine(marker_xs, marker_ys,
|
|
|
|
marker_xe - 4, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys,
|
|
|
|
marker_xe, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
|
|
|
|
} 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);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} //end huds both
|
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
} //end draw minor ticks
|
|
|
|
} //end minor ticks
|
|
|
|
|
|
|
|
// Major ticks
|
2006-06-12 23:27:55 +00:00
|
|
|
if (div_max()) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!(k % (int)div_max())) {
|
2006-06-12 23:27:55 +00:00
|
|
|
if (modulo()) {
|
2001-09-20 22:10:45 +00:00
|
|
|
disp_val = i % (int) modulo(); // ?????????
|
2006-06-12 23:27:55 +00:00
|
|
|
if (disp_val < 0) {
|
|
|
|
while (disp_val < 0)
|
2001-09-20 22:10:45 +00:00
|
|
|
disp_val += modulo();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
disp_val = i;
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
lenstr = sprintf(TextScale, "%d",
|
2006-06-14 23:27:55 +00:00
|
|
|
FloatToInt(disp_val * data_scaling()/*+.5*/));
|
2001-09-20 22:10:45 +00:00
|
|
|
// (int)(disp_val * data_scaling() +.5));
|
2006-06-12 23:27:55 +00:00
|
|
|
/* if (((marker_ys - 8) > scrn_rect.top) &&
|
|
|
|
((marker_ys + 8) < (height))){ */
|
2001-09-20 22:10:45 +00:00
|
|
|
// huds_both
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_both(options)) {
|
|
|
|
// drawOneLine(scrn_rect.left, marker_ys,
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xs, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(marker_xs, marker_ys,
|
2001-09-20 22:10:45 +00:00
|
|
|
// scrn_rect.left + scrn_rect.right,
|
|
|
|
// marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
if (tick_type == "line") {
|
2001-09-20 22:10:45 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2006-06-12 23:27:55 +00:00
|
|
|
glVertex2f(scrn_rect.left, marker_ys);
|
|
|
|
glVertex2f(marker_xs, marker_ys);
|
|
|
|
glVertex2f(width, marker_ys);
|
2001-09-20 22:10:45 +00:00
|
|
|
glEnd();
|
2006-06-14 23:27:55 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
} else if (tick_type == "circle") {
|
2006-06-14 23:27:55 +00:00
|
|
|
circles(scrn_rect.left, (float)marker_ys, 5.0);
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2006-06-12 23:27:55 +00:00
|
|
|
glVertex2f(scrn_rect.left, marker_ys);
|
|
|
|
glVertex2f(marker_xs, marker_ys);
|
|
|
|
glVertex2f(width, marker_ys);
|
2001-09-20 22:10:45 +00:00
|
|
|
glEnd();
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString (marker_xs + 2, marker_ys, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Changes are made to draw a circle when tick_type="circle" */
|
2001-09-20 22:10:45 +00:00
|
|
|
// anything other than huds_both
|
2006-06-14 23:27:55 +00:00
|
|
|
if (tick_type == "line")
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
|
2006-06-14 23:27:55 +00:00
|
|
|
else if (tick_type == "circle")
|
|
|
|
circles((float)marker_xs + 4, (float)marker_ys, 5.0);
|
|
|
|
else
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
|
|
|
|
|
|
|
|
if (!huds_notext(options)) {
|
|
|
|
if (huds_left(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
textString(marker_xs - 8 * lenstr - 2,
|
|
|
|
marker_ys - 4, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
|
|
|
textString(marker_xe + 3 * lenstr,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_ys - 4, TextScale, 0);
|
2001-09-20 22:10:45 +00:00
|
|
|
} //End if huds_left
|
|
|
|
} //End if !huds_notext
|
|
|
|
} //End if huds-both
|
|
|
|
} // End if draw major ticks
|
|
|
|
} // End if major ticks
|
|
|
|
} // End condition
|
2006-06-12 23:27:55 +00:00
|
|
|
} // End for
|
2001-09-20 22:10:45 +00:00
|
|
|
} //end of zoom
|
|
|
|
// End if VERTICAL SCALE TYPE (tape loop yet to be closed)
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
} else {
|
|
|
|
// Horizontal scale by default
|
|
|
|
// left tick bar
|
2006-06-14 23:27:55 +00:00
|
|
|
if (draw_tick_left)
|
|
|
|
drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// right tick bar
|
2006-06-14 23:27:55 +00:00
|
|
|
if (draw_tick_right)
|
|
|
|
drawOneLine(width, scrn_rect.top, width, height);
|
|
|
|
|
|
|
|
marker_ys = scrn_rect.top; // Starting point for
|
|
|
|
marker_ye = height; // tick y location calcs
|
2001-09-20 22:10:45 +00:00
|
|
|
marker_xe = width;
|
2006-06-12 23:27:55 +00:00
|
|
|
marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
|
2001-01-05 16:44:48 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// glBegin(GL_LINES);
|
|
|
|
// left tick bar
|
2006-06-12 23:27:55 +00:00
|
|
|
// glVertex2f(scrn_rect.left, scrn_rect.top);
|
|
|
|
// glVertex2f(scrn_rect.left, marker_ye);
|
2001-09-20 22:10:45 +00:00
|
|
|
|
|
|
|
// right tick bar
|
2006-06-12 23:27:55 +00:00
|
|
|
// glVertex2f(marker_xe, scrn_rect.top);
|
|
|
|
// glVertex2f(marker_xe, marker_ye);
|
2001-09-20 22:10:45 +00:00
|
|
|
// glEnd();
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_top(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
// Bottom box line
|
|
|
|
if (draw_cap_bottom)
|
|
|
|
drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
|
2001-09-20 22:10:45 +00:00
|
|
|
|
|
|
|
// Tick point adjust
|
|
|
|
marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
|
|
|
|
// Bottom arrow
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(mid_scr.x, marker_ye,
|
2001-09-20 22:10:45 +00:00
|
|
|
// mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(mid_scr.x, marker_ye,
|
2001-09-20 22:10:45 +00:00
|
|
|
// mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
|
|
|
|
// draw pointer
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer) {
|
|
|
|
if (pointer_type == "moving") {
|
|
|
|
if (zoom == 0) {
|
|
|
|
//Code for Moving Type Pointer
|
2006-06-14 23:27:55 +00:00
|
|
|
// static float xcentre, xpoint, ypoint;
|
2002-02-08 17:19:21 +00:00
|
|
|
// static int range;
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > maxValue)
|
|
|
|
cur_value = maxValue;
|
|
|
|
if (cur_value < minValue)
|
|
|
|
cur_value = minValue;
|
|
|
|
|
2002-02-08 17:19:21 +00:00
|
|
|
float xcentre = mid_scr.x;
|
|
|
|
int range = scrn_rect.right;
|
|
|
|
float xpoint = xcentre + (cur_value * range / val_span);
|
|
|
|
float ypoint = scrn_rect.top - marker_offset;
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xcentre, ypoint, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint, ypoint + marker_offset);
|
|
|
|
drawOneLine(xpoint, ypoint + marker_offset, xpoint + 5.0, ypoint + 5.0);
|
|
|
|
drawOneLine(xpoint, ypoint + marker_offset, xpoint - 5.0, ypoint + 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
//default to fixed
|
2006-06-14 23:27:55 +00:00
|
|
|
fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
|
|
|
|
marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
} //if pointer
|
|
|
|
} //End Horizontal scale/top
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_bottom(options)) {
|
2001-09-20 22:10:45 +00:00
|
|
|
// Top box line
|
2006-06-14 23:27:55 +00:00
|
|
|
if (draw_cap_top)
|
|
|
|
drawOneLine(scrn_rect.left, height, width, height);
|
2001-09-20 22:10:45 +00:00
|
|
|
|
|
|
|
// Tick point adjust
|
2006-06-12 23:27:55 +00:00
|
|
|
marker_ys = height - scrn_rect.bottom / 2;
|
2001-09-20 22:10:45 +00:00
|
|
|
// Top arrow
|
2006-06-12 23:27:55 +00:00
|
|
|
// drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
|
2001-09-20 22:10:45 +00:00
|
|
|
// scrn_rect.top + scrn_rect.bottom,
|
2006-06-12 23:27:55 +00:00
|
|
|
// mid_scr.x, marker_ys);
|
|
|
|
// drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
|
2001-09-20 22:10:45 +00:00
|
|
|
// scrn_rect.top + scrn_rect.bottom,
|
2006-06-12 23:27:55 +00:00
|
|
|
// mid_scr.x , marker_ys);
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// draw pointer
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer) {
|
2006-06-14 23:27:55 +00:00
|
|
|
if (pointer_type == "moving") {
|
2006-06-12 23:27:55 +00:00
|
|
|
if (zoom == 0) {
|
|
|
|
//Code for Moving Type Pointer
|
2006-06-14 23:27:55 +00:00
|
|
|
// static float xcentre, xpoint, ypoint;
|
|
|
|
// static int range, hgt;
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > maxValue)
|
|
|
|
cur_value = maxValue;
|
|
|
|
if (cur_value < minValue)
|
|
|
|
cur_value = minValue;
|
|
|
|
|
2002-02-08 17:19:21 +00:00
|
|
|
float xcentre = mid_scr.x ;
|
|
|
|
int range = scrn_rect.right;
|
2006-06-14 23:27:55 +00:00
|
|
|
int hgt = scrn_rect.top + scrn_rect.bottom;
|
2002-02-08 17:19:21 +00:00
|
|
|
float xpoint = xcentre + (cur_value * range / val_span);
|
|
|
|
float ypoint = hgt + marker_offset;
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xcentre, ypoint, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint, ypoint - marker_offset);
|
|
|
|
drawOneLine(xpoint, ypoint - marker_offset, xpoint + 5.0, ypoint - 5.0);
|
|
|
|
drawOneLine(xpoint, ypoint - marker_offset, xpoint - 5.0, ypoint - 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs - scrn_rect.bottom / 4, height);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
} //if pointer
|
|
|
|
} //end horizontal scale bottom
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
// if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xe = marker_ys;
|
|
|
|
// marker_ys = marker_ye;
|
|
|
|
// marker_ye = marker_xe;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// last = FloatToInt(vmax)+1;
|
|
|
|
// i = FloatToInt(vmin);
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (zoom == 1) {
|
|
|
|
zoomed_scale((int)vmin,(int)vmax);
|
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
//default to zoom=0
|
|
|
|
last = (int)vmax + 1;
|
|
|
|
i = (int)vmin;
|
2006-06-12 23:27:55 +00:00
|
|
|
for (; i < last; i++) {
|
|
|
|
// for (i = (int)vmin; i <= (int)vmax; i++) {
|
2001-09-20 22:10:45 +00:00
|
|
|
// printf("<*> i = %d\n", i);
|
|
|
|
condition = true;
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!modulo() && i < min_val())
|
|
|
|
condition = false;
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// printf("<**> i = %d\n", i);
|
2006-06-12 23:27:55 +00:00
|
|
|
if (condition) {
|
2001-09-20 22:10:45 +00:00
|
|
|
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
|
2006-06-12 23:27:55 +00:00
|
|
|
marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (oddtype == 1)
|
2006-06-14 23:27:55 +00:00
|
|
|
k = i + 1; //enable ticks at odd values
|
2001-09-20 22:10:45 +00:00
|
|
|
else
|
|
|
|
k = i;
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (div_min()) {
|
2006-06-14 23:27:55 +00:00
|
|
|
// if ((i % (int)div_min()) == 0) {
|
2001-09-20 22:10:45 +00:00
|
|
|
//draw minor ticks
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!(k % (int)div_min())) {
|
2001-09-20 22:10:45 +00:00
|
|
|
// draw in ticks only if they aren't too close to the edge.
|
2006-06-12 23:27:55 +00:00
|
|
|
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,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, marker_ys - 4);
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ye + 4,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, height);
|
2006-06-12 23:27:55 +00:00
|
|
|
} else {
|
|
|
|
drawOneLine(marker_xs, scrn_rect.top,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, marker_ys);
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ye,
|
2006-06-14 23:27:55 +00:00
|
|
|
marker_xs, height);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
// 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
|
2006-06-14 23:27:55 +00:00
|
|
|
if (tick_length == "variable")
|
|
|
|
drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
|
2006-06-12 23:27:55 +00:00
|
|
|
else
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
} 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);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
}
|
|
|
|
} //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(); // ?????????
|
|
|
|
if (disp_val < 0) {
|
|
|
|
while (disp_val<0)
|
|
|
|
disp_val += modulo();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
disp_val = i;
|
|
|
|
}
|
|
|
|
// printf("disp_val = %d\n", disp_val);
|
|
|
|
// printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
|
|
|
|
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 (huds_both(options)) {
|
|
|
|
// drawOneLine(marker_xs, scrn_rect.top,
|
|
|
|
// marker_xs, marker_ys);
|
|
|
|
// drawOneLine(marker_xs, marker_ye,
|
|
|
|
// marker_xs, scrn_rect.top + scrn_rect.bottom);
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
glVertex2f(marker_xs, scrn_rect.top);
|
|
|
|
glVertex2f(marker_xs, marker_ye);
|
|
|
|
glVertex2f(marker_xs, height);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
if (!huds_notext(options)) {
|
|
|
|
textString(marker_xs - 4 * lenstr,
|
|
|
|
marker_ys + 4, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (!huds_notext(options)) {
|
|
|
|
if (huds_top(options)) {
|
|
|
|
textString(marker_xs - 4 * lenstr,
|
2006-06-14 23:27:55 +00:00
|
|
|
height - 10, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
textString(marker_xs - 4 * lenstr,
|
2006-06-14 23:27:55 +00:00
|
|
|
scrn_rect.top, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-02-08 17:19:21 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
} //end draw major ticks
|
|
|
|
} //endif major ticks
|
|
|
|
} //end condition
|
|
|
|
} //end for
|
|
|
|
} //end zoom
|
|
|
|
} //end horizontal/vertical scale
|
|
|
|
} // end of type tape
|
2001-01-05 16:44:48 +00:00
|
|
|
} //draw
|
2001-09-19 22:23:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
void hud_card::circles(float x, float y, float size)
|
2001-09-19 22:23:25 +00:00
|
|
|
{
|
|
|
|
glEnable(GL_POINT_SMOOTH);
|
2006-06-12 23:27:55 +00:00
|
|
|
glPointSize(size);
|
2001-09-19 22:23:25 +00:00
|
|
|
|
|
|
|
glBegin(GL_POINTS);
|
2006-06-14 23:27:55 +00:00
|
|
|
glVertex2f(x, y);
|
2001-09-20 22:10:45 +00:00
|
|
|
glEnd();
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-19 22:23:25 +00:00
|
|
|
glPointSize(1.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
glDisable(GL_POINT_SMOOTH);
|
2001-09-19 22:23:25 +00:00
|
|
|
}
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
|
2001-09-19 22:23:25 +00:00
|
|
|
{
|
2001-09-20 22:10:45 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
glVertex2f(x1, y1);
|
|
|
|
glVertex2f(x2, y2);
|
2006-06-12 23:27:55 +00:00
|
|
|
glVertex2f(x3, y3);
|
2001-09-19 22:23:25 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
void hud_card::zoomed_scale(int first, int last)
|
2001-09-19 22:23:25 +00:00
|
|
|
{
|
2006-06-14 23:27:55 +00:00
|
|
|
POINT mid_scr = get_centroid();
|
|
|
|
RECT scrn_rect = get_location();
|
|
|
|
UINT options = get_options();
|
2001-09-20 22:10:45 +00:00
|
|
|
char TextScale[80];
|
|
|
|
int data[80];
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float x, y, w, h, bottom;
|
|
|
|
float cur_value = get_value();
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > maxValue)
|
|
|
|
cur_value = maxValue;
|
|
|
|
if (cur_value < minValue)
|
|
|
|
cur_value = minValue;
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
int a = 0;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
while (first <= last) {
|
|
|
|
if ((first % (int)Maj_div) == 0) {
|
2001-09-20 22:10:45 +00:00
|
|
|
data[a] = first;
|
|
|
|
a++ ;
|
|
|
|
}
|
2001-09-19 22:23:25 +00:00
|
|
|
first++;
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
2006-06-14 23:27:55 +00:00
|
|
|
int centre = a / 2;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_vert(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
x = scrn_rect.left;
|
|
|
|
y = scrn_rect.top;
|
|
|
|
w = scrn_rect.left + scrn_rect.right;
|
|
|
|
h = scrn_rect.top + scrn_rect.bottom;
|
|
|
|
bottom = scrn_rect.bottom;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
float xstart, yfirst, ycentre, ysecond;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
|
2001-09-20 22:10:45 +00:00
|
|
|
yfirst = mid_scr.y - hgt;
|
|
|
|
ycentre = mid_scr.y;
|
|
|
|
ysecond = mid_scr.y + hgt;
|
|
|
|
float range = hgt * 2;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
int i;
|
2006-06-14 23:27:55 +00:00
|
|
|
float factor = range / 10.0;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float hgt1 = bottom * 30.0 / 100.0;
|
2001-09-20 22:10:45 +00:00
|
|
|
int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
|
|
|
|
int incr = incrs / 2;
|
|
|
|
float factors = hgt1 / incr;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// begin
|
2006-06-12 23:27:55 +00:00
|
|
|
//this is for moving type pointer
|
2006-06-14 23:27:55 +00:00
|
|
|
static float ycent, ypoint, xpoint;
|
2001-09-20 22:10:45 +00:00
|
|
|
static int wth;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
ycent = mid_scr.y;
|
2006-06-14 23:27:55 +00:00
|
|
|
wth = scrn_rect.left + scrn_rect.right;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value <= data[centre + 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > data[centre]) {
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycent + ((cur_value - data[centre]) * hgt / Maj_div);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value >= data[centre - 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value <= data[centre]) {
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycent - ((data[centre]-cur_value) * hgt / Maj_div);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value < data[centre - 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value >= minValue) {
|
2006-06-14 23:27:55 +00:00
|
|
|
float diff = minValue - data[centre - 1];
|
|
|
|
float diff1 = cur_value - data[centre - 1];
|
2001-09-20 22:10:45 +00:00
|
|
|
float val = (diff1 * hgt1) / diff;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycent - hgt - val;
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value > data[centre + 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value <= maxValue) {
|
2006-06-14 23:27:55 +00:00
|
|
|
float diff = maxValue - data[centre + 1];
|
|
|
|
float diff1 = cur_value - data[centre + 1];
|
2001-09-20 22:10:45 +00:00
|
|
|
float val = (diff1 * hgt1) / diff;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
ypoint = ycent + hgt + val;
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (huds_left(options)) {
|
2001-09-20 22:10:45 +00:00
|
|
|
xstart = w;
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString(x, ycentre, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 5; i++) {
|
2006-06-14 23:27:55 +00:00
|
|
|
yfirst += factor;
|
2001-09-20 22:10:45 +00:00
|
|
|
ycentre += factor;
|
2006-06-14 23:27:55 +00:00
|
|
|
circles(xstart - 2.5, yfirst, 3.0);
|
|
|
|
circles(xstart - 2.5, ycentre, 3.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
yfirst = mid_scr.y - hgt;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
for (i = 0; i <= incr; i++) {
|
|
|
|
drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xstart, ysecond, xstart - 5.0, ysecond);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString (x, yfirst, TextScale, 0);
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString (x, ysecond, TextScale, 0);
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
yfirst -= factors;
|
|
|
|
ysecond += factors;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
//to draw moving type pointer for left option
|
2006-06-12 23:27:55 +00:00
|
|
|
//begin
|
2001-09-20 22:10:45 +00:00
|
|
|
xpoint = wth + 10.0;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (pointer_type == "moving") {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xpoint, ycent, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint - 10.0, ypoint);
|
|
|
|
drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
|
|
|
|
drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
//end
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
//huds_right
|
2006-06-14 23:27:55 +00:00
|
|
|
xstart = (x + w) / 2;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString(w, ycentre, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 5; i++) {
|
2006-06-14 23:27:55 +00:00
|
|
|
yfirst += factor;
|
2001-09-20 22:10:45 +00:00
|
|
|
ycentre += factor;
|
2006-06-14 23:27:55 +00:00
|
|
|
circles(xstart + 2.5, yfirst, 3.0);
|
|
|
|
circles(xstart + 2.5, ycentre, 3.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
yfirst = mid_scr.y - hgt;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
for (i = 0; i <= incr; i++) {
|
|
|
|
drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xstart, ysecond, xstart + 5.0, ysecond);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString(w, yfirst, TextScale, 0);
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString(w, ysecond, TextScale, 0);
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
yfirst -= factors;
|
2006-06-12 23:27:55 +00:00
|
|
|
ysecond += factors;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
// to draw moving type pointer for right option
|
2006-06-12 23:27:55 +00:00
|
|
|
//begin
|
2001-09-20 22:10:45 +00:00
|
|
|
xpoint = scrn_rect.left;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (pointer_type == "moving") {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xpoint, ycent, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint + 10.0, ypoint);
|
|
|
|
drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
|
|
|
|
drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
//end
|
2001-09-20 22:10:45 +00:00
|
|
|
}//end huds_right /left
|
2006-06-12 23:27:55 +00:00
|
|
|
//end of vertical scale
|
|
|
|
|
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
//horizontal scale
|
2006-06-14 23:27:55 +00:00
|
|
|
x = scrn_rect.left;
|
|
|
|
y = scrn_rect.top;
|
|
|
|
w = scrn_rect.left + scrn_rect.right;
|
|
|
|
h = scrn_rect.top + scrn_rect.bottom;
|
|
|
|
bottom = scrn_rect.right;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
float ystart, xfirst, xcentre, xsecond;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
|
2001-09-20 22:10:45 +00:00
|
|
|
xfirst = mid_scr.x - hgt;
|
|
|
|
xcentre = mid_scr.x;
|
|
|
|
xsecond = mid_scr.x + hgt;
|
|
|
|
float range = hgt * 2;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
int i;
|
2006-06-14 23:27:55 +00:00
|
|
|
float factor = range / 10.0;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
float hgt1 = bottom * 30.0 / 100.0;
|
2001-09-20 22:10:45 +00:00
|
|
|
int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
|
|
|
|
int incr = incrs / 2;
|
|
|
|
float factors = hgt1 / incr;
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
//Code for Moving Type Pointer
|
|
|
|
//begin
|
2006-06-14 23:27:55 +00:00
|
|
|
static float xcent, xpoint, ypoint;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xcent = mid_scr.x;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value <= data[centre + 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value > data[centre]) {
|
2006-06-14 23:27:55 +00:00
|
|
|
xpoint = xcent + ((cur_value - data[centre]) * hgt / Maj_div);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value >= data[centre - 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value <= data[centre]) {
|
2006-06-14 23:27:55 +00:00
|
|
|
xpoint = xcent - ((data[centre]-cur_value) * hgt / Maj_div);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value < data[centre - 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value >= minValue) {
|
2006-06-14 23:27:55 +00:00
|
|
|
float diff = minValue - data[centre - 1];
|
|
|
|
float diff1 = cur_value - data[centre - 1];
|
2001-09-20 22:10:45 +00:00
|
|
|
float val = (diff1 * hgt1) / diff;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
xpoint = xcent - hgt - val;
|
2001-09-20 22:10:45 +00:00
|
|
|
}
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (cur_value > data[centre + 1])
|
2006-06-12 23:27:55 +00:00
|
|
|
if (cur_value <= maxValue) {
|
2006-06-14 23:27:55 +00:00
|
|
|
float diff = maxValue - data[centre + 1];
|
|
|
|
float diff1 = cur_value - data[centre + 1];
|
2001-09-20 22:10:45 +00:00
|
|
|
float val = (diff1 * hgt1) / diff;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
xpoint = xcent + hgt + val;
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
//end
|
2006-06-12 23:27:55 +00:00
|
|
|
if (huds_top(options)) {
|
2006-06-14 23:27:55 +00:00
|
|
|
ystart = h;
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString (xcentre - 10.0, y, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 5; i++) {
|
2006-06-14 23:27:55 +00:00
|
|
|
xfirst += factor;
|
2001-09-20 22:10:45 +00:00
|
|
|
xcentre += factor;
|
2006-06-14 23:27:55 +00:00
|
|
|
circles(xfirst, ystart - 2.5, 3.0);
|
|
|
|
circles(xcentre, ystart - 2.5, 3.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xfirst = mid_scr.x - hgt;
|
|
|
|
|
|
|
|
for (i = 0; i <= incr; i++) {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
|
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
2006-06-14 23:27:55 +00:00
|
|
|
textString (xfirst - 10.0, y, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
if (!huds_notext(options))
|
2006-06-14 23:27:55 +00:00
|
|
|
textString (xsecond - 10.0, y, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xfirst -= factors;
|
2006-06-12 23:27:55 +00:00
|
|
|
xsecond += factors;
|
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
//this is for moving pointer for top option
|
|
|
|
//begin
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
|
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer_type == "moving") {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xcent, ypoint, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint, ypoint - 10.0);
|
|
|
|
drawOneLine(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
|
|
|
|
drawOneLine(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
//end of top option
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
} else {
|
2001-09-20 22:10:45 +00:00
|
|
|
//else huds_bottom
|
2006-06-12 23:27:55 +00:00
|
|
|
ystart = (y + h) / 2;
|
|
|
|
|
|
|
|
//drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
|
|
|
|
drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
|
|
|
textString (xcentre - 10.0, h, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 5; i++) {
|
2006-06-14 23:27:55 +00:00
|
|
|
xfirst += factor;
|
2001-09-20 22:10:45 +00:00
|
|
|
xcentre += factor;
|
2006-06-14 23:27:55 +00:00
|
|
|
circles(xfirst, ystart + 2.5, 3.0);
|
|
|
|
circles(xcentre, ystart + 2.5, 3.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xfirst = mid_scr.x - hgt;
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
for (i = 0; i <= incr; i++) {
|
|
|
|
drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xsecond, ystart, xsecond, ystart + 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
|
2001-09-20 22:10:45 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
2006-06-14 23:27:55 +00:00
|
|
|
textString (xfirst - 10.0, h, TextScale, 0);
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2006-06-14 23:27:55 +00:00
|
|
|
sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2006-06-12 23:27:55 +00:00
|
|
|
if (!huds_notext(options))
|
2006-06-14 23:27:55 +00:00
|
|
|
textString (xsecond - 10.0, h, TextScale, 0);
|
2001-09-19 22:23:25 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
xfirst -= factors;
|
|
|
|
xsecond += factors;
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
2001-09-20 22:10:45 +00:00
|
|
|
//this is for movimg pointer for bottom option
|
|
|
|
//begin
|
2006-06-12 23:27:55 +00:00
|
|
|
|
2001-09-20 22:10:45 +00:00
|
|
|
ypoint = scrn_rect.top - 10.0;
|
2006-06-12 23:27:55 +00:00
|
|
|
if (pointer_type == "moving") {
|
2006-06-14 23:27:55 +00:00
|
|
|
drawOneLine(xcent, ypoint, xpoint, ypoint);
|
|
|
|
drawOneLine(xpoint, ypoint, xpoint, ypoint + 10.0);
|
|
|
|
drawOneLine(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
|
|
|
|
drawOneLine(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
|
2006-06-12 23:27:55 +00:00
|
|
|
}
|
|
|
|
}//end hud_top or hud_bottom
|
2001-09-20 22:10:45 +00:00
|
|
|
} //end of horizontal/vertical scales
|
2001-09-19 22:23:25 +00:00
|
|
|
}//end draw
|
2006-06-12 23:27:55 +00:00
|
|
|
|
|
|
|
|