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