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/fgpath.hxx>
39 #include <Airports/simple.hxx>
41 #include <Main/bfi.hxx>
42 #include <Main/fg_init.hxx>
43 #include <Main/options.hxx>
45 #include "auto_gui.hxx"
46 #include "newauto.hxx"
49 #define mySlider puSlider
51 // Climb speed constants
52 const double min_climb = 70.0; // kts
53 const double best_climb = 75.0; // kts
54 const double ideal_climb_rate = 500.0; // fpm
56 /// These statics will eventually go into the class
57 /// they are just here while I am experimenting -- NHV :-)
58 // AutoPilot Gain Adjuster members
59 static double MaxRollAdjust; // MaxRollAdjust = 2 * APData->MaxRoll;
60 static double RollOutAdjust; // RollOutAdjust = 2 * APData->RollOut;
61 static double MaxAileronAdjust; // MaxAileronAdjust = 2 * APData->MaxAileron;
62 static double RollOutSmoothAdjust; // RollOutSmoothAdjust = 2 * APData->RollOutSmooth;
64 static float MaxRollValue; // 0.1 -> 1.0
65 static float RollOutValue;
66 static float MaxAileronValue;
67 static float RollOutSmoothValue;
69 static float TmpMaxRollValue; // for cancel operation
70 static float TmpRollOutValue;
71 static float TmpMaxAileronValue;
72 static float TmpRollOutSmoothValue;
74 static puDialogBox *APAdjustDialog;
75 static puFrame *APAdjustFrame;
76 static puText *APAdjustDialogMessage;
77 static puFont APAdjustLegendFont;
78 static puFont APAdjustLabelFont;
80 static puOneShot *APAdjustOkButton;
81 static puOneShot *APAdjustResetButton;
82 static puOneShot *APAdjustCancelButton;
84 //static puButton *APAdjustDragButton;
86 static puText *APAdjustMaxRollTitle;
87 static puText *APAdjustRollOutTitle;
88 static puText *APAdjustMaxAileronTitle;
89 static puText *APAdjustRollOutSmoothTitle;
91 static puText *APAdjustMaxAileronText;
92 static puText *APAdjustMaxRollText;
93 static puText *APAdjustRollOutText;
94 static puText *APAdjustRollOutSmoothText;
96 static mySlider *APAdjustHS0;
97 static mySlider *APAdjustHS1;
98 static mySlider *APAdjustHS2;
99 static mySlider *APAdjustHS3;
101 static char SliderText[ 4 ][ 8 ];
103 ///////// AutoPilot New Heading Dialog
105 static puDialogBox *ApHeadingDialog;
106 static puFrame *ApHeadingDialogFrame;
107 static puText *ApHeadingDialogMessage;
108 static puInput *ApHeadingDialogInput;
109 static puOneShot *ApHeadingDialogOkButton;
110 static puOneShot *ApHeadingDialogCancelButton;
113 ///////// AutoPilot New Altitude Dialog
115 static puDialogBox *ApAltitudeDialog = 0;
116 static puFrame *ApAltitudeDialogFrame = 0;
117 static puText *ApAltitudeDialogMessage = 0;
118 static puInput *ApAltitudeDialogInput = 0;
120 static puOneShot *ApAltitudeDialogOkButton = 0;
121 static puOneShot *ApAltitudeDialogCancelButton = 0;
124 /// The beginnings of Lock AutoPilot to target location :-)
125 // Needs cleaning up but works
126 // These statics should disapear when this is a class
127 static puDialogBox *TgtAptDialog = 0;
128 static puFrame *TgtAptDialogFrame = 0;
129 static puText *TgtAptDialogMessage = 0;
130 static puInput *TgtAptDialogInput = 0;
132 static char NewTgtAirportId[16];
133 static char NewTgtAirportLabel[] = "Enter New TgtAirport ID";
135 static puOneShot *TgtAptDialogOkButton = 0;
136 static puOneShot *TgtAptDialogCancelButton = 0;
137 static puOneShot *TgtAptDialogResetButton = 0;
140 // extern char *coord_format_lat(float);
141 // extern char *coord_format_lon(float);
143 // THIS NEEDS IMPROVEMENT !!!!!!!!!!!!!
144 static int scan_number(char *s, double *new_value)
149 char *WordBufPtr = WordBuf;
154 *WordBufPtr++ = *cptr++;
156 while (isdigit(*cptr) ) {
157 *WordBufPtr++ = *cptr++;
161 *WordBufPtr++ = *cptr++; // put the '.' into the string
162 while (isdigit(*cptr)) {
163 *WordBufPtr++ = *cptr++;
168 sscanf(WordBuf, "%lf", new_value);
175 void ApHeadingDialog_Cancel(puObject *)
177 ApHeadingDialogInput->rejectInput();
178 FG_POP_PUI_DIALOG( ApHeadingDialog );
181 void ApHeadingDialog_OK (puObject *me)
186 ApHeadingDialogInput -> getValue( &c );
190 if( scan_number( c, &NewHeading ) )
192 if ( !current_autopilot->get_HeadingEnabled() ) {
193 current_autopilot->set_HeadingEnabled( true );
195 current_autopilot->HeadingSet( NewHeading );
199 s += " is not a valid number.";
202 ApHeadingDialog_Cancel(me);
203 if( error ) mkDialog(s.c_str());
206 void NewHeading(puObject *cb)
208 // string ApHeadingLabel( "Enter New Heading" );
209 // ApHeadingDialogMessage -> setLabel(ApHeadingLabel.c_str());
210 ApHeadingDialogInput -> acceptInput();
211 FG_PUSH_PUI_DIALOG( ApHeadingDialog );
214 void NewHeadingInit(void)
216 // printf("NewHeadingInit\n");
217 char NewHeadingLabel[] = "Enter New Heading";
220 float heading = FGBFI::getHeading();
222 (puGetStringWidth( puGetDefaultLabelFont(), NewHeadingLabel ) /2 );
224 ApHeadingDialog = new puDialogBox (150, 50);
226 ApHeadingDialogFrame = new puFrame (0, 0, 260, 150);
228 ApHeadingDialogMessage = new puText (len, 110);
229 ApHeadingDialogMessage -> setDefaultValue (NewHeadingLabel);
230 ApHeadingDialogMessage -> getDefaultValue (&s);
231 ApHeadingDialogMessage -> setLabel (s);
233 ApHeadingDialogInput = new puInput ( 50, 70, 210, 100 );
234 ApHeadingDialogInput -> setValue ( heading );
236 ApHeadingDialogOkButton = new puOneShot (50, 10, 110, 50);
237 ApHeadingDialogOkButton -> setLegend (gui_msg_OK);
238 ApHeadingDialogOkButton -> makeReturnDefault (TRUE);
239 ApHeadingDialogOkButton -> setCallback (ApHeadingDialog_OK);
241 ApHeadingDialogCancelButton = new puOneShot (140, 10, 210, 50);
242 ApHeadingDialogCancelButton -> setLegend (gui_msg_CANCEL);
243 ApHeadingDialogCancelButton -> setCallback (ApHeadingDialog_Cancel);
246 FG_FINALIZE_PUI_DIALOG( ApHeadingDialog );
249 void ApAltitudeDialog_Cancel(puObject *)
251 ApAltitudeDialogInput -> rejectInput();
252 FG_POP_PUI_DIALOG( ApAltitudeDialog );
255 void ApAltitudeDialog_OK (puObject *me)
260 ApAltitudeDialogInput->getValue( &c );
264 if( scan_number( c, &NewAltitude) )
266 if ( !current_autopilot->get_AltitudeEnabled() ) {
267 current_autopilot->set_AltitudeEnabled( true );
269 current_autopilot->AltitudeSet( NewAltitude );
273 s += " is not a valid number.";
276 ApAltitudeDialog_Cancel(me);
277 if( error ) mkDialog(s.c_str());
280 void NewAltitude(puObject *cb)
282 ApAltitudeDialogInput -> acceptInput();
283 FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
286 void NewAltitudeInit(void)
288 // printf("NewAltitudeInit\n");
289 char NewAltitudeLabel[] = "Enter New Altitude";
292 float alt = cur_fdm_state->get_Altitude();
294 if ( current_options.get_units() == fgOPTIONS::FG_UNITS_METERS) {
295 alt *= FEET_TO_METER;
299 (puGetStringWidth( puGetDefaultLabelFont(), NewAltitudeLabel )/2);
301 // ApAltitudeDialog = new puDialogBox (150, 50);
302 ApAltitudeDialog = new puDialogBox (150, 200);
304 ApAltitudeDialogFrame = new puFrame (0, 0, 260, 150);
305 ApAltitudeDialogMessage = new puText (len, 110);
306 ApAltitudeDialogMessage -> setDefaultValue (NewAltitudeLabel);
307 ApAltitudeDialogMessage -> getDefaultValue (&s);
308 ApAltitudeDialogMessage -> setLabel (s);
310 ApAltitudeDialogInput = new puInput ( 50, 70, 210, 100 );
311 ApAltitudeDialogInput -> setValue ( alt );
312 // Uncomment the next line to have input active on startup
313 // ApAltitudeDialogInput -> acceptInput ( );
314 // cursor at begining or end of line ?
317 // ApAltitudeDialogInput -> setCursor ( len );
318 // ApAltitudeDialogInput -> setSelectRegion ( 5, 9 );
320 ApAltitudeDialogOkButton = new puOneShot (50, 10, 110, 50);
321 ApAltitudeDialogOkButton -> setLegend (gui_msg_OK);
322 ApAltitudeDialogOkButton -> makeReturnDefault (TRUE);
323 ApAltitudeDialogOkButton -> setCallback (ApAltitudeDialog_OK);
325 ApAltitudeDialogCancelButton = new puOneShot (140, 10, 210, 50);
326 ApAltitudeDialogCancelButton -> setLegend (gui_msg_CANCEL);
327 ApAltitudeDialogCancelButton -> setCallback (ApAltitudeDialog_Cancel);
330 FG_FINALIZE_PUI_DIALOG( ApAltitudeDialog );
333 /////// simple AutoPilot GAIN / LIMITS ADJUSTER
335 #define fgAP_CLAMP(val,min,max) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
337 static void maxroll_adj( puObject *hs ) {
340 hs-> getValue ( &val ) ;
341 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
342 // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
343 current_autopilot->set_MaxRoll( MaxRollAdjust * val );
344 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
345 APAdjustMaxRollText -> setLabel ( SliderText[ 0 ] ) ;
348 static void rollout_adj( puObject *hs ) {
351 hs-> getValue ( &val ) ;
352 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
353 // printf ( "rollout_adj( %p ) %f %f\n", hs, val, RollOutAdjust * val ) ;
354 current_autopilot->set_RollOut( RollOutAdjust * val );
355 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
356 APAdjustRollOutText -> setLabel ( SliderText[ 1 ] );
359 static void maxaileron_adj( puObject *hs ) {
362 hs-> getValue ( &val ) ;
363 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
364 // printf ( "maxaileron_adj( %p ) %f %f\n", hs, val, MaxAileronAdjust * val ) ;
365 current_autopilot->set_MaxAileron( MaxAileronAdjust * val );
366 sprintf( SliderText[ 3 ], "%05.2f", current_autopilot->get_MaxAileron() );
367 APAdjustMaxAileronText -> setLabel ( SliderText[ 3 ] );
370 static void rolloutsmooth_adj( puObject *hs ) {
373 hs -> getValue ( &val ) ;
374 fgAP_CLAMP ( val, 0.1, 1.0 ) ;
375 // printf ( "rolloutsmooth_adj( %p ) %f %f\n", hs, val, RollOutSmoothAdjust * val ) ;
376 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust * val );
377 sprintf( SliderText[ 2 ], "%5.2f", current_autopilot->get_RollOutSmooth() );
378 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
382 static void goAwayAPAdjust (puObject *)
384 FG_POP_PUI_DIALOG( APAdjustDialog );
387 void cancelAPAdjust( puObject *self ) {
388 current_autopilot->set_MaxRoll( TmpMaxRollValue );
389 current_autopilot->set_RollOut( TmpRollOutValue );
390 current_autopilot->set_MaxAileron( TmpMaxAileronValue );
391 current_autopilot->set_RollOutSmooth( TmpRollOutSmoothValue );
393 goAwayAPAdjust(self);
396 void resetAPAdjust( puObject *self ) {
397 current_autopilot->set_MaxRoll( MaxRollAdjust / 2 );
398 current_autopilot->set_RollOut( RollOutAdjust / 2 );
399 current_autopilot->set_MaxAileron( MaxAileronAdjust / 2 );
400 current_autopilot->set_RollOutSmooth( RollOutSmoothAdjust / 2 );
402 FG_POP_PUI_DIALOG( APAdjustDialog );
407 void fgAPAdjust( puObject * ) {
408 TmpMaxRollValue = current_autopilot->get_MaxRoll();
409 TmpRollOutValue = current_autopilot->get_RollOut();
410 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
411 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
413 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
414 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
415 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
416 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
417 / RollOutSmoothAdjust;
419 APAdjustHS0-> setValue ( MaxRollValue ) ;
420 APAdjustHS1-> setValue ( RollOutValue ) ;
421 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
422 APAdjustHS3-> setValue ( MaxAileronValue ) ;
424 FG_PUSH_PUI_DIALOG( APAdjustDialog );
427 // Done once at system initialization
428 void fgAPAdjustInit( void ) {
430 // printf("fgAPAdjustInit\n");
431 #define HORIZONTAL FALSE
435 int DialogWidth = 230;
437 char Label[] = "AutoPilot Adjust";
440 int labelX = (DialogWidth / 2) -
441 (puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
442 labelX -= 30; // KLUDGEY
447 int slider_width = 210;
448 int slider_title_x = 15;
449 int slider_value_x = 160;
450 float slider_delta = 0.1f;
452 TmpMaxRollValue = current_autopilot->get_MaxRoll();
453 TmpRollOutValue = current_autopilot->get_RollOut();
454 TmpMaxAileronValue = current_autopilot->get_MaxAileron();
455 TmpRollOutSmoothValue = current_autopilot->get_RollOutSmooth();
457 MaxRollAdjust = 2 * current_autopilot->get_MaxRoll();
458 RollOutAdjust = 2 * current_autopilot->get_RollOut();
459 MaxAileronAdjust = 2 * current_autopilot->get_MaxAileron();
460 RollOutSmoothAdjust = 2 * current_autopilot->get_RollOutSmooth();
462 MaxRollValue = current_autopilot->get_MaxRoll() / MaxRollAdjust;
463 RollOutValue = current_autopilot->get_RollOut() / RollOutAdjust;
464 MaxAileronValue = current_autopilot->get_MaxAileron() / MaxAileronAdjust;
465 RollOutSmoothValue = current_autopilot->get_RollOutSmooth()
466 / RollOutSmoothAdjust;
468 puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
469 APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
470 int horiz_slider_height = puGetStringHeight (APAdjustLabelFont) +
471 puGetStringDescender (APAdjustLabelFont) +
472 PUSTR_TGAP + PUSTR_BGAP + 5;
474 APAdjustFrame = new puFrame ( 0, 0,
476 85 + nSliders * horiz_slider_height );
478 APAdjustDialogMessage = new puText ( labelX,
480 * horiz_slider_height );
481 APAdjustDialogMessage -> setDefaultValue ( Label );
482 APAdjustDialogMessage -> getDefaultValue ( &s );
483 APAdjustDialogMessage -> setLabel ( s );
485 APAdjustHS0 = new mySlider ( slider_x, slider_y,
486 slider_width, HORIZONTAL ) ;
487 APAdjustHS0-> setDelta ( slider_delta ) ;
488 APAdjustHS0-> setValue ( MaxRollValue ) ;
489 APAdjustHS0-> setCBMode ( PUSLIDER_DELTA ) ;
490 APAdjustHS0-> setCallback ( maxroll_adj ) ;
492 sprintf( SliderText[ 0 ], "%05.2f", current_autopilot->get_MaxRoll() );
493 APAdjustMaxRollTitle = new puText ( slider_title_x, slider_y ) ;
494 APAdjustMaxRollTitle-> setDefaultValue ( "MaxRoll" ) ;
495 APAdjustMaxRollTitle-> getDefaultValue ( &s ) ;
496 APAdjustMaxRollTitle-> setLabel ( s ) ;
497 APAdjustMaxRollText = new puText ( slider_value_x, slider_y ) ;
498 APAdjustMaxRollText-> setLabel ( SliderText[ 0 ] ) ;
500 slider_y += horiz_slider_height;
502 APAdjustHS1 = new mySlider ( slider_x, slider_y, slider_width,
504 APAdjustHS1-> setDelta ( slider_delta ) ;
505 APAdjustHS1-> setValue ( RollOutValue ) ;
506 APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
507 APAdjustHS1-> setCallback ( rollout_adj ) ;
509 sprintf( SliderText[ 1 ], "%05.2f", current_autopilot->get_RollOut() );
510 APAdjustRollOutTitle = new puText ( slider_title_x, slider_y ) ;
511 APAdjustRollOutTitle-> setDefaultValue ( "AdjustRollOut" ) ;
512 APAdjustRollOutTitle-> getDefaultValue ( &s ) ;
513 APAdjustRollOutTitle-> setLabel ( s ) ;
514 APAdjustRollOutText = new puText ( slider_value_x, slider_y ) ;
515 APAdjustRollOutText-> setLabel ( SliderText[ 1 ] );
517 slider_y += horiz_slider_height;
519 APAdjustHS2 = new mySlider ( slider_x, slider_y, slider_width,
521 APAdjustHS2-> setDelta ( slider_delta ) ;
522 APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
523 APAdjustHS2-> setCBMode ( PUSLIDER_DELTA ) ;
524 APAdjustHS2-> setCallback ( rolloutsmooth_adj ) ;
526 sprintf( SliderText[ 2 ], "%5.2f",
527 current_autopilot->get_RollOutSmooth() );
528 APAdjustRollOutSmoothTitle = new puText ( slider_title_x, slider_y ) ;
529 APAdjustRollOutSmoothTitle-> setDefaultValue ( "RollOutSmooth" ) ;
530 APAdjustRollOutSmoothTitle-> getDefaultValue ( &s ) ;
531 APAdjustRollOutSmoothTitle-> setLabel ( s ) ;
532 APAdjustRollOutSmoothText = new puText ( slider_value_x, slider_y ) ;
533 APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
535 slider_y += horiz_slider_height;
537 APAdjustHS3 = new mySlider ( slider_x, slider_y, slider_width,
539 APAdjustHS3-> setDelta ( slider_delta ) ;
540 APAdjustHS3-> setValue ( MaxAileronValue ) ;
541 APAdjustHS3-> setCBMode ( PUSLIDER_DELTA ) ;
542 APAdjustHS3-> setCallback ( maxaileron_adj ) ;
544 sprintf( SliderText[ 3 ], "%05.2f",
545 current_autopilot->get_MaxAileron() );
546 APAdjustMaxAileronTitle = new puText ( slider_title_x, slider_y ) ;
547 APAdjustMaxAileronTitle-> setDefaultValue ( "MaxAileron" ) ;
548 APAdjustMaxAileronTitle-> getDefaultValue ( &s ) ;
549 APAdjustMaxAileronTitle-> setLabel ( s ) ;
550 APAdjustMaxAileronText = new puText ( slider_value_x, slider_y ) ;
551 APAdjustMaxAileronText-> setLabel ( SliderText[ 3 ] );
553 APAdjustOkButton = new puOneShot ( 10, 10, 60, 50 );
554 APAdjustOkButton-> setLegend ( gui_msg_OK );
555 APAdjustOkButton-> makeReturnDefault ( TRUE );
556 APAdjustOkButton-> setCallback ( goAwayAPAdjust );
558 APAdjustCancelButton = new puOneShot ( 70, 10, 150, 50 );
559 APAdjustCancelButton-> setLegend ( gui_msg_CANCEL );
560 APAdjustCancelButton-> setCallback ( cancelAPAdjust );
562 APAdjustResetButton = new puOneShot ( 160, 10, 220, 50 );
563 APAdjustResetButton-> setLegend ( gui_msg_RESET );
564 APAdjustResetButton-> setCallback ( resetAPAdjust );
566 FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
571 // Simple Dialog to input Target Airport
572 void TgtAptDialog_Cancel(puObject *)
574 FG_POP_PUI_DIALOG( TgtAptDialog );
577 void TgtAptDialog_OK (puObject *)
581 // FGTime *t = FGTime::cur_time_params;
582 // int PauseMode = t->getPause();
584 // t->togglePauseMode();
587 TgtAptDialogInput->getValue(&s);
590 TgtAptDialog_Cancel( NULL );
592 if ( TgtAptId.length() ) {
593 // set initial position from TgtAirport id
595 FGPath path( current_options.get_fg_root() );
596 path.append( "Airports" );
597 path.append( "simple.mk4" );
598 FGAirports airports( path.c_str() );
601 FG_LOG( FG_GENERAL, FG_INFO,
602 "Attempting to set starting position from airport code "
605 if ( airports.search( TgtAptId, &a ) )
607 double course, reverse, distance;
608 // fgAPset_tgt_airport_id( TgtAptId.c_str() );
609 current_options.set_airport_id( TgtAptId.c_str() );
610 sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
612 current_autopilot->set_WayPoint( a.longitude, a.latitude,
614 // current_autopilot->set_TargetLatitude( a.latitude );
615 // current_autopilot->set_TargetLongitude( a.longitude );
616 current_autopilot->MakeTargetLatLonStr(
617 current_autopilot->get_TargetLatitude(),
618 current_autopilot->get_TargetLongitude() );
620 current_autopilot->set_old_lat( FGBFI::getLatitude() );
621 current_autopilot->set_old_lon( FGBFI::getLongitude() );
623 // need to test for iter
624 if( ! geo_inverse_wgs_84( FGBFI::getAltitude() * FEET_TO_METER,
625 FGBFI::getLatitude(),
626 FGBFI::getLongitude(),
627 current_autopilot->get_TargetLatitude(),
628 current_autopilot->get_TargetLongitude(),
632 current_autopilot->set_TargetHeading( course );
633 current_autopilot->MakeTargetHeadingStr(
634 current_autopilot->get_TargetHeading() );
635 current_autopilot->set_TargetDistance( distance );
636 current_autopilot->MakeTargetDistanceStr( distance );
637 // This changes the AutoPilot Heading
638 // following cast needed
639 ApHeadingDialogInput->
640 setValue((float)current_autopilot->get_TargetHeading() );
642 current_autopilot->set_HeadingEnabled( true );
643 current_autopilot->set_HeadingMode(
644 FGAutopilot::FG_HEADING_WAYPOINT );
647 TgtAptId += " not in database.";
648 mkDialog(TgtAptId.c_str());
651 // get_control_values();
652 // if( PauseMode != t->getPause() )
653 // t->togglePauseMode();
656 void TgtAptDialog_Reset(puObject *)
658 // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
659 sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() );
660 TgtAptDialogInput->setValue ( NewTgtAirportId );
661 TgtAptDialogInput->setCursor( 0 ) ;
664 void NewTgtAirport(puObject *cb)
666 // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
667 sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() );
668 TgtAptDialogInput->setValue( NewTgtAirportId );
670 FG_PUSH_PUI_DIALOG( TgtAptDialog );
673 void NewTgtAirportInit(void)
675 FG_LOG( FG_AUTOPILOT, FG_INFO, " enter NewTgtAirportInit()" );
676 // fgAPset_tgt_airport_id( current_options.get_airport_id() );
677 sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() );
678 FG_LOG( FG_AUTOPILOT, FG_INFO, " NewTgtAirportId " << NewTgtAirportId );
679 // printf(" NewTgtAirportId %s\n", NewTgtAirportId);
680 int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
681 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()");