5 #ifdef USE_HUD_TextList
6 #define textString( x , y, text, font ) TextString( text, x , y )
8 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
11 //============== Top of guage_instr class member definitions ==============
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;
54 guage_instr( const guage_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;
68 guage_instr & guage_instr ::
69 operator = (const guage_instr & rhs )
71 if( !(this == &rhs)) {
72 instr_scale::operator = (rhs);
77 // As implemented, draw only correctly draws a horizontal or vertical
78 // scale. It should contain a variation that permits clock type displays.
79 // Now is supports "tickless" displays such as control surface indicators.
80 // This routine should be worked over before using. Current value would be
81 // fetched and not used if not commented out. Clearly that is intollerable.
83 void guage_instr :: draw (void)
85 int marker_xs, marker_xe;
86 int marker_ys, marker_ye;
88 int width, height, bottom_4;
94 float vmin = min_val();
95 float vmax = max_val();
96 POINT mid_scr = get_centroid();
97 float cur_value = get_value();
98 RECT scrn_rect = get_location();
99 UINT options = get_options();
101 width = scrn_rect.left + scrn_rect.right;
102 height = scrn_rect.top + scrn_rect.bottom,
103 bottom_4 = scrn_rect.bottom / 4;
104 // Draw the basic markings for the scale...
106 if( huds_vert(options) ) { // Vertical scale
107 drawOneLine( scrn_rect.left, // Bottom tick bar
112 drawOneLine( scrn_rect.left, // Top tick bar
117 marker_xs = scrn_rect.left;
120 if( huds_left(options) ) { // Read left, so line down right side
126 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
129 if( huds_right(options) ) { // Read right, so down left sides
130 drawOneLine( scrn_rect.left,
135 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
138 // At this point marker x_start and x_end values are transposed.
139 // To keep this from confusing things they are now interchanged.
140 if( huds_both(options) ) {
141 marker_ye = marker_xs;
142 marker_xs = marker_xe;
143 marker_xe = marker_ye;
146 // Work through from bottom to top of scale. Calculating where to put
147 // minor and major ticks.
149 if( !huds_noticks(options)) { // If not no ticks...:)
150 // Calculate x marker offsets
151 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
152 i = (int)vmin; //FloatToInt(vmin);
153 for(; i <last ; i++ ) {
154 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
156 // Calculate the location of this tick
157 marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
159 // We compute marker_ys even though we don't know if we will use
160 // either major or minor divisions. Simpler.
162 if( div_min()) { // Minor tick marks
163 if( !(i%(int)div_min()) ) {
164 if( huds_left(options) && huds_right(options) ) {
165 drawOneLine( scrn_rect.left, marker_ys,
166 marker_xs - 3, marker_ys );
167 drawOneLine( marker_xe + 3, marker_ys,
171 if( huds_left(options) ) {
172 drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
175 drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
181 // Now we work on the major divisions. Since these are also labeled
182 // and no labels are drawn otherwise, we label inside this if
185 if( div_max()) { // Major tick mark
186 if( !(i%(int)div_max()) ) {
187 if( huds_left(options) && huds_right(options) ) {
188 drawOneLine( scrn_rect.left, marker_ys,
189 marker_xs, marker_ys );
190 drawOneLine( marker_xe, marker_ys,
194 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
197 if( !huds_notext(options) ) {
199 sprintf( TextScale, "%d",
200 FloatToInt(disp_val * data_scaling()/*+.5*/ ));
202 lenstr = getStringWidth( TextScale );
204 if( huds_left(options) && huds_right(options) ) {
205 text_x = mid_scr.x - lenstr/2 ;
208 if( huds_left(options) ) {
209 text_x = marker_xs - lenstr;
212 text_x = marker_xe - lenstr;
215 // Now we know where to put the text.
217 textString( text_x, text_y, TextScale, GLUT_BITMAP_8_BY_13 );
223 // Now that the scale is drawn, we draw in the pointer(s). Since labels
224 // have been drawn, text_x and text_y may be recycled. This is used
225 // with the marker start stops to produce a pointer for each side reading
227 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
228 // text_x = marker_xs - scrn_rect.left;
230 if( huds_right(options) ) {
231 glBegin(GL_LINE_STRIP);
232 glVertex2f( scrn_rect.left, text_y + 5);
233 glVertex2f( marker_xe, text_y);
234 glVertex2f( scrn_rect.left, text_y - 5);
237 if( huds_left(options) ) {
238 glBegin(GL_LINE_STRIP);
239 glVertex2f( width, text_y + 5);
240 glVertex2f( marker_xs, text_y);
241 glVertex2f( width, text_y - 5);
244 } // End if VERTICAL SCALE TYPE
245 else { // Horizontal scale by default
246 drawOneLine( scrn_rect.left, // left tick bar
251 drawOneLine( width, // right tick bar
256 marker_ys = scrn_rect.top; // Starting point for
257 marker_ye = height; // tick y location calcs
258 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
260 if( huds_top(options) ) {
261 drawOneLine( scrn_rect.left,
264 scrn_rect.top); // Bottom box line
266 marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
268 glBegin(GL_LINE_STRIP);
269 glVertex2f( marker_xs - bottom_4, scrn_rect.top);
270 glVertex2f( marker_xs, marker_ye);
271 glVertex2f( marker_xs + bottom_4, scrn_rect.top);
274 if( huds_bottom(options) ) {
276 drawOneLine( scrn_rect.left, height, width, height);
278 marker_ys = height - scrn_rect.bottom / 2;
281 glBegin(GL_LINE_STRIP);
282 glVertex2f( marker_xs + bottom_4, height);
283 glVertex2f( marker_xs, marker_ys );
284 glVertex2f( marker_xs - bottom_4, height);
289 int last = (int)vmax + 1; //FloatToInt(vmax)+1;
290 i = (int)vmin; //FloatToInt(vmin);
291 for( ; i <last ; i++ ) {
299 marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
300 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
302 if( !(i%(int)div_min()) ) {
303 // draw in ticks only if they aren't too close to the edge.
304 if((( marker_xs + 5) > scrn_rect.left ) ||
305 (( marker_xs - 5 )< (width))){
307 if( huds_both(options) ) {
308 drawOneLine( marker_xs, scrn_rect.top,
309 marker_xs, marker_ys - 4);
310 drawOneLine( marker_xs, marker_ye + 4,
314 if( huds_top(options) ) {
315 drawOneLine( marker_xs, marker_ys,
316 marker_xs, marker_ye - 4);
319 drawOneLine( marker_xs, marker_ys + 4,
320 marker_xs, marker_ye);
327 if( !(i%(int)div_max()) ) {
330 while( disp_val < 0 ) {
331 disp_val += modulo();
334 disp_val = i % (int)modulo();
338 sprintf( TextScale, "%d",
339 FloatToInt(disp_val * data_scaling()/* +.5*/ ));
340 lenstr = getStringWidth( TextScale);
342 // Draw major ticks and text only if far enough from the edge.
343 if(( (marker_xs - 10)> scrn_rect.left ) &&
344 ( (marker_xs + 10) < width )){
345 if( huds_both(options) ) {
346 drawOneLine( marker_xs, scrn_rect.top,
347 marker_xs, marker_ys);
348 drawOneLine( marker_xs, marker_ye,
351 if( !huds_notext(options) ) {
352 textString ( marker_xs - lenstr, marker_ys + 4,
353 TextScale, GLUT_BITMAP_8_BY_13 );
357 drawOneLine( marker_xs, marker_ys,
358 marker_xs, marker_ye );
360 if( !huds_notext(options) ) {
361 if( huds_top(options) ) {
362 textString ( marker_xs - lenstr,
364 TextScale, GLUT_BITMAP_8_BY_13 );
367 textString( marker_xs - lenstr, scrn_rect.top,
368 TextScale, GLUT_BITMAP_8_BY_13 );