1 // auto_gui.cxx -- autopilot gui interface
3 // Written by Norman Vine <nhv@cape.com>
4 // Arranged by Curt Olson <curt@flightgear.org>
6 // Copyright (C) 1998 - 2000
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include <Scenery/scenery.hxx>
34 #include <simgear/constants.h>
35 #include <simgear/debug/logstream.hxx>
36 #include <simgear/math/sg_geodesy.hxx>
37 #include <simgear/misc/sg_path.hxx>
39 #include <Airports/simple.hxx>
41 #include <Main/fg_init.hxx>
42 #include <Main/globals.hxx>
43 #include <Main/fg_props.hxx>
44 #include <Navaids/fixlist.hxx>
46 #include "auto_gui.hxx"
47 #include "newauto.hxx"
50 #define mySlider puSlider
52 // Climb speed constants
53 const double min_climb = 70.0; // kts
54 const double best_climb = 75.0; // kts
55 const double ideal_climb_rate = 500.0; // fpm
57 /// These statics will eventually go into the class
58 /// they are just here while I am experimenting -- NHV :-)
59 // AutoPilot Gain Adjuster members
60 static double MaxRollAdjust; // MaxRollAdjust = 2 * APData->MaxRoll;
61 static double RollOutAdjust; // RollOutAdjust = 2 * APData->RollOut;
62 static double MaxAileronAdjust; // MaxAileronAdjust = 2 * APData->MaxAileron;
63 static double RollOutSmoothAdjust; // RollOutSmoothAdjust = 2 * APData->RollOutSmooth;
65 static float MaxRollValue; // 0.1 -> 1.0
66 static float RollOutValue;
67 static float MaxAileronValue;
68 static float RollOutSmoothValue;
70 static float TmpMaxRollValue; // for cancel operation
71 static float TmpRollOutValue;
72 static float TmpMaxAileronValue;
73 static float TmpRollOutSmoothValue;
75 static puDialogBox *APAdjustDialog;
76 static puFrame *APAdjustFrame;
77 static puText *APAdjustDialogMessage;
78 static puFont APAdjustLegendFont;
79 static puFont APAdjustLabelFont;
81 static puOneShot *APAdjustOkButton;
82 static puOneShot *APAdjustResetButton;
83 static puOneShot *APAdjustCancelButton;
85 //static puButton *APAdjustDragButton;
87 static puText *APAdjustMaxRollTitle;
88 static puText *APAdjustRollOutTitle;
89 static puText *APAdjustMaxAileronTitle;
90 static puText *APAdjustRollOutSmoothTitle;
92 static puText *APAdjustMaxAileronText;
93 static puText *APAdjustMaxRollText;
94 static puText *APAdjustRollOutText;
95 static puText *APAdjustRollOutSmoothText;
97 static mySlider *APAdjustHS0;
98 static mySlider *APAdjustHS1;
99 static mySlider *APAdjustHS2;
100 static mySlider *APAdjustHS3;
102 static char SliderText[ 4 ][ 8 ];
104 ///////// AutoPilot New Heading Dialog
106 static puDialogBox *ApHeadingDialog;
107 static puFrame *ApHeadingDialogFrame;
108 static puText *ApHeadingDialogMessage;
109 static puInput *ApHeadingDialogInput;
110 static puOneShot *ApHeadingDialogOkButton;
111 static puOneShot *ApHeadingDialogCancelButton;
114 ///////// AutoPilot New Altitude Dialog
116 static puDialogBox *ApAltitudeDialog = 0;
117 static puFrame *ApAltitudeDialogFrame = 0;
118 static puText *ApAltitudeDialogMessage = 0;
119 static puInput *ApAltitudeDialogInput = 0;
121 static puOneShot *ApAltitudeDialogOkButton = 0;
122 static puOneShot *ApAltitudeDialogCancelButton = 0;
125 /// The beginnings of Lock AutoPilot to target location :-)
126 // Needs cleaning up but works
127 // These statics should disapear when this is a class
128 static puDialogBox *TgtAptDialog = 0;
129 static puFrame *TgtAptDialogFrame = 0;
130 static puText *TgtAptDialogMessage = 0;
131 static puInput *TgtAptDialogInput = 0;
133 static char NewTgtAirportId[16];
134 static char NewTgtAirportLabel[] = "Enter New TgtAirport ID";
136 static puOneShot *TgtAptDialogOkButton = 0;
137 static puOneShot *TgtAptDialogCancelButton = 0;
138 static puOneShot *TgtAptDialogResetButton = 0;
141 // extern char *coord_format_lat(float);
142 // extern char *coord_format_lon(float);
144 // THIS NEEDS IMPROVEMENT !!!!!!!!!!!!!
145 static int scan_number(char *s, double *new_value)
150 char *WordBufPtr = WordBuf;
155 *WordBufPtr++ = *cptr++;
157 while (isdigit(*cptr) ) {
158 *WordBufPtr++ = *cptr++;
162 *WordBufPtr++ = *cptr++; // put the '.' into the string
163 while (isdigit(*cptr)) {
164 *WordBufPtr++ = *cptr++;
169 sscanf(WordBuf, "%lf", new_value);
176 void ApHeadingDialog_Cancel(puObject *)
178 ApHeadingDialogInput->rejectInput();
179 FG_POP_PUI_DIALOG( ApHeadingDialog );
182 void ApHeadingDialog_OK (puObject *me)
187 ApHeadingDialogInput -> getValue( &c );
191 if( scan_number( c, &NewHeading ) )
193 if ( !current_autopilot->get_HeadingEnabled() ) {
194 current_autopilot->set_HeadingEnabled( true );
196 current_autopilot->HeadingSet( NewHeading );
200 s += " is not a valid number.";
203 ApHeadingDialog_Cancel(me);
204 if( error ) mkDialog(s.c_str());
207 void NewHeading(puObject *cb)
209 // string ApHeadingLabel( "Enter New Heading" );
210 // ApHeadingDialogMessage -> setLabel(ApHeadingLabel.c_str());
211 ApHeadingDialogInput -> acceptInput();
212 FG_PUSH_PUI_DIALOG( ApHeadingDialog );
215 void NewHeadingInit(void)
217 // printf("NewHeadingInit\n");
218 char NewHeadingLabel[] = "Enter New Heading";
221 float heading = fgGetDouble("/orientation/heading-deg");
223 (puGetDefaultLabelFont().getStringWidth( NewHeadingLabel ) / 2 );
225 ApHeadingDialog = new puDialogBox (150, 50);
227 ApHeadingDialogFrame = new puFrame (0, 0, 260, 150);
229 ApHeadingDialogMessage = new puText (len, 110);
230 ApHeadingDialogMessage -> setDefaultValue (NewHeadingLabel);
231 ApHeadingDialogMessage -> getDefaultValue (&s);
232 ApHeadingDialogMessage -> setLabel (s);
234 ApHeadingDialogInput = new puInput ( 50, 70, 210, 100 );
235 ApHeadingDialogInput -> setValue ( heading );
237 ApHeadingDialogOkButton = new puOneShot (50, 10, 110, 50);
238 ApHeadingDialogOkButton -> setLegend (gui_msg_OK);
239 ApHeadingDialogOkButton -> makeReturnDefault (TRUE);
240 ApHeadingDialogOkButton -> setCallback (ApHeadingDialog_OK);
242 ApHeadingDialogCancelButton = new puOneShot (140, 10, 210, 50);
243 ApHeadingDialogCancelButton -> setLegend (gui_msg_CANCEL);
244 ApHeadingDialogCancelButton -> setCallback (ApHeadingDialog_Cancel);
247 FG_FINALIZE_PUI_DIALOG( ApHeadingDialog );
250 void ApAltitudeDialog_Cancel(puObject *)
252 ApAltitudeDialogInput -> rejectInput();
253 FG_POP_PUI_DIALOG( ApAltitudeDialog );
256 void ApAltitudeDialog_OK (puObject *me)
261 ApAltitudeDialogInput->getValue( &c );
265 if( scan_number( c, &NewAltitude) )
267 if ( !current_autopilot->get_AltitudeEnabled() ) {
268 current_autopilot->set_AltitudeEnabled( true );
270 current_autopilot->AltitudeSet( NewAltitude );
274 s += " is not a valid number.";
277 ApAltitudeDialog_Cancel(me);
278 if( error ) mkDialog(s.c_str());
281 void NewAltitude(puObject *cb)
283 ApAltitudeDialogInput -> acceptInput();
284 FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
287 void NewAltitudeInit(void)
289 // printf("NewAltitudeInit\n");
290 char NewAltitudeLabel[] = "Enter New Altitude";
293 float alt = cur_fdm_state->get_Altitude();
295 if ( fgGetString("/sim/startup/units") == "meters") {
296 alt *= SG_FEET_TO_METER;
300 (puGetDefaultLabelFont().getStringWidth( NewAltitudeLabel ) / 2);
302 // ApAltitudeDialog = new puDialogBox (150, 50);
303 ApAltitudeDialog = new puDialogBox (150, 200);
305 ApAltitudeDialogFrame = new puFrame (0, 0, 260, 150);
306 ApAltitudeDialogMessage = new puText (len, 110);
307 ApAltitudeDialogMessage -> setDefaultValue (NewAltitudeLabel);
308 ApAltitudeDialogMessage -> getDefaultValue (&s);
309 ApAltitudeDialogMessage -> setLabel (s);
311 ApAltitudeDialogInput = new puInput ( 50, 70, 210, 100 );
312 ApAltitudeDialogInput -> setValue ( alt );
313 // Uncomment the next line to have input active on startup
314 // ApAltitudeDialogInput -> acceptInput ( );
315 // cursor at begining or end of line ?
318 // ApAltitudeDialogInput -> setCursor ( len );
319 // ApAltitudeDialogInput -> setSelectRegion ( 5, 9 );
321 ApAltitudeDialogOkButton = new puOneShot (50, 10, 110, 50);
322 ApAltitudeDialogOkButton -> setLegend (gui_msg_OK);
323 ApAltitudeDialogOkButton -> makeReturnDefault (TRUE);
324 ApAltitudeDialogOkButton -> setCallback (ApAltitudeDialog_OK);
326 ApAltitudeDialogCancelButton = new puOneShot (140, 10, 210, 50);
327 ApAltitudeDialogCancelButton -> setLegend (gui_msg_CANCEL);
328 ApAltitudeDialogCancelButton -> setCallback (ApAltitudeDialog_Cancel);
331 FG_FINALIZE_PUI_DIALOG( ApAltitudeDialog );
334 /////// simple AutoPilot GAIN / LIMITS ADJUSTER
336 #define fgAP_CLAMP(val,min,max) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
338 static void maxroll_adj( puObject *hs ) {
341 hs-> getValue ( &val ) ;
342 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
343 // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
344 current_autopilot->set_MaxRoll( MaxRollAdjust * val );
345 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
346 APAdjustMaxRollText -> setLabel ( SliderText[ 0 ] ) ;
349 static void rollout_adj( puObject *hs ) {
352 hs-> getValue ( &val ) ;
353 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
354 // printf ( "rollout_adj( %p ) %f %f\n", hs, val, RollOutAdjust * val ) ;
355 current_autopilot->set_RollOut( RollOutAdjust * val );
356 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
357 APAdjustRollOutText -> setLabel ( SliderText[ 1 ] );
360 static void maxaileron_adj( puObject *hs ) {
363 hs-> getValue ( &val ) ;
364 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
365 // printf ( "maxaileron_adj( %p ) %f %f\n", hs, val, MaxAileronAdjust * val ) ;
366 current_autopilot->set_MaxAileron( MaxAileronAdjust * val );
367 sprintf( SliderText[ 3 ], "%05.2f", current_autopilot->get_MaxAileron() );
368 APAdjustMaxAileronText -> setLabel ( SliderText[ 3 ] );
371 static void rolloutsmooth_adj( puObject *hs ) {
374 hs -> getValue ( &val ) ;
375 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
376 // printf ( "rolloutsmooth_adj( %p ) %f %f\n", hs, val, RollOutSmoothAdjust * val ) ;
377 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust * val );
378 sprintf( SliderText[ 2 ], "%5.2f", current_autopilot->get_RollOutSmooth() );
379 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
383 static void goAwayAPAdjust (puObject *)
385 FG_POP_PUI_DIALOG( APAdjustDialog );
388 void cancelAPAdjust( puObject *self ) {
389 current_autopilot->set_MaxRoll( TmpMaxRollValue );
390 current_autopilot->set_RollOut( TmpRollOutValue );
391 current_autopilot->set_MaxAileron( TmpMaxAileronValue );
392 current_autopilot->set_RollOutSmooth( TmpRollOutSmoothValue );
394 goAwayAPAdjust(self);
397 void resetAPAdjust( puObject *self ) {
398 current_autopilot->set_MaxRoll( MaxRollAdjust / 2 );
399 current_autopilot->set_RollOut( RollOutAdjust / 2 );
400 current_autopilot->set_MaxAileron( MaxAileronAdjust / 2 );
401 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust / 2 );
403 FG_POP_PUI_DIALOG( APAdjustDialog );
408 void fgAPAdjust( puObject * ) {
409 TmpMaxRollValue = current_autopilot->get_MaxRoll();
410 TmpRollOutValue = current_autopilot->get_RollOut();
411 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
412 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
414 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
415 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
416 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
417 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
418 / RollOutSmoothAdjust;
420 APAdjustHS0-> setValue ( MaxRollValue ) ;
421 APAdjustHS1-> setValue ( RollOutValue ) ;
422 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
423 APAdjustHS3-> setValue ( MaxAileronValue ) ;
425 FG_PUSH_PUI_DIALOG( APAdjustDialog );
428 // Done once at system initialization
429 void fgAPAdjustInit( void ) {
431 // printf("fgAPAdjustInit\n");
432 #define HORIZONTAL FALSE
436 int DialogWidth = 230;
438 char Label[] = "AutoPilot Adjust";
441 int labelX = (DialogWidth / 2) -
442 (puGetDefaultLabelFont().getStringWidth( Label ) / 2);
443 labelX -= 30; // KLUDGEY
448 int slider_width = 210;
449 int slider_title_x = 15;
450 int slider_value_x = 160;
451 float slider_delta = 0.1f;
453 TmpMaxRollValue = current_autopilot->get_MaxRoll();
454 TmpRollOutValue = current_autopilot->get_RollOut();
455 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
456 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
458 MaxRollAdjust = 2 * current_autopilot->get_MaxRoll();
459 RollOutAdjust = 2 * current_autopilot->get_RollOut();
460 MaxAileronAdjust = 2 * current_autopilot->get_MaxAileron();
461 RollOutSmoothAdjust = 2 * current_autopilot->get_RollOutSmooth();
463 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
464 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
465 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
466 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
467 / RollOutSmoothAdjust;
469 puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
470 APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
471 int horiz_slider_height = APAdjustLabelFont.getStringHeight() +
472 APAdjustLabelFont.getStringDescender() +
473 PUSTR_TGAP + PUSTR_BGAP + 5;
475 APAdjustFrame = new puFrame ( 0, 0,
477 85 + nSliders * horiz_slider_height );
479 APAdjustDialogMessage = new puText ( labelX,
481 * horiz_slider_height );
482 APAdjustDialogMessage -> setDefaultValue ( Label );
483 APAdjustDialogMessage -> getDefaultValue ( &s );
484 APAdjustDialogMessage -> setLabel ( s );
486 APAdjustHS0 = new mySlider ( slider_x, slider_y,
487 slider_width, HORIZONTAL ) ;
488 APAdjustHS0-> setDelta ( slider_delta ) ;
489 APAdjustHS0-> setValue ( MaxRollValue ) ;
490 APAdjustHS0-> setCBMode ( PUSLIDER_DELTA ) ;
491 APAdjustHS0-> setCallback ( maxroll_adj ) ;
493 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
494 APAdjustMaxRollTitle = new puText ( slider_title_x, slider_y ) ;
495 APAdjustMaxRollTitle-> setDefaultValue ( "MaxRoll" ) ;
496 APAdjustMaxRollTitle-> getDefaultValue ( &s ) ;
497 APAdjustMaxRollTitle-> setLabel ( s ) ;
498 APAdjustMaxRollText = new puText ( slider_value_x, slider_y ) ;
499 APAdjustMaxRollText-> setLabel ( SliderText[ 0 ] ) ;
501 slider_y += horiz_slider_height;
503 APAdjustHS1 = new mySlider ( slider_x, slider_y, slider_width,
505 APAdjustHS1-> setDelta ( slider_delta ) ;
506 APAdjustHS1-> setValue ( RollOutValue ) ;
507 APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
508 APAdjustHS1-> setCallback ( rollout_adj ) ;
510 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
511 APAdjustRollOutTitle = new puText ( slider_title_x, slider_y ) ;
512 APAdjustRollOutTitle-> setDefaultValue ( "AdjustRollOut" ) ;
513 APAdjustRollOutTitle-> getDefaultValue ( &s ) ;
514 APAdjustRollOutTitle-> setLabel ( s ) ;
515 APAdjustRollOutText = new puText ( slider_value_x, slider_y ) ;
516 APAdjustRollOutText-> setLabel ( SliderText[ 1 ] );
518 slider_y += horiz_slider_height;
520 APAdjustHS2 = new mySlider ( slider_x, slider_y, slider_width,
522 APAdjustHS2-> setDelta ( slider_delta ) ;
523 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
524 APAdjustHS2-> setCBMode ( PUSLIDER_DELTA ) ;
525 APAdjustHS2-> setCallback ( rolloutsmooth_adj ) ;
527 sprintf( SliderText[ 2 ], "%5.2f",
528 current_autopilot->get_RollOutSmooth() );
529 APAdjustRollOutSmoothTitle = new puText ( slider_title_x, slider_y ) ;
530 APAdjustRollOutSmoothTitle-> setDefaultValue ( "RollOutSmooth" ) ;
531 APAdjustRollOutSmoothTitle-> getDefaultValue ( &s ) ;
532 APAdjustRollOutSmoothTitle-> setLabel ( s ) ;
533 APAdjustRollOutSmoothText = new puText ( slider_value_x, slider_y ) ;
534 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
536 slider_y += horiz_slider_height;
538 APAdjustHS3 = new mySlider ( slider_x, slider_y, slider_width,
540 APAdjustHS3-> setDelta ( slider_delta ) ;
541 APAdjustHS3-> setValue ( MaxAileronValue ) ;
542 APAdjustHS3-> setCBMode ( PUSLIDER_DELTA ) ;
543 APAdjustHS3-> setCallback ( maxaileron_adj ) ;
545 sprintf( SliderText[ 3 ], "%05.2f",
546 current_autopilot->get_MaxAileron() );
547 APAdjustMaxAileronTitle = new puText ( slider_title_x, slider_y ) ;
548 APAdjustMaxAileronTitle-> setDefaultValue ( "MaxAileron" ) ;
549 APAdjustMaxAileronTitle-> getDefaultValue ( &s ) ;
550 APAdjustMaxAileronTitle-> setLabel ( s ) ;
551 APAdjustMaxAileronText = new puText ( slider_value_x, slider_y ) ;
552 APAdjustMaxAileronText-> setLabel ( SliderText[ 3 ] );
554 APAdjustOkButton = new puOneShot ( 10, 10, 60, 50 );
555 APAdjustOkButton-> setLegend ( gui_msg_OK );
556 APAdjustOkButton-> makeReturnDefault ( TRUE );
557 APAdjustOkButton-> setCallback ( goAwayAPAdjust );
559 APAdjustCancelButton = new puOneShot ( 70, 10, 150, 50 );
560 APAdjustCancelButton-> setLegend ( gui_msg_CANCEL );
561 APAdjustCancelButton-> setCallback ( cancelAPAdjust );
563 APAdjustResetButton = new puOneShot ( 160, 10, 220, 50 );
564 APAdjustResetButton-> setLegend ( gui_msg_RESET );
565 APAdjustResetButton-> setCallback ( resetAPAdjust );
567 FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
572 // Simple Dialog to input Target Airport
573 void TgtAptDialog_Cancel(puObject *)
575 FG_POP_PUI_DIALOG( TgtAptDialog );
578 void TgtAptDialog_OK (puObject *)
582 // FGTime *t = FGTime::cur_time_params;
583 // int PauseMode = t->getPause();
585 // t->togglePauseMode();
588 TgtAptDialogInput->getValue(&s);
592 unsigned int pos = tmp.find( "@" );
593 if ( pos != string::npos ) {
594 TgtAptId = tmp.substr( 0, pos );
595 string alt_str = tmp.substr( pos + 1 );
596 alt = atof( alt_str.c_str() );
597 if ( fgGetString("/sim/startup/units") == "feet" ) {
598 alt *= SG_FEET_TO_METER;
604 TgtAptDialog_Cancel( NULL );
609 if ( fgFindAirportID( TgtAptId, &a ) ) {
611 SG_LOG( SG_GENERAL, SG_INFO,
612 "Adding waypoint (airport) = " << TgtAptId );
614 sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
616 SGWayPoint wp( a.longitude, a.latitude, alt,
617 SGWayPoint::WGS84, TgtAptId );
618 globals->get_route()->add_waypoint( wp );
619 } else if ( current_fixlist->query( TgtAptId, 0.0, 0.0, 0.0,
622 SG_LOG( SG_GENERAL, SG_INFO,
623 "Adding waypoint (fix) = " << TgtAptId );
625 sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
627 SGWayPoint wp( f.get_lon(), f.get_lat(), alt,
628 SGWayPoint::WGS84, TgtAptId );
629 globals->get_route()->add_waypoint( wp );
631 TgtAptId += " not in database.";
632 mkDialog(TgtAptId.c_str());
636 void TgtAptDialog_Reset(puObject *)
638 sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
639 TgtAptDialogInput->setValue ( NewTgtAirportId );
640 TgtAptDialogInput->setCursor( 0 ) ;
643 void AddWayPoint(puObject *cb)
645 sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
646 TgtAptDialogInput->setValue( NewTgtAirportId );
648 FG_PUSH_PUI_DIALOG( TgtAptDialog );
651 void PopWayPoint(puObject *cb)
653 globals->get_route()->delete_first();
655 // see if there are more waypoints on the list
656 if ( globals->get_route()->size() ) {
658 current_autopilot->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
661 current_autopilot->set_HeadingMode( FGAutopilot::FG_TC_HEADING_LOCK );
663 // use current heading
665 ->set_TargetHeading(fgGetDouble("/orientation/heading-deg"));
669 void ClearRoute(puObject *cb)
671 globals->get_route()->clear();
674 void NewTgtAirportInit(void)
676 SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
677 sprintf( NewTgtAirportId, "%s",
678 fgGetString("/sim/startup/airport-id").c_str() );
679 SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
681 - puGetDefaultLabelFont().getStringWidth( NewTgtAirportLabel ) / 2;
683 TgtAptDialog = new puDialogBox (150, 50);
685 TgtAptDialogFrame = new puFrame (0,0,350, 150);
686 TgtAptDialogMessage = new puText (len, 110);
687 TgtAptDialogMessage -> setLabel (NewTgtAirportLabel);
689 TgtAptDialogInput = new puInput (50, 70, 300, 100);
690 TgtAptDialogInput -> setValue (NewTgtAirportId);
691 TgtAptDialogInput -> acceptInput();
693 TgtAptDialogOkButton = new puOneShot (50, 10, 110, 50);
694 TgtAptDialogOkButton -> setLegend (gui_msg_OK);
695 TgtAptDialogOkButton -> setCallback (TgtAptDialog_OK);
696 TgtAptDialogOkButton -> makeReturnDefault(TRUE);
698 TgtAptDialogCancelButton = new puOneShot (140, 10, 210, 50);
699 TgtAptDialogCancelButton -> setLegend (gui_msg_CANCEL);
700 TgtAptDialogCancelButton -> setCallback (TgtAptDialog_Cancel);
702 TgtAptDialogResetButton = new puOneShot (240, 10, 300, 50);
703 TgtAptDialogResetButton -> setLegend (gui_msg_RESET);
704 TgtAptDialogResetButton -> setCallback (TgtAptDialog_Reset);
706 FG_FINALIZE_PUI_DIALOG( TgtAptDialog );
707 printf("leave NewTgtAirportInit()");