]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_ladr.cxx
Tweak #includes to use double quotes for local files not <>
[flightgear.git] / src / Cockpit / hud_ladr.cxx
1
2 #include "hud.hxx"
3 #include "panel.hxx"
4
5 #define DO_PANEL_HACK
6
7 //====================== Top of HudLadder Class =======================
8 HudLadder ::   HudLadder(  string name,
9                            int       x,
10                            int       y,
11                            UINT      width,
12                            UINT      height,
13                            float         factr,
14                            FLTFNPTR  ptch_source,
15                            FLTFNPTR  roll_source,
16                            float     span_units,
17                            float     major_div,
18                            float     minor_div,
19                            UINT      screen_hole,
20                            UINT      lbl_pos,
21                            bool      frl_spot,
22                            bool          target,
23                            bool          vel_vec,
24                            bool          drift,
25                            bool          alpha,
26                            bool      energy,
27                            bool      climb,
28                            bool      glide,
29                            float     glide_slope_val,
30                            bool      worm_energy,
31                            bool      waypoint,
32                            bool      working,
33                            int           zenithsymbol, //suma
34                            int       nadirsymbol, //suma
35                            int           hat_marker): //suma
36
37     dual_instr_item( x, y, width, height,
38                      ptch_source,
39                      roll_source,
40                      working,
41                      HUDS_RIGHT),
42     width_units                 ( (int)(span_units)   ),
43     div_units                   ( (int)(major_div < 0? -major_div: major_div) ),
44     minor_div                   ( (int)(minor_div)    ),
45     label_pos                   ( lbl_pos      ),
46     scr_hole                    ( screen_hole  ),
47     vmax                                ( span_units/2 ),
48     vmin                                ( -vmax        ),
49     factor                              ( factr           ),
50     hudladder_type              ( name            ),
51     frl                                 ( frl_spot              ),
52     target_spot                 ( target                ),
53     velocity_vector             ( vel_vec               ),
54     drift_marker                ( drift                 ),
55     alpha_bracket               ( alpha                 ),
56     energy_marker               ( energy                ),
57     climb_dive_marker   ( climb         ),
58     glide_slope_marker  ( glide                 ),
59     glide_slope                 ( glide_slope_val),
60     energy_worm                 ( worm_energy),
61     waypoint_marker             ( waypoint)
62
63
64 {
65                 
66     zenith= zenithsymbol; //suma
67         nadir=nadirsymbol; //suma
68         hat= hat_marker; //suma
69  
70         if( !width_units ) 
71         {
72            width_units = 45;
73     }
74 }
75    
76 HudLadder ::  ~HudLadder()
77 {
78 }
79            
80 HudLadder ::
81 HudLadder( const HudLadder & image ) :
82     dual_instr_item             ( (dual_instr_item &) image),
83     width_units                 ( image.width_units   ),
84     div_units                   ( image.div_units     ),
85     label_pos                   ( image.label_pos     ),
86     scr_hole                    ( image.scr_hole      ),
87     vmax                                ( image.vmax ),
88     vmin                                ( image.vmin ),
89     factor                              ( image.factor        ),
90     hudladder_type              ( image.hudladder_type),
91     frl                                 ( image.frl),
92     target_spot                 ( image.target_spot),
93     velocity_vector             ( image.velocity_vector),
94     drift_marker                ( image.drift_marker),
95     alpha_bracket               ( image.alpha_bracket),
96     energy_marker               ( image.energy_marker),
97     climb_dive_marker   ( image.climb_dive_marker),
98     glide_slope_marker  ( image.glide_slope_marker),
99     glide_slope                 ( image.glide_slope),
100     energy_worm                 ( image.energy_worm),
101     waypoint_marker             ( image.waypoint_marker)
102 {
103 }
104 HudLadder & HudLadder ::  operator = ( const HudLadder & rhs )
105 {
106     if( !(this == &rhs)) {
107         (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
108         width_units                     = rhs.width_units;
109         div_units                       = rhs.div_units;
110         label_pos                       = rhs.label_pos;
111         scr_hole                        = rhs.scr_hole;
112         vmax                            = rhs.vmax;
113         vmin                            = rhs.vmin;
114         factor                          = rhs.factor;
115         hudladder_type          = rhs.hudladder_type;
116         frl                                     = rhs.frl;
117         velocity_vector         = rhs.velocity_vector;
118         drift_marker            = rhs.drift_marker;
119         alpha_bracket           = rhs.alpha_bracket;
120         energy_marker           = rhs.energy_marker;
121         climb_dive_marker       = rhs.climb_dive_marker;
122         target_spot                     = rhs.target_spot;
123         glide_slope_marker      = rhs.glide_slope_marker;
124         glide_slope                     = rhs.glide_slope;
125         energy_worm                     = rhs.energy_worm;
126         waypoint_marker         = rhs.waypoint_marker;
127     }
128     return *this;
129 }
130                            
131 //
132 //  Draws a climb ladder in the center of the HUD
133 //
134
135 void HudLadder :: draw( void )
136 {
137
138     float  x_ini,x_ini2;
139     float  x_end,x_end2;
140     float  y = 0;
141     int count;
142     float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0,
143         up_vel, ground_vel, actslope = 0.0;
144     float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1,
145         t2 = 0.0, psi = 0.0, alpha,pla;
146     float vel_x = 0.0, vel_y = 0.0, drift;
147     // char     Textaux[8] ;
148     bool  pitch_ladder = false;
149     bool  climb_dive_ladder = false;
150     bool  clip_plane = false;
151
152     GLdouble eqn_top[4] = {0.0,-1.0,0.0,0.0};
153     GLdouble eqn_left[4] = {-1.0,0.0,0.0,100.0};
154     GLdouble eqn_right[4] = {1.0,0.0,0.0,100.0};
155
156     POINT  centroid    = get_centroid();
157     RECT   box         = get_location();
158
159     float   half_span  = box.right / 2.0;
160     float   roll_value = current_ch2();
161     alpha = get_aoa();
162     pla = get_throttleval();
163
164     int lgear,wown,wowm,ilcanclaw,ihook;
165     ilcanclaw = get_iaux2();
166     lgear = get_iaux3();
167     wown = get_iaux4();
168     wowm = get_iaux5();
169     ihook = get_iaux6();
170     
171     float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
172         
173     if(hudladder_type=="Climb/Dive Ladder") {
174         pitch_ladder = false;
175         climb_dive_ladder = true;
176         clip_plane = true;
177     }
178     else
179         // hudladder_type=="Pitch Ladder" 
180         {
181             pitch_ladder = true;
182             climb_dive_ladder = false;
183             clip_plane = false;
184         }
185         
186     //**************************************************************
187     glPushMatrix();
188     // define (0,0) as center of screen
189     glTranslatef( centroid.x, centroid.y, 0);
190
191     // OBJECT STATIC RETICLE
192     // TYPE FRL
193     // ATTRIB - ALWAYS
194     // Draw the FRL spot and line
195     if(frl)     {
196 #define FRL_DIAMOND_SIZE 2.0
197         glBegin(GL_LINE_LOOP);
198         glVertex2f( -FRL_DIAMOND_SIZE, 0.0);
199         glVertex2f(0.0, FRL_DIAMOND_SIZE);
200         glVertex2f( FRL_DIAMOND_SIZE, 0.0);
201         glVertex2f(0.0, -FRL_DIAMOND_SIZE);
202         glEnd();
203         glBegin(GL_LINE_STRIP);
204         glVertex2f(0, FRL_DIAMOND_SIZE);
205         glVertex2f(0, 8.0 );
206         glEnd();
207 #undef FRL_DIAMOND_SIZE
208     }
209     // TYPE WATERLINE_MARK (W shaped _    _ )
210     //                                                \/\/
211
212     //****************************************************************    
213     // TYPE TARGET_SPOT
214     // Draw the target spot.
215     if (target_spot)    {
216 #define CENTER_DIAMOND_SIZE 6.0
217         glBegin(GL_LINE_LOOP);
218         glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
219         glVertex2f(0.0, CENTER_DIAMOND_SIZE);
220         glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
221         glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
222         glEnd();
223 #undef CENTER_DIAMOND_SIZE
224     }
225
226     //****************************************************************    
227     //velocity vector reticle - computations
228     if(velocity_vector) {
229         Vxx = get_Vx();
230         Vyy = get_Vy();
231         Vzz = get_Vz();
232         Axx = get_Ax();
233         Ayy = get_Ay();
234         Azz = get_Az();
235         psi = get_heading();
236
237         if (psi > 180.0) psi = psi - 360;
238
239         total_vel = sqrt(Vxx*Vxx + Vyy*Vyy + Vzz*Vzz);
240         ground_vel = sqrt(Vxx*Vxx + Vyy*Vyy);
241         up_vel = Vzz;
242
243         if (ground_vel < 2.0) {
244             if (fabs(up_vel) < 2.0) {
245                 actslope = 0.0;
246             } else {
247                 actslope = (up_vel/fabs(up_vel))*90.0;
248             }
249         } else {
250             actslope = atan(up_vel/ground_vel)*SGD_RADIANS_TO_DEGREES;
251         }
252
253         xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*
254                 (factor/globals->get_current_view()->get_aspect_ratio()));
255         drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
256         yvvr = ((actslope - pitch_value)*factor);
257         vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
258         vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*
259                 (factor/globals->get_current_view()->get_aspect_ratio());
260         //  printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
261         //****************************************************************    
262         // OBJECT MOVING RETICLE
263         // TYPE - DRIFT MARKER
264         // ATTRIB - ALWAYS
265         // drift marker
266         if(drift_marker)        {
267             glBegin(GL_LINE_STRIP);
268             glVertex2f((xvvr*25/120)-6, -4);
269             glVertex2f(xvvr*25/120, 8);
270             glVertex2f((xvvr*25/120)+6, -4);
271             glEnd();
272         }
273
274         //****************************************************************    
275         // Clipping coordinates for ladder to be input from xml file
276         // Clip hud ladder
277         if (clip_plane) {
278             glClipPlane(GL_CLIP_PLANE0,eqn_top);
279             glEnable(GL_CLIP_PLANE0);
280             glClipPlane(GL_CLIP_PLANE1,eqn_left);
281             glEnable(GL_CLIP_PLANE1);
282             glClipPlane(GL_CLIP_PLANE2,eqn_right);
283             glEnable(GL_CLIP_PLANE2);
284             //      glScissor(-100,-240,200,240);
285             //      glEnable(GL_SCISSOR_TEST);
286         }
287         //****************************************************************    
288         // OBJECT MOVING RETICLE
289         // TYPE VELOCITY VECTOR
290         // ATTRIB - ALWAYS
291         //  velocity vector
292         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
293         for(count=0; count<50; count++) {             
294             cosine = 6 * cos(count * 2 * SGD_PI/50.0); 
295             sine =   6 * sin(count * 2 * SGD_PI/50.0); 
296             glVertex2f(cosine+vel_x, sine+vel_y);
297         }     
298         glEnd(); 
299         //velocity vector reticle orientation lines
300         glBegin(GL_LINE_STRIP);
301         glVertex2f(vel_x-12, vel_y);
302         glVertex2f(vel_x-6, vel_y);
303         glEnd();
304         glBegin(GL_LINE_STRIP);
305         glVertex2f(vel_x+12, vel_y);
306         glVertex2f(vel_x+6, vel_y);
307         glEnd();
308         glBegin(GL_LINE_STRIP);
309         glVertex2f(vel_x, vel_y+12);
310         glVertex2f(vel_x, vel_y+6);
311         glEnd();
312
313         // OBJECT MOVING RETICLE
314         // TYPE LINE
315         // ATTRIB - ON CONDITION
316         if (lgear == 1) {
317             // undercarriage status
318             glBegin(GL_LINE_STRIP);
319             glVertex2f(vel_x+8, vel_y);
320             glVertex2f(vel_x+8, vel_y-4);
321             glEnd();
322             // OBJECT MOVING RETICLE
323             // TYPE LINE
324             // ATTRIB - ON CONDITION
325             glBegin(GL_LINE_STRIP);
326             glVertex2f(vel_x-8, vel_y);
327             glVertex2f(vel_x-8, vel_y-4);
328             glEnd();
329             // OBJECT MOVING RETICLE
330             // TYPE LINE
331             // ATTRIB - ON CONDITION
332             glBegin(GL_LINE_STRIP);
333             glVertex2f(vel_x, vel_y-6);
334             glVertex2f(vel_x, vel_y-10);
335             glEnd();
336         }
337
338         // OBJECT MOVING RETICLE
339         // TYPE V
340         // ATTRIB - ON CONDITION
341         if (ihook == 1) {
342             // arrestor hook status
343             glBegin(GL_LINE_STRIP);
344             glVertex2f(vel_x-4, vel_y-8);
345             glVertex2f(vel_x, vel_y-10);
346             glVertex2f(vel_x+4, vel_y-8);
347             glEnd();
348         }
349     }//if velocity_vector
350
351     //***************************************************************
352     // OBJECT MOVING RETICLE
353     // TYPE - SQUARE_BRACKET
354     // ATTRIB - ON CONDITION
355     // alpha bracket
356     if (alpha_bracket)  {
357         if (ihook == 1) {
358             glBegin(GL_LINE_STRIP);
359             glVertex2f(vel_x-20 , vel_y-(16-alpha)*factor);
360             glVertex2f(vel_x-17, vel_y-(16-alpha)*factor);
361             glVertex2f(vel_x-17, vel_y-(14-alpha)*factor);
362             glVertex2f(vel_x-20, vel_y-(14-alpha)*factor);
363             glEnd();
364             glBegin(GL_LINE_STRIP);
365             glVertex2f(vel_x+20 , vel_y-(16-alpha)*factor);
366             glVertex2f(vel_x+17, vel_y-(16-alpha)*factor);
367             glVertex2f(vel_x+17, vel_y-(14-alpha)*factor);
368             glVertex2f(vel_x+20, vel_y-(14-alpha)*factor);
369             glEnd();
370         }
371     }
372     //printf("xvr=%f,yvr=%f,Vx=%f,Vy=%f,Vz=%f\n",xvvr,yvvr,Vx,Vy,Vz);
373     //printf("Ax=%f,Ay=%f,Az=%f\n",Ax,Ay,Az);
374     //****************************************************************  
375     // OBJECT MOVING RETICLE
376     // TYPE ENERGY_MARKERS
377     // ATTRIB - ALWAYS
378     //energy markers - compute potential slope
379     if(energy_marker)   {
380         if (total_vel < 5.0) {
381             t1 = 0;
382             t2 = 0;
383         } else {
384             t1 = up_vel/total_vel;
385             t2 = asin((Vxx*Axx + Vyy*Ayy + Vzz*Azz)/(9.81*total_vel));
386         }
387         pot_slope = ((t2/3)*SGD_RADIANS_TO_DEGREES)*factor + vel_y;
388         //    if (pot_slope < (vel_y - 45)) pot_slope = vel_y-45;
389         //    if (pot_slope > (vel_y + 45)) pot_slope = vel_y+45;
390
391         //energy markers
392         glBegin(GL_LINE_STRIP);
393         glVertex2f(vel_x-20, pot_slope-5);
394         glVertex2f(vel_x-15, pot_slope);
395         glVertex2f(vel_x-20, pot_slope+5);
396         glEnd();
397         glBegin(GL_LINE_STRIP);
398         glVertex2f(vel_x+20, pot_slope-5);
399         glVertex2f(vel_x+15, pot_slope);
400         glVertex2f(vel_x+20, pot_slope+5);
401         glEnd();
402         if (pla > (105.0/131.0)) {
403             glBegin(GL_LINE_STRIP);
404             glVertex2f(vel_x-24, pot_slope-5);
405             glVertex2f(vel_x-19, pot_slope);
406             glVertex2f(vel_x-24, pot_slope+5);
407             glEnd();
408             glBegin(GL_LINE_STRIP);
409             glVertex2f(vel_x+24, pot_slope-5);
410             glVertex2f(vel_x+19, pot_slope);
411             glVertex2f(vel_x+24, pot_slope+5);
412             glEnd();
413         }
414     }
415     //********************************************************** 
416     // ramp reticle
417     // OBJECT STATIC RETICLE
418     // TYPE LINE
419     // ATTRIB - ON CONDITION
420     if (energy_worm)    {
421         if (ilcanclaw == 1) {
422             glBegin(GL_LINE_STRIP);
423             glVertex2f(-15, -134);
424             glVertex2f(15, -134);
425             glEnd();
426             // OBJECT MOVING RETICLE
427             // TYPE BOX
428             // ATTRIB - ON CONDITION
429             glBegin(GL_LINE_STRIP);
430             glVertex2f(-6, -134);
431             glVertex2f(-6, t2*SGD_RADIANS_TO_DEGREES*4.0 - 134);
432             glVertex2f(+6, t2*SGD_RADIANS_TO_DEGREES*4.0 - 134);
433             glVertex2f(6, -134);
434             glEnd();
435             // OBJECT MOVING RETICLE
436             // TYPE DIAMOND
437             // ATTRIB - ON CONDITION
438             glBegin(GL_LINE_LOOP);
439             glVertex2f(-6, actslope*4.0 - 134);
440             glVertex2f(0, actslope*4.0 -134 +3);
441             glVertex2f(6, actslope*4.0 - 134);
442             glVertex2f(0, actslope*4.0 -134 -3);
443             glEnd();
444         }
445     }
446     //*************************************************************
447     // OBJECT MOVING RETICLE
448     // TYPE DIAMOND
449     // ATTRIB - ALWAYS
450     // Draw the locked velocity vector.
451     if(climb_dive_marker)       {
452         glBegin(GL_LINE_LOOP);
453         glVertex2f( -3.0, 0.0+vel_y);
454         glVertex2f(0.0, 6.0+vel_y);
455         glVertex2f( 3.0, 0.0+vel_y);
456         glVertex2f(0.0, -6.0+vel_y);
457         glEnd();
458     }
459
460     //****************************************************************    
461
462     if(climb_dive_ladder)
463         {                     // CONFORMAL_HUD
464
465         vmin              = pitch_value - (float)width_units;
466         vmax              = pitch_value + (float)width_units; 
467
468         glTranslatef( vel_x, vel_y, 0);
469
470     }
471     else 
472         // pitch_ladder - Default Hud
473         {
474
475             vmin              = pitch_value - (float)width_units * 0.5f;
476             vmax              = pitch_value + (float)width_units * 0.5f;
477
478         }
479
480     glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
481     // FRL marker not rotated - this line shifted below
482
483     if( div_units ) 
484         {
485         char     TextLadder[8] ;
486         float    label_length ;
487         float    label_height ;
488         float    left ;
489         float    right ;
490         float    bot ;
491         float    top ;
492         float    text_offset = 4.0f ;
493         float    zero_offset = 0.0;
494                 
495         if ( climb_dive_ladder ) {
496             zero_offset = 50.0f ; // horizon line is wider by this much (hard coded ??)
497         } else {
498                 zero_offset = 10.0f ;
499     }
500                 
501         fntFont *font      = HUDtext->getFont();
502         float    pointsize = HUDtext->getPointSize();
503         float    italic    = HUDtext->getSlant();
504
505     TextList.setFont( HUDtext );
506     TextList.erase();
507     LineList.erase();
508     StippleLineList.erase();
509
510     int last = FloatToInt(vmax)+1;
511     int i    = FloatToInt(vmin);
512
513         if( !scr_hole ) {
514             x_end =  half_span;
515             for( ; i<last ; i++ ) 
516                         {
517                 
518                 y =  (((float)(i - pitch_value) * factor) + .5f);
519                 if( !(i % div_units ))            //  At integral multiple of div
520                                 {
521                 
522                     sprintf( TextLadder, "%d", i );
523                     font->getBBox ( TextLadder, pointsize, italic,
524                                     &left, &right, &bot, &top ) ;
525                     label_length  = right - left;
526                     label_length += text_offset;
527                     label_height  = (top - bot)/2.0f;
528                 
529                     x_ini = -half_span;
530                     
531                     if( i >= 0 ) 
532                                         {
533                         // Make zero point wider on left
534                         if( i == 0 )
535                             x_ini -= zero_offset;
536                             
537                                                 // Zero or above draw solid lines
538                                                 Line(x_ini, y, x_end, y);
539                                                 
540                                                 if(i == 90)
541                                                 if(zenith == 1)
542                                                 {
543                                                   drawZenith(x_ini, x_end,y);
544                                                 }
545                     } else {
546                         // Below zero draw dashed lines.
547                         StippleLine(x_ini, y, x_end, y);
548
549                                                 
550                                                 if(i == -90)
551                                                 if(nadir ==1)
552                                                 { 
553                                                         drawNadir(x_ini, x_end,y);
554                                                 }
555                     }
556                     
557                     // Calculate the position of the left text and write it.
558                     Text( x_ini-label_length, y-label_height, TextLadder );
559                     Text( x_end+text_offset,  y-label_height, TextLadder );
560                 }
561             }
562         }
563         else // if(scr_hole )
564             {    // Draw ladder with space in the middle of the lines
565                 float hole = (float)((scr_hole)/2.0f);
566
567                 x_end = -half_span + hole;
568                 x_ini2= half_span  - hole;
569                 for( ; i<last ; i++ )      
570                 {
571
572                     if(hudladder_type=="Pitch Ladder")
573                         y = (((float)(i - pitch_value) * factor) + .5);
574                     else
575                         if(hudladder_type=="Climb/Dive Ladder")
576                             y = (((float)(i - actslope) * factor) + .5);
577
578                     if( !(i % div_units ))    {        //  At integral multiple of div
579
580                         sprintf( TextLadder, "%d", i );
581                         font->getBBox ( TextLadder, pointsize, italic,
582                                         &left, &right, &bot, &top ) ;
583                         label_length  = right - left;
584                         label_length += text_offset;
585                         label_height  = (top - bot)/2.0f;
586                         //                  printf("l %f r %f b %f t %f\n",left, right, bot, top );
587                 
588                         // Start by calculating the points and drawing the
589                         // left side lines.
590                         x_ini = -half_span;
591                         x_end2= half_span;
592                     
593                         if( i >= 0 ) 
594                         { 
595                             // Make zero point wider on left
596                             if( i == 0 ) 
597                                 {
598                                     x_ini -= zero_offset;
599                                         x_end2 +=zero_offset;
600                             } 
601                             //draw climb bar vertical lines
602                                 if(climb_dive_ladder)
603                                 {
604                                    // Zero or above draw solid lines
605                                    Line(x_end, y-5.0, x_end, y);
606                                    Line(x_ini2, y-5.0, x_ini2, y);
607                             }
608                                 // draw pitch / climb bar
609                             Line(x_ini, y, x_end, y);
610                             Line(x_ini2, y, x_end2, y);
611
612                                 if(i == 90)
613                                 if(zenith == 1)
614                                 {  
615                                   drawZenith(x_ini2, x_end,y);
616                                 }
617                         }
618                         else  // i < 0
619                         {
620                             // draw dive bar vertical lines
621                             if(climb_dive_ladder) 
622                                 {
623                                         Line(x_end, y+5.0, x_end, y);
624                                         Line(x_ini2, y+5.0, x_ini2, y);
625                             }
626                             // draw pitch / dive bars
627                                 StippleLine(x_ini, y, x_end, y);
628                             StippleLine(x_ini2, y, x_end2, y);
629                
630                             if(i == -90)
631                             if(nadir == 1)
632                                 {
633                                     drawNadir(x_ini2, x_end,y);
634                                 }
635                         }
636                     
637                         // Now calculate the location of the left side label using
638                         Text( x_ini-label_length, y-label_height, TextLadder );
639                         Text (x_end2+text_offset, y-label_height, TextLadder );
640
641                     }
642                 }
643
644                 // OBJECT LADDER MARK
645                 // TYPE LINE
646                 // ATTRIB - ON CONDITION
647                 // draw appraoch glide slope marker
648                 if (glide_slope_marker) {
649                     if (ihook) {
650                         Line(-half_span+15, (glide_slope-actslope)*factor, -half_span + hole, (glide_slope-actslope)*factor);
651                         Line(half_span-15, (glide_slope-actslope)*factor, half_span - hole, (glide_slope-actslope)*factor);
652                     }
653                 }// if glide_slope_marker
654             }
655         TextList.draw();
656
657         glLineWidth(0.2);
658         
659         LineList.draw();
660         
661         glEnable(GL_LINE_STIPPLE);
662         glLineStipple( 1, 0x00FF );
663         StippleLineList.draw( );
664         glDisable(GL_LINE_STIPPLE);
665     }
666     glDisable(GL_CLIP_PLANE0);
667     glDisable(GL_CLIP_PLANE1);
668     glDisable(GL_CLIP_PLANE2);
669     //      glDisable(GL_SCISSOR_TEST);
670     glPopMatrix();
671     //*************************************************************
672     //*************************************************************
673     if(waypoint_marker) {
674         //waypoint marker computation
675         float fromwp_lat,towp_lat,fromwp_lon,towp_lon,dist,delx,dely,hyp,theta,brg;
676
677         fromwp_lon = get_longitude()*SGD_DEGREES_TO_RADIANS;
678         fromwp_lat = get_latitude()*SGD_DEGREES_TO_RADIANS;
679         towp_lon = get_aux2()*SGD_DEGREES_TO_RADIANS;
680         towp_lat = get_aux1()*SGD_DEGREES_TO_RADIANS;
681
682         dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon)));
683         delx= towp_lat - fromwp_lat;
684         dely = towp_lon - fromwp_lon;
685         hyp = sqrt(pow(delx,2)+pow(dely,2));
686         if (hyp != 0) {
687             theta = asin(dely/hyp);
688         } else {
689             theta = 0.0;
690         }
691         brg = theta*SGD_RADIANS_TO_DEGREES;
692         if (brg > 360.0) brg = 0.0;
693         if (delx < 0) brg = 180 - brg;
694
695         //        {Brg  = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
696         //        Brg = Brg * SGD_RADIANS_TO_DEGREES; }
697         dist = dist*SGD_RADIANS_TO_DEGREES * 60.0*1852.0; //rad->deg->nm->m
698         // end waypoint marker computation
699         //*********************************************************
700         // OBJECT MOVING RETICLE
701         // TYPE ARROW
702         // waypoint marker
703
704           if (fabs(brg-psi) > 10.0) 
705           {
706             glPushMatrix();
707             glTranslatef( centroid.x, centroid.y, 0);
708             glTranslatef( vel_x, vel_y, 0);
709             glRotatef(brg - psi,0.0,0.0,-1.0);
710             glBegin(GL_LINE_LOOP);
711             glVertex2f(-2.5,20.0);
712             glVertex2f(-2.5,30.0);
713             glVertex2f(-5.0,30.0);
714             glVertex2f(0.0,35.0);
715             glVertex2f(5.0,30.0);
716             glVertex2f(2.5,30.0);
717             glVertex2f(2.5,20.0);
718             glEnd();
719             glPopMatrix();
720           }
721
722           // waypoint marker on heading scale
723           if (fabs(brg-psi) < 12.0) 
724           {
725           if(hat ==0)
726           {
727             glBegin(GL_LINE_LOOP);
728             glVertex2f(((brg-psi)*60/25)+320,240.0);
729             glVertex2f(((brg-psi)*60/25)+326,240.0-4);
730             glVertex2f(((brg-psi)*60/25)+323,240.0-4);
731             glVertex2f(((brg-psi)*60/25)+323,240.0-8);
732             glVertex2f(((brg-psi)*60/25)+317,240.0-8);
733             glVertex2f(((brg-psi)*60/25)+317,240.0-4);
734             glVertex2f(((brg-psi)*60/25)+314,240.0-4);
735             glEnd();
736           } else {//if hat=0
737
738                   float x= (brg-psi)*60/25 + 320,  y=240.0, r=5.0;
739                   float x1,y1;
740                                                                 
741                   glEnable(GL_POINT_SMOOTH);
742                                                                                   
743           glBegin(GL_POINTS);
744                         
745                   for(int count=0; count<=200; count++)
746                   {
747                         float temp = count * 3.142 * 3 / (200.0*2.0);
748                         float temp1 = temp-(45.0*SGD_DEGREES_TO_RADIANS);
749                     x1 = x + r * cos(temp1); 
750                     y1 = y + r * sin(temp1);
751                                          
752                         glVertex2f(x1, y1);
753                   }
754                                         
755                   glEnd();
756                   glDisable(GL_POINT_SMOOTH); 
757           } //hat=0
758
759           } //brg<12
760     } // if waypoint_marker
761 }//draw
762
763 /******************************************************************/
764
765 //begin suma
766         //  draws the zenith symbol  for highest possible climb angle (i,e 90 degree climb angle)
767
768 void HudLadder :: 
769 drawZenith(float xfirst,float xlast,float yvalue )
770 {
771
772              float xcentre = (xfirst + xlast)/2.0;
773                  float ycentre = yvalue;
774
775          Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre+1.3);
776              Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre-1.3);
777   
778              Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre+1.3);
779              Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre-1.3);
780
781              Line(xcentre, ycentre+9.0, xcentre-1.3, ycentre+3.0);
782              Line(xcentre, ycentre+9.0, xcentre+1.3, ycentre+3.0);
783
784                  Line(xcentre-3.9, ycentre+3.9, xcentre-3.0, ycentre+1.3);
785              Line(xcentre-3.9, ycentre+3.9, xcentre-1.3, ycentre+3.0);
786
787              Line(xcentre+3.9, ycentre+3.9, xcentre+1.3, ycentre+3.0);
788              Line(xcentre+3.9, ycentre+3.9, xcentre+3.0, ycentre+1.3);
789
790              Line(xcentre-3.9, ycentre-3.9, xcentre-3.0, ycentre-1.3);
791              Line(xcentre-3.9, ycentre-3.9, xcentre-1.3, ycentre-2.6);
792
793              Line(xcentre+3.9, ycentre-3.9, xcentre+3.0, ycentre-1.3);
794              Line(xcentre+3.9, ycentre-3.9, xcentre+1.3, ycentre-2.6);
795
796              Line(xcentre-1.3, ycentre-2.6, xcentre, ycentre-27.0);
797          Line(xcentre+1.3, ycentre-2.6, xcentre, ycentre-27.0);
798
799   
800
801         //end suma
802
803 //begin suma
804         //  draws the nadir symbol  for lowest possible dive angle (i,e 90 degree dive angle)
805
806
807 void HudLadder ::
808 drawNadir(float xfirst, float xlast, float yvalue)
809 {
810
811              float xcentre = (xfirst + xlast)/2.0;
812                  float ycentre = yvalue;    
813
814
815                 float r = 7.5;
816                 float ang,temp;
817                 float x1,y1,x2,y2,xcent,ycent;
818
819         
820         // to draw a circle
821
822                 float xcent1, xcent2, ycent1, ycent2;
823                 xcent1 = xcentre + r * cos(0.0);
824                 ycent1 = ycentre + r * sin(0.0);
825         for(int count=1; count<=400; count++) 
826                 {  
827                         float temp = count * 2 * 3.142 / 400.0;
828                     xcent2 = xcentre + r * cos(temp); 
829                         ycent2 = ycentre + r * sin(temp);                           
830                         
831                         Line(xcent1, ycent1, xcent2, ycent2);
832
833                         xcent1 = xcent2;
834                         ycent1 = ycent2;
835                 }     
836                 
837                 xcent2 = xcentre + r * cos(0.0);
838                 ycent2 = ycentre + r * sin(0.0);
839
840         drawOneLine(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
841                 //end circle
842
843
844                 Line(xcentre, ycentre+7.5, xcentre, ycentre+22.5); //to draw a line above the circle
845
846                 Line(xcentre-7.5, ycentre, xcentre+7.5,ycentre); //line in the middle of circle
847
848                 float theta = asin (2.5/7.5);
849                 float theta1 = asin(5.0/7.5);
850
851                  x1 = xcentre + r * cos(theta);
852                  y1 = ycentre + 2.5;
853
854                  x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
855                  y2 = ycentre + 2.5;
856
857                  Line(x1,y1,x2,y2);
858
859                 
860                  x1 = xcentre + r * cos(theta1);
861                  y1 = ycentre + 5.0;
862
863                  x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS)-theta1);
864                  y2 = ycentre + 5.0;
865
866                  Line(x1,y1,x2,y2);
867
868
869                  x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) +theta);
870                  y1 = ycentre - 2.5;
871
872                  x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta);
873                  y2 = ycentre - 2.5;
874
875                  Line(x1,y1,x2,y2);
876
877                 
878                  x1 = xcentre + r * cos((180.0* SGD_DEGREES_TO_RADIANS) +theta1);
879                  y1 = ycentre - 5.0;
880
881                  x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta1);
882                  y2 = ycentre - 5.0;
883
884                  Line(x1,y1,x2,y2);
885
886
887 }