]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_tbi.cxx
remove assignment operators: they aren't used now and won't in the future
[flightgear.git] / src / Cockpit / hud_tbi.cxx
1
2 #include "hud.hxx"
3 #include<math.h>
4
5
6 //============ Top of fgTBI_instr class member definitions ==============
7
8 fgTBI_instr ::
9 fgTBI_instr( int              x,
10              int              y,
11              UINT             width,
12              UINT             height,
13              FLTFNPTR  chn1_source,
14              FLTFNPTR  chn2_source,
15              float    maxBankAngle,
16              float    maxSlipAngle,
17              UINT      gap_width,
18              bool      working,
19                          bool      tsivalue, //suma
20                          float     radius) : //suma
21                dual_instr_item( x, y, width, height,
22                                 chn1_source,
23                                 chn2_source,
24                                 working,
25                                 HUDS_TOP),
26                BankLimit      ((int)(maxBankAngle)),
27                SlewLimit      ((int)(maxSlipAngle)),
28                scr_hole       (gap_width   )
29 {
30         tsi=tsivalue; //suma   
31         rad=radius; //suma
32 }
33
34 fgTBI_instr :: ~fgTBI_instr() {}
35
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 )
41 {
42 }
43
44
45 //
46 //  Draws a Turn Bank Indicator on the screen
47 //
48
49  void fgTBI_instr :: draw( void )
50 {
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;
54
55      int span = get_span();
56      
57      float zero = 0.0;
58   
59      RECT My_box = get_location();
60      POINT centroid = get_centroid();
61      int tee_height = My_box.bottom;
62          
63      bank_angle     = current_ch2();  // Roll limit +/- 30 degrees
64      
65      if( bank_angle < -SGD_PI_2/3 ) 
66          {
67          bank_angle = -SGD_PI_2/3;
68      }
69          else if( bank_angle > SGD_PI_2/3 ) 
70          {
71              bank_angle = SGD_PI_2/3;
72      }
73      
74          
75          sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
76
77      if( sideslip_angle < -SGD_PI/9 ) 
78          {
79          sideslip_angle = -SGD_PI/9;
80      }
81          else if( sideslip_angle > SGD_PI/9 ) 
82          {
83              sideslip_angle = SGD_PI/9;
84      }
85
86      cen_x = centroid.x;
87      cen_y = centroid.y;
88      
89      bank  = bank_angle * SGD_RADIANS_TO_DEGREES;
90          tee   = -tee_height;
91      fspan = span;
92      hole  = scr_hole;
93      ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9);  // width represents 40 degrees
94      
95 //   printf("side_slip: %f   fspan: %f\n", sideslip_angle, fspan);
96 //   printf("ss_const: %f   hole: %f\n", ss_const, hole);
97      
98         
99      glPushMatrix();
100      glTranslatef(cen_x, cen_y, zero);
101      glRotatef(-bank, zero, zero, 1.0);
102     
103          if(!tsi)
104          {
105                  
106                 glBegin(GL_LINES);
107              
108                 if( !scr_hole )  
109                 {
110                         glVertex2f( -fspan, zero );
111                         glVertex2f(  fspan, zero );
112                 } 
113                 else
114                 {
115                         glVertex2f( -fspan, zero );
116                         glVertex2f( -hole,  zero );
117                         glVertex2f(  hole,  zero );
118                         glVertex2f(  fspan, zero );
119                 }
120                 // draw teemarks
121                 glVertex2f(  hole, zero );
122                 glVertex2f(  hole, tee );
123                 glVertex2f( -hole, zero );
124                 glVertex2f( -hole, tee );
125              
126                 glEnd();
127      
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);
133                 glEnd();
134
135
136          }
137          
138
139          else //if tsi enabled
140          {
141                  // float factor = My_box.right / 6.0;
142
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);
147
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;
150                  
151                  xc = My_box.left + My_box.right/ 2.0 ;
152                  yc = My_box.top + r;
153
154 //first n last lines
155                   x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
156                   y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
157
158                   x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
159                   y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
160                   
161                   drawOneLine(x1,y1,x2,y2);
162
163                   x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
164                   y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
165
166                   x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
167                   y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
168
169           drawOneLine(x1,y1,x2,y2);
170
171 //second n fifth  lines
172
173                   x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
174                   y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
175                   
176                   x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
177                   y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
178                   
179                   drawOneLine(x1,y1,x2,y2);
180
181                   x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
182                   y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
183
184                   
185                   x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
186                   y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
187
188           drawOneLine(x1,y1,x2,y2);
189
190 //third n fourth lines
191
192
193                   x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
194                   y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
195
196                   
197                   x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
198                   y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
199                   
200                   drawOneLine(x1,y1,x2,y2);
201
202                   x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
203                   y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
204                   
205                   x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
206                   y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
207
208           drawOneLine(x1,y1,x2,y2);
209
210                   //to draw marker
211                   
212                   
213                 
214                           float  valbank, valsideslip, sideslip;
215                          
216                           r = rad + 5.0;  //5 is added to get a gap 
217                          // upper polygon
218               bank_angle     = current_ch2();
219
220                           bank= bank_angle * SGD_RADIANS_TO_DEGREES;  // Roll limit +/- 30 degrees
221                           if(bank > BankLimit)
222                                         bank = BankLimit;
223                           if(bank < -1.0*BankLimit)
224                                         bank = -1.0*BankLimit;
225
226                           valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
227                           
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;
235                           
236                           //values 270, 225 and 315 are angles in degrees...
237
238                           x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
239                           y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
240
241                           x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
242                           y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
243                           
244                           x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
245                           y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
246
247                       drawOneLine(x1, y1, x2, y2);
248                           drawOneLine(x2, y2, x3, y3);
249                           drawOneLine(x3, y3, x1, y1);
250
251                           //lower polygon...
252                          
253                          
254                           
255                           x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
256                           y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
257
258                           x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
259                           y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
260                           
261                           x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
262                           y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
263
264                           x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
265                           y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
266                           
267                           x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
268                           y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
269
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);
278
279                           drawOneLine(x2, y2, x3, y3); 
280                           drawOneLine(x3, y3, x5, y5);
281                           drawOneLine(x5, y5, x4, y4);
282                           drawOneLine(x4, y4, x2, y2);  
283                          
284  
285          }
286
287                 glPopMatrix();
288 }