6 //============ Top of fgTBI_instr class member definitions ==============
20 float radius) : //suma
21 dual_instr_item( x, y, width, height,
26 BankLimit ((int)(maxBankAngle)),
27 SlewLimit ((int)(maxSlipAngle)),
34 fgTBI_instr :: ~fgTBI_instr() {}
36 fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
37 dual_instr_item( (const dual_instr_item &) image),
38 BankLimit( image.BankLimit),
39 SlewLimit( image.SlewLimit),
40 scr_hole ( image.scr_hole )
46 // Draws a Turn Bank Indicator on the screen
49 void fgTBI_instr :: draw( void )
51 float bank_angle, sideslip_angle;
52 float ss_const; // sideslip angle pixels per rad
53 float cen_x, cen_y, bank, fspan, tee, hole;
55 int span = get_span();
59 RECT My_box = get_location();
60 POINT centroid = get_centroid();
61 int tee_height = My_box.bottom;
63 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
65 if( bank_angle < -SGD_PI_2/3 )
67 bank_angle = -SGD_PI_2/3;
69 else if( bank_angle > SGD_PI_2/3 )
71 bank_angle = SGD_PI_2/3;
75 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
77 if( sideslip_angle < -SGD_PI/9 )
79 sideslip_angle = -SGD_PI/9;
81 else if( sideslip_angle > SGD_PI/9 )
83 sideslip_angle = SGD_PI/9;
89 bank = bank_angle * SGD_RADIANS_TO_DEGREES;
93 ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
95 // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
96 // printf("ss_const: %f hole: %f\n", ss_const, hole);
100 glTranslatef(cen_x, cen_y, zero);
101 glRotatef(-bank, zero, zero, 1.0);
110 glVertex2f( -fspan, zero );
111 glVertex2f( fspan, zero );
115 glVertex2f( -fspan, zero );
116 glVertex2f( -hole, zero );
117 glVertex2f( hole, zero );
118 glVertex2f( fspan, zero );
121 glVertex2f( hole, zero );
122 glVertex2f( hole, tee );
123 glVertex2f( -hole, zero );
124 glVertex2f( -hole, tee );
128 glBegin(GL_LINE_LOOP);
129 glVertex2f( ss_const, -hole);
130 glVertex2f( ss_const + hole, zero);
131 glVertex2f( ss_const, hole);
132 glVertex2f( ss_const - hole, zero);
139 else //if tsi enabled
141 // float factor = My_box.right / 6.0;
143 drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top);
144 drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0);
145 drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
146 drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
148 float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5;
149 float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0;
151 xc = My_box.left + My_box.right/ 2.0 ;
155 x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
156 y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
158 x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
159 y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
161 drawOneLine(x1,y1,x2,y2);
163 x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
164 y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
166 x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
167 y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
169 drawOneLine(x1,y1,x2,y2);
171 //second n fifth lines
173 x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
174 y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
176 x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
177 y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
179 drawOneLine(x1,y1,x2,y2);
181 x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
182 y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
185 x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
186 y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
188 drawOneLine(x1,y1,x2,y2);
190 //third n fourth lines
193 x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
194 y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
197 x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
198 y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
200 drawOneLine(x1,y1,x2,y2);
202 x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
203 y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
205 x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
206 y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
208 drawOneLine(x1,y1,x2,y2);
214 float valbank, valsideslip, sideslip;
216 r = rad + 5.0; //5 is added to get a gap
218 bank_angle = current_ch2();
220 bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
223 if(bank < -1.0*BankLimit)
224 bank = -1.0*BankLimit;
226 valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
228 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
229 sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
230 if(sideslip > SlewLimit)
231 sideslip = SlewLimit;
232 if(sideslip < -1.0*SlewLimit)
233 sideslip = -1.0*SlewLimit;
234 valsideslip = sideslip * 15.0 / SlewLimit;
236 //values 270, 225 and 315 are angles in degrees...
238 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
239 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
241 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
242 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
244 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
245 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
247 drawOneLine(x1, y1, x2, y2);
248 drawOneLine(x2, y2, x3, y3);
249 drawOneLine(x3, y3, x1, y1);
255 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
256 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
258 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
259 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
261 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
262 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
264 x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
265 y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
267 x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
268 y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
270 x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
271 y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
272 x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
273 y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
274 x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
275 y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
276 x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
277 y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
279 drawOneLine(x2, y2, x3, y3);
280 drawOneLine(x3, y3, x5, y5);
281 drawOneLine(x5, y5, x4, y4);
282 drawOneLine(x4, y4, x2, y2);