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