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