9 extern float get_roll(void);
10 extern float get_sideslip(void);
12 // x, y, width, height, get_roll, get_sideslip, maxBankAngle, maxSlipAngle, gap_width, working, tsi, rad
14 // int x, int y, UINT width, UINT height, FLTFNPTR chn1_source, FLTFNPTR chn2_source, float maxBankAngle,
15 // float maxSlipAngle, UINT gap_width, bool working, bool tsivalue, float radius) :
18 fgTBI_instr::fgTBI_instr(const SGPropertyNode *node) :
20 node->getIntValue("x"),
21 node->getIntValue("y"),
22 node->getIntValue("width"),
23 node->getIntValue("height"),
26 node->getBoolValue("working", true),
28 BankLimit(int(node->getFloatValue("maxBankAngle"))),
29 SlewLimit(int(node->getFloatValue("maxSlipAngle"))),
30 scr_hole(node->getIntValue("gap_width")),
31 tsi(node->getBoolValue("tsi")),
32 rad(node->getFloatValue("rad"))
35 SG_LOG(SG_INPUT, SG_INFO, "Done reading TBI instrument"
36 << node->getStringValue("name", "[unnamed]"));
40 void fgTBI_instr::draw(void)
42 float bank_angle, sideslip_angle;
43 float ss_const; // sideslip angle pixels per rad
44 float cen_x, cen_y, bank, fspan, tee, hole;
46 int span = get_span();
49 RECT My_box = get_location();
50 POINT centroid = get_centroid();
51 int tee_height = My_box.bottom;
53 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
55 if (bank_angle < -SGD_PI_2 / 3)
56 bank_angle = -SGD_PI_2 / 3;
57 else if (bank_angle > SGD_PI_2 / 3)
58 bank_angle = SGD_PI_2 / 3;
61 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
63 if (sideslip_angle < -SGD_PI / 9)
64 sideslip_angle = -SGD_PI / 9;
65 else if ( sideslip_angle > SGD_PI / 9 )
66 sideslip_angle = SGD_PI / 9;
71 bank = bank_angle * SGD_RADIANS_TO_DEGREES;
75 ss_const = 2 * sideslip_angle * fspan / (SGD_2PI / 9); // width represents 40 degrees
77 // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
78 // printf("ss_const: %f hole: %f\n", ss_const, hole);
81 glTranslatef(cen_x, cen_y, zero);
82 glRotatef(-bank, zero, zero, 1.0);
88 glVertex2f(-fspan, zero);
89 glVertex2f(fspan, zero);
92 glVertex2f(-fspan, zero);
93 glVertex2f(-hole, zero);
94 glVertex2f(hole, zero);
95 glVertex2f(fspan, zero);
99 glVertex2f(hole, zero);
100 glVertex2f(hole, tee);
101 glVertex2f(-hole, zero);
102 glVertex2f(-hole, tee);
105 glBegin(GL_LINE_LOOP);
106 glVertex2f(ss_const, -hole);
107 glVertex2f(ss_const + hole, zero);
108 glVertex2f(ss_const, hole);
109 glVertex2f(ss_const - hole, zero);
112 } else { //if tsi enabled
113 drawOneLine(cen_x-1.0, My_box.top, cen_x + 1.0, My_box.top);
114 drawOneLine(cen_x-1.0, My_box.top, cen_x - 1.0, My_box.top + 10.0);
115 drawOneLine(cen_x+1.0, My_box.top, cen_x + 1.0, My_box.top + 10.0);
116 drawOneLine(cen_x-1.0, My_box.top + 10.0, cen_x + 1.0, My_box.top + 10.0);
118 float x1, y1, x2, y2, x3, y3, x4, y4, x5, y5;
119 float xc, yc, r = rad, r1 = rad - 10.0, r2 = rad - 5.0;
121 xc = My_box.left + My_box.right / 2.0 ;
124 // first n last lines
125 x1 = xc + r * cos(255.0 * SGD_DEGREES_TO_RADIANS);
126 y1 = yc + r * sin(255.0 * SGD_DEGREES_TO_RADIANS);
128 x2 = xc + r1 * cos(255.0 * SGD_DEGREES_TO_RADIANS);
129 y2 = yc + r1 * sin(255.0 * SGD_DEGREES_TO_RADIANS);
130 drawOneLine(x1,y1,x2,y2);
132 x1 = xc + r * cos(285.0 * SGD_DEGREES_TO_RADIANS);
133 y1 = yc + r * sin(285.0 * SGD_DEGREES_TO_RADIANS);
135 x2 = xc + r1 * cos(285.0 * SGD_DEGREES_TO_RADIANS);
136 y2 = yc + r1 * sin(285.0 * SGD_DEGREES_TO_RADIANS);
137 drawOneLine(x1, y1, x2, y2);
139 // second n fifth lines
140 x1 = xc + r * cos(260.0 * SGD_DEGREES_TO_RADIANS);
141 y1 = yc + r * sin(260.0 * SGD_DEGREES_TO_RADIANS);
143 x2 = xc + r2 * cos(260.0 * SGD_DEGREES_TO_RADIANS);
144 y2 = yc + r2 * sin(260.0 * SGD_DEGREES_TO_RADIANS);
145 drawOneLine(x1, y1, x2, y2);
147 x1 = xc + r * cos(280.0 * SGD_DEGREES_TO_RADIANS);
148 y1 = yc + r * sin(280.0 * SGD_DEGREES_TO_RADIANS);
150 x2 = xc + r2 * cos(280.0 * SGD_DEGREES_TO_RADIANS);
151 y2 = yc + r2 * sin(280.0 * SGD_DEGREES_TO_RADIANS);
152 drawOneLine(x1, y1, x2, y2);
154 // third n fourth lines
155 x1 = xc + r * cos(265.0 * SGD_DEGREES_TO_RADIANS);
156 y1 = yc + r * sin(265.0 * SGD_DEGREES_TO_RADIANS);
159 x2 = xc + r2 * cos(265.0 * SGD_DEGREES_TO_RADIANS);
160 y2 = yc + r2 * sin(265.0 * SGD_DEGREES_TO_RADIANS);
161 drawOneLine(x1, y1, x2, y2);
163 x1 = xc + r * cos(275.0 * SGD_DEGREES_TO_RADIANS);
164 y1 = yc + r * sin(275.0 * SGD_DEGREES_TO_RADIANS);
166 x2 = xc + r2 * cos(275.0 * SGD_DEGREES_TO_RADIANS);
167 y2 = yc + r2 * sin(275.0 * SGD_DEGREES_TO_RADIANS);
168 drawOneLine(x1,y1,x2,y2);
171 float valbank, valsideslip, sideslip;
173 r = rad + 5.0; // add gap
176 bank_angle = current_ch2();
178 bank = bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
179 if (bank > BankLimit)
181 if (bank < -1.0*BankLimit)
182 bank = -1.0*BankLimit;
184 valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
186 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
187 sideslip = sideslip_angle * SGD_RADIANS_TO_DEGREES;
188 if (sideslip > SlewLimit)
189 sideslip = SlewLimit;
190 if (sideslip < -1.0 * SlewLimit)
191 sideslip = -1.0 * SlewLimit;
192 valsideslip = sideslip * 15.0 / SlewLimit;
194 // values 270, 225 and 315 are angles in degrees...
195 x1 = xc + r * cos((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
196 y1 = yc + r * sin((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
198 x2 = x1 + 6.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
199 y2 = y1 + 6.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
201 x3 = x1 + 6.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
202 y3 = y1 + 6.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
204 drawOneLine(x1, y1, x2, y2);
205 drawOneLine(x2, y2, x3, y3);
206 drawOneLine(x3, y3, x1, y1);
209 x1 = xc + r * cos((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
210 y1 = yc + r * sin((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
212 x2 = x1 + 6.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
213 y2 = y1 + 6.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
215 x3 = x1 + 6.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
216 y3 = y1 + 6.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
218 x4 = x1 + 10.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
219 y4 = y1 + 10.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
221 x5 = x1 + 10.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
222 y5 = y1 + 10.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
224 x2 = x2 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
225 y2 = y2 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
226 x3 = x3 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
227 y3 = y3 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
228 x4 = x4 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
229 y4 = y4 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
230 x5 = x5 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
231 y5 = y5 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
233 drawOneLine(x2, y2, x3, y3);
234 drawOneLine(x3, y3, x5, y5);
235 drawOneLine(x5, y5, x4, y4);
236 drawOneLine(x4, y4, x2, y2);