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