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-2016 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>
87 #include "GUIGlobals.h"
91 
92 #ifdef CHECK_MEMORY_LEAKS
93 #include <foreign/nvwa/debug_new.h>
94 #endif
95 
96 //#define HAVE_DANGEROUS_SOUNDS
97 
98 // ===========================================================================
99 // FOX-declarations
100 // ===========================================================================
101 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
102  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
103  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
104  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
105 
109  FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
110  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
111  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
112  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
114  FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
115 
117  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
118  FXMAPFUNC(SEL_COMMAND, MID_FULLSCREEN, GUIApplicationWindow::onCmdFullScreen),
120  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
121  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
122 #ifdef HAVE_OSG
123  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
124 #endif
125  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
126  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
127  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
131 
135 
136  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
137  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
138  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
139  FXMAPFUNC(SEL_UPDATE, MID_OPEN_SHAPES, GUIApplicationWindow::onUpdReload),
140  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
143 #ifdef HAVE_OSG
144  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
145 #endif
146  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
147  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
148  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
152  FXMAPFUNC(SEL_COMMAND, MID_HELP, GUIApplicationWindow::onCmdHelp),
153 
154  // forward requests to the active view
155  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
156  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
157  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
158  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
159  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
160  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
161  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
162  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
171  FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
172  FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
173 
174  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
175 
180 };
181 
182 // Object implementation
183 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
184 
185 // ===========================================================================
186 // static members
187 // ===========================================================================
188 MTRand GUIApplicationWindow::myGamingRNG;
189 
190 // ===========================================================================
191 // member method definitions
192 // ===========================================================================
194  const std::string& configPattern)
195  : GUIMainWindow(a),
196  myLoadThread(0), myRunThread(0),
197  myAmLoading(false),
198  myAlternateSimDelay(0),
199  myRecentNets(a, "nets"), myConfigPattern(configPattern),
200  hadDependentBuild(false),
201  myShowTimeAsHMS(false),
202  myAmFullScreen(false),
203  myHaveNotifiedAboutSimEnd(false),
204  // game specific
205  myJamSoundTime(60),
206  myPreviousCollisionNumber(0),
207  myWaitingTime(0),
208  myTimeLoss(0) {
210 }
211 
212 
213 void
215  // don't do this twice
216  if (hadDependentBuild) {
217  return;
218  }
219  hadDependentBuild = true;
220 
221  setTarget(this);
222  setSelector(MID_WINDOW);
223 
224  // build menu bar
225  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
226  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
227  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
228  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
229  TOOLBARGRIP_DOUBLE);
230  buildToolBars();
231  // build the thread - io
236 
237  // build the status bar
238  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
239  {
240  myGeoFrame =
241  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
242  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
243  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
245  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
246  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
247  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
250  myStatButtons.back()->hide();
251  myStatButtons.push_back(new FXButton(myStatusbar, "-", GUIIconSubSys::getIcon(ICON_GREENEDGE), this, MID_SHOWVEHSTATS));
252  myStatButtons.back()->hide();
253  }
254 
255  // make the window a mdi-window
256  myMainSplitter = new FXSplitter(this,
257  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
258  myMDIClient = new FXMDIClient(myMainSplitter,
259  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
260  myMDIMenu = new FXMDIMenu(this, myMDIClient);
261  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
262  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
263  new FXMDIDeleteButton(myMenuBar, myMDIClient,
264  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
265  new FXMDIRestoreButton(myMenuBar, myMDIClient,
266  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
267  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
268  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
269 
270  // build the message window
272  // fill menu and tool bar
273  fillMenuBar();
274  myToolBar6->hide();
275  myToolBar7->hide();
276  // build additional threads
277  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
278  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
280  // set the status bar
281  myStatusbar->getStatusLine()->setText("Ready.");
282  // set the caption
283  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
284 
285  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
286  myRunThread->start();
288 }
289 
290 
291 void
293  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
294  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
295  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
296  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
297  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
298  }
299  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
300  FXMainWindow::create();
301  myMenuBarDrag->create();
302  myToolBarDrag1->create();
303  myToolBarDrag2->create();
304  myToolBarDrag3->create();
305  myToolBarDrag4->create();
306  myToolBarDrag5->create();
307  myToolBarDrag6->create();
308  myToolBarDrag7->create();
309  myFileMenu->create();
310  mySelectByPermissions->create();
311  myEditMenu->create();
312  mySettingsMenu->create();
313  myLocatorMenu->create();
314  myControlMenu->create();
315  myWindowsMenu->create();
316  myHelpMenu->create();
317 
318  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
319  myCartesianFrame->setWidth(width);
320  myGeoFrame->setWidth(width);
321 
322  show(PLACEMENT_SCREEN);
323  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
324  maximize();
325  }
326  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
327  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
328 }
329 
330 
333  myRunThread->join();
334  closeAllWindows();
335  //
337  delete myGLVisual;
338  // delete some non-parented windows
339  delete myToolBarDrag1;
340  //
341  delete myRunThread;
342  delete myFileMenu;
343  delete myEditMenu;
344  delete mySelectByPermissions;
345  delete mySettingsMenu;
346  delete myLocatorMenu;
347  delete myControlMenu;
348  delete myWindowsMenu;
349  delete myHelpMenu;
350 
351  delete myLoadThread;
352 
353  while (!myEvents.empty()) {
354  // get the next event
355  GUIEvent* e = myEvents.top();
356  myEvents.pop();
357  delete e;
358  }
359 }
360 
361 
362 void
364  FXMainWindow::detach();
365  myMenuBarDrag->detach();
366  myToolBarDrag1->detach();
367 }
368 
369 
370 void
372  // build file menu
373  myFileMenu = new FXMenuPane(this);
374  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
375  new FXMenuCommand(myFileMenu,
376  "&Open Simulation...\tCtrl+O\tOpen a simulation (Configuration file).",
378  new FXMenuCommand(myFileMenu,
379  "Open &Network...\tCtrl+N\tOpen a network.",
381  new FXMenuCommand(myFileMenu,
382  "Open Shapes \tCtrl+P\tLoad POIs and Polygons for visualization.",
384  new FXMenuCommand(myFileMenu,
385  "&Reload\tCtrl+R\tReloads the simulation / the network.",
387  new FXMenuSeparator(myFileMenu);
388  new FXMenuCommand(myFileMenu,
389  "Close\tCtrl+W\tClose the simulation.",
391  // Recent files
392  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
393  sep1->setTarget(&myRecentConfigs);
394  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
395  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
396  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
397  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
398  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
399  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
400  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
401  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
402  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
405  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
406  myRecentConfigs.setTarget(this);
407  myRecentConfigs.setSelector(MID_RECENTFILE);
408  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
409  sep2->setTarget(&myRecentNets);
410  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
411  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
412  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
413  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
414  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
415  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
416  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
417  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
418  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
419  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
420  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
421  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
422  myRecentNets.setTarget(this);
423  myRecentNets.setSelector(MID_RECENTFILE);
424  new FXMenuSeparator(myFileMenu);
425  new FXMenuCommand(myFileMenu,
426  "&Quit\tCtrl+Q\tQuit the Application.",
427  0, this, MID_QUIT, 0);
428 
429  // build edit menu
430  mySelectByPermissions = new FXMenuPane(this);
431  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
432  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
433  new FXMenuCommand(mySelectByPermissions,
434  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
435  }
436 
437  myEditMenu = new FXMenuPane(this);
438  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
439  new FXMenuCommand(myEditMenu,
440  "Edit Selected...\tCtrl+E\tOpens a dialog for editing the list of selected items.",
442  new FXMenuCascade(myEditMenu,
443  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
445  new FXMenuSeparator(myEditMenu);
446  new FXMenuCommand(myEditMenu,
447  "Edit Breakpoints...\tCtrl+B\tOpens a dialog for editing breakpoints.",
448  0, this, MID_EDIT_BREAKPOINTS);
449  new FXMenuSeparator(myEditMenu);
450  new FXMenuCommand(myEditMenu,
451  "Open in Netedit...\tCtrl+T\tOpens the netedit application with the current network.",
452  0, this, MID_NETEDIT);
453 
454  // build settings menu
455  mySettingsMenu = new FXMenuPane(this);
456  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
457  new FXMenuCommand(mySettingsMenu,
458  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
459  NULL, this, MID_APPSETTINGS);
460  new FXMenuCheck(mySettingsMenu,
461  "Gaming Mode\tCtrl+G\tToggle gaming mode on/off.",
462  this, MID_GAMING);
463  new FXMenuCheck(mySettingsMenu,
464  "Full Screen Mode\tCtrl+F\tToggle full screen mode on/off.",
465  this, MID_FULLSCREEN);
466  // build Locate menu
467  myLocatorMenu = new FXMenuPane(this);
468  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
469  new FXMenuCommand(myLocatorMenu,
470  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
472  new FXMenuCommand(myLocatorMenu,
473  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
475  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
476  new FXMenuCommand(myLocatorMenu,
477  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
479  }
480  new FXMenuCommand(myLocatorMenu,
481  "Locate &Persons\t\tOpen a Dialog for Locating a Person.",
483  new FXMenuCommand(myLocatorMenu,
484  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
486  new FXMenuCommand(myLocatorMenu,
487  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
489  new FXMenuCommand(myLocatorMenu,
490  "Locate P&oI\t\tOpen a Dialog for Locating a Point of Intereset.",
492  new FXMenuCommand(myLocatorMenu,
493  "Locate Po&lygon\t\tOpen a Dialog for Locating a Polygon.",
495  new FXMenuSeparator(myLocatorMenu);
496  new FXMenuCheck(myLocatorMenu,
497  "Show Internal Structures\t\tShow internal junctions and streets in locator dialog.",
498  this, MID_LISTINTERNAL);
499  // build control menu
500  myControlMenu = new FXMenuPane(this);
501  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
502  new FXMenuCommand(myControlMenu,
503  "Run\tCtrl+A\tStart running the simulation.",
504  NULL, this, MID_START);
505  new FXMenuCommand(myControlMenu,
506  "Stop\tCtrl+S\tStop running the simulation.",
507  NULL, this, MID_STOP);
508  new FXMenuCommand(myControlMenu,
509  "Step\tCtrl+D\tPerform one simulation step.",
510  NULL, this, MID_STEP);
511 
512  // build windows menu
513  myWindowsMenu = new FXMenuPane(this);
514  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
515  new FXMenuCheck(myWindowsMenu,
516  "Show Status Line\t\tToggle the Status Bar on/off.",
517  myStatusbar, FXWindow::ID_TOGGLESHOWN);
518  new FXMenuCheck(myWindowsMenu,
519  "Show Message Window\t\tToggle the Message Window on/off.",
520  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
521  new FXMenuCheck(myWindowsMenu,
522  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
523  myToolBar3, FXWindow::ID_TOGGLESHOWN);
524  new FXMenuCheck(myWindowsMenu,
525  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
526  myToolBar4, FXWindow::ID_TOGGLESHOWN);
528  new FXMenuSeparator(myWindowsMenu);
529  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
531  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
532  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
534  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
535  new FXMenuCommand(myWindowsMenu, "Cascade",
537  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
538  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
539  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
540  sep1 = new FXMenuSeparator(myWindowsMenu);
541  sep1->setTarget(myMDIClient);
542  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
543  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
544  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
545  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
546  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
547  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
548  new FXMenuSeparator(myWindowsMenu);
549  new FXMenuCommand(myWindowsMenu,
550  "Clear Message Window\t\tClear the message window.",
551  0, this, MID_CLEARMESSAGEWINDOW);
552 
553  // build help menu
554  myHelpMenu = new FXMenuPane(this);
555  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
556  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
557  new FXMenuCommand(myHelpMenu, "&About", GUIIconSubSys::getIcon(ICON_APP),
558  this, MID_ABOUT);
559 }
560 
561 
562 void
564  // build tool bars
565  {
566  // file and simulation tool bar
567  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
568  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
569  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
570  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
571  TOOLBARGRIP_DOUBLE);
572  // build file tools
573  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
575  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
576  new FXButton(myToolBar1, "\t\tOpen a network.",
578  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
579  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
581  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
582  }
583  {
584  // build simulation tools
585  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
586  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
587  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
588  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
589  TOOLBARGRIP_DOUBLE);
590  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
592  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
593  new FXButton(myToolBar2, "\t\tStop the running simulation.",
595  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
596  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
598  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
599  }
600  {
601  // Simulation Step Display
602  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
603  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
604  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
605  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
606  TOOLBARGRIP_DOUBLE);
607  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
608  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
609  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
613  myLCDLabel->setGroove(2);
614  myLCDLabel->setText("-------------");
615  }
616  {
617  // Simulation Delay
618  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
619  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
620  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
621  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
622  TOOLBARGRIP_DOUBLE);
623  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
624  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
627  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
629  mySimDelayTarget->setIncrements(1, 10, 10);
630  mySimDelayTarget->setRange(0, 1000);
632  }
633  {
634  // Views
635  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
636  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
637  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
638  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
639  TOOLBARGRIP_DOUBLE);
640  // build view tools
641  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
643  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
644 #ifdef HAVE_OSG
645  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
647  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
648 #endif
649  }
650  {
652  // total waitingTime
653  myToolBarDrag6 = new FXToolBarShell(this, FRAME_NORMAL);
654  myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
655  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
656  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
657  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, 0, 0, JUSTIFY_RIGHT);
662  myWaitingTimeLabel->setText("-------------");
663 
664  // idealistic time loss
665  myToolBarDrag7 = new FXToolBarShell(this, FRAME_NORMAL);
666  myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
667  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
668  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);
669  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, 0, 0, JUSTIFY_RIGHT);
674  myTimeLossLabel->setText("-------------");
675  }
676 }
677 
678 
679 long
680 GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
681  if (!myAmFullScreen) {
682  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
683  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
684  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
685  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
686  }
687  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
688  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
689  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
690  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", myAlternateSimDelay);
691  getApp()->exit(0);
692  return 1;
693 }
694 
695 
696 long
697 GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
698  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
699  if (mc->getText() == "Edit Selected...") {
700  GUIDialog_GLChosenEditor* chooser =
702  chooser->create();
703  chooser->show();
704  } else {
706  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
707  for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
708  const std::vector<MSLane*>& lanes = (*i)->getLanes();
709  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
710  GUILane* lane = dynamic_cast<GUILane*>(*it);
711  assert(lane != 0);
712  if ((lane->getPermissions() & svc) != 0) {
713  gSelected.select(lane->getGlID());
714  }
715  }
716  }
717  if (myMDIClient->numChildren() > 0) {
718  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
719  if (w != 0) {
720  // color by selection
722  }
723  }
724  }
725  updateChildren();
726  }
727  return 1;
728 }
729 
730 
731 long
732 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
734  chooser->create();
735  chooser->show();
736  return 1;
737 }
738 
739 
740 long
741 GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
742  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/SUMO-GUI");
743  return 1;
744 }
745 
746 
747 long
748 GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
749  if (mySubWindows.empty()) {
750  return 1;
751  }
752  FXRegistry reg("Netedit", "DLR");
753  reg.read();
754  const GUISUMOAbstractView* const v = static_cast<GUIGlChildWindow*>(mySubWindows[0])->getView();
755  reg.writeIntEntry("viewport", "x", v->getChanger().getXPos());
756  reg.writeIntEntry("viewport", "y", v->getChanger().getYPos());
757  reg.writeIntEntry("viewport", "z", v->getChanger().getZPos());
758  reg.write();
759  std::string netedit = "netedit";
760  const char* sumoPath = getenv("SUMO_HOME");
761  if (sumoPath != 0) {
762  std::string newPath = std::string(sumoPath) + "/bin/netedit";
763  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
764  netedit = "\"" + newPath + "\"";
765  }
766  }
767  std::string cmd = netedit + " --registry-viewport -s " + OptionsCont::getOptions().getString("net-file");
768  // start in background
769 #ifndef WIN32
770  cmd = cmd + " &";
771 #else
772  // see "help start" for the parameters
773  cmd = "start /B \"\" " + cmd;
774 #endif
775  WRITE_MESSAGE("Running " + cmd + ".");
776  // yay! fun with dangerous commands... Never use this over the internet
778  return 1;
779 }
780 
781 
782 long
783 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
784  // get the new file name
785  FXFileDialog opendialog(this, "Open Simulation Configuration");
786  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
787  opendialog.setSelectMode(SELECTFILE_EXISTING);
788  opendialog.setPatternList(myConfigPattern.c_str());
789  if (gCurrentFolder.length() != 0) {
790  opendialog.setDirectory(gCurrentFolder);
791  }
792  if (opendialog.execute()) {
793  gCurrentFolder = opendialog.getDirectory();
794  std::string file = opendialog.getFilename().text();
795  loadConfigOrNet(file, false);
796  myRecentConfigs.appendFile(file.c_str());
797  }
798  return 1;
799 }
800 
801 
802 long
803 GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
804  // get the new file name
805  FXFileDialog opendialog(this, "Open Network");
806  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
807  opendialog.setSelectMode(SELECTFILE_EXISTING);
808  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
809  if (gCurrentFolder.length() != 0) {
810  opendialog.setDirectory(gCurrentFolder);
811  }
812  if (opendialog.execute()) {
813  gCurrentFolder = opendialog.getDirectory();
814  std::string file = opendialog.getFilename().text();
815  loadConfigOrNet(file, true);
816  myRecentNets.appendFile(file.c_str());
817  }
818  return 1;
819 }
820 
821 
822 long
823 GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
824  // get the shape file name
825  FXFileDialog opendialog(this, "Open Shapes");
826  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
827  opendialog.setSelectMode(SELECTFILE_EXISTING);
828  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
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 
837  if (!XMLSubSys::runParser(handler, file, false)) {
838  WRITE_MESSAGE("Loading of " + file + " failed.");
839  }
840  update();
841  }
842  return 1;
843 }
844 
845 long
846 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
847  getApp()->beginWaitCursor();
848  myAmLoading = true;
849  closeAllWindows();
850  myLoadThread->start();
851  setStatusBarText("Reloading.");
852  update();
853  return 1;
854 }
855 
856 
857 long
858 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
859  if (myAmLoading) {
860  myStatusbar->getStatusLine()->setText("Already loading!");
861  return 1;
862  }
863  std::string file((const char*)data);
864  loadConfigOrNet(file, sender == &myRecentNets);
865  return 1;
866 }
867 
868 
869 long
870 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
871  closeAllWindows();
872  return 1;
873 }
874 
875 
876 long
877 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
878  sender->handle(this,
879  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
880  ptr);
881  return 1;
882 }
883 
884 
885 long
886 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
887  sender->handle(this,
889  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
890  ptr);
891  return 1;
892 }
893 
894 
895 long
896 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
897  sender->handle(this,
898  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
899  ptr);
900  return 1;
901 }
902 
903 
904 long
905 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
906  sender->handle(this,
908  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
909  ptr);
910  return 1;
911 }
912 
913 
914 long
915 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
916  // check whether a net was loaded successfully
918  myStatusbar->getStatusLine()->setText("No simulation loaded!");
919  return 1;
920  }
921  // check whether it was started before and paused;
922  if (!myWasStarted) {
923  myRunThread->begin();
924  myWasStarted = true;
925  }
926  myRunThread->resume();
927  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
928  return 1;
929 }
930 
931 
932 long
933 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
934  myRunThread->stop();
935  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
936  return 1;
937 }
938 
939 
940 long
941 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
942  // check whether a net was loaded successfully
944  myStatusbar->getStatusLine()->setText("No simulation loaded!");
945  return 1;
946  }
947  // check whether it was started before and paused;
948  if (!myWasStarted) {
949  myRunThread->begin();
950  myWasStarted = true;
951  }
953  return 1;
954 }
955 
956 
957 long
958 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
962  }
963  return 1;
964 }
965 
966 
967 long
968 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
969  const SUMOTime tmp = myAlternateSimDelay;
972  return 1;
973 }
974 
975 
976 long
977 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
979  return 1;
980 }
981 
982 
983 long
984 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
985  sender->handle(this,
987  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
988  ptr);
989  return 1;
990 }
991 
992 
993 long
994 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
995  sender->handle(this,
997  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
998  ptr);
999  return 1;
1000 }
1001 
1002 
1003 long
1004 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
1005  sender->handle(this,
1007  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1008  ptr);
1009  return 1;
1010 }
1011 
1012 
1013 long
1014 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
1015  sender->handle(this,
1017  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1018  ptr);
1019  return 1;
1020 }
1021 
1022 
1023 long
1024 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1025  if (myMDIClient->numChildren() > 0) {
1026  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1027  if (w != 0) {
1028  w->onCmdLocate(0, sel, 0);
1029  }
1030  }
1031  return 1;
1032 }
1033 
1034 
1035 long
1036 GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1037  if (myMDIClient->numChildren() > 0) {
1038  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1040  }
1041  return 1;
1042 }
1043 
1044 
1045 long
1046 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1048  d->create();
1049  d->show(PLACEMENT_OWNER);
1050  return 1;
1051 }
1052 
1053 
1054 long
1055 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1057  if (myAmGaming) {
1058  myMenuBar->hide();
1059  myStatusbar->hide();
1060  myToolBar1->hide();
1061  myToolBar2->hide();
1062  myToolBar4->hide();
1063  myToolBar5->hide();
1064  myToolBar6->show();
1065  myToolBar7->show();
1066  myMessageWindow->hide();
1070  gSchemeStorage.getDefault().gaming = true;
1071  } else {
1072  myMenuBar->show();
1073  myStatusbar->show();
1074  myToolBar1->show();
1075  myToolBar2->show();
1076  myToolBar4->show();
1077  myToolBar5->show();
1078  myToolBar6->hide();
1079  myToolBar7->hide();
1080  myMessageWindow->show();
1082  gSchemeStorage.getDefault().gaming = false;
1083  }
1084  if (myMDIClient->numChildren() > 0) {
1085  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1086  if (w != 0) {
1088  }
1089  }
1090  update();
1091  return 1;
1092 }
1093 
1094 
1095 long
1096 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1098  if (myAmFullScreen) {
1099  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1100  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1101  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1102  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1103  maximize();
1104  setDecorations(DECOR_NONE);
1105  place(PLACEMENT_MAXIMIZED);
1106  myMenuBar->hide();
1107  myStatusbar->hide();
1108  myToolBar1->hide();
1109  myToolBar2->hide();
1110  myToolBar3->hide();
1111  myToolBar4->hide();
1112  myToolBar5->hide();
1113  myToolBar6->hide();
1114  myToolBar7->hide();
1115  myMessageWindow->hide();
1116  if (myMDIClient->numChildren() > 0) {
1117  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1118  if (w != 0) {
1119  w->setToolBarVisibility(false);
1120  }
1121  }
1122  update();
1123  } else {
1124  place(PLACEMENT_VISIBLE);
1125  setDecorations(DECOR_ALL);
1126  restore();
1127  myToolBar3->show();
1129  onCmdGaming(0, 0, 0);
1130  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1131  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1132  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1133  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1134  }
1135  return 1;
1136 }
1137 
1138 
1139 long
1140 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1142  return 1;
1143 }
1144 
1145 
1146 long
1147 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1149  return 1;
1150 }
1151 
1152 
1153 #ifdef HAVE_OSG
1154 long
1155 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1157  return 1;
1158 }
1159 #endif
1160 
1161 
1162 long
1163 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1164  GUIDialog_AboutSUMO* about =
1165  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
1166  about->create();
1167  about->show(PLACEMENT_OWNER);
1168  return 1;
1169 }
1170 
1171 
1172 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1173  FXEvent* event = (FXEvent*)ptr;
1174  FXString string = GUIUserIO::clipped.c_str();
1175  setDNDData(FROM_CLIPBOARD, event->target, string);
1176  return 1;
1177 }
1178 
1179 
1180 long
1181 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1182  eventOccured();
1183  return 1;
1184 }
1185 
1186 
1187 long
1188 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1189  eventOccured();
1190  return 1;
1191 }
1192 
1193 
1194 void
1196  while (!myEvents.empty()) {
1197  // get the next event
1198  GUIEvent* e = myEvents.top();
1199  myEvents.pop();
1200  // process
1201  switch (e->getOwnType()) {
1204  break;
1205  case EVENT_SIMULATION_STEP:
1206  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1208  }
1209  break;
1210  case EVENT_MESSAGE_OCCURED:
1211  case EVENT_WARNING_OCCURED:
1212  case EVENT_ERROR_OCCURED:
1213  case EVENT_STATUS_OCCURED:
1215  break;
1218  break;
1219  case EVENT_SCREENSHOT:
1221  break;
1222  default:
1223  break;
1224  }
1225  delete e;
1226  }
1227  myToolBar2->forceRefresh();
1228  myToolBar3->forceRefresh();
1229 }
1230 
1231 
1232 void
1234  myAmLoading = false;
1236  // check whether the loading was successfull
1237  if (ec->myNet == 0) {
1238  // report failure
1239  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1240  if (GUIGlobals::gQuitOnEnd) {
1241  closeAllWindows();
1242  getApp()->exit(1);
1243  }
1244  } else {
1245  // initialise simulation thread
1246  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1247  if (GUIGlobals::gQuitOnEnd) {
1248  closeAllWindows();
1249  getApp()->exit(1);
1250  }
1251  } else {
1252  // report success
1253  setStatusBarText("'" + ec->myFile + "' loaded.");
1254  myWasStarted = false;
1255  myHaveNotifiedAboutSimEnd = false;
1256  // initialise views
1257  myViewNumber = 0;
1259  if (ec->mySettingsFiles.size() > 0) {
1260  // open a view for each file and apply settings
1261  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1262  GUISettingsHandler settings(*it);
1263  GUISUMOViewParent::ViewType vt = defaultType;
1264  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1266  }
1267  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1269  }
1270  GUISUMOAbstractView* view = openNewView(vt);
1271  if (view == 0) {
1272  break;
1273  }
1274  std::string settingsName = settings.addSettings(view);
1275  view->addDecals(settings.getDecals());
1276  settings.applyViewport(view);
1277  settings.setSnapshots(view);
1278  if (settings.getDelay() > 0) {
1279  mySimDelayTarget->setValue(settings.getDelay());
1280  }
1281  if (settings.getBreakpoints().size() > 0) {
1282  myRunThread->getBreakpointLock().lock();
1283  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1284  myRunThread->getBreakpointLock().unlock();
1285  }
1286  myJamSounds = settings.getEventDistribution("jam");
1287  myCollisionSounds = settings.getEventDistribution("collision");
1288  if (settings.getJamSoundTime() > 0) {
1289  myJamSoundTime = settings.getJamSoundTime();
1290  }
1291  }
1292  } else {
1293  openNewView(defaultType);
1294  }
1295 
1296  if (isGaming()) {
1297  setTitle("SUMO Interactive Traffic Light");
1298  } else {
1299  // set simulation name on the caption
1300  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1301  }
1302  // set simulation step begin information
1303  myLCDLabel->setText("-------------");
1304  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1305  (*it)->setText("-");
1306  }
1307  }
1308  }
1309  getApp()->endWaitCursor();
1310  // start if wished
1312  onCmdStart(0, 0, 0);
1313  }
1314  update();
1315 }
1316 
1317 
1318 void
1320  updateChildren();
1322  const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1323  const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1324  if (backlog > running) {
1325  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_GREENVEHICLE)) {
1327  }
1328  } else {
1329  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_YELLOWVEHICLE)) {
1331  }
1332  }
1333  myStatButtons.front()->setText(toString(running).c_str());
1334  if (myRunThread->getNet().hasPersons()) {
1335  if (!myStatButtons[1]->shown()) {
1336  myStatButtons[1]->show();
1337  }
1339  }
1340  if (myRunThread->getNet().hasContainers()) {
1341  if (!myStatButtons[2]->shown()) {
1342  myStatButtons[2]->show();
1343  }
1345  }
1346  if (myAmGaming) {
1348  }
1350  getApp()->forceRefresh(); // restores keyboard focus
1351  }
1352  update();
1353 }
1354 
1355 
1356 void
1358  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1359  if (ec->getOwnType() == EVENT_STATUS_OCCURED) {
1360  setStatusBarText(ec->getMsg());
1361  } else {
1362  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1363  }
1364 }
1365 
1366 
1367 void
1369  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1370  onCmdStop(0, 0, 0);
1371  if (GUIGlobals::gQuitOnEnd) {
1372  closeAllWindows();
1373  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1374  } else if (GUIGlobals::gDemoAutoReload) {
1375  onCmdReload(0, 0, 0);
1376  } else if (!myHaveNotifiedAboutSimEnd) {
1377  // build the text
1378  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1379  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1380  "\nDo you want to close all open files and views?";
1381  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1382  if (answer == 1) { //1:yes, 2:no, 4:esc
1383  closeAllWindows();
1384  }
1386  }
1387 }
1388 
1389 
1390 void
1392  GUIEvent_Screenshot* ec = static_cast<GUIEvent_Screenshot*>(e);
1393  myEventMutex.lock();
1394  const std::string error = ec->myView->makeSnapshot(ec->myFile);
1395  if (error != "") {
1396  WRITE_WARNING(error);
1397  }
1398  myEventCondition.signal();
1399  myEventMutex.unlock();
1400 }
1401 
1402 
1403 void
1408 #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1409  if (myJamSounds.getOverallProb() > 0) {
1410  // play honking sound if some vehicle is waiting too long
1411  for (; it != end; ++it) {
1412  // XXX use impatience instead of waiting time ?
1413  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1414  const std::string cmd = myJamSounds.get(&myGamingRNG);
1415  if (cmd != "") {
1416  // yay! fun with dangerous commands... Never use this over the internet
1418  // one sound per simulation step is enough
1419  break;
1420  }
1421  }
1422  }
1423  }
1424  if (myCollisionSounds.getOverallProb() > 0) {
1425  int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
1426  if (myPreviousCollisionNumber != collisions) {
1427  const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1428  if (cmd != "") {
1429  // yay! fun with dangerous commands... Never use this over the internet
1431  }
1432  myPreviousCollisionNumber = collisions;
1433  }
1434  }
1435 #endif
1436 
1437  // update performance indicators
1438  for (it = vc.loadedVehBegin(); it != end; ++it) {
1439  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1440  assert(veh != 0);
1441  if (veh->isOnRoad()) {
1442  const SUMOReal vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1443  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1445  }
1446  myTimeLoss += TS * TIME2STEPS(vmax - veh->getSpeed()) / vmax; // may be negative with speedFactor > 1
1447  }
1448  }
1451 }
1452 
1453 
1454 void
1455 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1456  getApp()->beginWaitCursor();
1457  myAmLoading = true;
1458  closeAllWindows();
1459  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1460  myLoadThread->loadConfigOrNet(file, isNet);
1461  setStatusBarText("Loading '" + file + "'.");
1462  update();
1463 }
1464 
1465 
1468  if (!myRunThread->simulationAvailable()) {
1469  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1470  return 0;
1471  }
1472  GUISUMOAbstractView* oldView = 0;
1473  if (myMDIClient->numChildren() > 0) {
1474  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1475  if (w != 0) {
1476  oldView = w->getView();
1477  }
1478  }
1479  std::string caption = "View #" + toString(myViewNumber++);
1480  FXuint opts = MDI_TRACKING;
1481  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1482  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1484  if (oldView != 0) {
1485  // copy viewport
1486  oldView->copyViewportTo(v);
1487  }
1488  w->create();
1489  if (myMDIClient->numChildren() == 1) {
1490  w->maximize();
1491  } else {
1492  myMDIClient->vertical(true);
1493  }
1494  myMDIClient->setActiveChild(w);
1495 
1496  return v;
1497 }
1498 
1499 
1500 FXGLCanvas*
1502  if (myMDIClient->numChildren() == 0) {
1503  return 0;
1504  }
1505  GUISUMOViewParent* share_tmp1 =
1506  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1507  return share_tmp1->getBuildGLCanvas();
1508 }
1509 
1510 
1511 void
1513  myTrackerLock.lock();
1514  myLCDLabel->setText("-------------");
1515  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1516  (*it)->setText("-");
1517  if (it != myStatButtons.begin()) {
1518  (*it)->hide();
1519  }
1520  }
1521  // remove trackers and other external windows
1522  int i;
1523  for (i = 0; i < (int)mySubWindows.size(); ++i) {
1524  mySubWindows[i]->destroy();
1525  }
1526  for (i = 0; i < (int)myTrackerWindows.size(); ++i) {
1527  myTrackerWindows[i]->destroy();
1528  }
1529  // delete the simulation
1531  // reset the caption
1532  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
1533  // delete other children
1534  while (myTrackerWindows.size() != 0) {
1535  delete myTrackerWindows[0];
1536  }
1537  while (mySubWindows.size() != 0) {
1538  delete mySubWindows[0];
1539  }
1540  mySubWindows.clear();
1541  // clear selected items
1542  gSelected.clear();
1543  // add a separator to the log
1546  // remove coordinate information
1547  myGeoCoordinate->setText("N/A");
1548  myCartesianCoordinate->setText("N/A");
1549  //
1551  update();
1552 }
1553 
1554 
1555 FXCursor*
1557  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1558 }
1559 
1560 
1561 SUMOTime
1564 }
1565 
1566 
1567 void
1569  loadConfigOrNet("", false);
1570 }
1571 
1572 
1573 void
1574 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1575  myStatusbar->getStatusLine()->setText(text.c_str());
1576  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1577 }
1578 
1579 
1580 void
1581 GUIApplicationWindow::addRecentFile(const FX::FXString& f, const bool isNet) {
1582  if (isNet) {
1583  myRecentNets.appendFile(f);
1584  } else {
1585  myRecentConfigs.appendFile(f);
1586  }
1587 }
1588 
1589 
1590 void
1592  time -= DELTA_T; // synchronize displayed time with netstate output
1593  if (time < 0) {
1594  myLCDLabel->setText("-------------");
1595  return;
1596  }
1597  if (myAmGaming) {
1598  // show time counting backwards
1599  time = myRunThread->getSimEndTime() - time;
1600  }
1601  SUMOReal fracSeconds = STEPS2TIME(time);
1602  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1603  const int BuffSize = 100;
1604  char buffer[BuffSize];
1605  if (myShowTimeAsHMS) {
1606  const int hours = (int)fracSeconds / 3600;
1607  const int minutes = ((int)fracSeconds % 3600) / 60;
1608  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1609  const std::string format = (hideFraction ?
1610  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1611  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1612  } else {
1613  const std::string format = (hideFraction ?
1614  "%13.0f" : "%13.3f");
1615  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1616  }
1617  myLCDLabel->setText(buffer);
1618 }
1619 
1620 
1621 long
1622 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1623  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1624  if (handled == 0 && myMDIClient->numChildren() > 0) {
1625  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1626  if (w != 0) {
1627  w->onKeyPress(0, sel, data);
1628  }
1629  }
1630  return 0;
1631 }
1632 
1633 
1634 long
1635 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1636  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1637  if (handled == 0 && myMDIClient->numChildren() > 0) {
1638  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1639  if (w != 0) {
1640  w->onKeyRelease(0, sel, data);
1641  }
1642  }
1643  return 0;
1644 }
1645 
1646 
1647 void
1649  myEventMutex.lock();
1650  myEvents.add(event);
1653  myEventMutex.unlock();
1654 }
1655 
1656 
1657 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
Event sent when the the simulation is over.
RandomDistributor< std::string > myJamSounds
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
long onCmdShowStats(FXObject *, FXSelector, void *)
Called on commands from the statistic buttons.
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
Locate vehicle - button.
Definition: GUIAppEnum.h:175
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
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:81
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.
Locate person - button.
Definition: GUIAppEnum.h:177
virtual bool simulationIsStepable() const
Open in netedit.
Definition: GUIAppEnum.h:133
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.
Show network statistics.
Definition: GUIAppEnum.h:156
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
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.
static MTRand myGamingRNG
A random number generator used to choose a gaming sound.
Show person statistics.
Definition: GUIAppEnum.h:160
Locate TLS - button.
Definition: GUIAppEnum.h:179
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
Show vehicle statistics.
Definition: GUIAppEnum.h:158
bool gaming
whether the application is in gaming mode or not
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:324
Gaming mode - menu entry.
Definition: GUIAppEnum.h:143
const bool myOsgView
whether to load the OpenSceneGraph view
void add(T what)
Definition: MFXEventQue.h:59
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
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
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
virtual void setValue(FXdouble value)
Change current value.
Locate poi - button.
Definition: GUIAppEnum.h:187
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
virtual bool simulationIsStartable() const
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:52
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
void setToolBarVisibility(const bool value)
about toggled gaming status
int myViewNumber
The current view number.
Start the simulation.
Definition: GUIAppEnum.h:95
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
FXGLVisual * myGLVisual
The gl-visual used.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
FXMutex myEventMutex
the mutex for the waiting semaphore
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
Main window-ID.
Definition: GUIAppEnum.h:53
toogle delay between alternative value
Definition: GUIAppEnum.h:203
long onCmdNetedit(FXObject *, FXSelector, void *)
Called on menu Edit->Netedit.
Stop the simulation.
Definition: GUIAppEnum.h:97
FXString gCurrentFolder
The folder used as last.
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 TS
Definition: SUMOTime.h:52
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:109
void show()
sets the focus after the window is created
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:81
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:254
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
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
Open network - ID.
Definition: GUIAppEnum.h:75
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual FXGLCanvas * getBuildGLCanvas() const
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
Open configuration - ID.
Definition: GUIAppEnum.h:73
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
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
Locate addtional structure - button.
Definition: GUIAppEnum.h:185
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.
static const RGBColor GREEN
Definition: RGBColor.h:190
An error occured during the simulation step.
Definition: MSNet.h:108
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Locator configuration - menu entry.
Definition: GUIAppEnum.h:147
void updateTimeLCD(SUMOTime time)
updates the simulation time display
void setRange(FXdouble lo, FXdouble hi)
Change the spinner&#39;s range.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:424
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
virtual SUMOReal getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
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:502
#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:430
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
Locate edge - button.
Definition: GUIAppEnum.h:173
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:307
The Simulation delay control.
Definition: GUIAppEnum.h:149
The Simulation execution thread.
Definition: GUIAppEnum.h:119
static void init(FXApp *a)
Initiate GUIIconSubSys.
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.
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:69
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
The application&#39;s "About" - dialog.
bool myAmFullScreen
whether to show the window in full screen mode
Locate junction - button.
Definition: GUIAppEnum.h:171
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
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:340
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:483
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
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.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
Clear simulation output.
Definition: GUIAppEnum.h:154
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:762
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
toogle time display mode
Definition: GUIAppEnum.h:201
virtual void fillMenuBar()
Builds the menu bar.
virtual SUMOReal getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
Application settings - menu entry.
Definition: GUIAppEnum.h:141
#define VERSION_STRING
Definition: config.h:225
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
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
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
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.
About SUMO - ID.
Definition: GUIAppEnum.h:87
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
The loading thread.
Definition: GUIAppEnum.h:117
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:360
MFXEventQue< GUIEvent * > myEvents
List of got requests.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:699
static void close()
close GUIIconSubSys
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:145
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
Open a new microscopic view.
Definition: GUIAppEnum.h:107
FXDockSite * myTopDock
void setStatusBarText(const std::string &text)
Locate polygons - button.
Definition: GUIAppEnum.h:189
FXRecentFiles myRecentConfigs
List of recent config files.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:97
Open editor for selections.
Definition: GUIAppEnum.h:129
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
void create()
Creates the widget (and the icons)
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:410
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
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
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
send when a warning occured
Definition: GUIEvent.h:53
FXToolBar * myToolBar1
The application tool bar.
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:213
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:554
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
Close simulation - ID.
Definition: GUIAppEnum.h:85
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.
virtual SUMOReal getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
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".
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:455
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
static bool gUseMesoSim
Definition: MSGlobals.h:90
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
Perform a single simulation step.
Definition: GUIAppEnum.h:99
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
The main window of the SUMO-gui.