]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_init.cxx
499641a1a5b3a2ff0c705a2c46e1b7abcecb469c
[flightgear.git] / src / Main / fg_init.cxx
1 //
2 // fg_init.cxx -- Flight Gear top level initialization routines
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
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.
12 //
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.
17 //
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.
21 //
22 //
23 // $Id$
24
25
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 // For BC 5.01 this must be included before OpenGL includes.
31 #ifdef FG_MATH_EXCEPTION_CLASH
32 #  include <math.h>
33 #endif
34
35 #include <GL/glut.h>
36 #include <simgear/xgl/xgl.h>
37
38 #include <stdio.h>
39 #include <stdlib.h>
40
41 // work around a stdc++ lib bug in some versions of linux, but doesn't
42 // seem to hurt to have this here for all versions of Linux.
43 #ifdef linux
44 #  define _G_NO_EXTERN_TEMPLATES
45 #endif
46
47 #include <simgear/compiler.h>
48
49 #include STL_STRING
50
51 #include <simgear/constants.h>
52 #include <simgear/debug/logstream.hxx>
53 #include <simgear/math/fg_geodesy.hxx>
54 #include <simgear/math/point3d.hxx>
55 #include <simgear/math/polar3d.hxx>
56 #include <simgear/misc/fgpath.hxx>
57
58 #include <Aircraft/aircraft.hxx>
59 #include <Airports/simple.hxx>
60 #include <Astro/stars.hxx>
61 #include <Autopilot/autopilot.hxx>
62 #include <Cockpit/cockpit.hxx>
63 #include <FDM/Balloon.h>
64 #include <FDM/External.hxx>
65 #include <FDM/JSBsim.hxx>
66 #include <FDM/LaRCsim.hxx>
67 #include <FDM/MagicCarpet.hxx>
68 #include <Include/general.hxx>
69 #include <Joystick/joystick.hxx>
70 #include <Scenery/scenery.hxx>
71 #include <Scenery/tilemgr.hxx>
72 #include <Time/event.hxx>
73 #include <Time/fg_time.hxx>
74 #include <Time/light.hxx>
75 #include <Time/sunpos.hxx>
76 #include <Time/moonpos.hxx>
77
78 #ifndef FG_OLD_WEATHER
79 #  include <WeatherCM/FGLocalWeatherDatabase.h>
80 #else
81 #  include <Weather/weather.hxx>
82 #endif
83
84 #include "fg_init.hxx"
85 #include "fg_io.hxx"
86 #include "options.hxx"
87 #include "views.hxx"
88
89 #if defined(FX) && defined(XMESA)
90 #include <GL/xmesa.h>
91 #endif
92
93 FG_USING_STD(string);
94
95 extern const char *default_root;
96
97
98 // Read in configuration (file and command line)
99 bool fgInitConfig ( int argc, char **argv ) {
100     // Attempt to locate and parse a config file
101     // First check fg_root
102     FGPath config( current_options.get_fg_root() );
103     config.append( "system.fgfsrc" );
104     current_options.parse_config_file( config.str() );
105
106     // Next check home directory
107     char* envp = ::getenv( "HOME" );
108     if ( envp != NULL ) {
109         config.set( envp );
110         config.append( ".fgfsrc" );
111         current_options.parse_config_file( config.str() );
112     }
113
114     // Parse remaining command line options
115     // These will override anything specified in a config file
116     if ( current_options.parse_command_line(argc, argv) !=
117          fgOPTIONS::FG_OPTIONS_OK )
118     {
119         // Something must have gone horribly wrong with the command
120         // line parsing or maybe the user just requested help ... :-)
121         current_options.usage();
122         FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ...");
123         return false;
124     }
125
126    return true;
127 }
128
129
130 // Set initial position and orientation
131 bool fgInitPosition( void ) {
132     string id;
133     FGInterface *f;
134
135     f = current_aircraft.fdm_state;
136
137     id = current_options.get_airport_id();
138     if ( id.length() ) {
139         // set initial position from airport id
140
141         fgAIRPORTS airports;
142         fgAIRPORT a;
143
144         FG_LOG( FG_GENERAL, FG_INFO,
145                 "Attempting to set starting position from airport code "
146                 << id );
147
148         airports.load("apt_simple");
149         if ( ! airports.search( id, &a ) ) {
150             FG_LOG( FG_GENERAL, FG_ALERT,
151                     "Failed to find " << id << " in database." );
152             exit(-1);
153         } else {
154             f->set_Longitude( a.longitude * DEG_TO_RAD );
155             f->set_Latitude( a.latitude * DEG_TO_RAD );
156         }
157     } else {
158         // set initial position from default or command line coordinates
159
160         f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
161         f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
162     }
163
164     FG_LOG( FG_GENERAL, FG_INFO,
165             "starting altitude is = " << current_options.get_altitude() );
166
167     f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
168     fgFDMSetGroundElevation( current_options.get_flight_model(),
169                              (f->get_Altitude() - 3.758099) * FEET_TO_METER );
170
171     FG_LOG( FG_GENERAL, FG_INFO,
172             "Initial position is: ("
173             << (f->get_Longitude() * RAD_TO_DEG) << ", "
174             << (f->get_Latitude() * RAD_TO_DEG) << ", "
175             << (f->get_Altitude() * FEET_TO_METER) << ")" );
176
177     return true;
178 }
179
180
181 // General house keeping initializations
182 bool fgInitGeneral( void ) {
183     string root;
184
185 #if defined(FX) && defined(XMESA)
186     char *mesa_win_state;
187 #endif
188
189     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
190     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
191
192     root = current_options.get_fg_root();
193     if ( ! root.length() ) {
194         // No root path set? Then bail ...
195         FG_LOG( FG_GENERAL, FG_ALERT,
196                 "Cannot continue without environment variable FG_ROOT"
197                 << "being defined." );
198         exit(-1);
199     }
200     FG_LOG( FG_GENERAL, FG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
201
202 #if defined(FX) && defined(XMESA)
203     // initialize full screen flag
204     global_fullscreen = false;
205     if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
206         // Test for the MESA_GLX_FX env variable
207         if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
208             // test if we are fullscreen mesa/glide
209             if ( (mesa_win_state[0] == 'f') ||
210                  (mesa_win_state[0] == 'F') ) {
211                 global_fullscreen = true;
212             }
213         }
214     }
215 #endif
216
217     return true;
218 }
219
220
221 // This is the top level init routine which calls all the other
222 // initialization routines.  If you are adding a subsystem to flight
223 // gear, its initialization call should located in this routine.
224 // Returns non-zero if a problem encountered.
225 bool fgInitSubsystems( void ) {
226     fgLIGHT *l = &cur_light_params;
227     FGTime *t = FGTime::cur_time_params;
228
229     FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
230     FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
231
232     if ( current_options.get_flight_model() == FGInterface::FG_LARCSIM ) {
233         cur_fdm_state = new FGLaRCsim;
234     } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
235         cur_fdm_state = new FGJSBsim;
236     } else if ( current_options.get_flight_model() == 
237                 FGInterface::FG_BALLOONSIM ) {
238         cur_fdm_state = new FGBalloonSim;
239     } else if ( current_options.get_flight_model() == 
240                 FGInterface::FG_MAGICCARPET ) {
241         cur_fdm_state = new FGMagicCarpet;
242     } else if ( current_options.get_flight_model() == 
243                 FGInterface::FG_EXTERNAL ) {
244         cur_fdm_state = new FGExternal;
245     } else {
246         FG_LOG( FG_GENERAL, FG_ALERT,
247                 "No flight model, can't init aircraft" );
248         exit(-1);
249     }
250
251     // allocates structures so must happen before any of the flight
252     // model or control parameters are set
253     fgAircraftInit();   // In the future this might not be the case.
254
255     // set the initial position
256     fgInitPosition();
257
258     // Initialize the Scenery Management subsystem
259     if ( fgSceneryInit() ) {
260         // Scenery initialized ok.
261     } else {
262         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
263         exit(-1);
264     }
265
266     if( global_tile_mgr.init() ) {
267         // Load the local scenery data
268         global_tile_mgr.update();
269     } else {
270         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
271         exit(-1);
272     }
273
274     FG_LOG( FG_GENERAL, FG_DEBUG,
275             "Current terrain elevation after tile mgr init " <<
276             scenery.cur_elev );
277
278     // Calculate ground elevation at starting point (we didn't have
279     // tmp_abs_view_pos calculated when fgTileMgrUpdate() was called above
280     //
281     // calculalate a cartesian point somewhere along the line between
282     // the center of the earth and our view position.  Doesn't have to
283     // be the exact elevation (this is good because we don't know it
284     // yet :-)
285
286     // now handled inside of the fgTileMgrUpdate()
287
288     /*
289     geod_pos = Point3D( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(), 0.0);
290     tmp_abs_view_pos = fgGeodToCart(geod_pos);
291
292     FG_LOG( FG_GENERAL, FG_DEBUG,
293             "Initial abs_view_pos = " << tmp_abs_view_pos );
294     scenery.cur_elev =
295         fgTileMgrCurElev( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(),
296                           tmp_abs_view_pos );
297     FG_LOG( FG_GENERAL, FG_DEBUG,
298             "Altitude after update " << scenery.cur_elev );
299     */
300
301     fgFDMSetGroundElevation( current_options.get_flight_model(),
302                              scenery.cur_elev );
303
304     // Reset our altitude if we are below ground
305     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
306     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
307             cur_fdm_state->get_Runway_altitude() );
308
309     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
310         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
311     }
312
313     FG_LOG( FG_GENERAL, FG_INFO,
314             "Updated position (after elevation adj): ("
315             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
316             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
317             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
318
319     // We need to calculate a few more values here that would normally
320     // be calculated by the FDM so that the current_view.UpdateViewMath()
321     // routine doesn't get hosed.
322
323     double sea_level_radius_meters;
324     double lat_geoc;
325     // Set the FG variables first
326     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
327                   &sea_level_radius_meters, &lat_geoc);
328     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(),
329                                 cur_fdm_state->get_Altitude() +
330                                 (sea_level_radius_meters * METER_TO_FEET) );
331     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
332
333     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
334     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
335         
336     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
337     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
338
339     // The following section sets up the flight model EOM parameters
340     // and should really be read in from one or more files.
341
342     // Initial Velocity
343     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
344                              current_options.get_vBody(),
345                              current_options.get_wBody());
346
347     // Initial Orientation
348     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
349                          current_options.get_pitch() * DEG_TO_RAD,
350                          current_options.get_heading() * DEG_TO_RAD );
351
352     // Initial Angular Body rates
353     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
354
355     cur_fdm_state->set_Earth_position_angle( 0.0 );
356
357     // Mass properties and geometry values
358     cur_fdm_state->set_Inertias( 8.547270E+01,
359                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
360
361     // CG position w.r.t. ref. point
362     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
363
364     // Initialize the event manager
365     global_events.Init();
366
367     // Output event stats every 60 seconds
368     global_events.Register( "fgEVENT_MGR::PrintStats()",
369                             fgMethodCallback<fgEVENT_MGR>( &global_events,
370                                                    &fgEVENT_MGR::PrintStats),
371                             fgEVENT::FG_EVENT_READY, 60000 );
372
373     // Initialize view parameters
374     FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
375     current_view.Init();
376     pilot_view.Init();
377     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
378     current_view.UpdateViewMath(*cur_fdm_state);
379     pilot_view.UpdateViewMath(*cur_fdm_state);
380     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
381     // current_view.UpdateWorldToEye(f);
382
383     // Initialize the planetary subsystem
384     // global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
385     //                      fgEVENT::FG_EVENT_READY, 600000);
386
387     // Initialize the sun's position
388     // global_events.Register( "fgSunInit()", fgSunInit,
389     //                      fgEVENT::FG_EVENT_READY, 30000 );
390
391     // Intialize the moon's position
392     // global_events.Register( "fgMoonInit()", fgMoonInit,
393     //                      fgEVENT::FG_EVENT_READY, 600000 );
394
395     // fgUpdateSunPos() needs a few position and view parameters set
396     // so it can calculate local relative sun angle and a few other
397     // things for correctly orienting the sky.
398     fgUpdateSunPos();
399     fgUpdateMoonPos();
400     global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
401                             fgEVENT::FG_EVENT_READY, 60000);
402     global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
403                             fgEVENT::FG_EVENT_READY, 60000);
404
405     // Initialize Lighting interpolation tables
406     l->Init();
407
408     // update the lighting parameters (based on sun angle)
409     global_events.Register( "fgLight::Update()",
410                             fgMethodCallback<fgLIGHT>( &cur_light_params,
411                                                        &fgLIGHT::Update),
412                             fgEVENT::FG_EVENT_READY, 30000 );
413     // update the current timezone each 30 minutes
414     global_events.Register( "fgTIME::updateLocal()",
415                             fgMethodCallback<FGTime>(FGTime::cur_time_params, 
416                                                      &FGTime::updateLocal),
417                             fgEVENT::FG_EVENT_READY, 1800000);
418
419     // Initialize the weather modeling subsystem
420 #ifndef FG_OLD_WEATHER
421     // Initialize the WeatherDatabase
422     FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
423     sgVec3 position;
424     sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
425                current_aircraft.fdm_state->get_Longitude(),
426                current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
427     FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 
428         new FGLocalWeatherDatabase( position );
429     // cout << theFGLocalWeatherDatabase << endl;
430     // cout << "visibility = " 
431     //      << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
432
433     WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
434      
435     // register the periodic update of the weather
436     global_events.Register( "weather update", fgUpdateWeatherDatabase,
437                             fgEVENT::FG_EVENT_READY, 30000);
438 #else
439     current_weather.Init();
440 #endif
441
442     // Initialize the Cockpit subsystem
443     if( fgCockpitInit( &current_aircraft )) {
444         // Cockpit initialized ok.
445     } else {
446         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Cockpit initialization!" );
447         exit(-1);
448     }
449
450     // Initialize the flight model subsystem data structures base on
451     // above values
452
453     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
454     //            1.0 / current_options.get_model_hz() );
455     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
456
457     // I'm just sticking this here for now, it should probably move
458     // eventually
459     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
460
461     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
462         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
463     }
464
465     FG_LOG( FG_GENERAL, FG_INFO,
466             "Updated position (after elevation adj): ("
467             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
468             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
469             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
470     // end of thing that I just stuck in that I should probably move
471
472     // Joystick support
473     if ( fgJoystickInit() ) {
474         // Joystick initialized ok.
475     } else {
476         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
477     }
478
479     // Autopilot init added here, by Jeff Goeke-Smith
480     fgAPInit(&current_aircraft);
481
482     // Initialize I/O channels
483 #if ! defined( MACOS )
484     fgIOInit();
485 #endif
486
487     FG_LOG( FG_GENERAL, FG_INFO, endl);
488
489     return true;
490 }
491
492
493 void fgReInitSubsystems( void )
494 {
495     FGTime *t = FGTime::cur_time_params;
496     
497     int toggle_pause = t->getPause();
498     
499     if( !toggle_pause )
500         t->togglePauseMode();
501     
502     fgInitPosition();
503     if( global_tile_mgr.init() ) {
504         // Load the local scenery data
505         global_tile_mgr.update();
506     } else {
507         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
508                 exit(-1);
509     }
510     fgFDMSetGroundElevation( current_options.get_flight_model(), 
511                              scenery.cur_elev );
512
513     // Reset our altitude if we are below ground
514     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
515     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
516             cur_fdm_state->get_Runway_altitude() );
517
518     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
519         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
520     }
521     double sea_level_radius_meters;
522     double lat_geoc;
523     // Set the FG variables first
524     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(), 
525                   &sea_level_radius_meters, &lat_geoc);
526     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(), 
527                                 cur_fdm_state->get_Altitude() + 
528                                 (sea_level_radius_meters * METER_TO_FEET) );
529     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
530         
531     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
532     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
533         
534     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
535     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
536
537     // The following section sets up the flight model EOM parameters
538     // and should really be read in from one or more files.
539
540     // Initial Velocity
541     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
542                              current_options.get_vBody(),
543                              current_options.get_wBody());
544
545     // Initial Orientation
546     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
547                          current_options.get_pitch() * DEG_TO_RAD,
548                          current_options.get_heading() * DEG_TO_RAD );
549
550     // Initial Angular Body rates
551     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
552
553     cur_fdm_state->set_Earth_position_angle( 0.0 );
554
555     // Mass properties and geometry values
556     cur_fdm_state->set_Inertias( 8.547270E+01, 
557                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
558
559     // CG position w.r.t. ref. point
560     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
561
562     // Initialize view parameters
563     current_view.set_view_offset( 0.0 );
564     current_view.set_goal_view_offset( 0.0 );
565     pilot_view.set_view_offset( 0.0 );
566     pilot_view.set_goal_view_offset( 0.0 );
567
568     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
569     current_view.UpdateViewMath(*cur_fdm_state);
570     pilot_view.UpdateViewMath(*cur_fdm_state);
571     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
572
573     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
574     //            1.0 / current_options.get_model_hz() );
575     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
576
577     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
578
579     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
580         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
581     }
582
583     controls.reset_all();
584     fgAPReset();
585
586     if( !toggle_pause )
587         t->togglePauseMode();
588 }