6 //====================== Top of HudLadder Class =======================
7 HudLadder :: HudLadder( int x,
20 dual_instr_item( x, y, width, height,
25 width_units ( (int)(span_units) ),
26 div_units ( (int)(major_div < 0? -major_div: major_div) ),
27 minor_div ( (int)(minor_div) ),
28 label_pos ( lbl_pos ),
29 scr_hole ( screen_hole ),
30 vmax ( span_units/2 ),
36 factor = (float)get_span() / (float) width_units;
40 HudLadder :: ~HudLadder()
45 HudLadder( const HudLadder & image ) :
46 dual_instr_item( (dual_instr_item &) image),
47 width_units ( image.width_units ),
48 div_units ( image.div_units ),
49 label_pos ( image.label_pos ),
50 scr_hole ( image.scr_hole ),
53 factor ( image.factor )
56 HudLadder & HudLadder :: operator = ( const HudLadder & rhs )
58 if( !(this == &rhs)) {
59 (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
60 width_units = rhs.width_units;
61 div_units = rhs.div_units;
62 label_pos = rhs.label_pos;
63 scr_hole = rhs.scr_hole;
72 // Draws a climb ladder in the center of the HUD
75 void HudLadder :: draw( void )
77 POINT centroid = get_centroid();
79 float roll_value = current_ch2();
82 glTranslatef( centroid.x, centroid.y, 0);
84 // glScalef( current_options.get_fov()/55.0, 1.0, 1.0 );
85 glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
87 // Draw the target spot.
88 #define CENTER_DIAMOND_SIZE 6.0f
90 glBegin(GL_LINE_LOOP);
91 glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
92 glVertex2f( 0.0, CENTER_DIAMOND_SIZE);
93 glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
94 glVertex2f( 0.0, -CENTER_DIAMOND_SIZE);
97 if( minimal || ! div_units ) {
106 float pitch_value = current_ch1() * RAD_TO_DEG;
107 vmin = pitch_value - (float)width_units * 0.5f;
108 vmax = pitch_value + (float)width_units * 0.5f;
110 RECT box = get_location();
112 float half_span = box.right * 0.5f ;
121 float text_offset = 4.0f ;
122 float zero_offset = 10.0f ;
124 fntFont *font = HUDtext->getFont();
125 float pointsize = HUDtext->getPointSize();
126 float italic = HUDtext->getSlant();
128 TextList.setFont( HUDtext );
131 StippleLineList.erase();
133 int last = FloatToInt(vmax)+1;
134 int i = FloatToInt(vmin);
138 for( ; i<last ; i++ ) {
140 y = (((float)(i - pitch_value) * factor) + .5f);
141 if( !(i % div_units )) { // At integral multiple of div
143 sprintf( TextLadder, "%d", i );
144 font->getBBox ( TextLadder, pointsize, italic,
145 &left, &right, &bot, &top ) ;
147 label_length = right - left;
148 label_length += text_offset;
149 label_height = (top - bot) * 0.5f;
154 // Make zero point wider on left
156 x_ini -= zero_offset;
157 // Zero or above draw solid lines
158 Line(x_ini, y, x_end, y);
160 // Below zero draw dashed lines.
161 StippleLine(x_ini, y, x_end, y);
164 // Calculate the position of the left text and write it.
165 Text( x_ini-label_length, y-label_height, TextLadder );
166 Text( x_end+text_offset, y-label_height, TextLadder );
169 } else { // scr_hole != 0
170 // Draw ladder with space in the middle of the lines
173 float hole = (float)((scr_hole)*0.5f);
175 x_end = -half_span + hole;
176 x_ini2 = half_span - hole;
178 for( ; i<last ; i++ ) {
180 y = (((float)(i - pitch_value) * factor) + .5);
181 if( !(i % div_units )) { // At integral multiple of div
183 sprintf( TextLadder, "%d", i );
184 font->getBBox ( TextLadder, pointsize, italic,
185 &left, &right, &bot, &top ) ;
186 label_length = right - left;
187 label_length += text_offset;
188 label_height = (top - bot) * 0.5f;
190 // Start by calculating the points and drawing the
196 // Make zero point wider on left
198 x_ini -= zero_offset;
199 x_end2 += zero_offset;
201 // Zero or above draw solid lines
202 Line(x_ini, y, x_end, y);
203 Line(x_ini2, y, x_end2, y);
205 // Below zero draw dashed lines.
206 StippleLine(x_ini, y, x_end, y);
207 StippleLine(x_ini2, y, x_end2, y);
209 // Calculate the location of the left side label using
210 Text( x_ini-label_length, y-label_height, TextLadder );
211 // Calculate the location and draw the right side label
212 Text( x_end2+text_offset, y-label_height, TextLadder );
220 glEnable(GL_LINE_STIPPLE);
222 glLineStipple( 1, current_options.get_panel_status() ? 0x0F0F : 0x00FF );
224 glLineStipple( 1, 0x00FF );
227 StippleLineList.draw( );
228 glDisable(GL_LINE_STIPPLE);
230 // } // if(div_units)