5 #ifdef USE_HUD_TextList
6 #define textString(x, y, text, digit) TextString(text, x , y ,digit)
8 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
11 //============== Top of gauge_instr class member definitions ==============
13 gauge_instr::gauge_instr(
28 instr_scale( x, y, width, height,
30 (maxValue - minValue), // Always shows span?
33 major_divs, minor_divs,
37 // UINT options = get_options();
38 // huds_vert = options & HUDS_VERT;
39 // huds_left = options & HUDS_LEFT;
40 // huds_right = options & HUDS_RIGHT;
41 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
42 // huds_noticks = options & HUDS_NOTICKS;
43 // huds_notext = options & HUDS_NOTEXT;
44 // huds_top = options & HUDS_TOP;
45 // huds_bottom = options & HUDS_BOTTOM;
49 gauge_instr::~gauge_instr()
54 gauge_instr::gauge_instr( const gauge_instr & image) :
55 instr_scale( (instr_scale &) image)
57 // UINT options = get_options();
58 // huds_vert = options & HUDS_VERT;
59 // huds_left = options & HUDS_LEFT;
60 // huds_right = options & HUDS_RIGHT;
61 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
62 // huds_noticks = options & HUDS_NOTICKS;
63 // huds_notext = options & HUDS_NOTEXT;
64 // huds_top = options & HUDS_TOP;
65 // huds_bottom = options & HUDS_BOTTOM;
69 // As implemented, draw only correctly draws a horizontal or vertical
70 // scale. It should contain a variation that permits clock type displays.
71 // Now is supports "tickless" displays such as control surface indicators.
72 // This routine should be worked over before using. Current value would be
73 // fetched and not used if not commented out. Clearly that is intollerable.
75 void gauge_instr::draw (void)
77 float marker_xs, marker_xe;
78 float marker_ys, marker_ye;
80 int width, height, bottom_4;
86 float vmin = min_val();
87 float vmax = max_val();
88 POINT mid_scr = get_centroid();
89 float cur_value = get_value();
90 RECT scrn_rect = get_location();
91 UINT options = get_options();
93 width = scrn_rect.left + scrn_rect.right;
94 height = scrn_rect.top + scrn_rect.bottom,
95 bottom_4 = scrn_rect.bottom / 4;
96 // Draw the basic markings for the scale...
98 if ( huds_vert(options) ) { // Vertical scale
99 drawOneLine( scrn_rect.left, // Bottom tick bar
104 drawOneLine( scrn_rect.left, // Top tick bar
109 marker_xs = scrn_rect.left;
112 if ( huds_left(options) ) { // Read left, so line down right side
118 marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick xs
121 if ( huds_right(options) ) { // Read right, so down left sides
122 drawOneLine( scrn_rect.left,
127 marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick xe
130 // At this point marker x_start and x_end values are transposed.
131 // To keep this from confusing things they are now interchanged.
132 if ( huds_both(options) ) {
133 marker_ye = marker_xs;
134 marker_xs = marker_xe;
135 marker_xe = marker_ye;
138 // Work through from bottom to top of scale. Calculating where to put
139 // minor and major ticks.
141 if ( !huds_noticks(options)) { // If not no ticks...:)
142 // Calculate x marker offsets
143 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
144 i = (int)vmin; //FloatToInt(vmin);
145 for (; i < last; i++) {
146 // for ( i = (int)vmin; i <= (int)vmax; i++ ) {
148 // Calculate the location of this tick
149 marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/;
151 // We compute marker_ys even though we don't know if we will use
152 // either major or minor divisions. Simpler.
154 if ( div_min()) { // Minor tick marks
155 if ( !(i%(int)div_min()) ) {
156 if ( huds_left(options) && huds_right(options) ) {
157 drawOneLine( scrn_rect.left, marker_ys,
158 marker_xs - 3, marker_ys );
159 drawOneLine( marker_xe + 3, marker_ys,
163 if ( huds_left(options) ) {
164 drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
167 drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
173 // Now we work on the major divisions. Since these are also labeled
174 // and no labels are drawn otherwise, we label inside this if
177 if ( div_max()) { // Major tick mark
178 if ( !(i%(int)div_max()) ) {
179 if ( huds_left(options) && huds_right(options) ) {
180 drawOneLine( scrn_rect.left, marker_ys,
181 marker_xs, marker_ys );
182 drawOneLine( marker_xe, marker_ys,
186 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
189 if ( !huds_notext(options) ) {
191 sprintf( TextScale, "%d",
192 FloatToInt(disp_val * data_scaling()/*+.5*/ ));
194 lenstr = getStringWidth( TextScale );
196 if ( huds_left(options) && huds_right(options) ) {
197 text_x = mid_scr.x - lenstr/2 ;
200 if ( huds_left(options) ) {
201 text_x = FloatToInt(marker_xs - lenstr);
204 text_x = FloatToInt(marker_xe - lenstr);
207 // Now we know where to put the text.
208 text_y = FloatToInt(marker_ys);
209 textString( text_x, text_y, TextScale, 0 );
215 // Now that the scale is drawn, we draw in the pointer(s). Since labels
216 // have been drawn, text_x and text_y may be recycled. This is used
217 // with the marker start stops to produce a pointer for each side reading
219 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
220 // text_x = marker_xs - scrn_rect.left;
222 if ( huds_right(options) ) {
223 glBegin(GL_LINE_STRIP);
224 glVertex2f( scrn_rect.left, text_y + 5);
225 glVertex2f( FloatToInt(marker_xe), text_y);
226 glVertex2f( scrn_rect.left, text_y - 5);
229 if ( huds_left(options) ) {
230 glBegin(GL_LINE_STRIP);
231 glVertex2f( width, text_y + 5);
232 glVertex2f( FloatToInt(marker_xs), text_y);
233 glVertex2f( width, text_y - 5);
236 // End if VERTICAL SCALE TYPE
238 } else { // Horizontal scale by default
239 drawOneLine( scrn_rect.left, // left tick bar
244 drawOneLine( width, // right tick bar
249 marker_ys = scrn_rect.top; // Starting point for
250 marker_ye = height; // tick y location calcs
251 marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/;
253 if ( huds_top(options) ) {
254 drawOneLine( scrn_rect.left,
257 scrn_rect.top); // Bottom box line
259 marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust
261 glBegin(GL_LINE_STRIP);
262 glVertex2f( marker_xs - bottom_4, scrn_rect.top);
263 glVertex2f( marker_xs, marker_ye);
264 glVertex2f( marker_xs + bottom_4, scrn_rect.top);
267 if ( huds_bottom(options) ) {
269 drawOneLine( scrn_rect.left, height, width, height);
271 marker_ys = height - scrn_rect.bottom / 2.0;
274 glBegin(GL_LINE_STRIP);
275 glVertex2f( marker_xs + bottom_4, height);
276 glVertex2f( marker_xs, marker_ys );
277 glVertex2f( marker_xs - bottom_4, height);
282 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
283 i = (int)vmin; //FloatToInt(vmin);
284 for ( ; i <last ; i++ ) {
287 if ( i < min_val()) {
292 marker_xs = scrn_rect.left + (i - vmin) * factor()/* +.5f*/;
293 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
295 if ( !(i%(int)div_min()) ) {
296 // draw in ticks only if they aren't too close to the edge.
297 if ((( marker_xs + 5) > scrn_rect.left ) ||
298 (( marker_xs - 5 )< (width))){
300 if ( huds_both(options) ) {
301 drawOneLine( marker_xs, scrn_rect.top,
302 marker_xs, marker_ys - 4);
303 drawOneLine( marker_xs, marker_ye + 4,
307 if ( huds_top(options) ) {
308 drawOneLine( marker_xs, marker_ys,
309 marker_xs, marker_ye - 4);
312 drawOneLine( marker_xs, marker_ys + 4,
313 marker_xs, marker_ye);
320 if ( !(i%(int)div_max()) ) {
323 while ( disp_val < 0 ) {
324 disp_val += modulo();
327 disp_val = i % (int)modulo();
331 sprintf( TextScale, "%d",
332 FloatToInt(disp_val * data_scaling()/* +.5*/ ));
333 lenstr = getStringWidth( TextScale);
335 // Draw major ticks and text only if far enough from the edge.
336 if (( (marker_xs - 10)> scrn_rect.left ) &&
337 ( (marker_xs + 10) < width )){
338 if ( huds_both(options) ) {
339 drawOneLine( marker_xs, scrn_rect.top,
340 marker_xs, marker_ys);
341 drawOneLine( marker_xs, marker_ye,
344 if ( !huds_notext(options) ) {
345 textString ( marker_xs - lenstr, marker_ys + 4,
350 drawOneLine( marker_xs, marker_ys,
351 marker_xs, marker_ye );
353 if ( !huds_notext(options) ) {
354 if ( huds_top(options) ) {
355 textString ( marker_xs - lenstr,
360 textString( marker_xs - lenstr, scrn_rect.top,