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