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