7 //====================== Top of HudLadder Class =======================
8 HudLadder :: HudLadder( int x,
21 dual_instr_item( x, y, width, height,
26 width_units ( (int)(span_units) ),
27 div_units ( (int)(major_div < 0? -major_div: major_div) ),
28 minor_div ( (int)(minor_div) ),
29 label_pos ( lbl_pos ),
30 scr_hole ( screen_hole ),
31 vmax ( span_units/2 ),
37 factor = (float)get_span() / (float) width_units;
41 HudLadder :: ~HudLadder()
46 HudLadder( const HudLadder & image ) :
47 dual_instr_item( (dual_instr_item &) image),
48 width_units ( image.width_units ),
49 div_units ( image.div_units ),
50 label_pos ( image.label_pos ),
51 scr_hole ( image.scr_hole ),
54 factor ( image.factor )
57 HudLadder & HudLadder :: operator = ( const HudLadder & rhs )
59 if( !(this == &rhs)) {
60 (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
61 width_units = rhs.width_units;
62 div_units = rhs.div_units;
63 label_pos = rhs.label_pos;
64 scr_hole = rhs.scr_hole;
73 // Draws a climb ladder in the center of the HUD
76 void HudLadder :: draw( void )
78 POINT centroid = get_centroid();
80 float roll_value = current_ch2();
83 glTranslatef( centroid.x, centroid.y, 0);
85 // glScalef( current_options.get_fov()/55.0, 1.0, 1.0 );
86 glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
88 // Draw the target spot.
89 #define CENTER_DIAMOND_SIZE 6.0f
91 glBegin(GL_LINE_LOOP);
92 glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
93 glVertex2f( 0.0, CENTER_DIAMOND_SIZE);
94 glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
95 glVertex2f( 0.0, -CENTER_DIAMOND_SIZE);
98 if( minimal || ! div_units ) {
107 float pitch_value = current_ch1() * RAD_TO_DEG;
108 vmin = pitch_value - (float)width_units * 0.5f;
109 vmax = pitch_value + (float)width_units * 0.5f;
111 RECT box = get_location();
113 float half_span = box.right * 0.5f ;
122 float text_offset = 4.0f ;
123 float zero_offset = 10.0f ;
125 fntFont *font = HUDtext->getFont();
126 float pointsize = HUDtext->getPointSize();
127 float italic = HUDtext->getSlant();
129 TextList.setFont( HUDtext );
132 StippleLineList.erase();
134 int last = FloatToInt(vmax)+1;
135 int i = FloatToInt(vmin);
139 for( ; i<last ; i++ ) {
141 y = (((float)(i - pitch_value) * factor) + .5f);
142 if( !(i % div_units )) { // At integral multiple of div
144 sprintf( TextLadder, "%d", i );
145 font->getBBox ( TextLadder, pointsize, italic,
146 &left, &right, &bot, &top ) ;
148 label_length = right - left;
149 label_length += text_offset;
150 label_height = (top - bot) * 0.5f;
155 // Make zero point wider on left
157 x_ini -= zero_offset;
158 // Zero or above draw solid lines
159 Line(x_ini, y, x_end, y);
161 // Below zero draw dashed lines.
162 StippleLine(x_ini, y, x_end, y);
165 // Calculate the position of the left text and write it.
166 Text( x_ini-label_length, y-label_height, TextLadder );
167 Text( x_end+text_offset, y-label_height, TextLadder );
170 } else { // scr_hole != 0
171 // Draw ladder with space in the middle of the lines
174 float hole = (float)((scr_hole)*0.5f);
176 x_end = -half_span + hole;
177 x_ini2 = half_span - hole;
179 for( ; i<last ; i++ ) {
181 y = (((float)(i - pitch_value) * factor) + .5);
182 if( !(i % div_units )) { // At integral multiple of div
184 sprintf( TextLadder, "%d", i );
185 font->getBBox ( TextLadder, pointsize, italic,
186 &left, &right, &bot, &top ) ;
187 label_length = right - left;
188 label_length += text_offset;
189 label_height = (top - bot) * 0.5f;
191 // Start by calculating the points and drawing the
197 // Make zero point wider on left
199 x_ini -= zero_offset;
200 x_end2 += zero_offset;
202 // Zero or above draw solid lines
203 Line(x_ini, y, x_end, y);
204 Line(x_ini2, y, x_end2, y);
206 // Below zero draw dashed lines.
207 StippleLine(x_ini, y, x_end, y);
208 StippleLine(x_ini2, y, x_end2, y);
210 // Calculate the location of the left side label using
211 Text( x_ini-label_length, y-label_height, TextLadder );
212 // Calculate the location and draw the right side label
213 Text( x_end2+text_offset, y-label_height, TextLadder );
221 glEnable(GL_LINE_STIPPLE);
223 glLineStipple( 1, fgPanelVisible() ? 0x0F0F : 0x00FF );
225 glLineStipple( 1, 0x00FF );
228 StippleLineList.draw( );
229 glDisable(GL_LINE_STIPPLE);
231 // } // if(div_units)