worldgui.cc
Go to the documentation of this file.
1 /* worldgui.cc
2  Implements a subclass of World that has an FLTK and OpenGL GUI
3  Authors: Richard Vaughan (vaughan@sfu.ca)
4  Alex Couture-Beil (asc17@sfu.ca)
5  Jeremy Asher (jra11@sfu.ca)
6  SVN: $Id$
7 */
8 
138 #include <FL/Fl_Image.H>
139 #include <FL/Fl_Shared_Image.H>
140 #include <FL/Fl_PNG_Image.H>
141 #include <FL/Fl_Output.H>
142 #include <FL/Fl_Text_Display.H>
143 #include <FL/Fl_File_Chooser.H>
144 
145 #include <set>
146 #include <sstream>
147 #include <iomanip>
148 #include <algorithm> // for std::sort
149 
150 #include "canvas.hh"
151 #include "region.hh"
152 #include "worldfile.hh"
153 #include "file_manager.hh"
154 #include "options_dlg.hh"
155 #include "config.h" // build options from CMake
156 
157 using namespace Stg;
158 
159 static const char* AboutText =
160  "\n"
161  "Part of the Player Project\n"
162  "http://playerstage.org\n"
163  "\n"
164  "Copyright 2000-2008 Richard Vaughan,\n"
165  "Brian Gerkey, Andrew Howard, Reed Hedges, \n"
166  "Toby Collett, Alex Couture-Beil, Jeremy Asher \n"
167  "and contributors\n"
168  "\n"
169  "Distributed under the terms of the \n"
170  "GNU General Public License v2";
171 
172 static const char* MoreHelpText =
173  "http://playerstage.org\n"
174  "\n"
175  "has these resources to help you:\n"
176  "\n"
177  "\t* A user manual including API documentation\n"
178  "\t* A bug and feature request tracking system\n"
179  "\t* Mailing lists for users and developers\n"
180  "\t* A Wiki"
181  "\n\n"
182  "The user manual is included with the Stage source code but\n"
183  "is not built by default. To build the manual, run \"make\"\n"
184  "in the directory \"docsrc\" to produce \"docsrc/stage/index.html\" .\n"
185  "(requires Doxygen and supporting programs to be installed first).\n";
186 
187 WorldGui::WorldGui(int W,int H,const char* L) :
188  Fl_Window(W,H,L ),
189  canvas( new Canvas( this,0,30,W,H-30 ) ),
190  drawOptions(),
191  fileMan( new FileManager() ),
192  interval_log(),
193  speedup(1.0), // real time
194  mbar( new Fl_Menu_Bar(0,0, W, 30)),
195  oDlg( NULL ),
196  pause_time( false ),
197  real_time_interval( sim_interval ),
198  real_time_now( RealTimeNow() ),
199  real_time_recorded( real_time_now ),
200  timing_interval( 20 )
201 {
202  Fl::scheme( "" );
203  resizable(canvas);
204  label( PROJECT );
205 
206  end();
207 
208  // make this menu's shortcuts work whoever has focus
209  mbar->global();
210  mbar->textsize(12);
211 
212  mbar->add( "&File", 0, 0, 0, FL_SUBMENU );
213  mbar->add( "File/&Load World...", FL_CTRL + 'l', (Fl_Callback*)fileLoadCb, this, FL_MENU_DIVIDER );
214  mbar->add( "File/&Save World", FL_CTRL + 's', (Fl_Callback*)fileSaveCb, this );
215  mbar->add( "File/Save World &As...", FL_CTRL + FL_SHIFT + 's', (Fl_Callback*)WorldGui::fileSaveAsCb, this, FL_MENU_DIVIDER );
216 
217  mbar->add( "File/E&xit", FL_CTRL+'q', (Fl_Callback*)fileExitCb, this );
218 
219  mbar->add( "&View", 0, 0, 0, FL_SUBMENU );
220 
221  mbar->add( "View/Reset", ' ', (Fl_Callback*)resetViewCb, this );
222 
223  mbar->add( "View/Filter data...", FL_SHIFT + 'd', (Fl_Callback*)viewOptionsCb, this );
224  canvas->createMenuItems( mbar, "View" );
225 
226  mbar->add( "Run", 0,0,0, FL_SUBMENU );
227  mbar->add( "Run/Pause", 'p', (Fl_Callback*)pauseCb, this );
228  mbar->add( "Run/One step", '.', (Fl_Callback*)onceCb, this, FL_MENU_DIVIDER );
229  mbar->add( "Run/Faster", ']', (Fl_Callback*)fasterCb, this );
230  mbar->add( "Run/Slower", '[', (Fl_Callback*)slowerCb, this, FL_MENU_DIVIDER );
231  mbar->add( "Run/Realtime", '{', (Fl_Callback*)realtimeCb, this );
232  mbar->add( "Run/Fast", '}', (Fl_Callback*)fasttimeCb, this );
233 
234  mbar->add( "&Help", 0, 0, 0, FL_SUBMENU );
235  mbar->add( "Help/Getting help...", 0, (Fl_Callback*)moreHelptCb, this, FL_MENU_DIVIDER );
236  mbar->add( "Help/&About Stage...", 0, (Fl_Callback*)helpAboutCb, this );
237 
238  callback( (Fl_Callback*)windowCb, this );
239 
240  show();
241 }
242 
244 {
245  if( mbar ) delete mbar;
246  if( oDlg ) delete oDlg;
247  if( canvas ) delete canvas;
248 }
249 
250 
252 {
253  show(); // fltk
254 }
255 
256 void WorldGui::Load( const std::string& filename )
257 {
258  PRINT_DEBUG1( "%s.Load()", token );
259 
260  // needs to happen before StgWorld load, or we segfault with GL calls on some graphics cards
261  Fl::check();
262 
263  fileMan->newWorld( filename );
264 
265  const usec_t load_start_time = RealTimeNow();
266 
267  World::Load( filename );
268 
269  // worldgui exclusive properties live in the top-level section
270  const int world_section = 0;
271  speedup = wf->ReadFloat( world_section, "speedup", speedup );
272  paused = wf->ReadInt( world_section, "paused", paused );
273 
274  // use the window section for the rest
275  const int window_section = wf->LookupEntity( "window" );
276 
277  if( window_section > 0 )
278  {
279  unsigned int width = w();
280  unsigned int height = h();
281  wf->ReadTuple(window_section, "size", 0, 2, "uu", &width, &height );
282 
283 
284  size( width,height );
285  size_range( 100, 100 ); // set min size to 100/100, max size to screen size
286 
287  // configure the canvas
288  canvas->Load( wf, window_section );
289 
290  std::string title = PROJECT;
291  if ( wf->filename.size() ) {
292  // improve the title bar to say "Stage: <worldfile name>"
293  title += ": ";
294  title += wf->filename;
295  }
296  label( title.c_str() );
297 
298  FOR_EACH( it, option_table )
299  (*it)->Load( wf, window_section );
300 
301  // warn about unused WF lines
302  wf->WarnUnused();
303  }
304 
305  const usec_t load_end_time = RealTimeNow();
306 
307  if( debug )
308  printf( "[Load time %.3fsec]\n",
309  (load_end_time - load_start_time) / 1e6 );
310 
311  Show();
312 }
313 
315 {
316  World::UnLoad();
317 }
318 
319 bool WorldGui::Save( const char* filename )
320 {
321  PRINT_DEBUG1( "%s.Save()", token );
322 
323  // worldgui exclusive properties live in the top-level section
324  const int world_section = 0;
325  wf->WriteFloat( world_section, "speedup", speedup );
326  wf->WriteInt( world_section, "paused", paused );
327 
328  // use the window section for the rest
329  const int window_section = wf->LookupEntity( "window" );
330 
331  if( window_section > 0 ) // section defined
332  {
333  unsigned int width = w();
334  unsigned int height = h();
335  wf->WriteTuple( window_section, "size", 0, 2, "uu", width, height );
336 
337  canvas->Save( wf, window_section );
338 
339  FOR_EACH( it, option_table )
340  (*it)->Save( wf, window_section );
341  }
342 
343  World::Save( filename );
344 
345  // TODO - error checking
346  return true;
347 }
348 
349 static void UpdateCallback( WorldGui* world )
350 {
351  world->Update();
352 }
353 
355 {
356  if( speedup > 0 )
357  Fl::repeat_timeout( (sim_interval/1e6) / speedup, (Fl_Timeout_Handler)UpdateCallback, this );
358  // else we're called by an idle callback
359 
360  //printf( "speedup %.2f timeout %.6f\n", speedup, timeout );
361 
362  // occasionally we measure the real time elapsing, for reporting the
363  // run speed
364  if( updates % timing_interval == 0 )
365  {
366  const usec_t timenow = RealTimeNow();
368  real_time_recorded = timenow;
369  }
370 
371  // inherit
372  const bool done = World::Update();
373 
376  (*it)->UpdateTrail();
377 
378  if( done )
379  {
380  quit_time = 0; // allows us to continue by un-pausing
381  Stop();
382  }
383 
384  return done;
385 }
386 
387 std::string WorldGui::ClockString() const
388 {
389  std::string str = World::ClockString();
390 
391  const double localratio =
392  (double)sim_interval / (double)(real_time_interval/timing_interval);
393 
394  char buf[32];
395  snprintf( buf, 32, " [%.1f]", localratio );
396  str += buf;
397 
398  if( paused == true )
399  str += " [ PAUSED ]";
400 
401  return str;
402 }
403 
404 
406 {
407  if( mod->parent == NULL )
408  canvas->AddModel( mod );
409 
410  World::AddModel( mod );
411 }
412 
413 
415 {
416  canvas->RemoveModel( mod );
417  World::RemoveChild( mod );
418 }
419 
420 
421 std::string WorldGui::EnergyString() const
422 {
423  char str[512];
424  snprintf( str, 255, "Energy\n stored: %.0f / %.0f KJ\n input: %.0f KJ\n output: %.0f KJ at %.2f KW\n",
429  (PowerPack::global_dissipated / (sim_time / 1e6)) / 1e3 );
430 
431  return std::string( str );
432 }
433 
435 {
436 // int count=0;
437 // FOR_EACH( it, superregions )
438 // printf( "sr %d [%d,%d] %p\n", count++, it->first.x, it->first.y, it->second );
439 // printf( "done\n" );
440 
441 // unsigned int layer( updates % 2 );
442 
443  FOR_EACH( it, superregions )
444  it->second->DrawOccupancy();
445 
446  // {
447 
448  // it->second->DrawOccupancy(0);
449  // it->second->DrawOccupancy(1);
450 
451  // }
452 }
453 
455 {
456  unsigned int layer( updates % 2 );
457 
458  FOR_EACH( it, superregions )
459  it->second->DrawVoxels( layer );
460 }
461 
462 void WorldGui::windowCb( Fl_Widget* w, WorldGui* wg )
463 {
464  switch ( Fl::event() ) {
465  case FL_SHORTCUT:
466  if ( Fl::event_key() == FL_Escape )
467  return;
468  case FL_CLOSE: // clicked close button
469  bool done = wg->closeWindowQuery();
470  if ( !done )
471  return;
472  }
473 
474  puts( "Stage: User closed window" );
475  exit(0);
476 }
477 
478 void WorldGui::fileLoadCb( Fl_Widget* w, WorldGui* wg )
479 {
480  const char* filename;
481  const char* pattern = "World Files (*.world)";
482 
483  std::string worldsPath = wg->fileMan->worldsRoot();
484  worldsPath.append( "/" );
485  Fl_File_Chooser fc( worldsPath.c_str(), pattern, Fl_File_Chooser::CREATE, "Load World File..." );
486  fc.ok_label( "Load" );
487 
488  fc.show();
489  while (fc.shown())
490  Fl::wait();
491 
492  filename = fc.value();
493 
494  if (filename != NULL) { // chose something
495  if ( FileManager::readable( filename ) ) {
496  // file is readable, clear and load
497 
498  // if (initialized) {
499  wg->Stop();
500  wg->UnLoad();
501  // }
502 
503  // todo: make sure loading is successful
504  wg->Load( filename );
505  wg->Start(); // if (stopped)
506  }
507  else {
508  fl_alert( "Unable to read selected world file." );
509  }
510 
511 
512  }
513 }
514 
515 void WorldGui::fileSaveCb( Fl_Widget* w, WorldGui* wg )
516 {
517  // save to current file
518  const bool success = wg->Save( NULL );
519  if ( !success ) {
520  fl_alert( "Error saving world file." );
521  }
522 }
523 
524 void WorldGui::fileSaveAsCb( Fl_Widget* w, WorldGui* wg )
525 {
526  wg->saveAsDialog();
527 }
528 
529 void WorldGui::fileExitCb( Fl_Widget* w, WorldGui* wg )
530 {
531  const bool done = wg->closeWindowQuery();
532  if (done) {
533  puts( "User exited via menu" );
534  exit(0);
535  }
536 }
537 
538 void WorldGui::resetViewCb( Fl_Widget* w, WorldGui* wg )
539 {
540  wg->canvas->current_camera->reset();
541 
542  if( Fl::event_state( FL_CTRL ) )
543  {
544  wg->canvas->resetCamera();
545  }
546  wg->canvas->redraw();
547 }
548 
549 void WorldGui::slowerCb( Fl_Widget* w, WorldGui* wg )
550 {
551  if( wg->speedup <= 0 )
552  {
553  wg->speedup = 100.0;
554  wg->SetTimeouts();
555  }
556  else
557  wg->speedup *= 0.8;
558 }
559 
560 void WorldGui::fasterCb( Fl_Widget* w, WorldGui* wg )
561 {
562  if( wg->speedup <= 0 )
563  putchar( 7 ); // bell - can go no faster
564  else
565  wg->speedup *= 1.2;
566 }
567 
568 void WorldGui::realtimeCb( Fl_Widget* w, WorldGui* wg )
569 {
570  //puts( "real time" );
571  wg->speedup = 1.0;
572 
573  if( !wg->paused )
574  wg->SetTimeouts();
575 }
576 
577 void WorldGui::fasttimeCb( Fl_Widget* w, WorldGui* wg )
578 {
579  //puts( "fast time" );
580  wg->speedup = -1;
581 
582  if( !wg->paused )
583  wg->SetTimeouts();
584 }
585 
587 {
588  //puts( "redrawing\n" );
589  canvas->redraw();
590 }
591 
593 {
594  World::Start();
595 
596  // start the timer that causes regular redraws
597  Fl::add_timeout( ((double)canvas->interval/1000),
598  (Fl_Timeout_Handler)Canvas::TimerCallback,
599  canvas );
600 
601  SetTimeouts();
602 }
603 
604 
606 {
607  // remove the old callback, wherever it was
608  Fl::remove_idle( (Fl_Timeout_Handler)UpdateCallback, this );
609  Fl::remove_timeout( (Fl_Timeout_Handler)UpdateCallback, this );
610 
611  if( speedup > 0.0 )
612  // attempt some multiple of real time
613  Fl::add_timeout( (sim_interval/1e6) / speedup, (Fl_Timeout_Handler)UpdateCallback, this );
614  else
615  // go as fast as possible
616  Fl::add_idle( (Fl_Timeout_Handler)UpdateCallback, this );
617 }
618 
620 {
621  World::Stop();
622 
623  Fl::remove_timeout( (Fl_Timeout_Handler)Canvas::TimerCallback );
624  Fl::remove_timeout( (Fl_Timeout_Handler)UpdateCallback );
625  Fl::remove_idle( (Fl_Timeout_Handler)UpdateCallback, this );
626 
627  // drawn 'cos we cancelled the timeout
628  canvas->redraw(); // in case something happened that will never be
629  // drawn otherwise
630 }
631 
632 void WorldGui::pauseCb( Fl_Widget* w, WorldGui* wg )
633 {
634  wg->TogglePause();
635 }
636 
637 void WorldGui::onceCb( Fl_Widget* w, WorldGui* wg )
638 {
639  //wg->paused = true;
640  wg->Stop();
641 
642  // run exactly once
643  wg->World::Update();
644 }
645 
647 {
648  // sort the vector by option label alphabetically
649  //std::sort();// wg->option_table.begin(), wg->option_table.end() );//, sort_option_pointer );
650  //std::sort();// wg->option_table.begin(), wg->option_table.end() );//, sort_option_pointer );
651 
652  if ( !wg->oDlg )
653  {
654  int x = wg->w()+wg->x() + 10;
655  int y = wg->y();
656  OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
657  oDlg->callback( (Fl_Callback*)optionsDlgCb, wg );
658 
659  oDlg->setOptions( wg->option_table );
660  oDlg->showAllOpt( &wg->canvas->visualizeAll );
661  wg->oDlg = oDlg;
662  oDlg->show();
663  }
664  else
665  {
666  wg->oDlg->hide();
667  delete wg->oDlg;
668  wg->oDlg = NULL;
669  }
670 
671 }
672 
674 {
675  // get event from dialog
676  OptionsDlg::event_t event = oDlg->event();
677 
678  // Check FLTK events first
679  switch ( Fl::event() ) {
680  case FL_SHORTCUT:
681  if ( Fl::event_key() != FL_Escape )
682  break; //return
683  // otherwise, ESC pressed-> do as below
684  case FL_CLOSE: // clicked close button
685  // override event to close
686  event = OptionsDlg::CLOSE;
687  break;
688  }
689 
690  switch ( event ) {
691  case OptionsDlg::CHANGE:
692  {
693  //Option* o = oDlg->changed();
694  //printf( "\"%s\" changed to %d!\n", o->name().c_str(), o->val() );
695  break;
696  }
697  case OptionsDlg::CLOSE:
698  // invalidate the oDlg pointer from the Wg
699  // instance before the dialog is destroyed
700  wg->oDlg = NULL;
701  oDlg->hide();
702  Fl::delete_widget( oDlg );
703  return;
706  break;
707  }
708 }
709 
710 void aboutOKBtnCb( Fl_Return_Button* btn, void* p )
711 {
712  btn->window()->do_callback();
713 }
714 
715 void aboutCloseCb( Fl_Window* win, Fl_Text_Display* textDisplay )
716 {
717  Fl_Text_Buffer* tbuf = textDisplay->buffer();
718  textDisplay->buffer( NULL );
719  delete tbuf;
720  Fl::delete_widget( win );
721 }
722 
723 void WorldGui::helpAboutCb( Fl_Widget* w, WorldGui* wg )
724 {
725  const int Width = 420;
726  const int Height = 330;
727  const int Spc = 10;
728  const int ButtonH = 25;
729  const int ButtonW = 60;
730  const int pngH = 82;
731  //const int pngW = 264;
732 
733  Fl_Window* win = new Fl_Window( Width, Height ); // make a window
734 
735  Fl_Box* box = new Fl_Box( Spc, Spc,
736  Width-2*Spc, pngH ); // widget that will contain image
737 
738  std::string fullpath = FileManager::findFile( "assets/stagelogo.png" );
739 
740  box->image( new Fl_PNG_Image( fullpath.c_str() )); // load image and attach image to box
741 
742  Fl_Text_Display* textDisplay =
743  new Fl_Text_Display( Spc, pngH+2*Spc,
744  Width-2*Spc, Height-pngH-ButtonH-4*Spc );
745 
746  textDisplay->box( FL_NO_BOX );
747  textDisplay->color( win->color() );
748  win->callback( (Fl_Callback*)aboutCloseCb, textDisplay );
749 
750  Fl_Text_Buffer* tbuf = new Fl_Text_Buffer;
751  tbuf->text( PROJECT );
752  tbuf->append( "-" );
753  tbuf->append( VERSION );
754  tbuf->append( AboutText );
755  //textDisplay->wrap_mode( true, 50 );
756  textDisplay->buffer( tbuf );
757 
758  Fl_Return_Button* button =
759  new Fl_Return_Button( (Width - ButtonW)/2, Height-Spc-ButtonH,
760  ButtonW, ButtonH,
761  "&OK" );
762  button->callback( (Fl_Callback*)aboutOKBtnCb );
763 
764  win->show();
765 }
766 
767 void WorldGui::moreHelptCb( Fl_Widget* w, WorldGui* wg )
768 {
769  const int Width = 500;
770  const int Height = 250;
771  const int Spc = 10;
772 
773  Fl_Window* win = new Fl_Window( Width, Height ); // make a window
774  win->label( "Getting help with Stage" );
775 
776  Fl_Text_Display* textDisplay =
777  new Fl_Text_Display( Spc, Spc,
778  Width-2*Spc, Height-2*Spc );
779 
780  win->resizable( textDisplay );
781  textDisplay->box( FL_NO_BOX );
782  textDisplay->color( win->color() );
783 
784  Fl_Text_Buffer* tbuf = new Fl_Text_Buffer();
785  tbuf->append( MoreHelpText );
786  // textDisplay->wrap_mode( true, 50 );
787  textDisplay->buffer( tbuf );
788 
789  win->show();
790 }
791 
792 
794 {
795  const char* newFilename;
796  bool success = false;
797  const char* pattern = "World Files (*.world)";
798 
799  Fl_File_Chooser fc( wf->filename.c_str(), pattern, Fl_File_Chooser::CREATE, "Save File As..." );
800  fc.ok_label( "Save" );
801 
802  fc.show();
803  while (fc.shown())
804  Fl::wait();
805 
806  newFilename = fc.value();
807 
808  if (newFilename != NULL) {
809  // todo: make sure file ends in .world
810  success = Save( newFilename );
811  if ( !success ) {
812  fl_alert( "Error saving world file." );
813  }
814  }
815 
816  return success;
817 }
818 
820 {
821  int choice;
822 
823  if ( wf ) {
824  // worldfile loaded, ask to save
825  choice = fl_choice("Quitting Stage",
826  "&Cancel", // ->0: defaults to ESC
827  "&Save, then quit", // ->1
828  "&Quit without saving" // ->2
829  );
830 
831  switch (choice) {
832  case 1: // Save before quitting
833  if ( saveAsDialog() )
834  return true;
835  else
836  return false;
837 
838  case 2: // Quit without saving
839  return true;
840  }
841 
842  // Cancel
843  return false;
844  }
845  else {
846  // nothing is loaded, just quit
847  return true;
848  }
849 }
850 
852 {
854  (*it)->DrawBoundingBoxTree();
855 }
856 
858 { canvas->PushColor( col ); }
859 
860 void WorldGui::PushColor( double r, double g, double b, double a )
861 { canvas->PushColor( r,g,b,a ); }
862 
864 { canvas->PopColor(); }
865 
867 { return canvas->last_selection; }
868 
870 {
871  struct timeval tv;
872  gettimeofday( &tv, NULL ); // slow system call: use sparingly
873  return( tv.tv_sec*1000000 + tv.tv_usec );
874 }
875 
877 { return canvas->IsTopView(); }
void aboutOKBtnCb(Fl_Return_Button *btn, void *p)
Definition: worldgui.cc:710
double speedup
Definition: stage.hh:1514
void setOptions(const std::set< Option * > &opts)
Definition: options_dlg.cc:71
static void windowCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:462
Model class
Definition: stage.hh:1742
static bool readable(const std::string &path)
Determine whether a file can be opened for reading.
Definition: file_manager.cc:68
static void moreHelptCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:767
virtual void Start()
Definition: stage.hh:923
static void UpdateCallback(WorldGui *world)
Definition: worldgui.cc:349
static void viewOptionsCb(OptionsDlg *oDlg, WorldGui *wg)
Definition: worldgui.cc:646
Canvas * canvas
Definition: stage.hh:1507
void Show()
Definition: worldgui.cc:251
virtual void Start()
Definition: worldgui.cc:592
virtual void UnLoad()
Definition: world.cc:488
static joules_t global_input
Definition: stage.hh:1687
uint64_t updates
the number of simulated time steps executed so far
Definition: stage.hh:912
int LookupEntity(const char *type)
Definition: worldfile.cc:1225
The Stage library uses its own namespace.
Definition: canvas.hh:8
virtual void AddModel(Model *mod)
Definition: worldgui.cc:405
virtual void Stop()
Definition: stage.hh:924
static joules_t global_capacity
Definition: stage.hh:1685
std::set< Option * > option_table
GUI options (toggles) registered by models.
Definition: stage.hh:902
virtual void RemoveChild(Model *mod)
Definition: worldgui.cc:414
void showAllOpt(Option *opt)
Definition: options_dlg.cc:78
std::string token
Definition: stage.hh:696
void DrawOccupancy() const
Definition: worldgui.cc:434
static void fileSaveAsCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:524
static const char * AboutText
Definition: worldgui.cc:159
static joules_t global_stored
Definition: stage.hh:1684
usec_t sim_interval
Definition: stage.hh:1087
const event_t event() const
Definition: options_dlg.hh:47
int ReadTuple(const int entity, const char *name, const unsigned int first, const unsigned int num, const char *format,...)
Definition: worldfile.cc:1506
static void slowerCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:549
void createMenuItems(Fl_Menu_Bar *menu, std::string path)
Definition: canvas.cc:1188
Model * last_selection
Definition: canvas.hh:67
OptionsDlg * oDlg
Definition: stage.hh:1517
uint64_t timing_interval
Definition: stage.hh:1532
bool saveAsDialog()
Definition: worldgui.cc:793
FileManager * fileMan
Used to load and save worldfiles.
Definition: stage.hh:1509
void aboutCloseCb(Fl_Window *win, Fl_Text_Display *textDisplay)
Definition: worldgui.cc:715
static void fileLoadCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:478
static void optionsDlgCb(OptionsDlg *oDlg, WorldGui *wg)
Definition: worldgui.cc:673
virtual void Redraw(void)
Definition: worldgui.cc:586
Option visualizeAll
Definition: canvas.hh:81
virtual void RemoveChild(Model *mod)
Definition: ancestor.cc:35
void newWorld(const std::string &worldfile)
Update the worldfile path.
Definition: file_manager.hh:20
void resetCamera()
Definition: canvas.cc:734
void PushColor(Color col)
Definition: canvas.hh:138
static void fileExitCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:529
void SetTimeouts()
Definition: worldgui.cc:605
virtual void Load(const std::string &filename)
Definition: worldgui.cc:256
Camera * current_camera
Definition: canvas.hh:56
void WriteInt(int entity, const char *name, int value)
Definition: worldfile.cc:1409
void WriteTuple(const int entity, const char *name, const unsigned int first, const unsigned int count, const char *format,...)
Definition: worldfile.cc:1573
static void fasttimeCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:577
static void resetViewCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:538
static void pauseCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:632
static unsigned int trail_length
Definition: stage.hh:1990
usec_t sim_time
the current sim time in this world in microseconds
Definition: stage.hh:907
virtual void AddModel(Model *mod)
Definition: world.cc:284
virtual bool Update(void)
Definition: world.cc:624
virtual void TogglePause()
Definition: stage.hh:925
std::string filename
Definition: worldfile.hh:350
static void realtimeCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:568
std::map< point_int_t, SuperRegion * > superregions
Definition: stage.hh:908
void DrawVoxels() const
Definition: worldgui.cc:454
virtual void reset()=0
std::string EnergyString(void) const
Definition: worldgui.cc:421
uint64_t usec_t
Definition: stage.hh:186
void RemoveModel(Model *mod)
Definition: canvas.cc:612
void WriteFloat(int entity, const char *name, double value)
Definition: worldfile.cc:1418
bool WarnUnused()
Definition: worldfile.cc:224
virtual Model * RecentlySelectedModel() const
Definition: worldgui.cc:866
WorldGui(int W, int H, const char *L=0)
Definition: worldgui.cc:187
Worldfile * wf
If set, points to the worldfile used to create this world.
Definition: stage.hh:913
static void helpAboutCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:723
Fl_Menu_Bar * mbar
Definition: stage.hh:1516
virtual void Stop()
Definition: worldgui.cc:619
static std::string findFile(const std::string &filename)
Definition: file_manager.cc:36
std::vector< Model * > children
Definition: stage.hh:689
virtual bool Update()
Definition: worldgui.cc:354
bool paused
if true, the simulation is stopped
Definition: stage.hh:921
virtual void PopColor()
Definition: worldgui.cc:863
static const char * MoreHelpText
Definition: worldgui.cc:172
virtual void PushColor(Color col)
Definition: worldgui.cc:857
static void onceCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:637
bool closeWindowQuery()
Definition: worldgui.cc:819
void AddModel(Model *mod)
Definition: canvas.cc:606
#define PRINT_DEBUG1(m, a)
Definition: stage.hh:667
double ReadFloat(int entity, const char *name, double value)
Definition: worldfile.cc:1434
usec_t real_time_recorded
Definition: stage.hh:1529
void PopColor()
Definition: canvas.hh:144
bool debug
Definition: stage.hh:691
void Save(Worldfile *wf, int section)
Definition: canvas.cc:1250
usec_t RealTimeNow(void) const
Definition: worldgui.cc:869
usec_t real_time_interval
Definition: stage.hh:1522
void DrawBoundingBoxTree()
Definition: worldgui.cc:851
void Load(Worldfile *wf, int section)
Definition: canvas.cc:1212
int ReadInt(int entity, const char *name, int value)
Definition: worldfile.cc:1398
std::set< ModelPosition * > active_velocity
Definition: stage.hh:1081
#define FOR_EACH(I, C)
Definition: stage.hh:616
static void fileSaveCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:515
virtual bool Save(const char *filename)
Definition: world.cc:1002
static uint64_t trail_interval
Definition: stage.hh:1993
bool IsTopView()
Definition: worldgui.cc:876
msec_t interval
(even if it is now unselected).
Definition: canvas.hh:70
static joules_t global_dissipated
Definition: stage.hh:1686
static void fasterCb(Fl_Widget *w, WorldGui *wg)
Definition: worldgui.cc:560
const std::string worldsRoot() const
Return the path where the current worldfile was loaded from.
Definition: file_manager.hh:18
virtual std::string ClockString(void) const
Definition: world.cc:511
virtual std::string ClockString() const
Definition: worldgui.cc:387
bool IsTopView()
Definition: canvas.hh:159
virtual bool Save(const char *filename)
Definition: worldgui.cc:319
static void TimerCallback(Canvas *canvas)
Definition: canvas.cc:42
virtual void Load(const std::string &worldfile_path)
Definition: world.cc:388
virtual void UnLoad()
Definition: worldgui.cc:314
Model * parent
Definition: stage.hh:1912
usec_t quit_time
Definition: stage.hh:905


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:10