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 )
44 fgTBI_instr & fgTBI_instr ::
45 operator = (const fgTBI_instr & rhs )
47 if( !(this == &rhs)) {
48 dual_instr_item::operator = (rhs);
49 BankLimit = rhs.BankLimit;
50 SlewLimit = rhs.SlewLimit;
51 scr_hole = rhs.scr_hole;
57 // Draws a Turn Bank Indicator on the screen
60 void fgTBI_instr :: draw( void )
62 float bank_angle, sideslip_angle;
63 float ss_const; // sideslip angle pixels per rad
64 float cen_x, cen_y, bank, fspan, tee, hole;
66 int span = get_span();
70 RECT My_box = get_location();
71 POINT centroid = get_centroid();
72 int tee_height = My_box.bottom;
74 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
76 if( bank_angle < -SGD_PI_2/3 )
78 bank_angle = -SGD_PI_2/3;
80 else if( bank_angle > SGD_PI_2/3 )
82 bank_angle = SGD_PI_2/3;
86 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
88 if( sideslip_angle < -SGD_PI/9 )
90 sideslip_angle = -SGD_PI/9;
92 else if( sideslip_angle > SGD_PI/9 )
94 sideslip_angle = SGD_PI/9;
100 bank = bank_angle * SGD_RADIANS_TO_DEGREES;
104 ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
106 // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
107 // printf("ss_const: %f hole: %f\n", ss_const, hole);
111 glTranslatef(cen_x, cen_y, zero);
112 glRotatef(-bank, zero, zero, 1.0);
121 glVertex2f( -fspan, zero );
122 glVertex2f( fspan, zero );
126 glVertex2f( -fspan, zero );
127 glVertex2f( -hole, zero );
128 glVertex2f( hole, zero );
129 glVertex2f( fspan, zero );
132 glVertex2f( hole, zero );
133 glVertex2f( hole, tee );
134 glVertex2f( -hole, zero );
135 glVertex2f( -hole, tee );
139 glBegin(GL_LINE_LOOP);
140 glVertex2f( ss_const, -hole);
141 glVertex2f( ss_const + hole, zero);
142 glVertex2f( ss_const, hole);
143 glVertex2f( ss_const - hole, zero);
150 else //if tsi enabled
152 // float factor = My_box.right / 6.0;
154 drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top);
155 drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0);
156 drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
157 drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
159 float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5;
160 float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0;
162 xc = My_box.left + My_box.right/ 2.0 ;
166 x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
167 y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
169 x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
170 y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
172 drawOneLine(x1,y1,x2,y2);
174 x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
175 y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
177 x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
178 y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
180 drawOneLine(x1,y1,x2,y2);
182 //second n fifth lines
184 x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
185 y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
187 x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
188 y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
190 drawOneLine(x1,y1,x2,y2);
192 x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
193 y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
196 x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
197 y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
199 drawOneLine(x1,y1,x2,y2);
201 //third n fourth lines
204 x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
205 y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
208 x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
209 y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
211 drawOneLine(x1,y1,x2,y2);
213 x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
214 y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
216 x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
217 y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
219 drawOneLine(x1,y1,x2,y2);
225 float valbank, valsideslip, sideslip;
227 r = rad + 5.0; //5 is added to get a gap
229 bank_angle = current_ch2();
231 bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
234 if(bank < -1.0*BankLimit)
235 bank = -1.0*BankLimit;
237 valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
239 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
240 sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
241 if(sideslip > SlewLimit)
242 sideslip = SlewLimit;
243 if(sideslip < -1.0*SlewLimit)
244 sideslip = -1.0*SlewLimit;
245 valsideslip = sideslip * 15.0 / SlewLimit;
247 //values 270, 225 and 315 are angles in degrees...
249 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
250 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
252 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
253 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
255 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
256 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
258 drawOneLine(x1, y1, x2, y2);
259 drawOneLine(x2, y2, x3, y3);
260 drawOneLine(x3, y3, x1, y1);
266 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
267 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
269 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
270 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
272 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
273 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
275 x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
276 y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
278 x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
279 y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
281 x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
282 y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
283 x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
284 y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
285 x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
286 y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
287 x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
288 y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
290 drawOneLine(x2, y2, x3, y3);
291 drawOneLine(x3, y3, x5, y5);
292 drawOneLine(x5, y5, x4, y4);
293 drawOneLine(x4, y4, x2, y2);