SUMO - Simulation of Urban MObility
GUIApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The main window of the SUMO-gui.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #ifdef HAVE_VERSION_H
35 #include <version.h>
36 #endif
37 
38 #include <string>
39 #include <sstream>
40 #include <algorithm>
41 #include <iomanip>
42 
43 #include <guisim/GUINet.h>
44 #include <guisim/GUILane.h>
45 #include <netload/NLHandler.h>
46 #include <microsim/MSGlobals.h>
47 #include <microsim/MSEdge.h>
48 #include <microsim/MSVehicle.h>
50 #include <microsim/MSEdgeControl.h>
53 
54 #include "GUISUMOViewParent.h"
55 #include "GUILoadThread.h"
56 #include "GUIRunThread.h"
57 #include "GUIApplicationWindow.h"
60 #include "GUIEvent_Screenshot.h"
61 
62 #include <utils/common/ToString.h>
69 
70 #include <utils/xml/XMLSubSys.h>
90 #include "GUIGlobals.h"
94 
95 
96 //#define HAVE_DANGEROUS_SOUNDS
97 
98 // ===========================================================================
99 // FOX-declarations
100 // ===========================================================================
101 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
102  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
103  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
104  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
105 
109  FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
110  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
111  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
112  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
114  FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
115 
117  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
118  FXMAPFUNC(SEL_COMMAND, MID_FULLSCREEN, GUIApplicationWindow::onCmdFullScreen),
122  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
123  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
124 #ifdef HAVE_OSG
125  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
126 #endif
127  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
128  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
129  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
133 
137 
138  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
139  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
140  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
141  FXMAPFUNC(SEL_UPDATE, MID_OPEN_SHAPES, GUIApplicationWindow::onUpdReload),
142  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
145 #ifdef HAVE_OSG
146  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
147 #endif
148  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
149  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
150  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
154  FXMAPFUNC(SEL_COMMAND, MID_HELP, GUIApplicationWindow::onCmdHelp),
155 
156  // forward requests to the active view
157  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
158  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
159  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
160  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
161  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
162  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
163  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
164  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
173  FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
174  FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
175 
176  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
177 
182 };
183 
184 // Object implementation
185 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
186 
187 // ===========================================================================
188 // static members
189 // ===========================================================================
190 std::mt19937 GUIApplicationWindow::myGamingRNG;
191 
192 // ===========================================================================
193 // member method definitions
194 // ===========================================================================
195 GUIApplicationWindow::GUIApplicationWindow(FXApp* a, const std::string& configPattern) :
196  GUIMainWindow(a),
197  myLoadThread(0), myRunThread(0),
198  myAmLoading(false),
199  myAlternateSimDelay(0),
200  myRecentNets(a, "nets"),
201  myConfigPattern(configPattern),
202  hadDependentBuild(false),
203  myShowTimeAsHMS(false),
204  myAmFullScreen(false),
205  myHaveNotifiedAboutSimEnd(false),
206  // game specific
207  myJamSoundTime(60),
208  myPreviousCollisionNumber(0),
209  myWaitingTime(0),
210  myTimeLoss(0) {
212 }
213 
214 
215 void
217  // don't do this twice
218  if (hadDependentBuild) {
219  return;
220  }
221  hadDependentBuild = true;
222 
223  setTarget(this);
224  setSelector(MID_WINDOW);
225 
226  // build menu bar
227  myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBarShell3);
228  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignBar);
229  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
230  buildToolBars();
231  // build the thread - io
234 
235  // build the status bar
236  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
237  {
238  myGeoFrame = new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
239  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
241  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
244  myStatButtons.back()->hide();
245  myStatButtons.push_back(new FXButton(myStatusbar, "-", GUIIconSubSys::getIcon(ICON_GREENEDGE), this, MID_SHOWVEHSTATS));
246  myStatButtons.back()->hide();
247  }
248 
249  // make the window a mdi-window
250  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
251  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
252  myMDIMenu = new FXMDIMenu(this, myMDIClient);
253  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
254  new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
255  new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
256  new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
257 
258  // build the message window
260  // fill menu and tool bar
261  fillMenuBar();
262  myToolBar6->hide();
263  myToolBar7->hide();
264  // build additional threads
265  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
267  // set the status bar
268  myStatusbar->getStatusLine()->setText("Ready.");
269  // set the caption
270  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
271 
272  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
273  myRunThread->start();
275 }
276 
277 
278 void
281  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
282  FXMainWindow::create();
283  myMenuBarDrag->create();
284  myToolBarDrag1->create();
285  myToolBarDrag2->create();
286  myToolBarDrag3->create();
287  myToolBarDrag4->create();
288  myToolBarDrag5->create();
289  myToolBarDrag6->create();
290  myToolBarDrag7->create();
291  myFileMenu->create();
292  mySelectByPermissions->create();
293  myEditMenu->create();
294  mySettingsMenu->create();
295  myLocatorMenu->create();
296  myControlMenu->create();
297  myWindowsMenu->create();
298  myHelpMenu->create();
299 
300  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
301  myCartesianFrame->setWidth(width);
302  myGeoFrame->setWidth(width);
303 
304  show(PLACEMENT_DEFAULT);
305  if (!OptionsCont::getOptions().isSet("window-size")) {
306  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
307  maximize();
308  }
309  }
310  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
311  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
312 }
313 
314 
317  myRunThread->join();
318  closeAllWindows();
319  //
321  delete myGLVisual;
322  // delete some non-parented windows
323  delete myToolBarDrag1;
324  //
325  delete myRunThread;
326  delete myFileMenu;
327  delete myEditMenu;
328  delete mySelectByPermissions;
329  delete mySettingsMenu;
330  delete myLocatorMenu;
331  delete myControlMenu;
332  delete myWindowsMenu;
333  delete myHelpMenu;
334 
335  delete myLoadThread;
336 
337  while (!myEvents.empty()) {
338  // get the next event
339  GUIEvent* e = myEvents.top();
340  myEvents.pop();
341  delete e;
342  }
343 }
344 
345 
346 void
348  FXMainWindow::detach();
349  myMenuBarDrag->detach();
350  myToolBarDrag1->detach();
351 }
352 
353 
354 void
356  // build file menu
357  myFileMenu = new FXMenuPane(this);
358  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
359  new FXMenuCommand(myFileMenu,
360  "&Open Simulation...\tCtrl+O\tOpen a simulation (Configuration file).",
362  new FXMenuCommand(myFileMenu,
363  "Open &Network...\tCtrl+N\tOpen a network.",
365  new FXMenuCommand(myFileMenu,
366  "Open Shapes \tCtrl+P\tLoad POIs and Polygons for visualization.",
368  new FXMenuCommand(myFileMenu,
369  "&Reload\tCtrl+R\tReloads the simulation / the network.",
371  new FXMenuSeparator(myFileMenu);
372  new FXMenuCommand(myFileMenu,
373  "Close\tCtrl+W\tClose the simulation.",
375  // Recent files
376  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
377  sep1->setTarget(&myRecentConfigs);
378  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
379  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
380  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
381  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
382  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
383  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
384  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
385  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
386  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
387  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
388  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
389  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
390  myRecentConfigs.setTarget(this);
391  myRecentConfigs.setSelector(MID_RECENTFILE);
392  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
393  sep2->setTarget(&myRecentNets);
394  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
395  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
396  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
397  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
398  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
399  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
400  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
401  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
402  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
405  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
406  myRecentNets.setTarget(this);
407  myRecentNets.setSelector(MID_RECENTFILE);
408  new FXMenuSeparator(myFileMenu);
409  new FXMenuCommand(myFileMenu,
410  "&Quit\tCtrl+Q\tQuit the Application.",
411  0, this, MID_QUIT, 0);
412 
413  // build edit menu
414  mySelectByPermissions = new FXMenuPane(this);
415  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
416  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
417  new FXMenuCommand(mySelectByPermissions,
418  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
419  }
420 
421  myEditMenu = new FXMenuPane(this);
422  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
423  new FXMenuCommand(myEditMenu,
424  "Edit Selected...\tCtrl+E\tOpens a dialog for editing the list of selected items.",
426  new FXMenuCascade(myEditMenu,
427  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
429  new FXMenuSeparator(myEditMenu);
430  new FXMenuCommand(myEditMenu,
431  "Edit Breakpoints...\tCtrl+B\tOpens a dialog for editing breakpoints.",
432  0, this, MID_EDIT_BREAKPOINTS);
433  new FXMenuSeparator(myEditMenu);
434  new FXMenuCommand(myEditMenu,
435  "Open in Netedit...\tCtrl+T\tOpens the netedit application with the current network.",
436  0, this, MID_NETEDIT);
437 
438  // build settings menu
439  mySettingsMenu = new FXMenuPane(this);
440  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
441  new FXMenuCommand(mySettingsMenu,
442  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
443  NULL, this, MID_APPSETTINGS);
444  new FXMenuCheck(mySettingsMenu,
445  "Gaming Mode\tCtrl+G\tToggle gaming mode on/off.",
446  this, MID_GAMING);
447  new FXMenuCheck(mySettingsMenu,
448  "Full Screen Mode\tCtrl+F\tToggle full screen mode on/off.",
449  this, MID_FULLSCREEN);
450  // build Locate menu
451  myLocatorMenu = new FXMenuPane(this);
452  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
453  new FXMenuCommand(myLocatorMenu,
454  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
456  new FXMenuCommand(myLocatorMenu,
457  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
459  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
460  new FXMenuCommand(myLocatorMenu,
461  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
463  }
464  new FXMenuCommand(myLocatorMenu,
465  "Locate &Persons\t\tOpen a Dialog for Locating a Person.",
467  new FXMenuCommand(myLocatorMenu,
468  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
470  new FXMenuCommand(myLocatorMenu,
471  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
473  new FXMenuCommand(myLocatorMenu,
474  "Locate P&oI\t\tOpen a Dialog for Locating a Point of Intereset.",
476  new FXMenuCommand(myLocatorMenu,
477  "Locate Po&lygon\t\tOpen a Dialog for Locating a Polygon.",
479  new FXMenuSeparator(myLocatorMenu);
480  new FXMenuCheck(myLocatorMenu,
481  "Show Internal Structures\t\tShow internal junctions and streets in locator dialog.",
482  this, MID_LISTINTERNAL);
483  FXMenuCheck* listParking = new FXMenuCheck(myLocatorMenu,
484  "Show Parking Vehicles\t\tShow parking vehicles in locator dialog.",
485  this, MID_LISTPARKING);
486  listParking->setCheck(myListParking);
487  new FXMenuCheck(myLocatorMenu,
488  "Show vehicles outside the road network\t\tShow vehicles that are teleporting or driving remote-controlled outside the road network in locator dialog.",
489  this, MID_LISTTELEPORTING);
490  // build control menu
491  myControlMenu = new FXMenuPane(this);
492  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
493  new FXMenuCommand(myControlMenu,
494  "Run\tCtrl+A\tStart running the simulation.",
496  new FXMenuCommand(myControlMenu,
497  "Stop\tCtrl+S\tStop running the simulation.",
499  new FXMenuCommand(myControlMenu,
500  "Step\tCtrl+D\tPerform one simulation step.",
502 
503  // build windows menu
504  myWindowsMenu = new FXMenuPane(this);
505  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
506  new FXMenuCheck(myWindowsMenu,
507  "Show Status Line\t\tToggle the Status Bar on/off.",
508  myStatusbar, FXWindow::ID_TOGGLESHOWN);
509  new FXMenuCheck(myWindowsMenu,
510  "Show Message Window\t\tToggle the Message Window on/off.",
511  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
512  new FXMenuCheck(myWindowsMenu,
513  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
514  myToolBar3, FXWindow::ID_TOGGLESHOWN);
515  new FXMenuCheck(myWindowsMenu,
516  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
517  myToolBar4, FXWindow::ID_TOGGLESHOWN);
519  new FXMenuSeparator(myWindowsMenu);
520  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
522  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
523  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
525  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
526  new FXMenuCommand(myWindowsMenu, "Cascade",
528  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
529  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
530  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
531  sep1 = new FXMenuSeparator(myWindowsMenu);
532  sep1->setTarget(myMDIClient);
533  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
534  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
535  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
536  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
537  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
538  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
539  new FXMenuSeparator(myWindowsMenu);
540  new FXMenuCommand(myWindowsMenu,
541  "Clear Message Window\t\tClear the message window.",
542  0, this, MID_CLEARMESSAGEWINDOW);
543 
544  // build help menu
545  myHelpMenu = new FXMenuPane(this);
546  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
547  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
548  new FXMenuCommand(myHelpMenu, "&About", GUIIconSubSys::getIcon(ICON_APP),
549  this, MID_ABOUT);
550 }
551 
552 
553 void
555  // build tool bars
556  {
557  // file and simulation tool bar
558  myToolBarDrag1 = new FXToolBarShell(this, GUIDesignToolBarShell3);
560  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
561  // build file tools
562  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).", GUIIconSubSys::getIcon(ICON_OPEN_CONFIG), this, MID_OPEN_CONFIG, GUIDesignButtonToolbar);
563  new FXButton(myToolBar1, "\t\tOpen a network.", GUIIconSubSys::getIcon(ICON_OPEN_NET), this, MID_OPEN_NETWORK, GUIDesignButtonToolbar);
564  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.", GUIIconSubSys::getIcon(ICON_RELOAD), this, MID_RELOAD, GUIDesignButtonToolbar);
565  }
566  {
567  // simulation toolbar
568  myToolBarDrag2 = new FXToolBarShell(this, GUIDesignToolBarShell3);
570  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
571  // build simulation tools
572  new FXButton(myToolBar2, "\t\tStart the loaded simulation.", GUIIconSubSys::getIcon(ICON_START), this, MID_START, GUIDesignButtonToolbar);
573  new FXButton(myToolBar2, "\t\tStop the running simulation.", GUIIconSubSys::getIcon(ICON_STOP), this, MID_STOP, GUIDesignButtonToolbar);
574  new FXButton(myToolBar2, "\t\tPerform a single simulation step.", GUIIconSubSys::getIcon(ICON_STEP), this, MID_STEP, GUIDesignButtonToolbar);
575  }
576  {
577  // Simulation Step Display
578  myToolBarDrag3 = new FXToolBarShell(this, GUIDesignToolBarShell3);
580  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
581  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE, GUIDesignButtonToolbarText);
582 
583  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 16, 0, 0, JUSTIFY_RIGHT);
587  myLCDLabel->setGroove(2);
588  myLCDLabel->setText("----------------");
589  }
590  {
591  // Simulation Delay
592  myToolBarDrag4 = new FXToolBarShell(this, GUIDesignToolBarShell3);
594  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
595  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE, GUIDesignButtonToolbarText);
596 
599  mySimDelayTarget->setIncrements(1, 10, 10);
600  mySimDelayTarget->setRange(0, 1000);
602  }
603  {
604  // Views
605  myToolBarDrag5 = new FXToolBarShell(this, GUIDesignToolBarShell3);
607  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
608  // build view tools
609  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
611 #ifdef HAVE_OSG
612  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
614 #endif
615  }
616  {
618  // total waitingTime
619  myToolBarDrag6 = new FXToolBarShell(this, GUIDesignToolBarShell3);
621  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
622  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
623  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, 0, 0, JUSTIFY_RIGHT);
628  myWaitingTimeLabel->setText("-------------");
629 
630  // idealistic time loss
631  myToolBarDrag7 = new FXToolBarShell(this, GUIDesignToolBarShell3);
633  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
634  new FXLabel(myToolBar7, "Time Loss:\t\tTime lost due to being unable to drive with maximum speed for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
635  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, 0, 0, JUSTIFY_RIGHT);
640  myTimeLossLabel->setText("-------------");
641  }
642 }
643 
644 
645 long
646 GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
647  if (!myAmFullScreen) {
648  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
649  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
650  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
651  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
652  }
653  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
654  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
655  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
656  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", (int)myAlternateSimDelay);
657  getApp()->exit(0);
658  return 1;
659 }
660 
661 
662 long
663 GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
664  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
665  if (mc->getText() == "Edit Selected...") {
666  GUIDialog_GLChosenEditor* chooser =
668  chooser->create();
669  chooser->show();
670  } else {
672  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
673  for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
674  const std::vector<MSLane*>& lanes = (*i)->getLanes();
675  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
676  GUILane* lane = dynamic_cast<GUILane*>(*it);
677  assert(lane != 0);
678  if ((lane->getPermissions() & svc) != 0) {
679  gSelected.select(lane->getGlID());
680  }
681  }
682  }
683  if (myMDIClient->numChildren() > 0) {
684  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
685  if (w != 0) {
686  // color by selection
688  }
689  }
690  }
691  updateChildren();
692  }
693  return 1;
694 }
695 
696 
697 long
698 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
700  chooser->create();
701  chooser->show();
702  return 1;
703 }
704 
705 
706 long
707 GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
708  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/SUMO-GUI");
709  return 1;
710 }
711 
712 
713 long
714 GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
715  if (mySubWindows.empty()) {
716  return 1;
717  }
718  FXRegistry reg("Netedit", "DLR");
719  reg.read();
720  const GUISUMOAbstractView* const v = static_cast<GUIGlChildWindow*>(mySubWindows[0])->getView();
721  reg.writeRealEntry("viewport", "x", v->getChanger().getXPos());
722  reg.writeRealEntry("viewport", "y", v->getChanger().getYPos());
723  reg.writeRealEntry("viewport", "z", v->getChanger().getZPos());
724  reg.write();
725  std::string netedit = "netedit";
726  const char* sumoPath = getenv("SUMO_HOME");
727  if (sumoPath != 0) {
728  std::string newPath = std::string(sumoPath) + "/bin/netedit";
729  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
730  netedit = "\"" + newPath + "\"";
731  }
732  }
733  std::string cmd = netedit + " --registry-viewport -s " + OptionsCont::getOptions().getString("net-file");
734  // start in background
735 #ifndef WIN32
736  cmd = cmd + " &";
737 #else
738  // see "help start" for the parameters
739  cmd = "start /B \"\" " + cmd;
740 #endif
741  WRITE_MESSAGE("Running " + cmd + ".");
742  // yay! fun with dangerous commands... Never use this over the internet
744  return 1;
745 }
746 
747 
748 long
749 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
750  // get the new file name
751  FXFileDialog opendialog(this, "Open Simulation Configuration");
752  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
753  opendialog.setSelectMode(SELECTFILE_EXISTING);
754  opendialog.setPatternList(myConfigPattern.c_str());
755  if (gCurrentFolder.length() != 0) {
756  opendialog.setDirectory(gCurrentFolder);
757  }
758  if (opendialog.execute()) {
759  gCurrentFolder = opendialog.getDirectory();
760  std::string file = opendialog.getFilename().text();
761  loadConfigOrNet(file, false);
762  myRecentConfigs.appendFile(file.c_str());
763  }
764  return 1;
765 }
766 
767 
768 long
769 GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
770  // get the new file name
771  FXFileDialog opendialog(this, "Open Network");
772  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
773  opendialog.setSelectMode(SELECTFILE_EXISTING);
774  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
775  if (gCurrentFolder.length() != 0) {
776  opendialog.setDirectory(gCurrentFolder);
777  }
778  if (opendialog.execute()) {
779  gCurrentFolder = opendialog.getDirectory();
780  std::string file = opendialog.getFilename().text();
781  loadConfigOrNet(file, true);
782  myRecentNets.appendFile(file.c_str());
783  }
784  return 1;
785 }
786 
787 
788 long
789 GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
790  // get the shape file name
791  FXFileDialog opendialog(this, "Open Shapes");
792  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
793  opendialog.setSelectMode(SELECTFILE_EXISTING);
794  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
795  if (gCurrentFolder.length() != 0) {
796  opendialog.setDirectory(gCurrentFolder);
797  }
798  if (opendialog.execute()) {
799  gCurrentFolder = opendialog.getDirectory();
800  std::string file = opendialog.getFilename().text();
801 
803  if (!XMLSubSys::runParser(handler, file, false)) {
804  WRITE_MESSAGE("Loading of " + file + " failed.");
805  }
806  update();
807  }
808  return 1;
809 }
810 
811 long
812 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
813  getApp()->beginWaitCursor();
814  myAmLoading = true;
815  closeAllWindows();
816  myLoadThread->start();
817  setStatusBarText("Reloading.");
818  update();
819  return 1;
820 }
821 
822 
823 long
824 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
825  if (myAmLoading) {
826  myStatusbar->getStatusLine()->setText("Already loading!");
827  return 1;
828  }
829  std::string file((const char*)data);
830  loadConfigOrNet(file, sender == &myRecentNets);
831  return 1;
832 }
833 
834 
835 long
836 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
837  closeAllWindows();
838  return 1;
839 }
840 
841 
842 long
843 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
844  sender->handle(this,
845  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
846  ptr);
847  return 1;
848 }
849 
850 
851 long
852 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
853  sender->handle(this,
855  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
856  ptr);
857  return 1;
858 }
859 
860 
861 long
862 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
863  sender->handle(this,
864  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
865  ptr);
866  return 1;
867 }
868 
869 
870 long
871 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
872  sender->handle(this,
874  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
875  ptr);
876  return 1;
877 }
878 
879 
880 long
881 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
882  // check whether a net was loaded successfully
884  myStatusbar->getStatusLine()->setText("No simulation loaded!");
885  return 1;
886  }
887  // check whether it was started before and paused;
888  if (!myWasStarted) {
889  myRunThread->begin();
890  myWasStarted = true;
891  }
892  myRunThread->resume();
893  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
894  return 1;
895 }
896 
897 
898 long
899 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
900  myRunThread->stop();
901  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
902  return 1;
903 }
904 
905 
906 long
907 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
908  // check whether a net was loaded successfully
910  myStatusbar->getStatusLine()->setText("No simulation loaded!");
911  return 1;
912  }
913  // check whether it was started before and paused;
914  if (!myWasStarted) {
915  myRunThread->begin();
916  myWasStarted = true;
917  }
919  return 1;
920 }
921 
922 
923 long
924 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
928  }
929  return 1;
930 }
931 
932 
933 long
934 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
935  const SUMOTime tmp = myAlternateSimDelay;
937  mySimDelayTarget->setValue((FXdouble)tmp);
938  return 1;
939 }
940 
941 
942 long
943 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
945  return 1;
946 }
947 
948 
949 long
950 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
951  sender->handle(this,
953  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
954  ptr);
955  return 1;
956 }
957 
958 
959 long
960 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
961  sender->handle(this,
963  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
964  ptr);
965  return 1;
966 }
967 
968 
969 long
970 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
971  sender->handle(this,
973  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
974  ptr);
975  return 1;
976 }
977 
978 
979 long
980 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
981  sender->handle(this,
983  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
984  ptr);
985  return 1;
986 }
987 
988 
989 long
990 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
991  if (myMDIClient->numChildren() > 0) {
992  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
993  if (w != 0) {
994  w->onCmdLocate(0, sel, 0);
995  }
996  }
997  return 1;
998 }
999 
1000 
1001 long
1002 GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1003  if (myMDIClient->numChildren() > 0) {
1004  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1006  }
1007  return 1;
1008 }
1009 
1010 
1011 long
1012 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1014  d->create();
1015  d->show(PLACEMENT_OWNER);
1016  return 1;
1017 }
1018 
1019 
1020 long
1021 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1023  if (myAmGaming) {
1024  myMenuBar->hide();
1025  myStatusbar->hide();
1026  myToolBar1->hide();
1027  myToolBar2->hide();
1028  myToolBar4->hide();
1029  myToolBar5->hide();
1030  myToolBar6->show();
1031  myToolBar7->show();
1032  myMessageWindow->hide();
1036  gSchemeStorage.getDefault().gaming = true;
1037  } else {
1038  myMenuBar->show();
1039  myStatusbar->show();
1040  myToolBar1->show();
1041  myToolBar2->show();
1042  myToolBar4->show();
1043  myToolBar5->show();
1044  myToolBar6->hide();
1045  myToolBar7->hide();
1046  myMessageWindow->show();
1048  gSchemeStorage.getDefault().gaming = false;
1049  }
1050  if (myMDIClient->numChildren() > 0) {
1051  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1052  if (w != 0) {
1054  }
1055  }
1056  update();
1057  return 1;
1058 }
1059 
1060 
1061 long
1062 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1064  if (myAmFullScreen) {
1065  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1066  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1067  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1068  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1069  maximize();
1070  setDecorations(DECOR_NONE);
1071  place(PLACEMENT_MAXIMIZED);
1072  myMenuBar->hide();
1073  myStatusbar->hide();
1074  myToolBar1->hide();
1075  myToolBar2->hide();
1076  myToolBar3->hide();
1077  myToolBar4->hide();
1078  myToolBar5->hide();
1079  myToolBar6->hide();
1080  myToolBar7->hide();
1081  myMessageWindow->hide();
1082  if (myMDIClient->numChildren() > 0) {
1083  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1084  if (w != 0) {
1085  w->setToolBarVisibility(false);
1086  }
1087  }
1088  update();
1089  } else {
1090  place(PLACEMENT_VISIBLE);
1091  setDecorations(DECOR_ALL);
1092  restore();
1093  myToolBar3->show();
1095  onCmdGaming(0, 0, 0);
1096  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1097  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1098  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1099  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1100  }
1101  return 1;
1102 }
1103 
1104 
1105 long
1106 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1108  return 1;
1109 }
1110 
1111 
1112 long
1113 GUIApplicationWindow::onCmdListParking(FXObject*, FXSelector, void*) {
1115  return 1;
1116 }
1117 
1118 long
1119 GUIApplicationWindow::onCmdListTeleporting(FXObject*, FXSelector, void*) {
1121  return 1;
1122 }
1123 
1124 
1125 long
1126 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1128  return 1;
1129 }
1130 
1131 
1132 #ifdef HAVE_OSG
1133 long
1134 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1136  return 1;
1137 }
1138 #endif
1139 
1140 
1141 long
1142 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1143  GUIDialog_AboutSUMO* about = new GUIDialog_AboutSUMO(this);
1144  about->create();
1145  about->show(PLACEMENT_OWNER);
1146  return 1;
1147 }
1148 
1149 
1150 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1151  FXEvent* event = (FXEvent*)ptr;
1152  FXString string = GUIUserIO::clipped.c_str();
1153  setDNDData(FROM_CLIPBOARD, event->target, string);
1154  return 1;
1155 }
1156 
1157 
1158 long
1159 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1160  eventOccured();
1161  return 1;
1162 }
1163 
1164 
1165 long
1166 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1167  eventOccured();
1168  return 1;
1169 }
1170 
1171 
1172 void
1174  while (!myEvents.empty()) {
1175  // get the next event
1176  GUIEvent* e = myEvents.top();
1177  myEvents.pop();
1178  // process
1179  switch (e->getOwnType()) {
1182  break;
1183  case EVENT_SIMULATION_STEP:
1184  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1186  }
1187  break;
1188  case EVENT_MESSAGE_OCCURED:
1189  case EVENT_WARNING_OCCURED:
1190  case EVENT_ERROR_OCCURED:
1191  case EVENT_STATUS_OCCURED:
1193  break;
1196  break;
1197  case EVENT_SCREENSHOT:
1199  break;
1200  default:
1201  break;
1202  }
1203  delete e;
1204  }
1205  myToolBar2->forceRefresh();
1206  myToolBar3->forceRefresh();
1207 }
1208 
1209 
1210 void
1212  myAmLoading = false;
1214  // check whether the loading was successfull
1215  if (ec->myNet == 0) {
1216  // report failure
1217  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1218  if (GUIGlobals::gQuitOnEnd) {
1219  closeAllWindows();
1220  getApp()->exit(1);
1221  }
1222  } else {
1223  if (OptionsCont::getOptions().getBool("game")) {
1224  onCmdGaming(0, 0, 0);
1225  }
1226  // initialise simulation thread
1227  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1228  if (GUIGlobals::gQuitOnEnd) {
1229  closeAllWindows();
1230  getApp()->exit(1);
1231  }
1232  } else {
1233  // report success
1234  setStatusBarText("'" + ec->myFile + "' loaded.");
1235  myWasStarted = false;
1236  myHaveNotifiedAboutSimEnd = false;
1237  // initialise views
1238  myViewNumber = 0;
1240  if (ec->mySettingsFiles.size() > 0) {
1241  // open a view for each file and apply settings
1242  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1243  GUISettingsHandler settings(*it);
1244  GUISUMOViewParent::ViewType vt = defaultType;
1245  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1247  }
1248  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1250  }
1251  GUISUMOAbstractView* view = openNewView(vt);
1252  if (view == 0) {
1253  break;
1254  }
1255  std::string settingsName = settings.addSettings(view);
1256  view->addDecals(settings.getDecals());
1257  settings.applyViewport(view);
1258  settings.setSnapshots(view);
1259  if (settings.getDelay() > 0) {
1260  mySimDelayTarget->setValue(settings.getDelay());
1261  }
1262  if (settings.getBreakpoints().size() > 0) {
1263  myRunThread->getBreakpointLock().lock();
1264  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1265  myRunThread->getBreakpointLock().unlock();
1266  }
1267  myJamSounds = settings.getEventDistribution("jam");
1268  myCollisionSounds = settings.getEventDistribution("collision");
1269  if (settings.getJamSoundTime() > 0) {
1270  myJamSoundTime = settings.getJamSoundTime();
1271  }
1272  }
1273  } else {
1274  openNewView(defaultType);
1275  }
1276 
1277  if (isGaming()) {
1278  setTitle("SUMO Interactive Traffic Light");
1279  } else {
1280  // set simulation name on the caption
1281  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1282  }
1283  // set simulation step begin information
1284  myLCDLabel->setText("----------------");
1285  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1286  (*it)->setText("-");
1287  }
1288  }
1289  }
1290  getApp()->endWaitCursor();
1291  // start if wished
1293  onCmdStart(0, 0, 0);
1294  }
1295  update();
1296 }
1297 
1298 
1299 void
1301  updateChildren();
1303  const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1304  const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1305  if (backlog > running) {
1306  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_GREENVEHICLE)) {
1308  }
1309  } else {
1310  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_YELLOWVEHICLE)) {
1312  }
1313  }
1314  myStatButtons.front()->setText(toString(running).c_str());
1315  if (myRunThread->getNet().hasPersons()) {
1316  if (!myStatButtons[1]->shown()) {
1317  myStatButtons[1]->show();
1318  }
1320  }
1321  if (myRunThread->getNet().hasContainers()) {
1322  if (!myStatButtons[2]->shown()) {
1323  myStatButtons[2]->show();
1324  }
1326  }
1327  if (myAmGaming) {
1329  }
1331  getApp()->forceRefresh(); // restores keyboard focus
1332  }
1333  update();
1334 }
1335 
1336 
1337 void
1339  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1340  if (ec->getOwnType() == EVENT_STATUS_OCCURED) {
1341  setStatusBarText(ec->getMsg());
1342  } else {
1343  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1344  }
1345 }
1346 
1347 
1348 void
1350  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1351  onCmdStop(0, 0, 0);
1352  if (ec->getReason() == MSNet::SIMSTATE_LOADING) {
1353  onCmdReload(0, 0, 0);
1354  } else if (GUIGlobals::gQuitOnEnd) {
1355  closeAllWindows();
1356  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1357  } else if (GUIGlobals::gDemoAutoReload) {
1358  onCmdReload(0, 0, 0);
1359  } else if (!myHaveNotifiedAboutSimEnd) {
1360  // build the text
1361  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1362  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1363  "\nDo you want to close all open files and views?";
1364  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1365  if (answer == 1) { //1:yes, 2:no, 4:esc
1366  closeAllWindows();
1367  }
1369  }
1370 }
1371 
1372 
1373 void
1375  GUIEvent_Screenshot* ec = static_cast<GUIEvent_Screenshot*>(e);
1376  myEventMutex.lock();
1377  const std::string error = ec->myView->makeSnapshot(ec->myFile);
1378  if (error != "") {
1379  WRITE_WARNING(error);
1380  }
1381  myEventCondition.signal();
1382  myEventMutex.unlock();
1383 }
1384 
1385 
1386 void
1391 #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1392  if (myJamSounds.getOverallProb() > 0) {
1393  // play honking sound if some vehicle is waiting too long
1394  for (; it != end; ++it) {
1395  // XXX use impatience instead of waiting time ?
1396  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1397  const std::string cmd = myJamSounds.get(&myGamingRNG);
1398  if (cmd != "") {
1399  // yay! fun with dangerous commands... Never use this over the internet
1401  // one sound per simulation step is enough
1402  break;
1403  }
1404  }
1405  }
1406  }
1407  if (myCollisionSounds.getOverallProb() > 0) {
1408  int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
1409  if (myPreviousCollisionNumber != collisions) {
1410  const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1411  if (cmd != "") {
1412  // yay! fun with dangerous commands... Never use this over the internet
1414  }
1415  myPreviousCollisionNumber = collisions;
1416  }
1417  }
1418 #endif
1419 
1420  // update performance indicators
1421  for (it = vc.loadedVehBegin(); it != end; ++it) {
1422  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1423  assert(veh != 0);
1424  if (veh->isOnRoad()) {
1425  const double vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1426  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1428  }
1429  myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
1430  }
1431  }
1434 }
1435 
1436 
1437 void
1438 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1439  getApp()->beginWaitCursor();
1440  myAmLoading = true;
1441  closeAllWindows();
1442  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1443  myLoadThread->loadConfigOrNet(file, isNet);
1444  setStatusBarText("Loading '" + file + "'.");
1445  update();
1446 }
1447 
1448 
1451  if (!myRunThread->simulationAvailable()) {
1452  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1453  return 0;
1454  }
1455  GUISUMOAbstractView* oldView = 0;
1456  if (myMDIClient->numChildren() > 0) {
1457  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1458  if (w != 0) {
1459  oldView = w->getView();
1460  }
1461  }
1462  std::string caption = "View #" + toString(myViewNumber++);
1463  FXuint opts = MDI_TRACKING;
1464  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1465  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1468  if (oldView != 0) {
1469  // copy viewport
1470  oldView->copyViewportTo(v);
1471  }
1472  w->create();
1473  if (myMDIClient->numChildren() == 1) {
1474  w->maximize();
1475  } else {
1476  myMDIClient->vertical(true);
1477  }
1478  myMDIClient->setActiveChild(w);
1479 
1480  return v;
1481 }
1482 
1483 
1484 FXGLCanvas*
1486  if (myMDIClient->numChildren() == 0) {
1487  return 0;
1488  }
1489  GUISUMOViewParent* share_tmp1 =
1490  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1491  return share_tmp1->getBuildGLCanvas();
1492 }
1493 
1494 
1495 void
1497  myTrackerLock.lock();
1498  myLCDLabel->setText("----------------");
1499  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1500  (*it)->setText("-");
1501  if (it != myStatButtons.begin()) {
1502  (*it)->hide();
1503  }
1504  }
1505  // remove trackers and other external windows
1506  int i;
1507  for (i = 0; i < (int)mySubWindows.size(); ++i) {
1508  mySubWindows[i]->destroy();
1509  }
1510  for (i = 0; i < (int)myTrackerWindows.size(); ++i) {
1511  myTrackerWindows[i]->destroy();
1512  }
1513  // delete the simulation
1515  // reset the caption
1516  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
1517  // delete other children
1518  while (myTrackerWindows.size() != 0) {
1519  delete myTrackerWindows[0];
1520  }
1521  while (mySubWindows.size() != 0) {
1522  delete mySubWindows[0];
1523  }
1524  mySubWindows.clear();
1525  // clear selected items
1526  gSelected.clear();
1527  // add a separator to the log
1530  // remove coordinate information
1531  myGeoCoordinate->setText("N/A");
1532  myCartesianCoordinate->setText("N/A");
1533  //
1535  update();
1536 }
1537 
1538 
1539 FXCursor*
1541  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1542 }
1543 
1544 
1545 SUMOTime
1548 }
1549 
1550 
1551 double
1554 }
1555 
1556 
1557 void
1559  loadConfigOrNet("", false);
1560 }
1561 
1562 
1563 void
1565  myStatusbar->getStatusLine()->setText(text.c_str());
1566 
1567  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1568 }
1569 
1570 
1571 void
1572 GUIApplicationWindow::addRecentFile(const FX::FXString& f, const bool isNet) {
1573  if (isNet) {
1574  myRecentNets.appendFile(f);
1575  } else {
1576  myRecentConfigs.appendFile(f);
1577  }
1578 }
1579 
1580 
1581 void
1583  time -= DELTA_T; // synchronize displayed time with netstate output
1584  if (time < 0) {
1585  myLCDLabel->setText("----------------");
1586  return;
1587  }
1588  if (myAmGaming) {
1589  // show time counting backwards
1590  time = myRunThread->getSimEndTime() - time;
1591  }
1592  std::ostringstream str;
1593  str << std::setfill('0');
1594  const bool hideFraction = myAmGaming || DELTA_T % 1000 == 0;
1595  if (myShowTimeAsHMS) {
1596  SUMOTime day = time / 86400000;
1597  if (day > 0) {
1598  str << day << '-';
1599  time %= 86400000;
1600  }
1601  str << std::setw(2);
1602  str << time / 3600000 << '-';
1603  time %= 3600000;
1604  str << std::setw(2) << time / 60000 << '-';
1605  time %= 60000;
1606  }
1607  str << std::setw(2) << time / 1000;
1608  if (!hideFraction) {
1609  str << '.' << std::setw(3) << time % 1000;
1610  }
1611  myLCDLabel->setText(str.str().c_str());
1612 }
1613 
1614 
1615 long
1616 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1617  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1618  if (handled == 0 && myMDIClient->numChildren() > 0) {
1619  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1620  if (w != 0) {
1621  w->onKeyPress(0, sel, data);
1622  }
1623  }
1624  return 0;
1625 }
1626 
1627 
1628 long
1629 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1630  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1631  if (handled == 0 && myMDIClient->numChildren() > 0) {
1632  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1633  if (w != 0) {
1634  w->onKeyRelease(0, sel, data);
1635  }
1636  }
1637  return 0;
1638 }
1639 
1640 
1641 void
1643  myEventMutex.lock();
1644  myEvents.add(event);
1647  myEventMutex.unlock();
1648 }
1649 
1650 
1651 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
Event sent when the the simulation is over.
RandomDistributor< std::string > myJamSounds
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
long onCmdShowStats(FXObject *, FXSelector, void *)
Called on commands from the statistic buttons.
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
Locate vehicle - button.
Definition: GUIAppEnum.h:177
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
void pop()
Definition: MFXEventQue.h:53
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
static std::string clipped
Definition: GUIUserIO.h:64
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
void handleEvent_SimulationLoaded(GUIEvent *e)
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
Locate person - button.
Definition: GUIAppEnum.h:179
virtual bool simulationIsStepable() const
Open in netedit.
Definition: GUIAppEnum.h:133
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
Show network statistics.
Definition: GUIAppEnum.h:158
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
send when a message occured
Definition: GUIEvent.h:50
bool empty()
Definition: MFXEventQue.h:72
virtual void deleteSim()
FXSplitter * myMainSplitter
The splitter that divides the main window into vies and the log window.
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:54
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
const std::string & getViewType() const
Returns the parsed view type.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
long onCmdListParking(FXObject *, FXSelector, void *)
Toggle listing of parking vehicles.
Show person statistics.
Definition: GUIAppEnum.h:162
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:294
Locate TLS - button.
Definition: GUIAppEnum.h:181
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
Show vehicle statistics.
Definition: GUIAppEnum.h:160
bool gaming
whether the application is in gaming mode or not
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:82
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:322
Gaming mode - menu entry.
Definition: GUIAppEnum.h:143
const bool myOsgView
whether to load the OpenSceneGraph view
void add(T what)
Definition: MFXEventQue.h:59
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
const std::string & getMsg() const
Returns the message.
GUIColorer laneColorer
The lane colorer.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:847
void addRecentFile(const FX::FXString &f, const bool isNet)
FXToolBarShell * myToolBarDrag4
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
bool myListParking
information whether the locator should list parking vehicles
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
virtual void setValue(FXdouble value)
Change current value.
Locate poi - button.
Definition: GUIAppEnum.h:189
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
virtual bool simulationIsStartable() const
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:52
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:263
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
void setToolBarVisibility(const bool value)
about toggled gaming status
int myViewNumber
The current view number.
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call ...
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
Definition: GUIDesigns.h:266
#define GUIDesignSplitter
Definition: GUIDesigns.h:291
Start the simulation.
Definition: GUIAppEnum.h:95
Edit simulation breakpoints.
Definition: GUIAppEnum.h:131
virtual void detach()
Detaches the tool/menu bar.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:169
Editor for the list of chosen objects.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
int getCollisionCount() const
return the number of collisions
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
void setThickness(const FXint width)
set/get segment width - must be less than half the segment length
Definition: FXLCDLabel.cpp:204
FXGLVisual * myGLVisual
The gl-visual used.
#define GUIDesignMDIButtonLeft
Definition: GUIDesigns.h:124
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
FXMutex myEventMutex
the mutex for the waiting semaphore
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
Main window-ID.
Definition: GUIAppEnum.h:53
toogle delay between alternative value
Definition: GUIAppEnum.h:205
long onCmdNetedit(FXObject *, FXSelector, void *)
Called on menu Edit->Netedit.
Stop the simulation.
Definition: GUIAppEnum.h:97
FXString gCurrentFolder
The folder used as last.
void handleEvent_Screenshot(GUIEvent *e)
void saveViewport(const double x, const double y, const double z)
Makes the given viewport the default.
virtual void copyViewportTo(GUISUMOAbstractView *view)
copy the viewport to the given view
void loadConfigOrNet(const std::string &file, bool isNet)
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
#define GUIDesignToolBarShell2
design for first toolbar shell positioned in the same position of dock
Definition: GUIDesigns.h:272
#define TS
Definition: SUMOTime.h:52
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:109
void show()
sets the focus after the window is created
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:81
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:252
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:87
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:110
const SUMOTime myBegin
the time the simulation shall start with
long onCmdNewView(FXObject *, FXSelector, void *)
Called if a new view shall be opened (2D view)
static bool gDemoAutoReload
the simulation shall reload when it has ended (demo)
Definition: GUIGlobals.h:58
bool listParking() const
return whether to list parking vehicles
Definition: GUIMainWindow.h:97
GUIGlID getGlID() const
Returns the numerical id of the object.
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
Open network - ID.
Definition: GUIAppEnum.h:75
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual FXGLCanvas * getBuildGLCanvas() const
bool myListTeleporting
information whether the locator should list teleporting vehicles
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
void addDecals(const std::vector< Decal > &decals)
add decals
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
FXToolBarShell * myToolBarDrag2
void setFgColor(FXColor clr)
set/get forground color
Definition: FXLCDLabel.cpp:127
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
void checkGamingEvents()
handles additional game-related events
FXMenuPane * myFileMenu
the submenus
void addSeparator()
Adds a a separator to this log window.
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:115
Open configuration - ID.
Definition: GUIAppEnum.h:73
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
FXHorizontalFrame * myCartesianFrame
FXRecentFiles myRecentNets
List of recent nets.
const std::vector< std::string > mySettingsFiles
the name of the settings file to load
void loadConfigOrNet(const std::string &file, bool isNet)
begins the loading of the given file
RandomDistributor< std::string > getEventDistribution(const std::string &id)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Editor for simulation breakpoints.
const std::string myFile
the name of the file to save to
Locate addtional structure - button.
Definition: GUIAppEnum.h:187
bool myAmGaming
information whether the gui is currently in gaming mode
bool myShowTimeAsHMS
whether to show time as hour:minute:second
void handleEvent_Message(GUIEvent *e)
std::vector< FXMDIChild * > mySubWindows
static void clearTextures()
clears loaded textures
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:84
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
#define GUIDesignMDIButtonRight
MDIButton oriented to right.
Definition: GUIDesigns.h:127
static const RGBColor GREEN
Definition: RGBColor.h:180
An error occured during the simulation step.
Definition: MSNet.h:106
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Locator configuration - menu entry.
Definition: GUIAppEnum.h:147
void updateTimeLCD(SUMOTime time)
updates the simulation time display
void setRange(FXdouble lo, FXdouble hi)
Change the spinner&#39;s range.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:419
FXCondition myEventCondition
the semaphore when waiting for event completion
double getTrackerInterval() const
void handleEvent_SimulationEnded(GUIEvent *e)
FXdouble getValue() const
Return current value.
bool myHaveNotifiedAboutSimEnd
whether the simulation end was already announced
static double gTrackerInterval
the aggregation period for tracker windows in seconds
Definition: GUIGlobals.h:61
std::string myConfigPattern
Input file pattern.
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
Definition: SysUtils.cpp:71
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:504
std::set< SUMOTime > & getSnapshots()
Definition: GUIRunThread.h:123
std::vector< FXButton * > myStatButtons
Buttons showing and running values and triggering statistic windows.
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:428
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
double getDelay() const
Returns the parsed delay.
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:168
Locate edge - button.
Definition: GUIAppEnum.h:175
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:305
The Simulation delay control.
Definition: GUIAppEnum.h:151
The Simulation execution thread.
Definition: GUIAppEnum.h:119
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:186
FXToolBarShell * myMenuBarDrag
SUMOTime getCurrentSimTime() const
ViewType
Available view types.
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
T MIN2(T a, T b)
Definition: StdDefs.h:68
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
The application&#39;s "About" - dialog.
bool myAmFullScreen
whether to show the window in full screen mode
Locate junction - button.
Definition: GUIAppEnum.h:173
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
const std::string & getFileName() const
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
send when a error occured
Definition: GUIEvent.h:56
Send when a screenshot is requested; View and file name are stored within the event.
Definition: GUIEvent.h:67
#define VERSION_STRING
Definition: version.h:1
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:338
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:492
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
bool myListInternal
information whether the locator should list internal structures
long onCmdOpenShapes(FXObject *, FXSelector, void *)
Called on menu File->Load Shapes.
Clear simulation output.
Definition: GUIAppEnum.h:156
virtual bool simulationIsStopable() const
The dialog to change the application (gui) settings.
Send when the simulation is over; The reason and the time step are stored within the event...
Definition: GUIEvent.h:63
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
std::string makeSnapshot(const std::string &destFile)
Takes a snapshots and writes it into the given file.
FXMenuPane * mySelectByPermissions
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:119
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:120
GUINet & getNet() const
toogle time display mode
Definition: GUIAppEnum.h:203
virtual void fillMenuBar()
Builds the menu bar.
Application settings - menu entry.
Definition: GUIAppEnum.h:141
A single child window which contains a view of the simulation area.
FXEX::FXLCDLabel * myWaitingTimeLabel
performance indicators
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:55
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
#define GUIDesignBar
Definition: GUIDesigns.h:260
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
#define GUIDesignButtonToolbarText
Definition: GUIDesigns.h:79
FXGLCanvas * getBuildGLCanvas() const
FXToolBarShell * myToolBarDrag7
long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
GUIVisualizationSettings & getDefault()
Returns the default scheme.
The simulation is loading.
Definition: MSNet.h:96
GUISUMOAbstractView *const myView
the view to save
FXToolBarShell * myToolBarDrag6
static const RGBColor RED
named colors
Definition: RGBColor.h:179
RandomDistributor< std::string > myCollisionSounds
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:64
void setGroove(const FXint width)
set/get groove width - must be less than segment width
Definition: FXLCDLabel.cpp:222
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
About SUMO - ID.
Definition: GUIAppEnum.h:87
void prepareDestruction()
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
The loading thread.
Definition: GUIAppEnum.h:117
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:358
#define GUIDesignToolBarShell1
design for first toolbar shell positioned in the next position of dock
Definition: GUIDesigns.h:269
MFXEventQue< GUIEvent * > myEvents
List of got requests.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:778
static void close()
close GUIIconSubSys
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:145
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:111
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXEX::FXLCDLabel * myTimeLossLabel
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
Open a new microscopic view.
Definition: GUIAppEnum.h:107
FXDockSite * myTopDock
void setStatusBarText(const std::string &text)
Locate polygons - button.
Definition: GUIAppEnum.h:191
FXRecentFiles myRecentConfigs
List of recent config files.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Open editor for selections.
Definition: GUIAppEnum.h:129
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
void create()
Creates the widget.
void clear()
Clears the list of selected objects.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void lock()
lock mutex
Definition: MFXMutex.cpp:84
void text()
Definition: gl2psTest.c:260
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
Definition: GUIEvent.h:44
bool simulationAvailable() const
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:58
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:121
GUIPerspectiveChanger & getChanger() const
get changer
send when a warning occured
Definition: GUIEvent.h:53
FXToolBar * myToolBar1
The application tool bar.
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:213
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
double myJamSoundTime
waiting time after which vehicles trigger jam sounds
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
long onUpdNeedsSimulation(FXObject *, FXSelector, void *)
Determines whether some buttons which require an active simulation may be shown.
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
An XML-handler for visualisation schemes.
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:598
#define GUIDesignSpinDial
Definition: GUIDesigns.h:301
long long int SUMOTime
Definition: TraCIDefs.h:52
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:69
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
Close simulation - ID.
Definition: GUIAppEnum.h:85
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:274
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The class responsible for building and deletion of vehicles.
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:153
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
const SUMOTime myEnd
the time the simulation shall end with
virtual void begin()
void clear()
Clears the window.
help button
Definition: GUIAppEnum.h:404
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
long onCmdListTeleporting(FXObject *, FXSelector, void *)
Toggle listing of teleporting vehicles.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:521
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
static std::mt19937 myGamingRNG
A random number generator used to choose a gaming sound.
GUISelectedStorage gSelected
A global holder of selected objects.
static bool gUseMesoSim
Definition: MSGlobals.h:98
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
Perform a single simulation step.
Definition: GUIAppEnum.h:99
send when a status change occured
Definition: GUIEvent.h:59
FXMutex & getSnapshotsLock()
Definition: GUIRunThread.h:127
virtual void addToWindowsMenu(FXMenuPane *)
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:129
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:443
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
void setApplicationSnapshots(std::set< SUMOTime > *snapshots, FXMutex *lock)
add snapshot synchronization
The main window of the SUMO-gui.