SUMO - Simulation of Urban MObility
GUIApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The main window of the SUMO-gui.
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #ifdef HAVE_VERSION_H
28 #include <version.h>
29 #endif
30 
31 #include <string>
32 #include <sstream>
33 #include <algorithm>
34 #include <iomanip>
35 
36 #include <guisim/GUINet.h>
37 #include <guisim/GUILane.h>
38 #include <netload/NLHandler.h>
39 #include <microsim/MSGlobals.h>
40 #include <microsim/MSEdge.h>
41 #include <microsim/MSVehicle.h>
44 #include <microsim/MSEdgeControl.h>
47 
48 #include "GUISUMOViewParent.h"
49 #include "GUILoadThread.h"
50 #include "GUIRunThread.h"
51 #include "GUIApplicationWindow.h"
54 
55 #include <utils/common/ToString.h>
61 
62 #include <utils/xml/XMLSubSys.h>
74 #include <utils/gui/div/GLHelper.h>
85 #include "GUIGlobals.h"
89 
90 
91 //#define HAVE_DANGEROUS_SOUNDS
92 
93 // ===========================================================================
94 // FOX-declarations
95 // ===========================================================================
96 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
97  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
98  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
99  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
100 
104  FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
105  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
106  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
107  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
111  FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
112 
114  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
115  FXMAPFUNC(SEL_COMMAND, MID_FULLSCREEN, GUIApplicationWindow::onCmdFullScreen),
119  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
120  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
121 #ifdef HAVE_OSG
122  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
123 #endif
124  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
125  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
126  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
127  FXMAPFUNC(SEL_COMMAND, MID_SIMSAVE, GUIApplicationWindow::onCmdSaveState),
132 
136 
137  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
138  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
139  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
140  FXMAPFUNC(SEL_UPDATE, MID_OPEN_SHAPES, GUIApplicationWindow::onUpdReload),
141  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
144 #ifdef HAVE_OSG
145  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
146 #endif
147  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
148  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
149  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
157  FXMAPFUNC(SEL_COMMAND, MID_HELP, GUIApplicationWindow::onCmdHelp),
158 
159  // forward requests to the active view
160  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
161  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
162  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
163  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
164  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
165  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
166  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
167  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
176  FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
177  FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
178 
179  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
180 
185 };
186 
187 // Object implementation
188 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
189 
190 // ===========================================================================
191 // static members
192 // ===========================================================================
194 
195 // ===========================================================================
196 // member method definitions
197 // ===========================================================================
198 GUIApplicationWindow::GUIApplicationWindow(FXApp* a, const std::string& configPattern) :
199  GUIMainWindow(a),
200  myLoadThread(nullptr), myRunThread(nullptr),
201  myAmLoading(false),
202  myAlternateSimDelay(0),
203  myRecentNets(a, "nets"),
204  myConfigPattern(configPattern),
205  hadDependentBuild(false),
206  myShowTimeAsHMS(false),
207  myHaveNotifiedAboutSimEnd(false),
208  // game specific
209  myJamSoundTime(60),
210  myPreviousCollisionNumber(0),
211  myWaitingTime(0),
212  myTimeLoss(0) {
213  // init icons
215  // init cursors
217 }
218 
219 
220 void
222  // don't do this twice
223  if (hadDependentBuild) {
224  return;
225  }
226  hadDependentBuild = true;
227 
228  setTarget(this);
229  setSelector(MID_WINDOW);
230 
231  // build menu bar
232  myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBarShell3);
233  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignBar);
234  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
235  buildToolBars();
236  // build the thread - io
239 
240  // build the status bar
241  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
242  {
243  myGeoFrame = new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
244  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", nullptr, LAYOUT_CENTER_Y);
246  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", nullptr, LAYOUT_CENTER_Y);
249  myStatButtons.back()->hide();
250  myStatButtons.push_back(new FXButton(myStatusbar, "-", GUIIconSubSys::getIcon(ICON_GREENEDGE), this, MID_SHOWVEHSTATS));
251  myStatButtons.back()->hide();
252  }
253 
254  // make the window a mdi-window
255  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
256  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
257  myMDIMenu = new FXMDIMenu(this, myMDIClient);
258  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
259  new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
260  new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
261  new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
262 
263  // build the message window
265  // fill menu and tool bar
266  fillMenuBar();
267  myToolBar6->hide();
268  myToolBar7->hide();
269  // build additional threads
270  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
272  // set the status bar
273  myStatusbar->getStatusLine()->setText("Ready.");
274  // set the caption
275  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
276 
277  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
278  myRunThread->start();
281 }
282 
283 
284 void
287  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
288  FXMainWindow::create();
289  myMenuBarDrag->create();
290  myToolBarDrag1->create();
291  myToolBarDrag2->create();
292  myToolBarDrag3->create();
293  myToolBarDrag4->create();
294  myToolBarDrag5->create();
295  myToolBarDrag6->create();
296  myToolBarDrag7->create();
297  myFileMenu->create();
298  mySelectByPermissions->create();
299  myEditMenu->create();
300  mySettingsMenu->create();
301  myLocatorMenu->create();
302  myControlMenu->create();
303  myWindowsMenu->create();
304  myHelpMenu->create();
305 
306  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
307  myCartesianFrame->setWidth(width);
308  myGeoFrame->setWidth(width);
309 
310  show(PLACEMENT_DEFAULT);
311  if (!OptionsCont::getOptions().isSet("window-size")) {
312  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
313  maximize();
314  }
315  }
316  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
317  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
318 }
319 
320 
323  myRunThread->join();
324  closeAllWindows();
325  //
327  delete myGLVisual;
328  // delete some non-parented windows
329  delete myToolBarDrag1;
330  //
331  delete myRunThread;
332  delete myFileMenu;
333  delete myEditMenu;
334  delete mySelectByPermissions;
335  delete mySettingsMenu;
336  delete myLocatorMenu;
337  delete myControlMenu;
338  delete myWindowsMenu;
339  delete myHelpMenu;
340 
341  delete myLoadThread;
342 
343  while (!myEvents.empty()) {
344  // get the next event
345  GUIEvent* e = myEvents.top();
346  myEvents.pop();
347  delete e;
348  }
349 }
350 
351 
352 void
354  FXMainWindow::detach();
355  myMenuBarDrag->detach();
356  myToolBarDrag1->detach();
357 }
358 
359 
360 void
362  // build file menu
363  myFileMenu = new FXMenuPane(this);
364  new FXMenuTitle(myMenuBar, "&File", nullptr, myFileMenu);
365  new FXMenuCommand(myFileMenu,
366  "&Open Simulation...\tCtrl+O\tOpen a simulation (Configuration file).",
368  new FXMenuCommand(myFileMenu,
369  "Open &Network...\tCtrl+N\tOpen a network.",
371  new FXMenuCommand(myFileMenu,
372  "Open Shapes \tCtrl+P\tLoad POIs and Polygons for visualization.",
374  new FXMenuCommand(myFileMenu,
375  "&Reload\tCtrl+R\tReloads the simulation / the network.",
377  new FXMenuSeparator(myFileMenu);
378  new FXMenuCommand(myFileMenu,
379  "Close\tCtrl+W\tClose the simulation.",
381  // Recent files
382  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
383  sep1->setTarget(&myRecentConfigs);
384  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
385  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
386  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
387  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
388  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
389  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
390  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
391  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
392  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
393  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
394  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
395  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", nullptr, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
396  myRecentConfigs.setTarget(this);
397  myRecentConfigs.setSelector(MID_RECENTFILE);
398  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
399  sep2->setTarget(&myRecentNets);
400  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
401  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_1);
402  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_2);
403  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_3);
404  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_4);
405  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_5);
406  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_6);
407  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_7);
408  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_8);
409  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_9);
410  new FXMenuCommand(myFileMenu, "", nullptr, &myRecentNets, FXRecentFiles::ID_FILE_10);
411  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", nullptr, &myRecentNets, FXRecentFiles::ID_CLEAR);
412  myRecentNets.setTarget(this);
413  myRecentNets.setSelector(MID_RECENTFILE);
414  new FXMenuSeparator(myFileMenu);
415  new FXMenuCommand(myFileMenu,
416  "&Quit\tCtrl+Q\tQuit the Application.",
417  nullptr, this, MID_QUIT, 0);
418 
419  // build edit menu
420  mySelectByPermissions = new FXMenuPane(this);
421  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
422  for (auto i : vehicleClasses) {
423  new FXMenuCommand(mySelectByPermissions, i.c_str(), nullptr, this, MID_EDITCHOSEN);
424  }
425 
426  myEditMenu = new FXMenuPane(this);
427  new FXMenuTitle(myMenuBar, "&Edit", nullptr, myEditMenu);
428  new FXMenuCommand(myEditMenu,
429  "Edit Selected...\tCtrl+E\tOpens a dialog for editing the list of selected items.",
431  mySelectLanesMenuCascade = new FXMenuCascade(myEditMenu,
432  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
434  new FXMenuSeparator(myEditMenu);
435  new FXMenuCommand(myEditMenu,
436  "Edit Breakpoints...\tCtrl+B\tOpens a dialog for editing breakpoints.",
437  nullptr, this, MID_EDIT_BREAKPOINTS);
438  new FXMenuCommand(myEditMenu,
439  "Edit Visualisation ...\tCtrl+V\tOpens a dialog for editing visualization settings.",
440  nullptr, this, MID_EDITVIEWSCHEME);
441  new FXMenuCommand(myEditMenu,
442  "Edit Viewport...\tCtrl+I\tOpens a dialog for editing viewing are, zoom and rotation.",
443  nullptr, this, MID_EDITVIEWPORT);
444  new FXMenuSeparator(myEditMenu);
445  new FXMenuCommand(myEditMenu,
446  "Open in Netedit...\tCtrl+T\tOpens the netedit application with the current network.",
447  nullptr, this, MID_NETEDIT);
448 
449  // build settings menu
450  mySettingsMenu = new FXMenuPane(this);
451  new FXMenuTitle(myMenuBar, "&Settings", nullptr, mySettingsMenu);
452  new FXMenuCommand(mySettingsMenu,
453  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
454  nullptr, this, MID_APPSETTINGS);
455  new FXMenuCheck(mySettingsMenu,
456  "Gaming Mode\tCtrl+G\tToggle gaming mode on/off.",
457  this, MID_GAMING);
458  new FXMenuCheck(mySettingsMenu,
459  "Full Screen Mode\tCtrl+F\tToggle full screen mode on/off.",
460  this, MID_FULLSCREEN);
461  // build Locate menu
462  myLocatorMenu = new FXMenuPane(this);
463  new FXMenuTitle(myMenuBar, "&Locate", nullptr, myLocatorMenu);
464  new FXMenuCommand(myLocatorMenu,
465  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
467  new FXMenuCommand(myLocatorMenu,
468  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
470  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
471  new FXMenuCommand(myLocatorMenu,
472  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
474  }
475  new FXMenuCommand(myLocatorMenu,
476  "Locate &Persons\t\tOpen a Dialog for Locating a Person.",
478  new FXMenuCommand(myLocatorMenu,
479  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
481  new FXMenuCommand(myLocatorMenu,
482  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
484  new FXMenuCommand(myLocatorMenu,
485  "Locate P&oI\t\tOpen a Dialog for Locating a Point of Intereset.",
487  new FXMenuCommand(myLocatorMenu,
488  "Locate Po&lygon\t\tOpen a Dialog for Locating a Polygon.",
490  new FXMenuSeparator(myLocatorMenu);
491  new FXMenuCheck(myLocatorMenu,
492  "Show Internal Structures\t\tShow internal junctions and streets in locator dialog.",
493  this, MID_LISTINTERNAL);
494  FXMenuCheck* listParking = new FXMenuCheck(myLocatorMenu,
495  "Show Parking Vehicles\t\tShow parking vehicles in locator dialog.",
496  this, MID_LISTPARKING);
497  listParking->setCheck(myListParking);
498  new FXMenuCheck(myLocatorMenu,
499  "Show vehicles outside the road network\t\tShow vehicles that are teleporting or driving remote-controlled outside the road network in locator dialog.",
500  this, MID_LISTTELEPORTING);
501  // build control menu
502  myControlMenu = new FXMenuPane(this);
503  new FXMenuTitle(myMenuBar, "Simulation", nullptr, myControlMenu);
504  new FXMenuCommand(myControlMenu,
505  "Run\tCtrl+A\tStart running the simulation.",
507  new FXMenuCommand(myControlMenu,
508  "Stop\tCtrl+S\tStop running the simulation.",
510  new FXMenuCommand(myControlMenu,
511  "Step\tCtrl+D\tPerform one simulation step.",
513  new FXMenuCommand(myControlMenu,
514  "Save\t\tSave the current simulation state to a file.",
516 
517  // build windows menu
518  myWindowsMenu = new FXMenuPane(this);
519  new FXMenuTitle(myMenuBar, "&Windows", nullptr, myWindowsMenu);
520  new FXMenuCheck(myWindowsMenu,
521  "Show Status Line\t\tToggle the Status Bar on/off.",
522  myStatusbar, FXWindow::ID_TOGGLESHOWN);
523  new FXMenuCheck(myWindowsMenu,
524  "Show Message Window\t\tToggle the Message Window on/off.",
525  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
526  new FXMenuCheck(myWindowsMenu,
527  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
528  myToolBar3, FXWindow::ID_TOGGLESHOWN);
529  new FXMenuCheck(myWindowsMenu,
530  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
531  myToolBar4, FXWindow::ID_TOGGLESHOWN);
533  new FXMenuSeparator(myWindowsMenu);
534  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
536  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
537  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
539  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
540  new FXMenuCommand(myWindowsMenu, "Cascade",
542  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
543  new FXMenuCommand(myWindowsMenu, "&Close", nullptr,
544  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
545  sep1 = new FXMenuSeparator(myWindowsMenu);
546  sep1->setTarget(myMDIClient);
547  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
548  new FXMenuCommand(myWindowsMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_1);
549  new FXMenuCommand(myWindowsMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_2);
550  new FXMenuCommand(myWindowsMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_3);
551  new FXMenuCommand(myWindowsMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_4);
552  new FXMenuCommand(myWindowsMenu, "&Others...", nullptr, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
553  new FXMenuSeparator(myWindowsMenu);
554  new FXMenuCommand(myWindowsMenu,
555  "Clear Message Window\t\tClear the message window.",
556  nullptr, this, MID_CLEARMESSAGEWINDOW);
557 
558  // build help menu
559  myHelpMenu = new FXMenuPane(this);
560  new FXMenuTitle(myMenuBar, "&Help", nullptr, myHelpMenu);
561  new FXMenuCommand(myHelpMenu, "&Online Documentation\tF1\tOpen Online documentation", nullptr, this, MID_HELP);
562  new FXMenuCommand(myHelpMenu, "&About\tF2\tAbout sumo-gui", GUIIconSubSys::getIcon(ICON_SUMO_MINI),
563  this, MID_ABOUT);
564 
565  // initialize Ctrl hotkeys with Caps Lock enabled using decimal code (to avoid problems in Linux)
566  getAccelTable()->addAccel(262222, this, FXSEL(SEL_COMMAND, MID_OPEN_NETWORK)); // Ctrl + N
567  getAccelTable()->addAccel(262223, this, FXSEL(SEL_COMMAND, MID_OPEN_CONFIG)); // Ctrl + O
568  getAccelTable()->addAccel(262226, this, FXSEL(SEL_COMMAND, MID_RELOAD)); // Ctrl + R
569  getAccelTable()->addAccel(262224, this, FXSEL(SEL_COMMAND, MID_OPEN_SHAPES)); // Ctrl + P
570  getAccelTable()->addAccel(262230, this, FXSEL(SEL_COMMAND, MID_CLOSE)); // Ctrl + W
571  getAccelTable()->addAccel(262225, this, FXSEL(SEL_COMMAND, MID_QUIT)); // Ctrl + Q
572  getAccelTable()->addAccel(262214, this, FXSEL(SEL_COMMAND, MID_FULLSCREEN)); // Ctrl + F
573  getAccelTable()->addAccel(262215, this, FXSEL(SEL_COMMAND, MID_GAMING)); // Ctrl + G
574  getAccelTable()->addAccel(262209, this, FXSEL(SEL_COMMAND, MID_START)); // Ctrl + A
575  getAccelTable()->addAccel(262227, this, FXSEL(SEL_COMMAND, MID_STOP)); // Ctrl + S
576  getAccelTable()->addAccel(262212, this, FXSEL(SEL_COMMAND, MID_STEP)); // Ctrl + D
577 
587 }
588 
589 
590 void
592  // build tool bars
593  {
594  // file and simulation tool bar
595  myToolBarDrag1 = new FXToolBarShell(this, GUIDesignToolBarShell3);
597  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
598  // build file tools
599  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).", GUIIconSubSys::getIcon(ICON_OPEN_CONFIG), this, MID_OPEN_CONFIG, GUIDesignButtonToolbar);
600  new FXButton(myToolBar1, "\t\tOpen a network.", GUIIconSubSys::getIcon(ICON_OPEN_NET), this, MID_OPEN_NETWORK, GUIDesignButtonToolbar);
601  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.", GUIIconSubSys::getIcon(ICON_RELOAD), this, MID_RELOAD, GUIDesignButtonToolbar);
602  }
603  {
604  // simulation toolbar
605  myToolBarDrag2 = new FXToolBarShell(this, GUIDesignToolBarShell3);
607  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
608  // build simulation tools
609  new FXButton(myToolBar2, "\t\tStart the loaded simulation.", GUIIconSubSys::getIcon(ICON_START), this, MID_START, GUIDesignButtonToolbar);
610  new FXButton(myToolBar2, "\t\tStop the running simulation.", GUIIconSubSys::getIcon(ICON_STOP), this, MID_STOP, GUIDesignButtonToolbar);
611  new FXButton(myToolBar2, "\t\tPerform a single simulation step.", GUIIconSubSys::getIcon(ICON_STEP), this, MID_STEP, GUIDesignButtonToolbar);
612  }
613  {
614  // Simulation Step Display
615  myToolBarDrag3 = new FXToolBarShell(this, GUIDesignToolBarShell3);
617  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
618  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", nullptr, this, MID_TIME_TOOGLE, GUIDesignButtonToolbarText);
619 
620  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 16, nullptr, 0, JUSTIFY_RIGHT);
624  myLCDLabel->setGroove(2);
625  myLCDLabel->setText("----------------");
626  }
627  {
628  // Simulation Delay
629  myToolBarDrag4 = new FXToolBarShell(this, GUIDesignToolBarShell3);
631  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
632  new FXButton(myToolBar4, "Delay (ms):\t\tDelay per simulated second. Click to toggle between the last two delay values", nullptr, this, MID_DELAY_TOOGLE, GUIDesignButtonToolbarText);
633 
634  mySimDelay = 0;
635  mySimDelayTarget = new FXDataTarget(mySimDelay);
636  mySimDelaySpinner = new FXRealSpinner(myToolBar4, 7, mySimDelayTarget, FXDataTarget::ID_VALUE, GUIDesignSpinDial);
637  mySimDelaySlider = new FXSlider(myToolBar4, mySimDelayTarget, FXDataTarget::ID_VALUE, LAYOUT_FIX_WIDTH | SLIDER_ARROW_UP | SLIDER_TICKS_TOP, 0, 0, 300, 10, 0, 0, 5, 0);
638  mySimDelaySlider->setRange(0, 1000);
639  mySimDelaySlider->setHeadSize(10);
640  mySimDelaySlider->setIncrement(50);
641  mySimDelaySlider->setTickDelta(100);
642  mySimDelaySlider->setValue((int)mySimDelay);
643  //mySimDelayTarget->setNumberFormat(0);
644  //mySimDelayTarget->setIncrements(1, 10, 10);
645  mySimDelaySpinner->setIncrement(10);
646  mySimDelaySpinner->setRange(0, 10000);
647  mySimDelaySpinner->setValue(mySimDelay);
648  }
649  {
650  // Scale traffic (flows and incrementally loaded vehicles)
651  myToolBarDrag8 = new FXToolBarShell(this, GUIDesignToolBarShell3);
653  new FXToolBarGrip(myToolBar8, myToolBar8, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
654  new FXLabel(myToolBar8, "Scale Traffic:\t\tScale traffic from flows and vehicles that are loaded incrementally from route files", nullptr, LAYOUT_TOP | LAYOUT_LEFT);
655  myDemandScaleSpinner = new FXRealSpinner(myToolBar8, 7, this, MID_DEMAND_SCALE, GUIDesignSpinDial);
656  myDemandScaleSpinner->setIncrement(0.5);
657  myDemandScaleSpinner->setRange(0, 1000);
658  myDemandScaleSpinner->setValue(1);
659  }
660  {
661  // Views
662  myToolBarDrag5 = new FXToolBarShell(this, GUIDesignToolBarShell3);
664  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
665  // build view tools
666  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
668 #ifdef HAVE_OSG
669  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
671 #endif
672  }
673  {
675  // total waitingTime
676  myToolBarDrag6 = new FXToolBarShell(this, GUIDesignToolBarShell3);
678  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
679  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", nullptr, LAYOUT_TOP | LAYOUT_LEFT);
680  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, nullptr, 0, JUSTIFY_RIGHT);
685  myWaitingTimeLabel->setText("-------------");
686 
687  // idealistic time loss
688  myToolBarDrag7 = new FXToolBarShell(this, GUIDesignToolBarShell3);
690  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
691  new FXLabel(myToolBar7, "Time Loss:\t\tTime lost due to being unable to drive with maximum speed for all vehicles", nullptr, LAYOUT_TOP | LAYOUT_LEFT);
692  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, nullptr, 0, JUSTIFY_RIGHT);
697  myTimeLossLabel->setText("-------------");
698  }
699 }
700 
701 
702 long
703 GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
705  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
706  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
707  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
708  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", (int)myAlternateSimDelay);
709  getApp()->exit(0);
710  return 1;
711 }
712 
713 
714 long
715 GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
716  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
717  if (mc->getText() == "Edit Selected...") {
718  GUIDialog_GLChosenEditor* chooser =
720  chooser->create();
721  chooser->show();
722  } else {
724  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
725  for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
726  const std::vector<MSLane*>& lanes = (*i)->getLanes();
727  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
728  GUILane* lane = dynamic_cast<GUILane*>(*it);
729  assert(lane != 0);
730  if ((lane->getPermissions() & svc) != 0) {
731  gSelected.select(lane->getGlID());
732  }
733  }
734  }
735  if (myMDIClient->numChildren() > 0) {
736  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
737  if (w != nullptr) {
738  // color by selection
740  }
741  }
742  }
743  updateChildren();
744  }
745  return 1;
746 }
747 
748 
749 long
750 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
752  chooser->create();
753  chooser->show();
754  return 1;
755 }
756 
757 long
758 GUIApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
759  if (!myGLWindows.empty()) {
760  myGLWindows[0]->getView()->showViewportEditor();
761  }
762  return 1;
763 }
764 
765 
766 long
767 GUIApplicationWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
768  if (!myGLWindows.empty()) {
769  myGLWindows[0]->getView()->showViewschemeEditor();
770  }
771  return 1;
772 }
773 
774 
775 long
776 GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
777  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/SUMO-GUI");
778  return 1;
779 }
780 
781 
782 long
783 GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
784  if (myGLWindows.empty()) {
785  return 1;
786  }
787  FXRegistry reg("SUMO netedit", "Eclipse");
788  reg.read();
789  const GUISUMOAbstractView* const v = myGLWindows[0]->getView();
790  reg.writeRealEntry("viewport", "x", v->getChanger().getXPos());
791  reg.writeRealEntry("viewport", "y", v->getChanger().getYPos());
792  reg.writeRealEntry("viewport", "z", v->getChanger().getZPos());
793  reg.write();
794  std::string netedit = "netedit";
795  const char* sumoPath = getenv("SUMO_HOME");
796  if (sumoPath != nullptr) {
797  std::string newPath = std::string(sumoPath) + "/bin/netedit";
798  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
799  netedit = "\"" + newPath + "\"";
800  }
801  }
802  std::string cmd = netedit + " --registry-viewport -s " + OptionsCont::getOptions().getString("net-file");
803  // start in background
804 #ifndef WIN32
805  cmd = cmd + " &";
806 #else
807  // see "help start" for the parameters
808  cmd = "start /B \"\" " + cmd;
809 #endif
810  WRITE_MESSAGE("Running " + cmd + ".");
811  // yay! fun with dangerous commands... Never use this over the internet
813  return 1;
814 }
815 
816 
817 long
818 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
819  // get the new file name
820  FXFileDialog opendialog(this, "Open Simulation Configuration");
821  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
822  opendialog.setSelectMode(SELECTFILE_EXISTING);
823  opendialog.setPatternList(myConfigPattern.c_str());
824  if (gCurrentFolder.length() != 0) {
825  opendialog.setDirectory(gCurrentFolder);
826  }
827  if (opendialog.execute()) {
828  gCurrentFolder = opendialog.getDirectory();
829  std::string file = opendialog.getFilename().text();
830  loadConfigOrNet(file, false);
831  myRecentConfigs.appendFile(file.c_str());
832  }
833  return 1;
834 }
835 
836 
837 long
838 GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
839  // get the new file name
840  FXFileDialog opendialog(this, "Open Network");
841  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
842  opendialog.setSelectMode(SELECTFILE_EXISTING);
843  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
844  if (gCurrentFolder.length() != 0) {
845  opendialog.setDirectory(gCurrentFolder);
846  }
847  if (opendialog.execute()) {
848  gCurrentFolder = opendialog.getDirectory();
849  std::string file = opendialog.getFilename().text();
850  loadConfigOrNet(file, true);
851  myRecentNets.appendFile(file.c_str());
852  }
853  return 1;
854 }
855 
856 
857 long
858 GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
859  // get the shape file name
860  FXFileDialog opendialog(this, "Open Shapes");
861  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
862  opendialog.setSelectMode(SELECTFILE_EXISTING);
863  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
864  if (gCurrentFolder.length() != 0) {
865  opendialog.setDirectory(gCurrentFolder);
866  }
867  if (opendialog.execute()) {
868  gCurrentFolder = opendialog.getDirectory();
869  std::string file = opendialog.getFilename().text();
870 
871  dynamic_cast<GUIShapeContainer&>(myRunThread->getNet().getShapeContainer()).allowReplacement();
873  if (!XMLSubSys::runParser(handler, file, false)) {
874  WRITE_MESSAGE("Loading of " + file + " failed.");
875  }
876  update();
877  if (myMDIClient->numChildren() > 0) {
878  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
879  if (w != nullptr) {
880  w->getView()->update();
881  }
882  }
883  }
884  return 1;
885 }
886 
887 long
888 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
890  getApp()->beginWaitCursor();
891  myAmLoading = true;
892  closeAllWindows();
893  myLoadThread->start();
894  setStatusBarText("Reloading.");
895  update();
896  return 1;
897 }
898 
899 
900 long
901 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
902  if (myAmLoading) {
903  myStatusbar->getStatusLine()->setText("Already loading!");
904  return 1;
905  }
906  std::string file((const char*)data);
907  loadConfigOrNet(file, sender == &myRecentNets);
908  return 1;
909 }
910 
911 
912 long
913 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
914  closeAllWindows();
915  return 1;
916 }
917 
918 
919 long
920 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
921  sender->handle(this,
922  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
923  ptr);
924  return 1;
925 }
926 
927 
928 long
929 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
930  sender->handle(this,
932  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
933  ptr);
934  return 1;
935 }
936 
937 
938 long
939 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
940  sender->handle(this,
941  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
942  ptr);
943  return 1;
944 }
945 
946 
947 long
948 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
949  sender->handle(this,
951  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
952  ptr);
953  return 1;
954 }
955 
956 
957 long
958 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
959  // check whether a net was loaded successfully
961  myStatusbar->getStatusLine()->setText("No simulation loaded!");
962  return 1;
963  }
964  // check whether it was started before and paused;
965  if (!myWasStarted) {
966  myRunThread->begin();
967  myWasStarted = true;
968  }
969  myRunThread->resume();
970  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
971  return 1;
972 }
973 
974 
975 long
976 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
977  myRunThread->stop();
978  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
979  return 1;
980 }
981 
982 
983 long
984 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
985  // check whether a net was loaded successfully
987  myStatusbar->getStatusLine()->setText("No simulation loaded!");
988  return 1;
989  }
990  // check whether it was started before and paused;
991  if (!myWasStarted) {
992  myRunThread->begin();
993  myWasStarted = true;
994  }
996  return 1;
997 }
998 
999 
1000 long
1001 GUIApplicationWindow::onCmdSaveState(FXObject*, FXSelector, void*) {
1002  // get the new file name
1003  FXFileDialog opendialog(this, "Save Simulation State");
1004  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_SAVE));
1005  opendialog.setSelectMode(SELECTFILE_ANY);
1006  opendialog.setPatternList("Binary State (*.sbx)\nXML State (*.xml)");
1007  if (gCurrentFolder.length() != 0) {
1008  opendialog.setDirectory(gCurrentFolder);
1009  }
1010  if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1011  return 1;
1012  }
1013 
1014  FXString file = MFXUtils::assureExtension(opendialog.getFilename(),
1015  opendialog.getPatternText(opendialog.getCurrentPattern()).after('.').before(')'));
1017  myStatusbar->getStatusLine()->setText("Simulation saved to " + file);
1018  return 1;
1019 }
1020 
1021 
1022 long
1023 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
1027  }
1028  return 1;
1029 }
1030 
1031 
1032 long
1033 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
1034  const double tmp = myAlternateSimDelay;
1036  mySimDelay = tmp;
1037  return 1;
1038 }
1039 
1040 
1041 long
1042 GUIApplicationWindow::onCmdDemandScale(FXObject*, FXSelector, void*) {
1045  }
1046  return 1;
1047 }
1048 
1049 
1050 long
1051 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
1053  return 1;
1054 }
1055 
1056 
1057 long
1058 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
1059  sender->handle(this,
1061  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1062  ptr);
1063  return 1;
1064 }
1065 
1066 
1067 long
1068 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
1069  sender->handle(this,
1071  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1072  ptr);
1073  return 1;
1074 }
1075 
1076 
1077 long
1078 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
1079  sender->handle(this,
1081  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1082  ptr);
1083  return 1;
1084 }
1085 
1086 
1087 long
1088 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
1089  bool disable = !myRunThread->simulationAvailable() || myAmLoading;
1090  sender->handle(this, disable ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1091  // mySelectLanesMenuCascade has to be disabled manually
1092  if (disable) {
1093  mySelectLanesMenuCascade->disable();
1094  } else {
1095  mySelectLanesMenuCascade->enable();
1096  }
1097  return 1;
1098 }
1099 
1100 
1101 long
1102 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1103  if (myMDIClient->numChildren() > 0) {
1104  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1105  if (w != nullptr) {
1106  w->onCmdLocate(nullptr, sel, nullptr);
1107  }
1108  }
1109  return 1;
1110 }
1111 
1112 
1113 long
1114 GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1115  if (myMDIClient->numChildren() > 0) {
1116  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1118  }
1119  return 1;
1120 }
1121 
1122 
1123 long
1124 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1126  d->create();
1127  d->show(PLACEMENT_OWNER);
1128  return 1;
1129 }
1130 
1131 
1132 long
1133 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1135  if (myAmGaming) {
1136  myMenuBar->hide();
1137  myStatusbar->hide();
1138  myToolBar1->hide();
1139  myToolBar2->hide();
1140  myToolBar4->hide();
1141  myToolBar5->hide();
1142  myToolBar6->show();
1143  myToolBar7->show();
1144  myToolBar8->hide();
1145  myMessageWindow->hide();
1149  gSchemeStorage.getDefault().gaming = true;
1150  } else {
1151  myMenuBar->show();
1152  myStatusbar->show();
1153  myToolBar1->show();
1154  myToolBar2->show();
1155  myToolBar4->show();
1156  myToolBar5->show();
1157  myToolBar6->hide();
1158  myToolBar7->hide();
1159  myToolBar8->show();
1160  myMessageWindow->show();
1162  gSchemeStorage.getDefault().gaming = false;
1163  }
1164  if (myMDIClient->numChildren() > 0) {
1165  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1166  if (w != nullptr) {
1168  }
1169  }
1170  update();
1171  return 1;
1172 }
1173 
1174 
1175 long
1176 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1178  if (myAmFullScreen) {
1179  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1180  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1181  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1182  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1183  maximize();
1184  setDecorations(DECOR_NONE);
1185  place(PLACEMENT_MAXIMIZED);
1186  myMenuBar->hide();
1187  myStatusbar->hide();
1188  myToolBar1->hide();
1189  myToolBar2->hide();
1190  myToolBar3->hide();
1191  myToolBar4->hide();
1192  myToolBar5->hide();
1193  myToolBar6->hide();
1194  myToolBar7->hide();
1195  myToolBar8->hide();
1196  myMessageWindow->hide();
1197  if (myMDIClient->numChildren() > 0) {
1198  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1199  if (w != nullptr) {
1200  w->setToolBarVisibility(false);
1201  }
1202  }
1203  update();
1204  } else {
1205  place(PLACEMENT_VISIBLE);
1206  setDecorations(DECOR_ALL);
1207  restore();
1208  myToolBar3->show();
1210  onCmdGaming(nullptr, 0, nullptr);
1211  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1212  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1213  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1214  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1215  }
1216  return 1;
1217 }
1218 
1219 
1220 long
1221 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1223  return 1;
1224 }
1225 
1226 
1227 long
1228 GUIApplicationWindow::onCmdListParking(FXObject*, FXSelector, void*) {
1230  return 1;
1231 }
1232 
1233 long
1234 GUIApplicationWindow::onCmdListTeleporting(FXObject*, FXSelector, void*) {
1236  return 1;
1237 }
1238 
1239 
1240 long
1241 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1243  return 1;
1244 }
1245 
1246 
1247 #ifdef HAVE_OSG
1248 long
1249 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1251  return 1;
1252 }
1253 #endif
1254 
1255 
1256 long
1257 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1258  GUIDialog_AboutSUMO* about = new GUIDialog_AboutSUMO(this);
1259  about->create();
1260  about->show(PLACEMENT_OWNER);
1261  return 1;
1262 }
1263 
1264 
1265 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1266  FXEvent* event = (FXEvent*)ptr;
1267  FXString string = GUIUserIO::clipped.c_str();
1268  setDNDData(FROM_CLIPBOARD, event->target, string);
1269  return 1;
1270 }
1271 
1272 
1273 long
1274 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1275  eventOccurred();
1276  return 1;
1277 }
1278 
1279 
1280 long
1281 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1282  eventOccurred();
1283  return 1;
1284 }
1285 
1286 
1287 void
1289  while (!myEvents.empty()) {
1290  // get the next event
1291  GUIEvent* e = myEvents.top();
1292  myEvents.pop();
1293  // process
1294  switch (e->getOwnType()) {
1297  break;
1298  case EVENT_SIMULATION_STEP:
1299  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1301  }
1302  break;
1305  case EVENT_ERROR_OCCURRED:
1306  case EVENT_DEBUG_OCCURRED:
1308  case EVENT_STATUS_OCCURRED:
1310  break;
1313  break;
1314  default:
1315  break;
1316  }
1317  delete e;
1318  }
1319  myToolBar2->forceRefresh();
1320  myToolBar3->forceRefresh();
1321 }
1322 
1323 
1324 void
1326  myAmLoading = false;
1328  // check whether the loading was successfull
1329  if (ec->myNet == nullptr) {
1330  // report failure
1331  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1332  if (GUIGlobals::gQuitOnEnd) {
1333  closeAllWindows();
1334  getApp()->exit(1);
1335  }
1336  } else {
1337  if (OptionsCont::getOptions().getBool("game")) {
1338  onCmdGaming(nullptr, 0, nullptr);
1339  }
1340  // initialise simulation thread
1341  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1342  if (GUIGlobals::gQuitOnEnd) {
1343  closeAllWindows();
1344  getApp()->exit(1);
1345  }
1346  } else {
1347  // report success
1348  setStatusBarText("'" + ec->myFile + "' loaded.");
1350  myWasStarted = false;
1351  myHaveNotifiedAboutSimEnd = false;
1352  // initialise views
1353  myViewNumber = 0;
1355  if (ec->mySettingsFiles.size() > 0) {
1356  // open a view for each file and apply settings
1357  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1358  GUISettingsHandler settings(*it);
1359  GUISUMOViewParent::ViewType vt = defaultType;
1360  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1362  }
1363  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1365  }
1366  GUISUMOAbstractView* view = openNewView(vt);
1367  if (view == nullptr) {
1368  break;
1369  }
1370  std::string settingsName = settings.addSettings(view);
1371  view->addDecals(settings.getDecals());
1372  settings.applyViewport(view);
1373  settings.setSnapshots(view);
1374  if (settings.getDelay() > 0.) {
1375  mySimDelay = settings.getDelay();
1376  }
1377  if (settings.getBreakpoints().size() > 0) {
1378  myRunThread->getBreakpointLock().lock();
1379  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1380  myRunThread->getBreakpointLock().unlock();
1381  }
1382  myJamSounds = settings.getEventDistribution("jam");
1383  myCollisionSounds = settings.getEventDistribution("collision");
1384  if (settings.getJamSoundTime() > 0) {
1385  myJamSoundTime = settings.getJamSoundTime();
1386  }
1387  }
1388  } else {
1389  openNewView(defaultType);
1390  }
1391  if (!OptionsCont::getOptions().isDefault("breakpoints")) {
1392  std::vector<SUMOTime> breakpoints;
1393  for (const std::string& val : OptionsCont::getOptions().getStringVector("breakpoints")) {
1394  breakpoints.push_back(string2time(val));
1395  }
1396  std::sort(breakpoints.begin(), breakpoints.end());
1397  myRunThread->getBreakpointLock().lock();
1398  myRunThread->getBreakpoints().assign(breakpoints.begin(), breakpoints.end());
1399  myRunThread->getBreakpointLock().unlock();
1400  }
1401 
1402  if (isGaming()) {
1403  setTitle("SUMO Interactive Traffic Light");
1404  } else {
1405  // set simulation name on the caption
1406  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1407  }
1408  if (ec->myViewportFromRegistry) {
1409  Position off;
1410  off.set(getApp()->reg().readRealEntry("viewport", "x"),
1411  getApp()->reg().readRealEntry("viewport", "y"),
1412  getApp()->reg().readRealEntry("viewport", "z"));
1413  Position p(off.x(), off.y(), 0);
1414  GUISUMOAbstractView* view = myGLWindows[0]->getView();
1415  view->setViewportFromToRot(off, p, 0);
1416  }
1417  // set simulation step begin information
1418  myLCDLabel->setText("----------------");
1419  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1420  (*it)->setText("-");
1421  }
1422  // initialize scale from options
1423  myDemandScaleSpinner->setValue(OptionsCont::getOptions().getFloat("scale"));
1424  }
1425  }
1426  getApp()->endWaitCursor();
1427  // start if wished
1428  if (GUIGlobals::gRunAfterLoad && ec->myNet != nullptr && myRunThread->simulationIsStartable()) {
1429  onCmdStart(nullptr, 0, nullptr);
1430  }
1431  update();
1432 }
1433 
1434 
1435 void
1437  updateChildren();
1439  const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1440  const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1441  if (backlog > running) {
1442  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_GREENVEHICLE)) {
1444  }
1445  } else {
1446  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_YELLOWVEHICLE)) {
1448  }
1449  }
1450  myStatButtons.front()->setText(toString(running).c_str());
1451  if (myRunThread->getNet().hasPersons()) {
1452  if (!myStatButtons[1]->shown()) {
1453  myStatButtons[1]->show();
1454  }
1456  }
1457  if (myRunThread->getNet().hasContainers()) {
1458  if (!myStatButtons[2]->shown()) {
1459  myStatButtons[2]->show();
1460  }
1462  }
1463  if (myAmGaming) {
1465  }
1467  getApp()->forceRefresh(); // restores keyboard focus
1468  }
1469  update();
1470 }
1471 
1472 
1473 void
1475  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1476  if (ec->getOwnType() == EVENT_STATUS_OCCURRED) {
1477  setStatusBarText(ec->getMsg());
1478  } else {
1479  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1480  }
1481 }
1482 
1483 
1484 void
1486  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1487  onCmdStop(nullptr, 0, nullptr);
1488  if (ec->getReason() == MSNet::SIMSTATE_LOADING) {
1489  onCmdReload(nullptr, 0, nullptr);
1490  } else if (GUIGlobals::gQuitOnEnd) {
1491  closeAllWindows();
1492  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1493  } else if (GUIGlobals::gDemoAutoReload) {
1494  onCmdReload(nullptr, 0, nullptr);
1495  } else if (!myHaveNotifiedAboutSimEnd) {
1496  // build the text
1497  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1498  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1499  "\nDo you want to close all open files and views?";
1500  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1501  if (answer == 1) { //1:yes, 2:no, 4:esc
1502  closeAllWindows();
1503  }
1505  }
1506 }
1507 
1508 
1509 void
1514 #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1515  if (myJamSounds.getOverallProb() > 0) {
1516  // play honking sound if some vehicle is waiting too long
1517  for (; it != end; ++it) {
1518  // XXX use impatience instead of waiting time ?
1519  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1520  const std::string cmd = myJamSounds.get(&myGamingRNG);
1521  if (cmd != "") {
1522  // yay! fun with dangerous commands... Never use this over the internet
1524  // one sound per simulation step is enough
1525  break;
1526  }
1527  }
1528  }
1529  }
1530  if (myCollisionSounds.getOverallProb() > 0) {
1531  int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
1532  if (myPreviousCollisionNumber != collisions) {
1533  const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1534  if (cmd != "") {
1535  // yay! fun with dangerous commands... Never use this over the internet
1537  }
1538  myPreviousCollisionNumber = collisions;
1539  }
1540  }
1541 #endif
1542 
1543  // update performance indicators
1544  for (it = vc.loadedVehBegin(); it != end; ++it) {
1545  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1546  assert(veh != 0);
1547  if (veh->isOnRoad()) {
1548  const double vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1549  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1551  }
1552  myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
1553  }
1554  }
1557 }
1558 
1559 
1560 void
1561 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1563  getApp()->beginWaitCursor();
1564  myAmLoading = true;
1565  closeAllWindows();
1566  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1567  myLoadThread->loadConfigOrNet(file, isNet);
1568  setStatusBarText("Loading '" + file + "'.");
1569  update();
1570 }
1571 
1572 
1575  if (!myRunThread->simulationAvailable()) {
1576  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1577  return nullptr;
1578  }
1579  GUISUMOAbstractView* oldView = nullptr;
1580  if (myMDIClient->numChildren() > 0) {
1581  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1582  if (w != nullptr) {
1583  oldView = w->getView();
1584  }
1585  }
1586  std::string caption = "View #" + toString(myViewNumber++);
1587  FXuint opts = MDI_TRACKING;
1588  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1589  this, GUIIconSubSys::getIcon(ICON_SUMO_MINI), opts, 10, 10, 300, 200);
1591  if (oldView != nullptr) {
1592  // copy viewport
1593  oldView->copyViewportTo(v);
1594  }
1595  w->create();
1596  if (myMDIClient->numChildren() == 1) {
1597  w->maximize();
1598  } else {
1599  myMDIClient->vertical(true);
1600  }
1601  myMDIClient->setActiveChild(w);
1602 
1603  return v;
1604 }
1605 
1606 
1607 FXGLCanvas*
1609  if (myMDIClient->numChildren() == 0) {
1610  return nullptr;
1611  }
1612  GUISUMOViewParent* share_tmp1 =
1613  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1614  return share_tmp1->getBuildGLCanvas();
1615 }
1616 
1617 
1618 void
1620  myTrackerLock.lock();
1621  myLCDLabel->setText("----------------");
1622  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1623  (*it)->setText("-");
1624  if (it != myStatButtons.begin()) {
1625  (*it)->hide();
1626  }
1627  }
1628  // delete the simulation
1630  // reset the caption
1631  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
1632  // remove trackers and other external windows (must be delayed until deleteSim)
1633  while (!myGLWindows.empty()) {
1634  delete myGLWindows.front();
1635  }
1636  for (FXMainWindow* const window : myTrackerWindows) {
1637  delete window;
1638  }
1639  myTrackerWindows.clear();
1640  // clear selected items
1641  gSelected.clear();
1642  // add a separator to the log
1645  // remove coordinate information
1646  myGeoCoordinate->setText("N/A");
1647  myCartesianCoordinate->setText("N/A");
1648  //
1651  update();
1652 }
1653 
1654 
1655 FXCursor*
1657  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1658 }
1659 
1660 
1661 SUMOTime
1664 }
1665 
1666 
1667 double
1670 }
1671 
1672 
1673 void
1675  loadConfigOrNet("", false);
1676 }
1677 
1678 
1679 void
1680 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1681  myStatusbar->getStatusLine()->setText(text.c_str());
1682 
1683  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1684 }
1685 
1686 
1687 void
1688 GUIApplicationWindow::addRecentFile(const FX::FXString& f, const bool isNet) {
1689  if (isNet) {
1690  myRecentNets.appendFile(f);
1691  } else {
1692  myRecentConfigs.appendFile(f);
1693  }
1694 }
1695 
1696 
1697 void
1699  time -= DELTA_T; // synchronize displayed time with netstate output
1700  if (time < 0) {
1701  myLCDLabel->setText("----------------");
1702  return;
1703  }
1704  if (myAmGaming) {
1705  // show time counting backwards
1706  time = myRunThread->getSimEndTime() - time;
1707  }
1708  std::ostringstream str;
1709  str << std::setfill('0');
1710  const bool hideFraction = myAmGaming || DELTA_T % 1000 == 0;
1711  if (myShowTimeAsHMS) {
1712  SUMOTime day = time / 86400000;
1713  if (day > 0) {
1714  str << day << '-';
1715  time %= 86400000;
1716  }
1717  str << std::setw(2);
1718  str << time / 3600000 << '-';
1719  time %= 3600000;
1720  str << std::setw(2) << time / 60000 << '-';
1721  time %= 60000;
1722  }
1723  str << std::setw(2) << time / 1000;
1724  if (!hideFraction) {
1725  str << '.' << std::setw(3) << time % 1000;
1726  }
1727  myLCDLabel->setText(str.str().c_str());
1728 }
1729 
1730 
1731 long
1732 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1733  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1734  if (handled == 0 && myMDIClient->numChildren() > 0) {
1735  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1736  if (w != nullptr) {
1737  w->onKeyPress(nullptr, sel, data);
1738  }
1739  }
1740  return 0;
1741 }
1742 
1743 
1744 long
1745 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1746  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1747  if (handled == 0 && myMDIClient->numChildren() > 0) {
1748  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1749  if (w != nullptr) {
1750  w->onKeyRelease(nullptr, sel, data);
1751  }
1752  }
1753  return 0;
1754 }
1755 
1756 
1757 void
1759  myEventMutex.lock();
1760  myEvents.add(event);
1763  myEventMutex.unlock();
1764 }
1765 
1766 
1767 const std::vector<SUMOTime>
1769  myRunThread->getBreakpointLock().lock();
1770  std::vector<SUMOTime> result = myRunThread->getBreakpoints();
1771  myRunThread->getBreakpointLock().unlock();
1772  return result;
1773 }
1774 
1775 /****************************************************************************/
Locate junction - button.
Definition: GUIAppEnum.h:172
Show vehicle statistics.
Definition: GUIAppEnum.h:159
Main window-ID.
Definition: GUIAppEnum.h:46
std::vector< FXMainWindow * > myTrackerWindows
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
Event sent when the the simulation is over.
RandomDistributor< std::string > myJamSounds
FXLabel * myGeoCoordinate
long onCmdShowStats(FXObject *, FXSelector, void *)
Called on commands from the statistic buttons.
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
the thread that loads simulations
GUISUMOAbstractView * getView() const
GUICompleteSchemeStorage gSchemeStorage
void pop()
Definition: MFXEventQue.h:46
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
send when a warning occured
Definition: GUIEvent.h:46
static std::string clipped
Definition: GUIUserIO.h:61
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
void handleEvent_SimulationLoaded(GUIEvent *e)
long long int SUMOTime
Definition: SUMOTime.h:36
Show network statistics.
Definition: GUIAppEnum.h:157
FXRealSpinner * myDemandScaleSpinner
the demand scale
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:333
static void resetFont()
to be called when the font context is invalidated
Definition: GLHelper.cpp:590
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
virtual FXGLCanvas * getBuildGLCanvas() const
bool empty()
Definition: MFXEventQue.h:65
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
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
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
Save state to file.
Definition: GUIAppEnum.h:96
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:47
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
Storage for geometrical objects extended by mutexes.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
Open in netedit.
Definition: GUIAppEnum.h:130
long onCmdListParking(FXObject *, FXSelector, void *)
Toggle listing of parking vehicles.
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:311
Show person statistics.
Definition: GUIAppEnum.h:161
bool gaming
whether the application is in gaming mode or not
Locate addtional structure - button.
Definition: GUIAppEnum.h:182
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:80
const bool myOsgView
whether to load the OpenSceneGraph view
void add(T what)
Definition: MFXEventQue.h:52
GUIColorer laneColorer
The lane colorer.
Open configuration - ID.
Definition: GUIAppEnum.h:66
toogle time display mode
Definition: GUIAppEnum.h:198
const std::string & getFileName() const
long onCmdEditViewport(FXObject *, FXSelector, void *)
Called on menu Edit->Viewport.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
double y() const
Returns the y-position.
Definition: Position.h:62
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
void addRecentFile(const FX::FXString &f, const bool isNet)
GUINet & getNet() const
FXToolBarShell * myToolBarDrag4
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
static FXbool userPermitsOverwritingWhenFileExists(FXWindow *const parent, const FXString &file)
Returns true if either the file given by its name does not exist or the user allows overwriting it...
Definition: MFXUtils.cpp:41
long onCmdSaveState(FXObject *, FXSelector, void *)
Called on "save state".
bool myListParking
information whether the locator should list parking vehicles
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:45
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:280
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
void setToolBarVisibility(const bool value)
about toggled gaming status
static void initCursors(FXApp *a)
Initiate GUICursorSubSys.
double x() const
Returns the x-position.
Definition: Position.h:57
send when a debug occured
Definition: GUIEvent.h:52
int myViewNumber
The current view number.
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call ...
virtual bool simulationIsStopable() const
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
Definition: GUIDesigns.h:283
#define GUIDesignSplitter
Definition: GUIDesigns.h:308
virtual void detach()
Detaches the tool/menu bar.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
Editor for the list of chosen objects.
void setThickness(const FXint width)
set/get segment width - must be less than half the segment length
Definition: FXLCDLabel.cpp:197
FXGLVisual * myGLVisual
The gl-visual used.
#define GUIDesignMDIButtonLeft
Definition: GUIDesigns.h:125
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
bool myWasStarted
the information whether the simulation was started before
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
FXMutex myEventMutex
the mutex for the waiting semaphore
long onCmdNetedit(FXObject *, FXSelector, void *)
Called on menu Edit->Netedit.
FXString gCurrentFolder
The folder used as last.
Start the simulation.
Definition: GUIAppEnum.h:90
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:60
const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
#define GUIDesignToolBarShell2
design for first toolbar shell positioned in the same position of dock
Definition: GUIDesigns.h:289
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
#define TS
Definition: SUMOTime.h:45
void set(double x, double y)
set positions x and y
Definition: Position.h:87
void show()
sets the focus after the window is created
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:113
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:51
FXMenuCascade * mySelectLanesMenuCascade
the menu cascades
double myAlternateSimDelay
The alternate simulation delay in milliseconds for toggling.
send when a status change occured
Definition: GUIEvent.h:58
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
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:899
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
bool myListTeleporting
information whether the locator should list teleporting vehicles
virtual bool simulationIsStepable() const
void addDecals(const std::vector< Decal > &decals)
add decals
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:70
FXToolBarShell * myToolBarDrag2
Loads a file previously loaded.
Definition: GUIAppEnum.h:78
void setFgColor(FXColor clr)
set/get forground color
Definition: FXLCDLabel.cpp:120
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
const bool myViewportFromRegistry
whether loading viewport from registry
void checkGamingEvents()
handles additional game-related events
FXMenuPane * myFileMenu
the submenus
double getDelay() const
Returns the parsed delay.
Open editor for selections.
Definition: GUIAppEnum.h:126
void addSeparator()
Adds a a separator to this log window.
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:110
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:63
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)
const std::string & getMsg() const
Returns the message.
Editor for simulation breakpoints.
bool myAmGaming
information whether the gui is currently in gaming mode
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:587
bool myShowTimeAsHMS
whether to show time as hour:minute:second
void handleEvent_Message(GUIEvent *e)
static void clearTextures()
clears loaded textures
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
#define GUIDesignMDIButtonRight
MDIButton oriented to right.
Definition: GUIDesigns.h:128
static const RGBColor GREEN
Definition: RGBColor.h:185
An error occurred during the simulation step.
Definition: MSNet.h:101
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Locate polygons - button.
Definition: GUIAppEnum.h:186
void updateTimeLCD(SUMOTime time)
updates the simulation time display
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:411
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:106
FXCondition myEventCondition
the semaphore when waiting for event completion
void handleEvent_SimulationEnded(GUIEvent *e)
bool myHaveNotifiedAboutSimEnd
whether the simulation end was already announced
static double gTrackerInterval
the aggregation period for tracker windows in seconds
Definition: GUIGlobals.h:54
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:64
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:503
help button
Definition: GUIAppEnum.h:400
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:439
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
toogle delay between alternative value
Definition: GUIAppEnum.h:200
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
virtual void buildToolBars()
Builds the tool bar.
Locate person - button.
Definition: GUIAppEnum.h:178
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:161
Open a new microscopic view.
Definition: GUIAppEnum.h:104
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:316
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
virtual bool simulationIsStartable() const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Open viewport editor - button.
Definition: GUIAppEnum.h:188
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:179
FXToolBarShell * myMenuBarDrag
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:522
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:349
ViewType
Available view types.
GUIRunThread * myRunThread
the thread that runs simulations
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
Locate vehicle - button.
Definition: GUIAppEnum.h:176
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:84
GUIPerspectiveChanger & getChanger() const
get changer
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag8
FXToolBarShell * myToolBarDrag3
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:263
bool simulationAvailable() const
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
T MIN2(T a, T b)
Definition: StdDefs.h:70
The application&#39;s "About" - dialog.
FXGLCanvas * getBuildGLCanvas() const
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
Locate edge - button.
Definition: GUIAppEnum.h:174
double mySimDelay
the simulation delay in milliseconds
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
Gaming mode - menu entry.
Definition: GUIAppEnum.h:142
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Perform a single simulation step.
Definition: GUIAppEnum.h:94
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Clear simulation output.
Definition: GUIAppEnum.h:155
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:130
bool myListInternal
information whether the locator should list internal structures
long onCmdOpenShapes(FXObject *, FXSelector, void *)
Called on menu File->Load Shapes.
The dialog to change the application (gui) settings.
Send when the simulation is over;.
Definition: GUIEvent.h:63
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
std::vector< GUIGlChildWindow * > myGLWindows
FXMenuPane * mySelectByPermissions
Edit simulation breakpoints.
Definition: GUIAppEnum.h:128
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:114
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:114
virtual void fillMenuBar()
Builds the menu bar.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
GUIApplicationWindow()
FOX needs this for static members.
#define VERSION_STRING
Definition: config.h:207
Stop the simulation.
Definition: GUIAppEnum.h:92
Open view editor - button.
Definition: GUIAppEnum.h:190
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:48
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:87
#define GUIDesignBar
Definition: GUIDesigns.h:277
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
#define GUIDesignButtonToolbarText
Definition: GUIDesigns.h:77
FXToolBarShell * myToolBarDrag7
long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
static FXString assureExtension(const FXString &filename, const FXString &defaultExtension)
Corrects missing extension.
Definition: MFXUtils.cpp:71
GUIVisualizationSettings & getDefault()
Returns the default scheme.
The simulation is loading.
Definition: MSNet.h:91
FXToolBarShell * myToolBarDrag6
static const RGBColor RED
named colors
Definition: RGBColor.h:184
About SUMO - ID.
Definition: GUIAppEnum.h:82
bool listParking() const
return whether to list parking vehicles
Definition: GUIMainWindow.h:94
RandomDistributor< std::string > myCollisionSounds
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
Locate TLS - button.
Definition: GUIAppEnum.h:180
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:57
void setGroove(const FXint width)
set/get groove width - must be less than segment width
Definition: FXLCDLabel.cpp:215
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
send when a gldebug occured
Definition: GUIEvent.h:55
void prepareDestruction()
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
Locator configuration - menu entry.
Definition: GUIAppEnum.h:146
Main window closes.
Definition: GUIAppEnum.h:48
Open network - ID.
Definition: GUIAppEnum.h:68
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:140
The loading thread.
Definition: GUIAppEnum.h:114
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:369
#define GUIDesignToolBarShell1
design for first toolbar shell positioned in the next position of dock
Definition: GUIDesigns.h:286
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
MFXEventQue< GUIEvent * > myEvents
List of got requests.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:821
void setScale(double scale)
sets the demand scaling factor
send when a message occured
Definition: GUIEvent.h:43
static void close()
close GUIIconSubSys
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXEX::FXLCDLabel * myTimeLossLabel
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:144
FXHorizontalFrame * myGeoFrame
FXDockSite * myTopDock
void setStatusBarText(const std::string &text)
FXRecentFiles myRecentConfigs
List of recent config files.
SUMOTime getCurrentSimTime() const
void create()
Creates the widget.
send when a error occured
Definition: GUIEvent.h:49
void clear()
Clears the list of selected objects.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
scale traffic
Definition: GUIAppEnum.h:202
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:77
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
FXMDIClient * myMDIClient
The multi view panel.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
send when a simulation has been loaded
Definition: GUIEvent.h:37
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:114
FXRealSpinner * mySimDelaySpinner
GUIGlID getGlID() const
Returns the numerical id of the object.
FXToolBar * myToolBar1
The application tool bar.
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:221
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
double myJamSoundTime
waiting time after which vehicles trigger jam sounds
long onUpdNeedsSimulation(FXObject *, FXSelector, void *)
Determines whether some buttons which require an active simulation may be shown.
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:595
bool myAmFullScreen
whether to show the window in full screen mode
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:76
const std::string & getViewType() const
Returns the parsed view type.
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:80
#define GUIDesignSpinDial
Definition: GUIDesigns.h:318
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:62
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
long onCmdDemandScale(FXObject *, FXSelector, void *)
Called on "demand scale".
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:291
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
Called on menu Edit->Visualization.
The class responsible for building and deletion of vehicles.
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:146
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.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
long onCmdListTeleporting(FXObject *, FXSelector, void *)
Toggle listing of teleporting vehicles.
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:483
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Locate poi - button.
Definition: GUIAppEnum.h:184
Application settings - menu entry.
Definition: GUIAppEnum.h:140
void storeWindowSizeAndPos()
record window position and size in registry
void handleEvent_SimulationStep(GUIEvent *e)
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:242
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:106
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:91
int getCollisionCount() const
return the number of collisions
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:40
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
virtual void addToWindowsMenu(FXMenuPane *)
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
The Simulation execution thread.
Definition: GUIAppEnum.h:116
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:123
FXDataTarget * mySimDelayTarget
Close simulation - ID.
Definition: GUIAppEnum.h:80
The main window of the SUMO-gui.