GUIApplicationWindow.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The main window of the SUMO-gui.
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #ifdef HAVE_VERSION_H
00031 #include <version.h>
00032 #endif
00033 
00034 #include <fx.h>
00035 #include <fx3d.h>
00036 #include <string>
00037 #include <sstream>
00038 #include <algorithm>
00039 
00040 #include <guisim/GUINet.h>
00041 
00042 #include "GUISUMOViewParent.h"
00043 #include "GUILoadThread.h"
00044 #include "GUIRunThread.h"
00045 #include "GUIApplicationWindow.h"
00046 #include "GUIEvent_SimulationLoaded.h"
00047 #include "GUIEvent_SimulationEnded.h"
00048 
00049 #include <utils/common/ToString.h>
00050 #include <utils/foxtools/MFXUtils.h>
00051 #include <utils/foxtools/FXLCDLabel.h>
00052 #include <utils/foxtools/FXRealSpinDial.h>
00053 #include <utils/foxtools/FXThreadEvent.h>
00054 
00055 #include <utils/gui/windows/GUIAppEnum.h>
00056 #include <utils/gui/events/GUIEvent_SimulationStep.h>
00057 #include <utils/gui/events/GUIEvent_Message.h>
00058 #include <utils/gui/div/GUIMessageWindow.h>
00059 #include <utils/gui/div/GUIDialog_GLChosenEditor.h>
00060 #include "GUIGlobals.h"
00061 #include <utils/gui/tracker/GUIParameterTracker.h>
00062 #include <utils/gui/div/GUIParameterTableWindow.h>
00063 #include <utils/gui/images/GUIIconSubSys.h>
00064 #include <utils/gui/images/GUITexturesHelper.h>
00065 #include "dialogs/GUIDialog_AboutSUMO.h"
00066 #include "dialogs/GUIDialog_AppSettings.h"
00067 #include "dialogs/GUIDialog_Breakpoints.h"
00068 #include <utils/gui/div/GUIIOGlobals.h>
00069 #include <utils/gui/settings/GUICompleteSchemeStorage.h>
00070 #include <utils/gui/globjects/GUIGlObjectStorage.h>
00071 #include <utils/gui/div/GUIGlobalSelection.h>
00072 #include <utils/gui/settings/GUISettingsHandler.h>
00073 #include <guisim/GUISelectionLoader.h>
00074 
00075 #ifdef CHECK_MEMORY_LEAKS
00076 #include <foreign/nvwa/debug_new.h>
00077 #endif
00078 
00079 
00080 // ===========================================================================
00081 // FOX-declarations
00082 // ===========================================================================
00083 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]= {
00084     //________Message_Type____________ID________________________Message_Handler________
00085     FXMAPFUNC(SEL_COMMAND,  MID_QUIT,        GUIApplicationWindow::onCmdQuit),
00086     FXMAPFUNC(SEL_SIGNAL,   MID_QUIT,        GUIApplicationWindow::onCmdQuit),
00087     FXMAPFUNC(SEL_CLOSE,    MID_WINDOW,      GUIApplicationWindow::onCmdQuit),
00088 
00089     FXMAPFUNC(SEL_COMMAND,  MID_OPEN_CONFIG,       GUIApplicationWindow::onCmdOpenConfiguration),
00090     FXMAPFUNC(SEL_COMMAND,  MID_OPEN_NETWORK,      GUIApplicationWindow::onCmdOpenNetwork),
00091     FXMAPFUNC(SEL_COMMAND,  MID_RECENTFILE,        GUIApplicationWindow::onCmdOpenRecent),
00092     FXMAPFUNC(SEL_COMMAND,  MID_RELOAD,            GUIApplicationWindow::onCmdReload),
00093     FXMAPFUNC(SEL_COMMAND,  MID_CLOSE,             GUIApplicationWindow::onCmdClose),
00094     FXMAPFUNC(SEL_COMMAND,  MID_EDITCHOSEN,        GUIApplicationWindow::onCmdEditChosen),
00095     FXMAPFUNC(SEL_COMMAND,  MID_EDIT_BREAKPOINTS,  GUIApplicationWindow::onCmdEditBreakpoints),
00096 
00097     FXMAPFUNC(SEL_COMMAND,  MID_APPSETTINGS,        GUIApplicationWindow::onCmdAppSettings),
00098     FXMAPFUNC(SEL_COMMAND,  MID_GAMING,             GUIApplicationWindow::onCmdGaming),
00099     FXMAPFUNC(SEL_COMMAND,  MID_ABOUT,              GUIApplicationWindow::onCmdAbout),
00100     FXMAPFUNC(SEL_COMMAND,  MID_NEW_MICROVIEW,      GUIApplicationWindow::onCmdNewView),
00101     FXMAPFUNC(SEL_COMMAND,  MID_START,              GUIApplicationWindow::onCmdStart),
00102     FXMAPFUNC(SEL_COMMAND,  MID_STOP,               GUIApplicationWindow::onCmdStop),
00103     FXMAPFUNC(SEL_COMMAND,  MID_STEP,               GUIApplicationWindow::onCmdStep),
00104     FXMAPFUNC(SEL_COMMAND,  MID_CLEARMESSAGEWINDOW, GUIApplicationWindow::onCmdClearMsgWindow),
00105 
00106     FXMAPFUNC(SEL_UPDATE,   MID_OPEN_CONFIG,       GUIApplicationWindow::onUpdOpen),
00107     FXMAPFUNC(SEL_UPDATE,   MID_OPEN_NETWORK,      GUIApplicationWindow::onUpdOpen),
00108     FXMAPFUNC(SEL_UPDATE,   MID_RELOAD,            GUIApplicationWindow::onUpdReload),
00109     FXMAPFUNC(SEL_UPDATE,   MID_RECENTFILE,        GUIApplicationWindow::onUpdOpenRecent),
00110     FXMAPFUNC(SEL_UPDATE,   MID_NEW_MICROVIEW,     GUIApplicationWindow::onUpdAddMicro),
00111     FXMAPFUNC(SEL_UPDATE,   MID_START,             GUIApplicationWindow::onUpdStart),
00112     FXMAPFUNC(SEL_UPDATE,   MID_STOP,              GUIApplicationWindow::onUpdStop),
00113     FXMAPFUNC(SEL_UPDATE,   MID_STEP,              GUIApplicationWindow::onUpdStep),
00114     FXMAPFUNC(SEL_UPDATE,   MID_EDITCHOSEN,        GUIApplicationWindow::onUpdEditChosen),
00115     FXMAPFUNC(SEL_UPDATE,   MID_EDIT_BREAKPOINTS,  GUIApplicationWindow::onUpdEditBreakpoints),
00116 
00117     FXMAPFUNC(FXEX::SEL_THREAD_EVENT, ID_LOADTHREAD_EVENT, GUIApplicationWindow::onLoadThreadEvent),
00118     FXMAPFUNC(FXEX::SEL_THREAD_EVENT, ID_RUNTHREAD_EVENT,  GUIApplicationWindow::onRunThreadEvent),
00119     FXMAPFUNC(FXEX::SEL_THREAD, ID_LOADTHREAD_EVENT,       GUIApplicationWindow::onLoadThreadEvent),
00120     FXMAPFUNC(FXEX::SEL_THREAD, ID_RUNTHREAD_EVENT,        GUIApplicationWindow::onRunThreadEvent),
00121 };
00122 
00123 // Object implementation
00124 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
00125 
00126 // ===========================================================================
00127 // member method definitions
00128 // ===========================================================================
00129 GUIApplicationWindow::GUIApplicationWindow(FXApp* a,
00130         const std::string &configPattern)
00131         : GUIMainWindow(a),
00132         myLoadThread(0), myRunThread(0),
00133         myAmLoading(false),
00134         mySimDelay(50), myConfigPattern(configPattern), hadDependentBuild(false), myRecentNets(a, "nets") {
00135     GUIIconSubSys::init(a);
00136 }
00137 
00138 
00139 void
00140 GUIApplicationWindow::dependentBuild(bool game) {
00141     // do this not twice
00142     if (hadDependentBuild) {
00143         return;
00144     }
00145     hadDependentBuild = true;
00146 
00147     setTarget(this);
00148     setSelector(MID_WINDOW);
00149     GUITexturesHelper::init(getApp());
00150 
00151     // build menu bar
00152     myMenuBarDrag=new FXToolBarShell(this,FRAME_NORMAL);
00153     myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
00154                               LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
00155     new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
00156                       TOOLBARGRIP_DOUBLE);
00157     buildToolBars();
00158     // build the thread - io
00159     myLoadThreadEvent.setTarget(this),
00160     myLoadThreadEvent.setSelector(ID_LOADTHREAD_EVENT);
00161     myRunThreadEvent.setTarget(this),
00162     myRunThreadEvent.setSelector(ID_RUNTHREAD_EVENT);
00163 
00164     // build the status bar
00165     myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED);
00166     {
00167         myGeoFrame =
00168             new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y|LAYOUT_RIGHT|FRAME_SUNKEN,
00169                                   0,0,20,0, 0,0,0,0, 0,0);
00170         myGeoCoordinate = new FXLabel(myGeoFrame, "N/A", 0, LAYOUT_CENTER_Y);
00171         myCartesianFrame =
00172             new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y|LAYOUT_RIGHT|FRAME_SUNKEN,
00173                                   0,0,20,0, 0,0,0,0, 0,0);
00174         myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A", 0, LAYOUT_CENTER_Y);
00175     }
00176 
00177     // make the window a mdi-window
00178     myMainSplitter = new FXSplitter(this,
00179                                     SPLITTER_REVERSED|SPLITTER_VERTICAL|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_TRACKING|FRAME_RAISED|FRAME_THICK);
00180     myMDIClient = new FXMDIClient(myMainSplitter,
00181                                   LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK);
00182     myMDIMenu = new FXMDIMenu(this,myMDIClient);
00183     new FXMDIWindowButton(myMenuBar,myMDIMenu,myMDIClient,
00184                           FXMDIClient::ID_MDI_MENUWINDOW,LAYOUT_LEFT);
00185     new FXMDIDeleteButton(myMenuBar,myMDIClient,
00186                           FXMDIClient::ID_MDI_MENUCLOSE,FRAME_RAISED|LAYOUT_RIGHT);
00187     new FXMDIRestoreButton(myMenuBar,myMDIClient,
00188                            FXMDIClient::ID_MDI_MENURESTORE,FRAME_RAISED|LAYOUT_RIGHT);
00189     new FXMDIMinimizeButton(myMenuBar,myMDIClient,
00190                             FXMDIClient::ID_MDI_MENUMINIMIZE,FRAME_RAISED|LAYOUT_RIGHT);
00191 
00192     // build the message window
00193     myMessageWindow = new GUIMessageWindow(myMainSplitter);
00194     // fill menu and tool bar
00195     fillMenuBar();
00196     if (game) {
00197         onCmdGaming(0,0,0);
00198         myMenuBar->hide();
00199         myTopDock->hide();
00200     }
00201     // build additional threads
00202     myLoadThread = new GUILoadThread(this, myEvents, myLoadThreadEvent);
00203     myRunThread = new GUIRunThread(this, *mySimDelayTarget, myEvents,
00204                                    myRunThreadEvent);
00205     // set the status bar
00206     myStatusbar->getStatusLine()->setText("Ready.");
00207     // set the caption
00208     setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
00209 
00210     // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
00211     myRunThread->start();
00212     setIcon(GUIIconSubSys::getIcon(ICON_APP));
00213 }
00214 
00215 
00216 void
00217 GUIApplicationWindow::create() {
00218     if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0)==0) {
00219         setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
00220         setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
00221         setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
00222         setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
00223     }
00224     gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
00225     FXMainWindow::create();
00226     myMenuBarDrag->create();
00227     myToolBarDrag1->create();
00228     myToolBarDrag2->create();
00229     myFileMenu->create();
00230     myEditMenu->create();
00231     mySettingsMenu->create();
00232     myWindowsMenu->create();
00233     myHelpMenu->create();
00234 
00235     FXint width = getApp()->getNormalFont()->getTextWidth("8", 1)*22;
00236     myCartesianFrame->setWidth(width);
00237     myGeoFrame->setWidth(width);
00238 
00239     show(PLACEMENT_SCREEN);
00240     if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0)==1) {
00241         maximize();
00242     }
00243 }
00244 
00245 
00246 GUIApplicationWindow::~GUIApplicationWindow() {
00247     myRunThread->prepareDestruction();
00248     myRunThread->join();
00249     closeAllWindows();
00250     //
00251     GUIIconSubSys::close();
00252     GUITexturesHelper::close();
00253     delete myGLVisual;
00254     // delete some non-parented windows
00255     delete myToolBarDrag1;
00256     //
00257     delete myRunThread;
00258     delete myFileMenu;
00259     delete myEditMenu;
00260     delete mySettingsMenu;
00261     delete myWindowsMenu;
00262     delete myHelpMenu;
00263 
00264     delete myLoadThread;
00265 
00266     while (!myEvents.empty()) {
00267         // get the next event
00268         GUIEvent *e = static_cast<GUIEvent*>(myEvents.top());
00269         myEvents.pop();
00270         delete e;
00271     }
00272 }
00273 
00274 
00275 void
00276 GUIApplicationWindow::detach() {
00277     FXMainWindow::detach();
00278     myMenuBarDrag->detach();
00279     myToolBarDrag1->detach();
00280 }
00281 
00282 
00283 void
00284 GUIApplicationWindow::fillMenuBar() {
00285     // build file menu
00286     myFileMenu = new FXMenuPane(this);
00287     new FXMenuTitle(myMenuBar,"&File",NULL,myFileMenu);
00288     new FXMenuCommand(myFileMenu,
00289                       "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
00290                       GUIIconSubSys::getIcon(ICON_OPEN_CONFIG),this,MID_OPEN_CONFIG);
00291     new FXMenuCommand(myFileMenu,
00292                       "Open &Network...\tCtl-N\tOpen a network.",
00293                       GUIIconSubSys::getIcon(ICON_OPEN_NET),this,MID_OPEN_NETWORK);
00294     new FXMenuCommand(myFileMenu,
00295                       "&Reload\tCtl-R\tReloads the simulation / the network.",
00296                       GUIIconSubSys::getIcon(ICON_RELOAD),this,MID_RELOAD);
00297     new FXMenuSeparator(myFileMenu);
00298     new FXMenuCommand(myFileMenu,
00299                       "&Close\tCtl-C\tClose the simulation.",
00300                       GUIIconSubSys::getIcon(ICON_CLOSE),this,MID_CLOSE);
00301     // Recent files
00302     FXMenuSeparator* sep1=new FXMenuSeparator(myFileMenu);
00303     sep1->setTarget(&myRecentConfigs);
00304     sep1->setSelector(FXRecentFiles::ID_ANYFILES);
00305     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_1);
00306     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_2);
00307     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_3);
00308     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_4);
00309     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_5);
00310     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_6);
00311     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_7);
00312     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_8);
00313     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_9);
00314     new FXMenuCommand(myFileMenu,"",0,&myRecentConfigs,FXRecentFiles::ID_FILE_10);
00315     new FXMenuCommand(myFileMenu,"C&lear Recent Configurations",NULL,&myRecentConfigs,FXRecentFiles::ID_CLEAR);
00316     myRecentConfigs.setTarget(this);
00317     myRecentConfigs.setSelector(MID_RECENTFILE);
00318     FXMenuSeparator* sep2=new FXMenuSeparator(myFileMenu);
00319     sep2->setTarget(&myRecentNets);
00320     sep2->setSelector(FXRecentFiles::ID_ANYFILES);
00321     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_1);
00322     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_2);
00323     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_3);
00324     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_4);
00325     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_5);
00326     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_6);
00327     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_7);
00328     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_8);
00329     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_9);
00330     new FXMenuCommand(myFileMenu,"",0,&myRecentNets,FXRecentFiles::ID_FILE_10);
00331     new FXMenuCommand(myFileMenu,"Cl&ear Recent Networks",NULL,&myRecentNets,FXRecentFiles::ID_CLEAR);
00332     myRecentNets.setTarget(this);
00333     myRecentNets.setSelector(MID_RECENTFILE);
00334     new FXMenuSeparator(myFileMenu);
00335     new FXMenuCommand(myFileMenu,
00336                       "&Quit\tCtl-Q\tQuit the Application.",
00337                       0, this, MID_QUIT, 0);
00338 
00339     // build edit menu
00340     myEditMenu = new FXMenuPane(this);
00341     new FXMenuTitle(myMenuBar,"&Edit",NULL,myEditMenu);
00342     new FXMenuCommand(myEditMenu,
00343                       "Edit Chosen...\t\tOpens a Dialog for editing the List of chosen Items.",
00344                       GUIIconSubSys::getIcon(ICON_FLAG), this, MID_EDITCHOSEN);
00345     new FXMenuSeparator(myEditMenu);
00346     new FXMenuCommand(myEditMenu,
00347                       "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
00348                       0, this, MID_EDIT_BREAKPOINTS);
00349 
00350     // build settings menu
00351     mySettingsMenu = new FXMenuPane(this);
00352     new FXMenuTitle(myMenuBar,"&Settings",NULL,mySettingsMenu);
00353     new FXMenuCommand(mySettingsMenu,
00354                       "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
00355                       NULL,this,MID_APPSETTINGS);
00356     new FXMenuCheck(mySettingsMenu,
00357                     "Gaming Mode\t\tToggle gaming mode on/off.",
00358                     this,MID_GAMING);
00359 
00360     // build windows menu
00361     myWindowsMenu = new FXMenuPane(this);
00362     new FXMenuTitle(myMenuBar,"&Windows",NULL,myWindowsMenu);
00363     new FXMenuCheck(myWindowsMenu,
00364                     "Show Status Line\t\tToggle this Status Bar on/off.",
00365                     myStatusbar,FXWindow::ID_TOGGLESHOWN);
00366     new FXMenuCheck(myWindowsMenu,
00367                     "Show Message Window\t\tToggle the Message Window on/off.",
00368                     myMessageWindow,FXWindow::ID_TOGGLESHOWN);
00369     new FXMenuCheck(myWindowsMenu,
00370                     "Show Simulation Time\t\tToggle the Simulation Time on/off.",
00371                     myToolBar3, FXWindow::ID_TOGGLESHOWN);
00372     new FXMenuCheck(myWindowsMenu,
00373                     "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
00374                     myToolBar4, FXWindow::ID_TOGGLESHOWN);
00375     addToWindowsMenu(myWindowsMenu);
00376     new FXMenuSeparator(myWindowsMenu);
00377     new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
00378                       GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
00379                       myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
00380     new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
00381                       GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
00382                       myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
00383     new FXMenuCommand(myWindowsMenu,"C&ascade",
00384                       GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
00385                       myMDIClient,FXMDIClient::ID_MDI_CASCADE);
00386     new FXMenuCommand(myWindowsMenu,"&Close",NULL,
00387                       myMDIClient,FXMDIClient::ID_MDI_CLOSE);
00388     sep1=new FXMenuSeparator(myWindowsMenu);
00389     sep1->setTarget(myMDIClient);
00390     sep1->setSelector(FXMDIClient::ID_MDI_ANY);
00391     new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
00392     new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
00393     new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
00394     new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
00395     new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
00396     new FXMenuSeparator(myWindowsMenu);
00397     new FXMenuCommand(myWindowsMenu,
00398                       "Clear Message Window\t\tClear the message window.",
00399                       0, this, MID_CLEARMESSAGEWINDOW);
00400 
00401     // build help menu
00402     myHelpMenu = new FXMenuPane(this);
00403     new FXMenuTitle(myMenuBar,"&Help",NULL,myHelpMenu);
00404     new FXMenuCommand(myHelpMenu,"&About", GUIIconSubSys::getIcon(ICON_APP),
00405                       this, MID_ABOUT);
00406 }
00407 
00408 
00409 void
00410 GUIApplicationWindow::buildToolBars() {
00411     // build tool bars
00412     {
00413         // file and simulation tool bar
00414         myToolBarDrag1=new FXToolBarShell(this,FRAME_NORMAL);
00415         myToolBar1 = new FXToolBar(myTopDock,myToolBarDrag1,
00416                                    LAYOUT_DOCK_NEXT|LAYOUT_SIDE_TOP|FRAME_RAISED);
00417         new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
00418                           TOOLBARGRIP_DOUBLE);
00419         // build file tools
00420         new FXButton(myToolBar1,"\t\tOpen a simulation (Configuration file).",
00421                      GUIIconSubSys::getIcon(ICON_OPEN_CONFIG), this, MID_OPEN_CONFIG,
00422                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00423         new FXButton(myToolBar1,"\t\tOpen a network.",
00424                      GUIIconSubSys::getIcon(ICON_OPEN_NET), this, MID_OPEN_NETWORK,
00425                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00426         new FXButton(myToolBar1,"\t\tReloads the simulation / the network.",
00427                      GUIIconSubSys::getIcon(ICON_RELOAD), this, MID_RELOAD,
00428                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00429     }
00430     {
00431         // build simulation tools
00432         myToolBarDrag2=new FXToolBarShell(this,FRAME_NORMAL);
00433         myToolBar2 = new FXToolBar(myTopDock,myToolBarDrag2,
00434                                    LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|FRAME_RAISED);
00435         new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
00436                           TOOLBARGRIP_DOUBLE);
00437         new FXButton(myToolBar2,"\t\tStart the loaded simulation.",
00438                      GUIIconSubSys::getIcon(ICON_START), this, MID_START,
00439                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00440         new FXButton(myToolBar2,"\t\tStop the running simulation.",
00441                      GUIIconSubSys::getIcon(ICON_STOP), this, MID_STOP,
00442                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00443         new FXButton(myToolBar2,"\t\tPerform a single simulation step.",
00444                      GUIIconSubSys::getIcon(ICON_STEP), this, MID_STEP,
00445                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00446     }
00447     {
00448         // Simulation Step Display
00449         myToolBarDrag3=new FXToolBarShell(this,FRAME_NORMAL);
00450         myToolBar3 = new FXToolBar(myTopDock,myToolBarDrag3,
00451                                    LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|FRAME_RAISED);
00452         new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
00453                           TOOLBARGRIP_DOUBLE);
00454         new FXLabel(myToolBar3, "Next Step:", 0, LAYOUT_CENTER_Y);
00455         myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 6, 0, 0,
00456                                           FXEX::LCDLABEL_LEADING_ZEROS);
00457         myLCDLabel->setHorizontal(2);
00458         myLCDLabel->setVertical(6);
00459         myLCDLabel->setThickness(2);
00460         myLCDLabel->setGroove(2);
00461         myLCDLabel->setText("-----------");
00462     }
00463     {
00464         // Simulation Delay
00465         myToolBarDrag4=new FXToolBarShell(this,FRAME_NORMAL);
00466         myToolBar4 = new FXToolBar(myTopDock,myToolBarDrag4,
00467                                    LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|FRAME_RAISED|LAYOUT_FILL_Y);
00468         new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
00469                           TOOLBARGRIP_DOUBLE);
00470         new FXLabel(myToolBar4, "Delay (ms):", 0, LAYOUT_CENTER_Y);
00471         mySimDelayTarget =
00472             new FXRealSpinDial(myToolBar4, 7, 0, MID_SIMDELAY,
00473                                LAYOUT_TOP|FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_Y);
00474         mySimDelayTarget->setNumberFormat(0);
00475         mySimDelayTarget->setIncrements(1,10,10);
00476         mySimDelayTarget->setRange(0,1000);
00477         mySimDelayTarget->setValue(0);
00478     }
00479     {
00480         // Views
00481         myToolBarDrag5=new FXToolBarShell(this,FRAME_NORMAL);
00482         myToolBar5 = new FXToolBar(myTopDock,myToolBarDrag5,
00483                                    LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|FRAME_RAISED);
00484         new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
00485                           TOOLBARGRIP_DOUBLE);
00486         // build view tools
00487         new FXButton(myToolBar5,"\t\tOpen a new microscopic view.",
00488                      GUIIconSubSys::getIcon(ICON_MICROVIEW), this, MID_NEW_MICROVIEW,
00489                      ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00490     }
00491 }
00492 
00493 
00494 long
00495 GUIApplicationWindow::onCmdQuit(FXObject*,FXSelector,void*) {
00496     getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
00497     getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
00498     getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
00499     getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
00500     getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
00501     if (isMaximized()) {
00502         getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
00503     } else {
00504         getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
00505     }
00506     getApp()->exit(0);
00507     return 1;
00508 }
00509 
00510 
00511 long
00512 GUIApplicationWindow::onCmdEditChosen(FXObject*,FXSelector,void*) {
00513     GUIDialog_GLChosenEditor *chooser =
00514         new GUIDialog_GLChosenEditor(this, &gSelected);
00515     chooser->create();
00516     chooser->show();
00517     return 1;
00518 }
00519 
00520 
00521 long
00522 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*,FXSelector,void*) {
00523     GUIDialog_Breakpoints *chooser =
00524         new GUIDialog_Breakpoints(this);
00525     chooser->create();
00526     chooser->show();
00527     return 1;
00528 }
00529 
00530 
00531 long
00532 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*,FXSelector,void*) {
00533     // get the new file name
00534     FXFileDialog opendialog(this,"Open Simulation Configuration");
00535     opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
00536     opendialog.setSelectMode(SELECTFILE_EXISTING);
00537     opendialog.setPatternList(myConfigPattern.c_str());
00538     if (gCurrentFolder.length()!=0) {
00539         opendialog.setDirectory(gCurrentFolder);
00540     }
00541     if (opendialog.execute()) {
00542         gCurrentFolder = opendialog.getDirectory();
00543         std::string file = opendialog.getFilename().text();
00544         load(file, false);
00545         myRecentConfigs.appendFile(file.c_str());
00546     }
00547     return 1;
00548 }
00549 
00550 
00551 long
00552 GUIApplicationWindow::onCmdOpenNetwork(FXObject*,FXSelector,void*) {
00553     // get the new file name
00554     FXFileDialog opendialog(this,"Open Network");
00555     opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
00556     opendialog.setSelectMode(SELECTFILE_EXISTING);
00557     opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
00558     if (gCurrentFolder.length()!=0) {
00559         opendialog.setDirectory(gCurrentFolder);
00560     }
00561     if (opendialog.execute()) {
00562         gCurrentFolder = opendialog.getDirectory();
00563         std::string file = opendialog.getFilename().text();
00564         load(file, true);
00565         myRecentNets.appendFile(file.c_str());
00566     }
00567     return 1;
00568 }
00569 
00570 
00571 long
00572 GUIApplicationWindow::onCmdReload(FXObject*,FXSelector,void*) {
00573     load("", false, true);
00574     return 1;
00575 }
00576 
00577 
00578 long
00579 GUIApplicationWindow::onCmdOpenRecent(FXObject*sender,FXSelector,void *data) {
00580     if (myAmLoading) {
00581         myStatusbar->getStatusLine()->setText("Already loading!");
00582         return 1;
00583     }
00584     std::string file((const char*)data);
00585     load(file, sender == &myRecentNets);
00586     return 1;
00587 }
00588 
00589 
00590 long
00591 GUIApplicationWindow::onCmdClose(FXObject*,FXSelector,void*) {
00592     closeAllWindows();
00593     return 1;
00594 }
00595 
00596 
00597 long
00598 GUIApplicationWindow::onUpdOpen(FXObject*sender,FXSelector,void*ptr) {
00599     sender->handle(this,
00600                    myAmLoading?FXSEL(SEL_COMMAND,ID_DISABLE):FXSEL(SEL_COMMAND,ID_ENABLE),
00601                    ptr);
00602     return 1;
00603 }
00604 
00605 
00606 long
00607 GUIApplicationWindow::onUpdReload(FXObject*sender,FXSelector,void*ptr) {
00608     sender->handle(this,
00609                    myAmLoading||myLoadThread->getFileName()==""
00610                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00611                    ptr);
00612     return 1;
00613 }
00614 
00615 
00616 long
00617 GUIApplicationWindow::onUpdOpenRecent(FXObject*sender,FXSelector,void*ptr) {
00618     sender->handle(this,
00619                    myAmLoading?FXSEL(SEL_COMMAND,ID_DISABLE):FXSEL(SEL_COMMAND,ID_ENABLE),
00620                    ptr);
00621     return 1;
00622 }
00623 
00624 
00625 long
00626 GUIApplicationWindow::onUpdAddMicro(FXObject*sender,FXSelector,void*ptr) {
00627     sender->handle(this,
00628                    myAmLoading||!myRunThread->simulationAvailable()
00629                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00630                    ptr);
00631     return 1;
00632 }
00633 
00634 
00635 long
00636 GUIApplicationWindow::onCmdStart(FXObject*,FXSelector,void*) {
00637     // check whether a net was loaded successfully
00638     if (!myRunThread->simulationAvailable()) {
00639         myStatusbar->getStatusLine()->setText("No simulation loaded!");
00640         return 1;
00641     }
00642     // check whether it was started before and paused;
00643     if (!myWasStarted) {
00644         myRunThread->begin();
00645         myWasStarted = true;
00646     }
00647     myRunThread->resume();
00648     return 1;
00649 }
00650 
00651 
00652 long
00653 GUIApplicationWindow::onCmdStop(FXObject*,FXSelector,void*) {
00654     myRunThread->stop();
00655     return 1;
00656 }
00657 
00658 
00659 long
00660 GUIApplicationWindow::onCmdStep(FXObject*,FXSelector,void*) {
00661     // check whether a net was loaded successfully
00662     if (!myRunThread->simulationAvailable()) {
00663         myStatusbar->getStatusLine()->setText("No simulation loaded!");
00664         return 1;
00665     }
00666     // check whether it was started before and paused;
00667     if (!myWasStarted) {
00668         myRunThread->begin();
00669         myWasStarted = true;
00670     }
00671     myRunThread->singleStep();
00672     return 1;
00673 }
00674 
00675 
00676 long
00677 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*,FXSelector,void*) {
00678     myMessageWindow->clear();
00679     return 1;
00680 }
00681 
00682 
00683 long
00684 GUIApplicationWindow::onUpdStart(FXObject*sender,FXSelector,void*ptr) {
00685     sender->handle(this,
00686                    !myRunThread->simulationIsStartable()||myAmLoading
00687                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00688                    ptr);
00689     return 1;
00690 }
00691 
00692 
00693 long
00694 GUIApplicationWindow::onUpdStop(FXObject*sender,FXSelector,void*ptr) {
00695     sender->handle(this,
00696                    !myRunThread->simulationIsStopable()||myAmLoading
00697                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00698                    ptr);
00699     return 1;
00700 }
00701 
00702 
00703 long
00704 GUIApplicationWindow::onUpdStep(FXObject*sender,FXSelector,void*ptr) {
00705     sender->handle(this,
00706                    !myRunThread->simulationIsStepable()||myAmLoading
00707                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00708                    ptr);
00709     return 1;
00710 }
00711 
00712 
00713 long
00714 GUIApplicationWindow::onUpdEditChosen(FXObject*sender,FXSelector,void*ptr) {
00715     sender->handle(this,
00716                    !myRunThread->simulationAvailable()||myAmLoading
00717                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00718                    ptr);
00719     return 1;
00720 }
00721 
00722 
00723 long
00724 GUIApplicationWindow::onUpdEditBreakpoints(FXObject *sender,FXSelector,void *ptr) {
00725     sender->handle(this,
00726                    !myRunThread->simulationAvailable()||myAmLoading
00727                    ? FXSEL(SEL_COMMAND,ID_DISABLE) : FXSEL(SEL_COMMAND,ID_ENABLE),
00728                    ptr);
00729     return 1;
00730 }
00731 
00732 
00733 long
00734 GUIApplicationWindow::onCmdAppSettings(FXObject*,FXSelector,void*) {
00735     GUIDialog_AppSettings *d = new GUIDialog_AppSettings(this);
00736     d->create();
00737     d->show(PLACEMENT_OWNER);
00738     return 1;
00739 }
00740 
00741 
00742 long
00743 GUIApplicationWindow::onCmdGaming(FXObject*,FXSelector,void*) {
00744     myAmGaming = !myAmGaming;
00745     if (myAmGaming) {
00746         mySimDelayTarget->setValue(1000);
00747     }
00748     return 1;
00749 }
00750 
00751 
00752 long
00753 GUIApplicationWindow::onCmdNewView(FXObject*,FXSelector,void*) {
00754     openNewView();
00755     return 1;
00756 }
00757 
00758 
00759 long
00760 GUIApplicationWindow::onCmdAbout(FXObject*,FXSelector,void*) {
00761     GUIDialog_AboutSUMO *about =
00762         new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
00763     about->create();
00764     about->show(PLACEMENT_OWNER);
00765     return 1;
00766 }
00767 
00768 
00769 long
00770 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
00771     eventOccured();
00772     return 1;
00773 }
00774 
00775 
00776 long
00777 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
00778     eventOccured();
00779     return 1;
00780 }
00781 
00782 
00783 void
00784 GUIApplicationWindow::eventOccured() {
00785     while (!myEvents.empty()) {
00786         // get the next event
00787         GUIEvent *e = static_cast<GUIEvent*>(myEvents.top());
00788         myEvents.pop();
00789         // process
00790         switch (e->getOwnType()) {
00791         case EVENT_SIMULATION_LOADED:
00792             handleEvent_SimulationLoaded(e);
00793             break;
00794         case EVENT_SIMULATION_STEP:
00795             handleEvent_SimulationStep(e);
00796             break;
00797         case EVENT_MESSAGE_OCCURED:
00798         case EVENT_WARNING_OCCURED:
00799         case EVENT_ERROR_OCCURED:
00800             handleEvent_Message(e);
00801             break;
00802         case EVENT_SIMULATION_ENDED:
00803             handleEvent_SimulationEnded(e);
00804             break;
00805         default:
00806             break;
00807         }
00808         delete e;
00809     }
00810     myToolBar2->forceRefresh();
00811     myToolBar3->forceRefresh();
00812 }
00813 
00814 
00815 void
00816 GUIApplicationWindow::handleEvent_SimulationLoaded(GUIEvent *e) {
00817     GUITexturesHelper::init(getApp());
00818     myAmLoading = false;
00819     GUIEvent_SimulationLoaded *ec = static_cast<GUIEvent_SimulationLoaded*>(e);
00820     // check whether the loading was successfull
00821     if (ec->myNet==0) {
00822         // report failure
00823         setStatusBarText("Loading of '" + ec->myFile + "' failed!");
00824         if (gQuitOnEnd) {
00825             closeAllWindows();
00826             getApp()->exit(1);
00827         }
00828     } else {
00829         // report success
00830         setStatusBarText("'" + ec->myFile + "' loaded.");
00831         // initialise simulation thread
00832         myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd);
00833         myWasStarted = false;
00834         // initialise views
00835         myViewNumber = 0;
00836         GUISUMOAbstractView* view = openNewView();
00837         if (view && ec->mySettingsFile != "") {
00838             GUISettingsHandler settings(ec->mySettingsFile);
00839             std::string settingsName = settings.addSettings(view);
00840             view->addDecals(settings.getDecals());
00841             settings.setViewport(view);
00842             settings.setSnapshots(view);
00843             if (settings.getDelay() > 0) {
00844                 mySimDelayTarget->setValue(settings.getDelay());
00845             }
00846         }
00847         // set simulation name on the caption
00848         std::string caption = "SUMO " + std::string(VERSION_STRING);
00849         setTitle(MFXUtils::getTitleText(caption.c_str(), ec->myFile.c_str()));
00850         // set simulation step begin information
00851         std::string t = time2string(ec->myNet->getCurrentTimeStep());
00852         myLCDLabel->setText(t.substr(0, t.length()-3).c_str());
00853     }
00854     getApp()->endWaitCursor();
00855     // start if wished
00856     if (myRunAtBegin&&ec->myNet!=0&&myRunThread->simulationIsStartable()) {
00857         onCmdStart(0, 0, 0);
00858     }
00859     update();
00860 }
00861 
00862 
00863 void
00864 GUIApplicationWindow::handleEvent_SimulationStep(GUIEvent *) {
00865     updateChildren();
00866     std::string t = time2string(myRunThread->getNet().getCurrentTimeStep());
00867     myLCDLabel->setText(t.substr(0, t.length()-3).c_str());
00868     update();
00869 }
00870 
00871 
00872 void
00873 GUIApplicationWindow::handleEvent_Message(GUIEvent *e) {
00874     GUIEvent_Message *ec = static_cast<GUIEvent_Message*>(e);
00875     myMessageWindow->appendText(ec->getOwnType(), ec->getMsg());
00876 }
00877 
00878 
00879 void
00880 GUIApplicationWindow::handleEvent_SimulationEnded(GUIEvent *e) {
00881     GUIEvent_SimulationEnded *ec = static_cast<GUIEvent_SimulationEnded*>(e);
00882     if (!gQuitOnEnd) {
00883         // build the text
00884         std::stringstream text;
00885         text << "The simulation has ended at time step " << ec->getTimeStep() << ".\n";
00886         MSNet::SimulationState state = ec->getReason();
00887         text << "Reason: " << MSNet::getStateMessage(state);
00888         onCmdStop(0, 0, 0);
00889         FXMessageBox::warning(this, MBOX_OK, "Simulation Ended", text.str().c_str());
00890     } else {
00891         onCmdStop(0, 0, 0);
00892     }
00893     if (gQuitOnEnd) {
00894         closeAllWindows();
00895         getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
00896     }
00897 }
00898 
00899 
00900 
00901 void
00902 GUIApplicationWindow::load(const std::string &file, bool isNet, bool isReload) {
00903     getApp()->beginWaitCursor();
00904     myAmLoading = true;
00905     closeAllWindows();
00906     if (isReload) {
00907         myLoadThread->start();
00908         setStatusBarText("Reloading.");
00909     } else {
00910         gSchemeStorage.saveViewport(0, 0, 100);
00911         myLoadThread->load(file, isNet);
00912         setStatusBarText("Loading '" + file + "'.");
00913     }
00914     update();
00915 }
00916 
00917 
00918 
00919 GUISUMOAbstractView*
00920 GUIApplicationWindow::openNewView() {
00921     if (!myRunThread->simulationAvailable()) {
00922         myStatusbar->getStatusLine()->setText("No simulation loaded!");
00923         return 0;
00924     }
00925     std::string caption = "View #" + toString(myViewNumber++);
00926     FXuint opts = MDI_TRACKING;
00927     GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient,
00928             myMDIMenu, FXString(caption.c_str()),
00929             this, GUIIconSubSys::getIcon(ICON_APP),
00930             opts, 10, 10, 300, 200);
00931     GUISUMOAbstractView* v = w->init(getBuildGLCanvas(), myRunThread->getNet());
00932     w->create();
00933     if (myMDIClient->numChildren()==1) {
00934         w->maximize();
00935     } else {
00936         myMDIClient->vertical(true);
00937     }
00938     myMDIClient->setActiveChild(w);
00939     return v;
00940 }
00941 
00942 
00943 FXGLCanvas *
00944 GUIApplicationWindow::getBuildGLCanvas() const {
00945     if (myMDIClient->numChildren()==0) {
00946         return 0;
00947     }
00948     GUISUMOViewParent *share_tmp1 =
00949         static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
00950     return share_tmp1->getBuildGLCanvas();
00951 }
00952 
00953 
00954 void
00955 GUIApplicationWindow::closeAllWindows() {
00956     myTrackerLock.lock();
00957     myLCDLabel->setText("-----------");
00958     // remove trackers and other external windows
00959     size_t i;
00960     for (i=0; i<mySubWindows.size(); ++i) {
00961         mySubWindows[i]->destroy();
00962     }
00963     for (i=0; i<myTrackerWindows.size(); ++i) {
00964         myTrackerWindows[i]->destroy();
00965     }
00966     // delete the simulation
00967     myRunThread->deleteSim();
00968     // reset the caption
00969     setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
00970     // delete other children
00971     while (myTrackerWindows.size()!=0) {
00972         delete myTrackerWindows[0];
00973     }
00974     while (mySubWindows.size()!=0) {
00975         delete mySubWindows[0];
00976     }
00977     mySubWindows.clear();
00978     // clear selected items
00979     gSelected.clear();
00980     // add a separator to the log
00981     myMessageWindow->addSeparator();
00982     myTrackerLock.unlock();
00983     // remove coordinate information
00984     myGeoCoordinate->setText("N/A");
00985     myCartesianCoordinate->setText("N/A");
00986     //
00987     update();
00988 }
00989 
00990 
00991 FXCursor *
00992 GUIApplicationWindow::getDefaultCursor() {
00993     return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
00994 }
00995 
00996 
00997 SUMOTime
00998 GUIApplicationWindow::getCurrentSimTime() const {
00999     return myRunThread->getNet().getCurrentTimeStep();
01000 }
01001 
01002 
01003 void
01004 GUIApplicationWindow::loadOnStartup(const std::string &config, bool run) {
01005     myRunAtBegin = run;
01006     load(config, false);
01007 }
01008 /*
01009 long
01010 GUIApplicationWindow::onCmdCutSwell(FXObject*, FXSelector, void*)
01011 {
01012     /
01013     GUIDialog_CutSwell *about =
01014         new GUIDialog_CutSwell(this, "Simulating...", 0, 0);
01015     about->create();
01016     about->show(PLACEMENT_OWNER);
01017     /
01018     std::string prev = myStatusbar->getStatusLine()->getText().text();
01019     std::string text = std::string("Computing strategies.");
01020     myStatusbar->getStatusLine()->setText(text.c_str());
01021     myStatusbar->getStatusLine()->setNormalText(text.c_str());
01022     for(int i=0; i<100; ++i) {
01023         fxsleep(3000);
01024         myProgressBar->setProgress(i);
01025     }
01026 //    delete about;
01027     myProgressBar->setProgress(0);
01028     myStatusbar->getStatusLine()->setText(prev.c_str());
01029     myStatusbar->getStatusLine()->setNormalText(prev.c_str());
01030     return 1;
01031 }
01032 */
01033 
01034 
01035 void
01036 GUIApplicationWindow::setStatusBarText(const std::string &text) {
01037     myStatusbar->getStatusLine()->setText(text.c_str());
01038     myStatusbar->getStatusLine()->setNormalText(text.c_str());
01039 }
01040 
01041 
01042 bool
01043 GUIApplicationWindow::loadSelection(const std::string &file, std::string &msg) throw() {
01044     return GUISelectionLoader::loadSelection(file, msg);
01045 }
01046 
01047 
01048 /****************************************************************************/
01049 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6