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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // The main window of the SUMO-gui.
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #ifdef HAVE_VERSION_H
34 #include <version.h>
35 #endif
36 
37 #include <string>
38 #include <sstream>
39 #include <algorithm>
40 #include <iomanip>
41 
42 #include <guisim/GUINet.h>
43 #include <guisim/GUILane.h>
44 #include <netload/NLHandler.h>
45 #include <microsim/MSGlobals.h>
46 #include <microsim/MSEdge.h>
47 #include <microsim/MSVehicle.h>
49 #include <microsim/MSEdgeControl.h>
52 
53 #include "GUISUMOViewParent.h"
54 #include "GUILoadThread.h"
55 #include "GUIRunThread.h"
56 #include "GUIApplicationWindow.h"
59 #include "GUIEvent_Screenshot.h"
60 
61 #include <utils/common/ToString.h>
68 
69 #include <utils/xml/XMLSubSys.h>
80 #include <utils/gui/div/GLHelper.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 // ===========================================================================
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  if (myMDIClient->numChildren() > 0) {
808  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
809  if (w != 0) {
810  w->getView()->update();
811  }
812  }
813  }
814  return 1;
815 }
816 
817 long
818 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
819  getApp()->beginWaitCursor();
820  myAmLoading = true;
821  closeAllWindows();
822  myLoadThread->start();
823  setStatusBarText("Reloading.");
824  update();
825  return 1;
826 }
827 
828 
829 long
830 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
831  if (myAmLoading) {
832  myStatusbar->getStatusLine()->setText("Already loading!");
833  return 1;
834  }
835  std::string file((const char*)data);
836  loadConfigOrNet(file, sender == &myRecentNets);
837  return 1;
838 }
839 
840 
841 long
842 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
843  closeAllWindows();
844  return 1;
845 }
846 
847 
848 long
849 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
850  sender->handle(this,
851  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
852  ptr);
853  return 1;
854 }
855 
856 
857 long
858 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
859  sender->handle(this,
861  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
862  ptr);
863  return 1;
864 }
865 
866 
867 long
868 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
869  sender->handle(this,
870  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
871  ptr);
872  return 1;
873 }
874 
875 
876 long
877 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
878  sender->handle(this,
880  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
881  ptr);
882  return 1;
883 }
884 
885 
886 long
887 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
888  // check whether a net was loaded successfully
890  myStatusbar->getStatusLine()->setText("No simulation loaded!");
891  return 1;
892  }
893  // check whether it was started before and paused;
894  if (!myWasStarted) {
895  myRunThread->begin();
896  myWasStarted = true;
897  }
898  myRunThread->resume();
899  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
900  return 1;
901 }
902 
903 
904 long
905 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
906  myRunThread->stop();
907  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
908  return 1;
909 }
910 
911 
912 long
913 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
914  // check whether a net was loaded successfully
916  myStatusbar->getStatusLine()->setText("No simulation loaded!");
917  return 1;
918  }
919  // check whether it was started before and paused;
920  if (!myWasStarted) {
921  myRunThread->begin();
922  myWasStarted = true;
923  }
925  return 1;
926 }
927 
928 
929 long
930 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
934  }
935  return 1;
936 }
937 
938 
939 long
940 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
941  const SUMOTime tmp = myAlternateSimDelay;
943  mySimDelayTarget->setValue((FXdouble)tmp);
944  return 1;
945 }
946 
947 
948 long
949 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
951  return 1;
952 }
953 
954 
955 long
956 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
957  sender->handle(this,
959  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
960  ptr);
961  return 1;
962 }
963 
964 
965 long
966 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
967  sender->handle(this,
969  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
970  ptr);
971  return 1;
972 }
973 
974 
975 long
976 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
977  sender->handle(this,
979  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
980  ptr);
981  return 1;
982 }
983 
984 
985 long
986 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
987  sender->handle(this,
989  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
990  ptr);
991  return 1;
992 }
993 
994 
995 long
996 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
997  if (myMDIClient->numChildren() > 0) {
998  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
999  if (w != 0) {
1000  w->onCmdLocate(0, sel, 0);
1001  }
1002  }
1003  return 1;
1004 }
1005 
1006 
1007 long
1008 GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1009  if (myMDIClient->numChildren() > 0) {
1010  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1012  }
1013  return 1;
1014 }
1015 
1016 
1017 long
1018 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1020  d->create();
1021  d->show(PLACEMENT_OWNER);
1022  return 1;
1023 }
1024 
1025 
1026 long
1027 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1029  if (myAmGaming) {
1030  myMenuBar->hide();
1031  myStatusbar->hide();
1032  myToolBar1->hide();
1033  myToolBar2->hide();
1034  myToolBar4->hide();
1035  myToolBar5->hide();
1036  myToolBar6->show();
1037  myToolBar7->show();
1038  myMessageWindow->hide();
1042  gSchemeStorage.getDefault().gaming = true;
1043  } else {
1044  myMenuBar->show();
1045  myStatusbar->show();
1046  myToolBar1->show();
1047  myToolBar2->show();
1048  myToolBar4->show();
1049  myToolBar5->show();
1050  myToolBar6->hide();
1051  myToolBar7->hide();
1052  myMessageWindow->show();
1054  gSchemeStorage.getDefault().gaming = false;
1055  }
1056  if (myMDIClient->numChildren() > 0) {
1057  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1058  if (w != 0) {
1060  }
1061  }
1062  update();
1063  return 1;
1064 }
1065 
1066 
1067 long
1068 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1070  if (myAmFullScreen) {
1071  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1072  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1073  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1074  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1075  maximize();
1076  setDecorations(DECOR_NONE);
1077  place(PLACEMENT_MAXIMIZED);
1078  myMenuBar->hide();
1079  myStatusbar->hide();
1080  myToolBar1->hide();
1081  myToolBar2->hide();
1082  myToolBar3->hide();
1083  myToolBar4->hide();
1084  myToolBar5->hide();
1085  myToolBar6->hide();
1086  myToolBar7->hide();
1087  myMessageWindow->hide();
1088  if (myMDIClient->numChildren() > 0) {
1089  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1090  if (w != 0) {
1091  w->setToolBarVisibility(false);
1092  }
1093  }
1094  update();
1095  } else {
1096  place(PLACEMENT_VISIBLE);
1097  setDecorations(DECOR_ALL);
1098  restore();
1099  myToolBar3->show();
1101  onCmdGaming(0, 0, 0);
1102  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1103  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1104  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1105  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1106  }
1107  return 1;
1108 }
1109 
1110 
1111 long
1112 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1114  return 1;
1115 }
1116 
1117 
1118 long
1119 GUIApplicationWindow::onCmdListParking(FXObject*, FXSelector, void*) {
1121  return 1;
1122 }
1123 
1124 long
1125 GUIApplicationWindow::onCmdListTeleporting(FXObject*, FXSelector, void*) {
1127  return 1;
1128 }
1129 
1130 
1131 long
1132 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1134  return 1;
1135 }
1136 
1137 
1138 #ifdef HAVE_OSG
1139 long
1140 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1142  return 1;
1143 }
1144 #endif
1145 
1146 
1147 long
1148 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1149  GUIDialog_AboutSUMO* about = new GUIDialog_AboutSUMO(this);
1150  about->create();
1151  about->show(PLACEMENT_OWNER);
1152  return 1;
1153 }
1154 
1155 
1156 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1157  FXEvent* event = (FXEvent*)ptr;
1158  FXString string = GUIUserIO::clipped.c_str();
1159  setDNDData(FROM_CLIPBOARD, event->target, string);
1160  return 1;
1161 }
1162 
1163 
1164 long
1165 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1166  eventOccured();
1167  return 1;
1168 }
1169 
1170 
1171 long
1172 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1173  eventOccured();
1174  return 1;
1175 }
1176 
1177 
1178 void
1180  while (!myEvents.empty()) {
1181  // get the next event
1182  GUIEvent* e = myEvents.top();
1183  myEvents.pop();
1184  // process
1185  switch (e->getOwnType()) {
1188  break;
1189  case EVENT_SIMULATION_STEP:
1190  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1192  }
1193  break;
1194  case EVENT_MESSAGE_OCCURED:
1195  case EVENT_WARNING_OCCURED:
1196  case EVENT_ERROR_OCCURED:
1197  case EVENT_STATUS_OCCURED:
1199  break;
1202  break;
1203  case EVENT_SCREENSHOT:
1205  break;
1206  default:
1207  break;
1208  }
1209  delete e;
1210  }
1211  myToolBar2->forceRefresh();
1212  myToolBar3->forceRefresh();
1213 }
1214 
1215 
1216 void
1218  myAmLoading = false;
1220  // check whether the loading was successfull
1221  if (ec->myNet == 0) {
1222  // report failure
1223  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1224  if (GUIGlobals::gQuitOnEnd) {
1225  closeAllWindows();
1226  getApp()->exit(1);
1227  }
1228  } else {
1229  if (OptionsCont::getOptions().getBool("game")) {
1230  onCmdGaming(0, 0, 0);
1231  }
1232  // initialise simulation thread
1233  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1234  if (GUIGlobals::gQuitOnEnd) {
1235  closeAllWindows();
1236  getApp()->exit(1);
1237  }
1238  } else {
1239  // report success
1240  setStatusBarText("'" + ec->myFile + "' loaded.");
1242  myWasStarted = false;
1243  myHaveNotifiedAboutSimEnd = false;
1244  // initialise views
1245  myViewNumber = 0;
1247  if (ec->mySettingsFiles.size() > 0) {
1248  // open a view for each file and apply settings
1249  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1250  GUISettingsHandler settings(*it);
1251  GUISUMOViewParent::ViewType vt = defaultType;
1252  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1254  }
1255  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1257  }
1258  GUISUMOAbstractView* view = openNewView(vt);
1259  if (view == 0) {
1260  break;
1261  }
1262  std::string settingsName = settings.addSettings(view);
1263  view->addDecals(settings.getDecals());
1264  settings.applyViewport(view);
1265  settings.setSnapshots(view);
1266  if (settings.getDelay() > 0) {
1267  mySimDelayTarget->setValue(settings.getDelay());
1268  }
1269  if (settings.getBreakpoints().size() > 0) {
1270  myRunThread->getBreakpointLock().lock();
1271  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1272  myRunThread->getBreakpointLock().unlock();
1273  }
1274  myJamSounds = settings.getEventDistribution("jam");
1275  myCollisionSounds = settings.getEventDistribution("collision");
1276  if (settings.getJamSoundTime() > 0) {
1277  myJamSoundTime = settings.getJamSoundTime();
1278  }
1279  }
1280  } else {
1281  openNewView(defaultType);
1282  }
1283 
1284  if (isGaming()) {
1285  setTitle("SUMO Interactive Traffic Light");
1286  } else {
1287  // set simulation name on the caption
1288  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1289  }
1290  // set simulation step begin information
1291  myLCDLabel->setText("----------------");
1292  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1293  (*it)->setText("-");
1294  }
1295  }
1296  }
1297  getApp()->endWaitCursor();
1298  // start if wished
1300  onCmdStart(0, 0, 0);
1301  }
1302  update();
1303 }
1304 
1305 
1306 void
1308  updateChildren();
1310  const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1311  const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1312  if (backlog > running) {
1313  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_GREENVEHICLE)) {
1315  }
1316  } else {
1317  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_YELLOWVEHICLE)) {
1319  }
1320  }
1321  myStatButtons.front()->setText(toString(running).c_str());
1322  if (myRunThread->getNet().hasPersons()) {
1323  if (!myStatButtons[1]->shown()) {
1324  myStatButtons[1]->show();
1325  }
1327  }
1328  if (myRunThread->getNet().hasContainers()) {
1329  if (!myStatButtons[2]->shown()) {
1330  myStatButtons[2]->show();
1331  }
1333  }
1334  if (myAmGaming) {
1336  }
1338  getApp()->forceRefresh(); // restores keyboard focus
1339  }
1340  update();
1341 }
1342 
1343 
1344 void
1346  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1347  if (ec->getOwnType() == EVENT_STATUS_OCCURED) {
1348  setStatusBarText(ec->getMsg());
1349  } else {
1350  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1351  }
1352 }
1353 
1354 
1355 void
1357  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1358  onCmdStop(0, 0, 0);
1359  if (ec->getReason() == MSNet::SIMSTATE_LOADING) {
1360  onCmdReload(0, 0, 0);
1361  } else if (GUIGlobals::gQuitOnEnd) {
1362  closeAllWindows();
1363  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1364  } else if (GUIGlobals::gDemoAutoReload) {
1365  onCmdReload(0, 0, 0);
1366  } else if (!myHaveNotifiedAboutSimEnd) {
1367  // build the text
1368  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1369  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1370  "\nDo you want to close all open files and views?";
1371  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1372  if (answer == 1) { //1:yes, 2:no, 4:esc
1373  closeAllWindows();
1374  }
1376  }
1377 }
1378 
1379 
1380 void
1382  GUIEvent_Screenshot* ec = static_cast<GUIEvent_Screenshot*>(e);
1383  myEventMutex.lock();
1384  const std::string error = ec->myView->makeSnapshot(ec->myFile);
1385  if (error != "") {
1386  WRITE_WARNING(error);
1387  }
1388  myEventCondition.signal();
1389  myEventMutex.unlock();
1390 }
1391 
1392 
1393 void
1398 #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1399  if (myJamSounds.getOverallProb() > 0) {
1400  // play honking sound if some vehicle is waiting too long
1401  for (; it != end; ++it) {
1402  // XXX use impatience instead of waiting time ?
1403  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1404  const std::string cmd = myJamSounds.get(&myGamingRNG);
1405  if (cmd != "") {
1406  // yay! fun with dangerous commands... Never use this over the internet
1408  // one sound per simulation step is enough
1409  break;
1410  }
1411  }
1412  }
1413  }
1414  if (myCollisionSounds.getOverallProb() > 0) {
1415  int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
1416  if (myPreviousCollisionNumber != collisions) {
1417  const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1418  if (cmd != "") {
1419  // yay! fun with dangerous commands... Never use this over the internet
1421  }
1422  myPreviousCollisionNumber = collisions;
1423  }
1424  }
1425 #endif
1426 
1427  // update performance indicators
1428  for (it = vc.loadedVehBegin(); it != end; ++it) {
1429  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1430  assert(veh != 0);
1431  if (veh->isOnRoad()) {
1432  const double vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1433  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1435  }
1436  myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
1437  }
1438  }
1441 }
1442 
1443 
1444 void
1445 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1446  getApp()->beginWaitCursor();
1447  myAmLoading = true;
1448  closeAllWindows();
1449  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1450  myLoadThread->loadConfigOrNet(file, isNet);
1451  setStatusBarText("Loading '" + file + "'.");
1452  update();
1453 }
1454 
1455 
1458  if (!myRunThread->simulationAvailable()) {
1459  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1460  return 0;
1461  }
1462  GUISUMOAbstractView* oldView = 0;
1463  if (myMDIClient->numChildren() > 0) {
1464  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1465  if (w != 0) {
1466  oldView = w->getView();
1467  }
1468  }
1469  std::string caption = "View #" + toString(myViewNumber++);
1470  FXuint opts = MDI_TRACKING;
1471  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1472  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1475  if (oldView != 0) {
1476  // copy viewport
1477  oldView->copyViewportTo(v);
1478  }
1479  w->create();
1480  if (myMDIClient->numChildren() == 1) {
1481  w->maximize();
1482  } else {
1483  myMDIClient->vertical(true);
1484  }
1485  myMDIClient->setActiveChild(w);
1486 
1487  return v;
1488 }
1489 
1490 
1491 FXGLCanvas*
1493  if (myMDIClient->numChildren() == 0) {
1494  return 0;
1495  }
1496  GUISUMOViewParent* share_tmp1 =
1497  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1498  return share_tmp1->getBuildGLCanvas();
1499 }
1500 
1501 
1502 void
1504  myTrackerLock.lock();
1505  myLCDLabel->setText("----------------");
1506  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1507  (*it)->setText("-");
1508  if (it != myStatButtons.begin()) {
1509  (*it)->hide();
1510  }
1511  }
1512  // remove trackers and other external windows
1513  int i;
1514  for (i = 0; i < (int)mySubWindows.size(); ++i) {
1515  mySubWindows[i]->destroy();
1516  }
1517  for (i = 0; i < (int)myTrackerWindows.size(); ++i) {
1518  myTrackerWindows[i]->destroy();
1519  }
1520  // delete the simulation
1522  // reset the caption
1523  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
1524  // delete other children
1525  while (myTrackerWindows.size() != 0) {
1526  delete myTrackerWindows[0];
1527  }
1528  while (mySubWindows.size() != 0) {
1529  delete mySubWindows[0];
1530  }
1531  mySubWindows.clear();
1532  // clear selected items
1533  gSelected.clear();
1534  // add a separator to the log
1537  // remove coordinate information
1538  myGeoCoordinate->setText("N/A");
1539  myCartesianCoordinate->setText("N/A");
1540  //
1543  update();
1544 }
1545 
1546 
1547 FXCursor*
1549  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1550 }
1551 
1552 
1553 SUMOTime
1556 }
1557 
1558 
1559 double
1562 }
1563 
1564 
1565 void
1567  loadConfigOrNet("", false);
1568 }
1569 
1570 
1571 void
1572 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1573  myStatusbar->getStatusLine()->setText(text.c_str());
1574 
1575  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1576 }
1577 
1578 
1579 void
1580 GUIApplicationWindow::addRecentFile(const FX::FXString& f, const bool isNet) {
1581  if (isNet) {
1582  myRecentNets.appendFile(f);
1583  } else {
1584  myRecentConfigs.appendFile(f);
1585  }
1586 }
1587 
1588 
1589 void
1591  time -= DELTA_T; // synchronize displayed time with netstate output
1592  if (time < 0) {
1593  myLCDLabel->setText("----------------");
1594  return;
1595  }
1596  if (myAmGaming) {
1597  // show time counting backwards
1598  time = myRunThread->getSimEndTime() - time;
1599  }
1600  std::ostringstream str;
1601  str << std::setfill('0');
1602  const bool hideFraction = myAmGaming || DELTA_T % 1000 == 0;
1603  if (myShowTimeAsHMS) {
1604  SUMOTime day = time / 86400000;
1605  if (day > 0) {
1606  str << day << '-';
1607  time %= 86400000;
1608  }
1609  str << std::setw(2);
1610  str << time / 3600000 << '-';
1611  time %= 3600000;
1612  str << std::setw(2) << time / 60000 << '-';
1613  time %= 60000;
1614  }
1615  str << std::setw(2) << time / 1000;
1616  if (!hideFraction) {
1617  str << '.' << std::setw(3) << time % 1000;
1618  }
1619  myLCDLabel->setText(str.str().c_str());
1620 }
1621 
1622 
1623 long
1624 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1625  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1626  if (handled == 0 && myMDIClient->numChildren() > 0) {
1627  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1628  if (w != 0) {
1629  w->onKeyPress(0, sel, data);
1630  }
1631  }
1632  return 0;
1633 }
1634 
1635 
1636 long
1637 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1638  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1639  if (handled == 0 && myMDIClient->numChildren() > 0) {
1640  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1641  if (w != 0) {
1642  w->onKeyRelease(0, sel, data);
1643  }
1644  }
1645  return 0;
1646 }
1647 
1648 
1649 void
1651  myEventMutex.lock();
1652  myEvents.add(event);
1655  myEventMutex.unlock();
1656 }
1657 
1658 
1659 /****************************************************************************/
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
Locate poi - button.
Definition: GUIAppEnum.h:184
GUISUMOAbstractView * getView() const
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:76
GUICompleteSchemeStorage gSchemeStorage
Show vehicle statistics.
Definition: GUIAppEnum.h:159
void pop()
Definition: MFXEventQue.h:52
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
Show network statistics.
Definition: GUIAppEnum.h:157
static std::string clipped
Definition: GUIUserIO.h:63
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.
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:323
static void resetFont()
to be called when the font context is invalidated
Definition: GLHelper.cpp:466
Locate person - button.
Definition: GUIAppEnum.h:178
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.
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
virtual FXGLCanvas * getBuildGLCanvas() const
send when a message occured
Definition: GUIEvent.h:49
Start the simulation.
Definition: GUIAppEnum.h:94
bool empty()
Definition: MFXEventQue.h:71
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...
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:53
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
long onCmdListParking(FXObject *, FXSelector, void *)
Toggle listing of parking vehicles.
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:296
bool gaming
whether the application is in gaming mode or not
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:81
const bool myOsgView
whether to load the OpenSceneGraph view
void add(T what)
Definition: MFXEventQue.h:58
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:80
The Simulation delay control.
Definition: GUIAppEnum.h:150
GUIColorer laneColorer
The lane colorer.
const std::string & getFileName() const
Locate junction - button.
Definition: GUIAppEnum.h:172
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
void addRecentFile(const FX::FXString &f, const bool isNet)
GUINet & getNet() const
FXToolBarShell * myToolBarDrag4
toogle delay between alternative value
Definition: GUIAppEnum.h:200
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.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:51
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:265
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
void setToolBarVisibility(const bool value)
about toggled gaming status
Open editor for selections.
Definition: GUIAppEnum.h:128
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:268
#define GUIDesignSplitter
Definition: GUIDesigns.h:293
virtual void detach()
Detaches the tool/menu bar.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
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:203
FXGLVisual * myGLVisual
The gl-visual used.
#define GUIDesignMDIButtonLeft
Definition: GUIDesigns.h:123
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
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.
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:144
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:274
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
#define TS
Definition: SUMOTime.h:51
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:109
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:57
help button
Definition: GUIAppEnum.h:396
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:846
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.
The loading thread.
Definition: GUIAppEnum.h:116
bool myListTeleporting
information whether the locator should list teleporting vehicles
virtual bool simulationIsStepable() const
void addDecals(const std::vector< Decal > &decals)
add decals
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
Perform a single simulation step.
Definition: GUIAppEnum.h:98
FXToolBarShell * myToolBarDrag2
void setFgColor(FXColor clr)
set/get forground color
Definition: FXLCDLabel.cpp:126
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
void checkGamingEvents()
handles additional game-related events
FXMenuPane * myFileMenu
the submenus
double getDelay() const
Returns the parsed delay.
void addSeparator()
Adds a a separator to this log window.
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:114
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:69
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.
const std::string myFile
the name of the file to save to
bool myAmGaming
information whether the gui is currently in gaming mode
Gaming mode - menu entry.
Definition: GUIAppEnum.h:142
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:586
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
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
#define GUIDesignMDIButtonRight
MDIButton oriented to right.
Definition: GUIDesigns.h:126
Loads a file previously loaded.
Definition: GUIAppEnum.h:82
Stop the simulation.
Definition: GUIAppEnum.h:96
Locator configuration - menu entry.
Definition: GUIAppEnum.h:146
static const RGBColor GREEN
Definition: RGBColor.h:179
An error occured during the simulation step.
Definition: MSNet.h:107
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
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:55
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:416
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:60
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:70
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:506
std::set< SUMOTime > & getSnapshots()
Definition: GUIRunThread.h:122
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:429
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
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:167
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:306
Clear simulation output.
Definition: GUIAppEnum.h:155
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)
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:185
FXToolBarShell * myMenuBarDrag
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:505
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:339
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".
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:86
GUIPerspectiveChanger & getChanger() const
get changer
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
bool simulationAvailable() const
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
T MIN2(T a, T b)
Definition: StdDefs.h:67
The application&#39;s "About" - dialog.
FXGLCanvas * getBuildGLCanvas() const
bool myAmFullScreen
whether to show the window in full screen mode
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
Locate polygons - button.
Definition: GUIAppEnum.h:186
send when a error occured
Definition: GUIEvent.h:55
Send when a screenshot is requested; View and file name are stored within the event.
Definition: GUIEvent.h:66
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:136
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; The reason and the time step are stored within the event...
Definition: GUIEvent.h:62
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::string makeSnapshot(const std::string &destFile)
Takes a snapshots and writes it into the given file.
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:108
FXMenuPane * mySelectByPermissions
Open network - ID.
Definition: GUIAppEnum.h:74
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:118
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:119
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:210
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:54
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:93
#define GUIDesignBar
Definition: GUIDesigns.h:262
FXMenuBar * myMenuBar
The application menu bar.
Application settings - menu entry.
Definition: GUIAppEnum.h:140
FXToolBarShell * myToolBarDrag5
#define GUIDesignButtonToolbarText
Definition: GUIDesigns.h:78
About SUMO - ID.
Definition: GUIAppEnum.h:86
FXToolBarShell * myToolBarDrag7
long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
GUIVisualizationSettings & getDefault()
Returns the default scheme.
The simulation is loading.
Definition: MSNet.h:97
GUISUMOAbstractView *const myView
the view to save
FXToolBarShell * myToolBarDrag6
static const RGBColor RED
named colors
Definition: RGBColor.h:178
bool listParking() const
return whether to list parking vehicles
Definition: GUIMainWindow.h:96
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:63
void setGroove(const FXint width)
set/get groove width - must be less than segment width
Definition: FXLCDLabel.cpp:221
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
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.
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:146
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:359
#define GUIDesignToolBarShell1
design for first toolbar shell positioned in the next position of dock
Definition: GUIDesigns.h:271
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:777
Open a new microscopic view.
Definition: GUIAppEnum.h:106
static void close()
close GUIIconSubSys
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
Locate vehicle - button.
Definition: GUIAppEnum.h:176
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
Open configuration - ID.
Definition: GUIAppEnum.h:72
FXEX::FXLCDLabel * myTimeLossLabel
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
Locate addtional structure - button.
Definition: GUIAppEnum.h:182
Main window-ID.
Definition: GUIAppEnum.h:52
FXDockSite * myTopDock
void setStatusBarText(const std::string &text)
FXRecentFiles myRecentConfigs
List of recent config files.
SUMOTime getCurrentSimTime() const
The Simulation execution thread.
Definition: GUIAppEnum.h:118
FXdouble getValue() const
Return current value.
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:83
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
FXMDIClient * myMDIClient
The multi view panel.
Close simulation - ID.
Definition: GUIAppEnum.h:84
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
send when a simulation has been loaded
Definition: GUIEvent.h:43
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
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:120
send when a warning occured
Definition: GUIEvent.h:52
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:215
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.
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
const std::string & getViewType() const
Returns the parsed view type.
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:83
#define GUIDesignSpinDial
Definition: GUIDesigns.h:303
Locate edge - button.
Definition: GUIAppEnum.h:174
long long int SUMOTime
Definition: TraCIDefs.h:51
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:68
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
Locate TLS - button.
Definition: GUIAppEnum.h:180
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:276
Show person statistics.
Definition: GUIAppEnum.h:161
The class responsible for building and deletion of vehicles.
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:152
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:482
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Edit simulation breakpoints.
Definition: GUIAppEnum.h:130
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:110
static std::mt19937 myGamingRNG
A random number generator used to choose a gaming sound.
toogle time display mode
Definition: GUIAppEnum.h:198
GUISelectedStorage gSelected
A global holder of selected objects.
static bool gUseMesoSim
Definition: MSGlobals.h:97
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:46
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.
send when a status change occured
Definition: GUIEvent.h:58
FXMutex & getSnapshotsLock()
Definition: GUIRunThread.h:126
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
virtual void addToWindowsMenu(FXMenuPane *)
Open in netedit.
Definition: GUIAppEnum.h:132
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:128
Main window closes.
Definition: GUIAppEnum.h:54
void setApplicationSnapshots(std::set< SUMOTime > *snapshots, FXMutex *lock)
add snapshot synchronization
The main window of the SUMO-gui.