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.
29 #include <simgear/compiler.h>
37 #include <Aircraft/aircraft.hxx>
38 #include <FDM/flight.hxx>
39 #include <Controls/controls.hxx>
40 #include <Scenery/scenery.hxx>
42 #include <simgear/constants.h>
43 #include <simgear/sg_inlines.h>
44 #include <simgear/debug/logstream.hxx>
45 #include <simgear/math/sg_geodesy.hxx>
46 #include <simgear/misc/sg_path.hxx>
48 #include <Airports/simple.hxx>
50 #include <Main/fg_init.hxx>
51 #include <Main/globals.hxx>
52 #include <Main/fg_props.hxx>
53 #include <Navaids/fixlist.hxx>
55 #include "auto_gui.hxx"
56 #include "newauto.hxx"
61 #define mySlider puSlider
63 // Climb speed constants
64 const double min_climb = 70.0; // kts
65 const double best_climb = 75.0; // kts
66 const double ideal_climb_rate = 500.0; // fpm
68 /// These statics will eventually go into the class
69 /// they are just here while I am experimenting -- NHV :-)
70 // AutoPilot Gain Adjuster members
71 static double MaxRollAdjust; // MaxRollAdjust = 2 * APData->MaxRoll;
72 static double RollOutAdjust; // RollOutAdjust = 2 * APData->RollOut;
73 static double MaxAileronAdjust; // MaxAileronAdjust = 2 * APData->MaxAileron;
74 static double RollOutSmoothAdjust; // RollOutSmoothAdjust = 2 * APData->RollOutSmooth;
76 static float MaxRollValue; // 0.1 -> 1.0
77 static float RollOutValue;
78 static float MaxAileronValue;
79 static float RollOutSmoothValue;
81 static float TmpMaxRollValue; // for cancel operation
82 static float TmpRollOutValue;
83 static float TmpMaxAileronValue;
84 static float TmpRollOutSmoothValue;
86 static puDialogBox *APAdjustDialog;
87 static puFrame *APAdjustFrame;
88 static puText *APAdjustDialogMessage;
89 static puFont APAdjustLegendFont;
90 static puFont APAdjustLabelFont;
92 static puOneShot *APAdjustOkButton;
93 static puOneShot *APAdjustResetButton;
94 static puOneShot *APAdjustCancelButton;
96 //static puButton *APAdjustDragButton;
98 static puText *APAdjustMaxRollTitle;
99 static puText *APAdjustRollOutTitle;
100 static puText *APAdjustMaxAileronTitle;
101 static puText *APAdjustRollOutSmoothTitle;
103 static puText *APAdjustMaxAileronText;
104 static puText *APAdjustMaxRollText;
105 static puText *APAdjustRollOutText;
106 static puText *APAdjustRollOutSmoothText;
108 static mySlider *APAdjustHS0;
109 static mySlider *APAdjustHS1;
110 static mySlider *APAdjustHS2;
111 static mySlider *APAdjustHS3;
113 static char SliderText[ 4 ][ 8 ];
115 ///////// AutoPilot New Heading Dialog
117 static puDialogBox *ApHeadingDialog;
118 static puFrame *ApHeadingDialogFrame;
119 static puText *ApHeadingDialogMessage;
120 static puInput *ApHeadingDialogInput;
121 static puOneShot *ApHeadingDialogOkButton;
122 static puOneShot *ApHeadingDialogCancelButton;
125 ///////// AutoPilot New Altitude Dialog
127 static puDialogBox *ApAltitudeDialog = 0;
128 static puFrame *ApAltitudeDialogFrame = 0;
129 static puText *ApAltitudeDialogMessage = 0;
130 static puInput *ApAltitudeDialogInput = 0;
132 static puOneShot *ApAltitudeDialogOkButton = 0;
133 static puOneShot *ApAltitudeDialogCancelButton = 0;
136 /// The beginnings of Lock AutoPilot to target location :-)
137 // Needs cleaning up but works
138 // These statics should disapear when this is a class
139 static puDialogBox *TgtAptDialog = 0;
140 static puFrame *TgtAptDialogFrame = 0;
141 static puText *TgtAptDialogMessage = 0;
142 static puInput *TgtAptDialogInput = 0;
144 static char NewTgtAirportId[16];
145 static char NewTgtAirportLabel[] = "Enter New TgtAirport ID";
147 static puOneShot *TgtAptDialogOkButton = 0;
148 static puOneShot *TgtAptDialogCancelButton = 0;
149 static puOneShot *TgtAptDialogResetButton = 0;
152 // extern char *coord_format_lat(float);
153 // extern char *coord_format_lon(float);
155 // THIS NEEDS IMPROVEMENT !!!!!!!!!!!!!
156 static int scan_number(char *s, double *new_value)
161 char *WordBufPtr = WordBuf;
166 *WordBufPtr++ = *cptr++;
168 while (isdigit(*cptr) ) {
169 *WordBufPtr++ = *cptr++;
173 *WordBufPtr++ = *cptr++; // put the '.' into the string
174 while (isdigit(*cptr)) {
175 *WordBufPtr++ = *cptr++;
180 sscanf(WordBuf, "%lf", new_value);
187 void ApHeadingDialog_Cancel(puObject *)
189 ApHeadingDialogInput->rejectInput();
190 FG_POP_PUI_DIALOG( ApHeadingDialog );
193 void ApHeadingDialog_OK (puObject *me)
198 ApHeadingDialogInput -> getValue( &c );
202 if( scan_number( c, &NewHeading ) )
204 if ( !current_autopilot->get_HeadingEnabled() ) {
205 current_autopilot->set_HeadingEnabled( true );
207 current_autopilot->HeadingSet( NewHeading );
211 s += " is not a valid number.";
214 ApHeadingDialog_Cancel(me);
215 if( error ) mkDialog(s.c_str());
218 void NewHeading(puObject *cb)
220 // string ApHeadingLabel( "Enter New Heading" );
221 // ApHeadingDialogMessage -> setLabel(ApHeadingLabel.c_str());
222 ApHeadingDialogInput -> acceptInput();
223 FG_PUSH_PUI_DIALOG( ApHeadingDialog );
226 void NewHeadingInit()
228 // printf("NewHeadingInit\n");
229 char NewHeadingLabel[] = "Enter New Heading";
232 float heading = fgGetDouble("/orientation/heading-deg");
234 (puGetDefaultLabelFont().getStringWidth( NewHeadingLabel ) / 2 );
236 ApHeadingDialog = new puDialogBox (150, 50);
238 ApHeadingDialogFrame = new puFrame (0, 0, 260, 150);
240 ApHeadingDialogMessage = new puText (len, 110);
241 ApHeadingDialogMessage -> setDefaultValue (NewHeadingLabel);
242 ApHeadingDialogMessage -> getDefaultValue (&s);
243 ApHeadingDialogMessage -> setLabel (s);
245 ApHeadingDialogInput = new puInput ( 50, 70, 210, 100 );
246 ApHeadingDialogInput -> setValue ( heading );
248 ApHeadingDialogOkButton = new puOneShot (50, 10, 110, 50);
249 ApHeadingDialogOkButton -> setLegend (gui_msg_OK);
250 ApHeadingDialogOkButton -> makeReturnDefault (TRUE);
251 ApHeadingDialogOkButton -> setCallback (ApHeadingDialog_OK);
253 ApHeadingDialogCancelButton = new puOneShot (140, 10, 210, 50);
254 ApHeadingDialogCancelButton -> setLegend (gui_msg_CANCEL);
255 ApHeadingDialogCancelButton -> setCallback (ApHeadingDialog_Cancel);
258 FG_FINALIZE_PUI_DIALOG( ApHeadingDialog );
261 void ApAltitudeDialog_Cancel(puObject *)
263 ApAltitudeDialogInput -> rejectInput();
264 FG_POP_PUI_DIALOG( ApAltitudeDialog );
267 void ApAltitudeDialog_OK (puObject *me)
272 ApAltitudeDialogInput->getValue( &c );
276 if( scan_number( c, &NewAltitude) )
278 if ( !current_autopilot->get_AltitudeEnabled() ) {
279 current_autopilot->set_AltitudeEnabled( true );
281 current_autopilot->AltitudeSet( NewAltitude );
285 s += " is not a valid number.";
288 ApAltitudeDialog_Cancel(me);
289 if( error ) mkDialog(s.c_str());
292 void NewAltitude(puObject *cb)
294 ApAltitudeDialogInput -> acceptInput();
295 FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
298 void NewAltitudeInit()
300 // printf("NewAltitudeInit\n");
301 char NewAltitudeLabel[] = "Enter New Altitude";
304 float alt = cur_fdm_state->get_Altitude();
306 if ( fgGetString("/sim/startup/units") == "meters") {
307 alt *= SG_FEET_TO_METER;
311 (puGetDefaultLabelFont().getStringWidth( NewAltitudeLabel ) / 2);
313 // ApAltitudeDialog = new puDialogBox (150, 50);
314 ApAltitudeDialog = new puDialogBox (150, 200);
316 ApAltitudeDialogFrame = new puFrame (0, 0, 260, 150);
317 ApAltitudeDialogMessage = new puText (len, 110);
318 ApAltitudeDialogMessage -> setDefaultValue (NewAltitudeLabel);
319 ApAltitudeDialogMessage -> getDefaultValue (&s);
320 ApAltitudeDialogMessage -> setLabel (s);
322 ApAltitudeDialogInput = new puInput ( 50, 70, 210, 100 );
323 ApAltitudeDialogInput -> setValue ( alt );
324 // Uncomment the next line to have input active on startup
325 // ApAltitudeDialogInput -> acceptInput ( );
326 // cursor at begining or end of line ?
329 // ApAltitudeDialogInput -> setCursor ( len );
330 // ApAltitudeDialogInput -> setSelectRegion ( 5, 9 );
332 ApAltitudeDialogOkButton = new puOneShot (50, 10, 110, 50);
333 ApAltitudeDialogOkButton -> setLegend (gui_msg_OK);
334 ApAltitudeDialogOkButton -> makeReturnDefault (TRUE);
335 ApAltitudeDialogOkButton -> setCallback (ApAltitudeDialog_OK);
337 ApAltitudeDialogCancelButton = new puOneShot (140, 10, 210, 50);
338 ApAltitudeDialogCancelButton -> setLegend (gui_msg_CANCEL);
339 ApAltitudeDialogCancelButton -> setCallback (ApAltitudeDialog_Cancel);
342 FG_FINALIZE_PUI_DIALOG( ApAltitudeDialog );
346 static void maxroll_adj( puObject *hs ) {
349 hs-> getValue ( &val ) ;
350 SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
351 // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
352 current_autopilot->set_MaxRoll( MaxRollAdjust * val );
353 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
354 APAdjustMaxRollText -> setLabel ( SliderText[ 0 ] ) ;
357 static void rollout_adj( puObject *hs ) {
360 hs-> getValue ( &val ) ;
361 SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
362 // printf ( "rollout_adj( %p ) %f %f\n", hs, val, RollOutAdjust * val ) ;
363 current_autopilot->set_RollOut( RollOutAdjust * val );
364 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
365 APAdjustRollOutText -> setLabel ( SliderText[ 1 ] );
368 static void maxaileron_adj( puObject *hs ) {
371 hs-> getValue ( &val ) ;
372 SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
373 // printf ( "maxaileron_adj( %p ) %f %f\n", hs, val, MaxAileronAdjust * val ) ;
374 current_autopilot->set_MaxAileron( MaxAileronAdjust * val );
375 sprintf( SliderText[ 3 ], "%05.2f", current_autopilot->get_MaxAileron() );
376 APAdjustMaxAileronText -> setLabel ( SliderText[ 3 ] );
379 static void rolloutsmooth_adj( puObject *hs ) {
382 hs -> getValue ( &val ) ;
383 SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
384 // printf ( "rolloutsmooth_adj( %p ) %f %f\n", hs, val, RollOutSmoothAdjust * val ) ;
385 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust * val );
386 sprintf( SliderText[ 2 ], "%5.2f", current_autopilot->get_RollOutSmooth() );
387 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
391 static void goAwayAPAdjust (puObject *)
393 FG_POP_PUI_DIALOG( APAdjustDialog );
396 void cancelAPAdjust( puObject *self ) {
397 current_autopilot->set_MaxRoll( TmpMaxRollValue );
398 current_autopilot->set_RollOut( TmpRollOutValue );
399 current_autopilot->set_MaxAileron( TmpMaxAileronValue );
400 current_autopilot->set_RollOutSmooth( TmpRollOutSmoothValue );
402 goAwayAPAdjust(self);
405 void resetAPAdjust( puObject *self ) {
406 current_autopilot->set_MaxRoll( MaxRollAdjust / 2 );
407 current_autopilot->set_RollOut( RollOutAdjust / 2 );
408 current_autopilot->set_MaxAileron( MaxAileronAdjust / 2 );
409 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust / 2 );
411 FG_POP_PUI_DIALOG( APAdjustDialog );
416 void fgAPAdjust( puObject *self ) {
417 TmpMaxRollValue = current_autopilot->get_MaxRoll();
418 TmpRollOutValue = current_autopilot->get_RollOut();
419 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
420 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
422 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
423 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
424 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
425 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
426 / RollOutSmoothAdjust;
428 APAdjustHS0-> setValue ( MaxRollValue ) ;
429 APAdjustHS1-> setValue ( RollOutValue ) ;
430 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
431 APAdjustHS3-> setValue ( MaxAileronValue ) ;
433 FG_PUSH_PUI_DIALOG( APAdjustDialog );
436 // Done once at system initialization
437 void fgAPAdjustInit() {
439 // printf("fgAPAdjustInit\n");
440 #define HORIZONTAL FALSE
444 int DialogWidth = 230;
446 char Label[] = "AutoPilot Adjust";
449 int labelX = (DialogWidth / 2) -
450 (puGetDefaultLabelFont().getStringWidth( Label ) / 2);
451 labelX -= 30; // KLUDGEY
456 int slider_width = 210;
457 int slider_title_x = 15;
458 int slider_value_x = 160;
459 float slider_delta = 0.1f;
461 TmpMaxRollValue = current_autopilot->get_MaxRoll();
462 TmpRollOutValue = current_autopilot->get_RollOut();
463 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
464 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
466 MaxRollAdjust = 2 * current_autopilot->get_MaxRoll();
467 RollOutAdjust = 2 * current_autopilot->get_RollOut();
468 MaxAileronAdjust = 2 * current_autopilot->get_MaxAileron();
469 RollOutSmoothAdjust = 2 * current_autopilot->get_RollOutSmooth();
471 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
472 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
473 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
474 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
475 / RollOutSmoothAdjust;
477 puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
478 APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
479 int horiz_slider_height = APAdjustLabelFont.getStringHeight() +
480 APAdjustLabelFont.getStringDescender() +
481 PUSTR_TGAP + PUSTR_BGAP + 5;
483 APAdjustFrame = new puFrame ( 0, 0,
485 85 + nSliders * horiz_slider_height );
487 APAdjustDialogMessage = new puText ( labelX,
489 * horiz_slider_height );
490 APAdjustDialogMessage -> setDefaultValue ( Label );
491 APAdjustDialogMessage -> getDefaultValue ( &s );
492 APAdjustDialogMessage -> setLabel ( s );
494 APAdjustHS0 = new mySlider ( slider_x, slider_y,
495 slider_width, HORIZONTAL ) ;
496 APAdjustHS0-> setDelta ( slider_delta ) ;
497 APAdjustHS0-> setValue ( MaxRollValue ) ;
498 APAdjustHS0-> setCBMode ( PUSLIDER_DELTA ) ;
499 APAdjustHS0-> setCallback ( maxroll_adj ) ;
501 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
502 APAdjustMaxRollTitle = new puText ( slider_title_x, slider_y ) ;
503 APAdjustMaxRollTitle-> setDefaultValue ( "MaxRoll" ) ;
504 APAdjustMaxRollTitle-> getDefaultValue ( &s ) ;
505 APAdjustMaxRollTitle-> setLabel ( s ) ;
506 APAdjustMaxRollText = new puText ( slider_value_x, slider_y ) ;
507 APAdjustMaxRollText-> setLabel ( SliderText[ 0 ] ) ;
509 slider_y += horiz_slider_height;
511 APAdjustHS1 = new mySlider ( slider_x, slider_y, slider_width,
513 APAdjustHS1-> setDelta ( slider_delta ) ;
514 APAdjustHS1-> setValue ( RollOutValue ) ;
515 APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
516 APAdjustHS1-> setCallback ( rollout_adj ) ;
518 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
519 APAdjustRollOutTitle = new puText ( slider_title_x, slider_y ) ;
520 APAdjustRollOutTitle-> setDefaultValue ( "AdjustRollOut" ) ;
521 APAdjustRollOutTitle-> getDefaultValue ( &s ) ;
522 APAdjustRollOutTitle-> setLabel ( s ) ;
523 APAdjustRollOutText = new puText ( slider_value_x, slider_y ) ;
524 APAdjustRollOutText-> setLabel ( SliderText[ 1 ] );
526 slider_y += horiz_slider_height;
528 APAdjustHS2 = new mySlider ( slider_x, slider_y, slider_width,
530 APAdjustHS2-> setDelta ( slider_delta ) ;
531 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
532 APAdjustHS2-> setCBMode ( PUSLIDER_DELTA ) ;
533 APAdjustHS2-> setCallback ( rolloutsmooth_adj ) ;
535 sprintf( SliderText[ 2 ], "%5.2f",
536 current_autopilot->get_RollOutSmooth() );
537 APAdjustRollOutSmoothTitle = new puText ( slider_title_x, slider_y ) ;
538 APAdjustRollOutSmoothTitle-> setDefaultValue ( "RollOutSmooth" ) ;
539 APAdjustRollOutSmoothTitle-> getDefaultValue ( &s ) ;
540 APAdjustRollOutSmoothTitle-> setLabel ( s ) ;
541 APAdjustRollOutSmoothText = new puText ( slider_value_x, slider_y ) ;
542 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
544 slider_y += horiz_slider_height;
546 APAdjustHS3 = new mySlider ( slider_x, slider_y, slider_width,
548 APAdjustHS3-> setDelta ( slider_delta ) ;
549 APAdjustHS3-> setValue ( MaxAileronValue ) ;
550 APAdjustHS3-> setCBMode ( PUSLIDER_DELTA ) ;
551 APAdjustHS3-> setCallback ( maxaileron_adj ) ;
553 sprintf( SliderText[ 3 ], "%05.2f",
554 current_autopilot->get_MaxAileron() );
555 APAdjustMaxAileronTitle = new puText ( slider_title_x, slider_y ) ;
556 APAdjustMaxAileronTitle-> setDefaultValue ( "MaxAileron" ) ;
557 APAdjustMaxAileronTitle-> getDefaultValue ( &s ) ;
558 APAdjustMaxAileronTitle-> setLabel ( s ) ;
559 APAdjustMaxAileronText = new puText ( slider_value_x, slider_y ) ;
560 APAdjustMaxAileronText-> setLabel ( SliderText[ 3 ] );
562 APAdjustOkButton = new puOneShot ( 10, 10, 60, 50 );
563 APAdjustOkButton-> setLegend ( gui_msg_OK );
564 APAdjustOkButton-> makeReturnDefault ( TRUE );
565 APAdjustOkButton-> setCallback ( goAwayAPAdjust );
567 APAdjustCancelButton = new puOneShot ( 70, 10, 150, 50 );
568 APAdjustCancelButton-> setLegend ( gui_msg_CANCEL );
569 APAdjustCancelButton-> setCallback ( cancelAPAdjust );
571 APAdjustResetButton = new puOneShot ( 160, 10, 220, 50 );
572 APAdjustResetButton-> setLegend ( gui_msg_RESET );
573 APAdjustResetButton-> setCallback ( resetAPAdjust );
575 FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
580 // Simple Dialog to input Target Airport
581 void TgtAptDialog_Cancel(puObject *)
583 FG_POP_PUI_DIALOG( TgtAptDialog );
586 void TgtAptDialog_OK (puObject *)
590 // FGTime *t = FGTime::cur_time_params;
591 // int PauseMode = t->getPause();
593 // t->togglePauseMode();
596 TgtAptDialogInput->getValue(&s);
600 unsigned int pos = tmp.find( "@" );
601 if ( pos != string::npos ) {
602 TgtAptId = tmp.substr( 0, pos );
603 string alt_str = tmp.substr( pos + 1 );
604 alt = atof( alt_str.c_str() );
605 if ( fgGetString("/sim/startup/units") == "feet" ) {
606 alt *= SG_FEET_TO_METER;
612 TgtAptDialog_Cancel( NULL );
617 if ( fgFindAirportID( TgtAptId, &a ) ) {
619 SG_LOG( SG_GENERAL, SG_INFO,
620 "Adding waypoint (airport) = " << TgtAptId );
622 sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
624 SGWayPoint wp( a.longitude, a.latitude, alt,
625 SGWayPoint::WGS84, TgtAptId );
626 globals->get_route()->add_waypoint( wp );
627 } else if ( current_fixlist->query( TgtAptId, 0.0, 0.0, 0.0,
630 SG_LOG( SG_GENERAL, SG_INFO,
631 "Adding waypoint (fix) = " << TgtAptId );
633 sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
635 SGWayPoint wp( f.get_lon(), f.get_lat(), alt,
636 SGWayPoint::WGS84, TgtAptId );
637 globals->get_route()->add_waypoint( wp );
639 TgtAptId += " not in database.";
640 mkDialog(TgtAptId.c_str());
644 void TgtAptDialog_Reset(puObject *)
646 sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
647 TgtAptDialogInput->setValue ( NewTgtAirportId );
648 TgtAptDialogInput->setCursor( 0 ) ;
651 void AddWayPoint(puObject *cb)
653 sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
654 TgtAptDialogInput->setValue( NewTgtAirportId );
656 FG_PUSH_PUI_DIALOG( TgtAptDialog );
659 void PopWayPoint(puObject *cb)
661 globals->get_route()->delete_first();
663 // see if there are more waypoints on the list
664 if ( globals->get_route()->size() ) {
666 current_autopilot->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
669 current_autopilot->set_HeadingMode( FGAutopilot::FG_TC_HEADING_LOCK );
671 // use current heading
673 ->set_TargetHeading(fgGetDouble("/orientation/heading-deg"));
677 void ClearRoute(puObject *cb)
679 globals->get_route()->clear();
682 void NewTgtAirportInit()
684 SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
685 sprintf( NewTgtAirportId, "%s",
686 fgGetString("/sim/startup/airport-id").c_str() );
687 SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
689 - puGetDefaultLabelFont().getStringWidth( NewTgtAirportLabel ) / 2;
691 TgtAptDialog = new puDialogBox (150, 50);
693 TgtAptDialogFrame = new puFrame (0,0,350, 150);
694 TgtAptDialogMessage = new puText (len, 110);
695 TgtAptDialogMessage -> setLabel (NewTgtAirportLabel);
697 TgtAptDialogInput = new puInput (50, 70, 300, 100);
698 TgtAptDialogInput -> setValue (NewTgtAirportId);
699 TgtAptDialogInput -> acceptInput();
701 TgtAptDialogOkButton = new puOneShot (50, 10, 110, 50);
702 TgtAptDialogOkButton -> setLegend (gui_msg_OK);
703 TgtAptDialogOkButton -> setCallback (TgtAptDialog_OK);
704 TgtAptDialogOkButton -> makeReturnDefault(TRUE);
706 TgtAptDialogCancelButton = new puOneShot (140, 10, 210, 50);
707 TgtAptDialogCancelButton -> setLegend (gui_msg_CANCEL);
708 TgtAptDialogCancelButton -> setCallback (TgtAptDialog_Cancel);
710 TgtAptDialogResetButton = new puOneShot (240, 10, 300, 50);
711 TgtAptDialogResetButton -> setLegend (gui_msg_RESET);
712 TgtAptDialogResetButton -> setCallback (TgtAptDialog_Reset);
714 FG_FINALIZE_PUI_DIALOG( TgtAptDialog );
715 printf("leave NewTgtAirportInit()");