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 gauge_instr & gauge_instr::operator=(const gauge_instr & rhs)
71 if (!(this == &rhs)) {
72 instr_scale::operator = (rhs);
78 // As implemented, draw only correctly draws a horizontal or vertical
79 // scale. It should contain a variation that permits clock type displays.
80 // Now is supports "tickless" displays such as control surface indicators.
81 // This routine should be worked over before using. Current value would be
82 // fetched and not used if not commented out. Clearly that is intollerable.
84 void gauge_instr::draw (void)
86 float marker_xs, marker_xe;
87 float marker_ys, marker_ye;
89 int width, height, bottom_4;
95 float vmin = min_val();
96 float vmax = max_val();
97 POINT mid_scr = get_centroid();
98 float cur_value = get_value();
99 RECT scrn_rect = get_location();
100 UINT options = get_options();
102 width = scrn_rect.left + scrn_rect.right;
103 height = scrn_rect.top + scrn_rect.bottom,
104 bottom_4 = scrn_rect.bottom / 4;
105 // Draw the basic markings for the scale...
107 if ( huds_vert(options) ) { // Vertical scale
108 drawOneLine( scrn_rect.left, // Bottom tick bar
113 drawOneLine( scrn_rect.left, // Top tick bar
118 marker_xs = scrn_rect.left;
121 if ( huds_left(options) ) { // Read left, so line down right side
127 marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick xs
130 if ( huds_right(options) ) { // Read right, so down left sides
131 drawOneLine( scrn_rect.left,
136 marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick xe
139 // At this point marker x_start and x_end values are transposed.
140 // To keep this from confusing things they are now interchanged.
141 if ( huds_both(options) ) {
142 marker_ye = marker_xs;
143 marker_xs = marker_xe;
144 marker_xe = marker_ye;
147 // Work through from bottom to top of scale. Calculating where to put
148 // minor and major ticks.
150 if ( !huds_noticks(options)) { // If not no ticks...:)
151 // Calculate x marker offsets
152 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
153 i = (int)vmin; //FloatToInt(vmin);
154 for (; i < last; i++) {
155 // for ( i = (int)vmin; i <= (int)vmax; i++ ) {
157 // Calculate the location of this tick
158 marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/;
160 // We compute marker_ys even though we don't know if we will use
161 // either major or minor divisions. Simpler.
163 if ( div_min()) { // Minor tick marks
164 if ( !(i%(int)div_min()) ) {
165 if ( huds_left(options) && huds_right(options) ) {
166 drawOneLine( scrn_rect.left, marker_ys,
167 marker_xs - 3, marker_ys );
168 drawOneLine( marker_xe + 3, marker_ys,
172 if ( huds_left(options) ) {
173 drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
176 drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
182 // Now we work on the major divisions. Since these are also labeled
183 // and no labels are drawn otherwise, we label inside this if
186 if ( div_max()) { // Major tick mark
187 if ( !(i%(int)div_max()) ) {
188 if ( huds_left(options) && huds_right(options) ) {
189 drawOneLine( scrn_rect.left, marker_ys,
190 marker_xs, marker_ys );
191 drawOneLine( marker_xe, marker_ys,
195 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
198 if ( !huds_notext(options) ) {
200 sprintf( TextScale, "%d",
201 FloatToInt(disp_val * data_scaling()/*+.5*/ ));
203 lenstr = getStringWidth( TextScale );
205 if ( huds_left(options) && huds_right(options) ) {
206 text_x = mid_scr.x - lenstr/2 ;
209 if ( huds_left(options) ) {
210 text_x = FloatToInt(marker_xs - lenstr);
213 text_x = FloatToInt(marker_xe - lenstr);
216 // Now we know where to put the text.
217 text_y = FloatToInt(marker_ys);
218 textString( text_x, text_y, TextScale, 0 );
224 // Now that the scale is drawn, we draw in the pointer(s). Since labels
225 // have been drawn, text_x and text_y may be recycled. This is used
226 // with the marker start stops to produce a pointer for each side reading
228 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
229 // text_x = marker_xs - scrn_rect.left;
231 if ( huds_right(options) ) {
232 glBegin(GL_LINE_STRIP);
233 glVertex2f( scrn_rect.left, text_y + 5);
234 glVertex2f( FloatToInt(marker_xe), text_y);
235 glVertex2f( scrn_rect.left, text_y - 5);
238 if ( huds_left(options) ) {
239 glBegin(GL_LINE_STRIP);
240 glVertex2f( width, text_y + 5);
241 glVertex2f( FloatToInt(marker_xs), text_y);
242 glVertex2f( width, text_y - 5);
245 // End if VERTICAL SCALE TYPE
247 } else { // Horizontal scale by default
248 drawOneLine( scrn_rect.left, // left tick bar
253 drawOneLine( width, // right tick bar
258 marker_ys = scrn_rect.top; // Starting point for
259 marker_ye = height; // tick y location calcs
260 marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/;
262 if ( huds_top(options) ) {
263 drawOneLine( scrn_rect.left,
266 scrn_rect.top); // Bottom box line
268 marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust
270 glBegin(GL_LINE_STRIP);
271 glVertex2f( marker_xs - bottom_4, scrn_rect.top);
272 glVertex2f( marker_xs, marker_ye);
273 glVertex2f( marker_xs + bottom_4, scrn_rect.top);
276 if ( huds_bottom(options) ) {
278 drawOneLine( scrn_rect.left, height, width, height);
280 marker_ys = height - scrn_rect.bottom / 2.0;
283 glBegin(GL_LINE_STRIP);
284 glVertex2f( marker_xs + bottom_4, height);
285 glVertex2f( marker_xs, marker_ys );
286 glVertex2f( marker_xs - bottom_4, height);
291 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
292 i = (int)vmin; //FloatToInt(vmin);
293 for ( ; i <last ; i++ ) {
296 if ( i < min_val()) {
301 marker_xs = scrn_rect.left + (i - vmin) * factor()/* +.5f*/;
302 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
304 if ( !(i%(int)div_min()) ) {
305 // draw in ticks only if they aren't too close to the edge.
306 if ((( marker_xs + 5) > scrn_rect.left ) ||
307 (( marker_xs - 5 )< (width))){
309 if ( huds_both(options) ) {
310 drawOneLine( marker_xs, scrn_rect.top,
311 marker_xs, marker_ys - 4);
312 drawOneLine( marker_xs, marker_ye + 4,
316 if ( huds_top(options) ) {
317 drawOneLine( marker_xs, marker_ys,
318 marker_xs, marker_ye - 4);
321 drawOneLine( marker_xs, marker_ys + 4,
322 marker_xs, marker_ye);
329 if ( !(i%(int)div_max()) ) {
332 while( disp_val < 0 ) {
333 disp_val += modulo();
336 disp_val = i % (int)modulo();
340 sprintf( TextScale, "%d",
341 FloatToInt(disp_val * data_scaling()/* +.5*/ ));
342 lenstr = getStringWidth( TextScale);
344 // Draw major ticks and text only if far enough from the edge.
345 if (( (marker_xs - 10)> scrn_rect.left ) &&
346 ( (marker_xs + 10) < width )){
347 if ( huds_both(options) ) {
348 drawOneLine( marker_xs, scrn_rect.top,
349 marker_xs, marker_ys);
350 drawOneLine( marker_xs, marker_ye,
353 if ( !huds_notext(options) ) {
354 textString ( marker_xs - lenstr, marker_ys + 4,
359 drawOneLine( marker_xs, marker_ys,
360 marker_xs, marker_ye );
362 if ( !huds_notext(options) ) {
363 if ( huds_top(options) ) {
364 textString ( marker_xs - lenstr,
369 textString( marker_xs - lenstr, scrn_rect.top,