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