6 //============ Top of fgTBI_instr class member definitions ==============
8 fgTBI_instr::fgTBI_instr(
21 dual_instr_item( x, y, width, height,
26 BankLimit ((int)(maxBankAngle)),
27 SlewLimit ((int)(maxSlipAngle)),
35 fgTBI_instr::~fgTBI_instr() {}
38 fgTBI_instr::fgTBI_instr(const fgTBI_instr & image) :
39 dual_instr_item( (const dual_instr_item &) image),
40 BankLimit( image.BankLimit),
41 SlewLimit( image.SlewLimit),
42 scr_hole ( image.scr_hole )
48 // Draws a Turn Bank Indicator on the screen
51 void fgTBI_instr :: draw( void )
53 float bank_angle, sideslip_angle;
54 float ss_const; // sideslip angle pixels per rad
55 float cen_x, cen_y, bank, fspan, tee, hole;
57 int span = get_span();
60 RECT My_box = get_location();
61 POINT centroid = get_centroid();
62 int tee_height = My_box.bottom;
64 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
66 if ( bank_angle < -SGD_PI_2/3 )
67 bank_angle = -SGD_PI_2/3;
68 else if ( bank_angle > SGD_PI_2/3 )
69 bank_angle = SGD_PI_2/3;
72 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
74 if ( sideslip_angle < -SGD_PI/9 )
75 sideslip_angle = -SGD_PI/9;
76 else if ( sideslip_angle > SGD_PI/9 )
77 sideslip_angle = SGD_PI/9;
82 bank = bank_angle * SGD_RADIANS_TO_DEGREES;
86 ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
88 // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
89 // printf("ss_const: %f hole: %f\n", ss_const, hole);
93 glTranslatef(cen_x, cen_y, zero);
94 glRotatef(-bank, zero, zero, 1.0);
101 glVertex2f( -fspan, zero );
102 glVertex2f( fspan, zero );
105 glVertex2f( -fspan, zero );
106 glVertex2f( -hole, zero );
107 glVertex2f( hole, zero );
108 glVertex2f( fspan, zero );
111 glVertex2f( hole, zero );
112 glVertex2f( hole, tee );
113 glVertex2f( -hole, zero );
114 glVertex2f( -hole, tee );
117 glBegin(GL_LINE_LOOP);
118 glVertex2f( ss_const, -hole);
119 glVertex2f( ss_const + hole, zero);
120 glVertex2f( ss_const, hole);
121 glVertex2f( ss_const - hole, zero);
124 } else { //if tsi enabled
125 // float factor = My_box.right / 6.0;
127 drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top);
128 drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0);
129 drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
130 drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
132 float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5;
133 float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0;
135 xc = My_box.left + My_box.right/ 2.0 ;
139 x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
140 y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
142 x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
143 y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
145 drawOneLine(x1,y1,x2,y2);
147 x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
148 y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
150 x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
151 y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
153 drawOneLine(x1,y1,x2,y2);
155 //second n fifth lines
157 x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
158 y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
160 x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
161 y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
163 drawOneLine(x1,y1,x2,y2);
165 x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
166 y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
169 x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
170 y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
172 drawOneLine(x1,y1,x2,y2);
174 //third n fourth lines
177 x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
178 y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
181 x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
182 y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
184 drawOneLine(x1,y1,x2,y2);
186 x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
187 y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
189 x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
190 y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
192 drawOneLine(x1,y1,x2,y2);
198 float valbank, valsideslip, sideslip;
200 r = rad + 5.0; //5 is added to get a gap
202 bank_angle = current_ch2();
204 bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
205 if (bank > BankLimit)
207 if (bank < -1.0*BankLimit)
208 bank = -1.0*BankLimit;
210 valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
212 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
213 sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
214 if (sideslip > SlewLimit)
215 sideslip = SlewLimit;
216 if (sideslip < -1.0*SlewLimit)
217 sideslip = -1.0*SlewLimit;
218 valsideslip = sideslip * 15.0 / SlewLimit;
220 //values 270, 225 and 315 are angles in degrees...
221 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
222 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
224 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
225 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
227 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
228 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
230 drawOneLine(x1, y1, x2, y2);
231 drawOneLine(x2, y2, x3, y3);
232 drawOneLine(x3, y3, x1, y1);
235 x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
236 y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
238 x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
239 y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
241 x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
242 y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
244 x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
245 y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
247 x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
248 y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
250 x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
251 y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
252 x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
253 y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
254 x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
255 y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
256 x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
257 y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
259 drawOneLine(x2, y2, x3, y3);
260 drawOneLine(x3, y3, x5, y5);
261 drawOneLine(x5, y5, x4, y4);
262 drawOneLine(x4, y4, x2, y2);