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