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>
62 #include <utils/common/TplCheck.h>
69 
70 #include <utils/xml/XMLSubSys.h>
89 #include "GUIGlobals.h"
93 
94 #ifdef CHECK_MEMORY_LEAKS
95 #include <foreign/nvwa/debug_new.h>
96 #endif
97 
98 //#define HAVE_DANGEROUS_SOUNDS
99 
100 // ===========================================================================
101 // FOX-declarations
102 // ===========================================================================
103 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
104  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
105  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
106  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
107 
111  FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
112  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
113  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
114  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
116  FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
117 
119  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
120  FXMAPFUNC(SEL_COMMAND, MID_FULLSCREEN, GUIApplicationWindow::onCmdFullScreen),
122  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
123  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
124 #ifdef HAVE_OSG
125  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
126 #endif
127  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
128  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
129  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
133 
137 
138  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
139  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
140  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
141  FXMAPFUNC(SEL_UPDATE, MID_OPEN_SHAPES, GUIApplicationWindow::onUpdReload),
142  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
145 #ifdef HAVE_OSG
146  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
147 #endif
148  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
149  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
150  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
154  FXMAPFUNC(SEL_COMMAND, MID_HELP, GUIApplicationWindow::onCmdHelp),
155 
156  // forward requests to the active view
157  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
158  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
159  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
160  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
161  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
162  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
163  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
164  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
173  FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
174  FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
175 
176  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
177 
182 };
183 
184 // Object implementation
185 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
186 
187 // ===========================================================================
188 // static members
189 // ===========================================================================
190 MTRand GUIApplicationWindow::myGamingRNG;
191 
192 // ===========================================================================
193 // member method definitions
194 // ===========================================================================
196  const std::string& configPattern)
197  : GUIMainWindow(a),
198  myLoadThread(0), myRunThread(0),
199  myAmLoading(false),
200  myAlternateSimDelay(0),
201  myRecentNets(a, "nets"), myConfigPattern(configPattern),
202  hadDependentBuild(false),
203  myShowTimeAsHMS(false),
204  myAmFullScreen(false),
205  myHaveNotifiedAboutSimEnd(false),
206  // game specific
207  myJamSoundTime(60),
208  myPreviousCollisionNumber(0),
209  myWaitingTime(0),
210  myTimeLoss(0) {
212 }
213 
214 
215 void
217  // don't do this twice
218  if (hadDependentBuild) {
219  return;
220  }
221  hadDependentBuild = true;
222 
223  setTarget(this);
224  setSelector(MID_WINDOW);
225 
226  // build menu bar
227  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
228  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
229  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
230  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
231  TOOLBARGRIP_DOUBLE);
232  buildToolBars();
233  // build the thread - io
238 
239  // build the status bar
240  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
241  {
242  myGeoFrame =
243  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
244  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
245  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
247  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
248  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
249  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
252  myStatButtons.back()->hide();
253  myStatButtons.push_back(new FXButton(myStatusbar, "-", GUIIconSubSys::getIcon(ICON_GREENEDGE), this, MID_SHOWVEHSTATS));
254  myStatButtons.back()->hide();
255  }
256 
257  // make the window a mdi-window
258  myMainSplitter = new FXSplitter(this,
259  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
260  myMDIClient = new FXMDIClient(myMainSplitter,
261  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
262  myMDIMenu = new FXMDIMenu(this, myMDIClient);
263  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
264  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
265  new FXMDIDeleteButton(myMenuBar, myMDIClient,
266  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
267  new FXMDIRestoreButton(myMenuBar, myMDIClient,
268  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
269  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
270  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
271 
272  // build the message window
274  // fill menu and tool bar
275  fillMenuBar();
276  myToolBar6->hide();
277  myToolBar7->hide();
278  // build additional threads
279  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
280  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
282  // set the status bar
283  myStatusbar->getStatusLine()->setText("Ready.");
284  // set the caption
285  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
286 
287  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
288  myRunThread->start();
290 }
291 
292 
293 void
295  int windowWidth = getApp()->reg().readIntEntry("SETTINGS", "width", 600);
296  int windowHeight = getApp()->reg().readIntEntry("SETTINGS", "height", 400);
297  const OptionsCont& oc = OptionsCont::getOptions();
298  if (oc.isSet("window-size")) {
299  std::vector<std::string> windowSize = oc.getStringVector("window-size");
300  if (windowSize.size() != 2
301  || !TplCheck::_str2int(windowSize[0])
302  || !TplCheck::_str2int(windowSize[1])) {
303  WRITE_ERROR("option window-size requires INT,INT");
304  } else {
305  windowWidth = TplConvert::_str2int(windowSize[0]);
306  windowHeight = TplConvert::_str2int(windowSize[1]);
307  }
308  }
309 
310  if (oc.isSet("window-size") || getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
311  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
312  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
313  setWidth(windowWidth);
314  setHeight(windowHeight);
315  }
316  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
317  FXMainWindow::create();
318  myMenuBarDrag->create();
319  myToolBarDrag1->create();
320  myToolBarDrag2->create();
321  myToolBarDrag3->create();
322  myToolBarDrag4->create();
323  myToolBarDrag5->create();
324  myToolBarDrag6->create();
325  myToolBarDrag7->create();
326  myFileMenu->create();
327  mySelectByPermissions->create();
328  myEditMenu->create();
329  mySettingsMenu->create();
330  myLocatorMenu->create();
331  myControlMenu->create();
332  myWindowsMenu->create();
333  myHelpMenu->create();
334 
335  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
336  myCartesianFrame->setWidth(width);
337  myGeoFrame->setWidth(width);
338 
339  show(PLACEMENT_SCREEN);
340  if (!OptionsCont::getOptions().isSet("window-size")) {
341  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
342  maximize();
343  }
344  }
345  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
346  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
347 }
348 
349 
352  myRunThread->join();
353  closeAllWindows();
354  //
356  delete myGLVisual;
357  // delete some non-parented windows
358  delete myToolBarDrag1;
359  //
360  delete myRunThread;
361  delete myFileMenu;
362  delete myEditMenu;
363  delete mySelectByPermissions;
364  delete mySettingsMenu;
365  delete myLocatorMenu;
366  delete myControlMenu;
367  delete myWindowsMenu;
368  delete myHelpMenu;
369 
370  delete myLoadThread;
371 
372  while (!myEvents.empty()) {
373  // get the next event
374  GUIEvent* e = myEvents.top();
375  myEvents.pop();
376  delete e;
377  }
378 }
379 
380 
381 void
383  FXMainWindow::detach();
384  myMenuBarDrag->detach();
385  myToolBarDrag1->detach();
386 }
387 
388 
389 void
391  // build file menu
392  myFileMenu = new FXMenuPane(this);
393  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
394  new FXMenuCommand(myFileMenu,
395  "&Open Simulation...\tCtrl+O\tOpen a simulation (Configuration file).",
397  new FXMenuCommand(myFileMenu,
398  "Open &Network...\tCtrl+N\tOpen a network.",
400  new FXMenuCommand(myFileMenu,
401  "Open Shapes \tCtrl+P\tLoad POIs and Polygons for visualization.",
403  new FXMenuCommand(myFileMenu,
404  "&Reload\tCtrl+R\tReloads the simulation / the network.",
406  new FXMenuSeparator(myFileMenu);
407  new FXMenuCommand(myFileMenu,
408  "Close\tCtrl+W\tClose the simulation.",
410  // Recent files
411  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
412  sep1->setTarget(&myRecentConfigs);
413  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
414  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
415  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
416  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
417  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
418  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
419  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
420  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
421  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
422  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
423  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
424  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
425  myRecentConfigs.setTarget(this);
426  myRecentConfigs.setSelector(MID_RECENTFILE);
427  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
428  sep2->setTarget(&myRecentNets);
429  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
430  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
431  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
432  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
433  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
434  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
435  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
436  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
437  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
438  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
439  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
440  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
441  myRecentNets.setTarget(this);
442  myRecentNets.setSelector(MID_RECENTFILE);
443  new FXMenuSeparator(myFileMenu);
444  new FXMenuCommand(myFileMenu,
445  "&Quit\tCtrl+Q\tQuit the Application.",
446  0, this, MID_QUIT, 0);
447 
448  // build edit menu
449  mySelectByPermissions = new FXMenuPane(this);
450  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
451  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
452  new FXMenuCommand(mySelectByPermissions,
453  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
454  }
455 
456  myEditMenu = new FXMenuPane(this);
457  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
458  new FXMenuCommand(myEditMenu,
459  "Edit Selected...\tCtrl+E\tOpens a dialog for editing the list of selected items.",
461  new FXMenuCascade(myEditMenu,
462  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
464  new FXMenuSeparator(myEditMenu);
465  new FXMenuCommand(myEditMenu,
466  "Edit Breakpoints...\tCtrl+B\tOpens a dialog for editing breakpoints.",
467  0, this, MID_EDIT_BREAKPOINTS);
468  new FXMenuSeparator(myEditMenu);
469  new FXMenuCommand(myEditMenu,
470  "Open in Netedit...\tCtrl+T\tOpens the netedit application with the current network.",
471  0, this, MID_NETEDIT);
472 
473  // build settings menu
474  mySettingsMenu = new FXMenuPane(this);
475  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
476  new FXMenuCommand(mySettingsMenu,
477  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
478  NULL, this, MID_APPSETTINGS);
479  new FXMenuCheck(mySettingsMenu,
480  "Gaming Mode\tCtrl+G\tToggle gaming mode on/off.",
481  this, MID_GAMING);
482  new FXMenuCheck(mySettingsMenu,
483  "Full Screen Mode\tCtrl+F\tToggle full screen mode on/off.",
484  this, MID_FULLSCREEN);
485  // build Locate menu
486  myLocatorMenu = new FXMenuPane(this);
487  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
488  new FXMenuCommand(myLocatorMenu,
489  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
491  new FXMenuCommand(myLocatorMenu,
492  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
494  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
495  new FXMenuCommand(myLocatorMenu,
496  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
498  }
499  new FXMenuCommand(myLocatorMenu,
500  "Locate &Persons\t\tOpen a Dialog for Locating a Person.",
502  new FXMenuCommand(myLocatorMenu,
503  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
505  new FXMenuCommand(myLocatorMenu,
506  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
508  new FXMenuCommand(myLocatorMenu,
509  "Locate P&oI\t\tOpen a Dialog for Locating a Point of Intereset.",
511  new FXMenuCommand(myLocatorMenu,
512  "Locate Po&lygon\t\tOpen a Dialog for Locating a Polygon.",
514  new FXMenuSeparator(myLocatorMenu);
515  new FXMenuCheck(myLocatorMenu,
516  "Show Internal Structures\t\tShow internal junctions and streets in locator dialog.",
517  this, MID_LISTINTERNAL);
518  // build control menu
519  myControlMenu = new FXMenuPane(this);
520  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
521  new FXMenuCommand(myControlMenu,
522  "Run\tCtrl+A\tStart running the simulation.",
523  NULL, this, MID_START);
524  new FXMenuCommand(myControlMenu,
525  "Stop\tCtrl+S\tStop running the simulation.",
526  NULL, this, MID_STOP);
527  new FXMenuCommand(myControlMenu,
528  "Step\tCtrl+D\tPerform one simulation step.",
529  NULL, this, MID_STEP);
530 
531  // build windows menu
532  myWindowsMenu = new FXMenuPane(this);
533  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
534  new FXMenuCheck(myWindowsMenu,
535  "Show Status Line\t\tToggle the Status Bar on/off.",
536  myStatusbar, FXWindow::ID_TOGGLESHOWN);
537  new FXMenuCheck(myWindowsMenu,
538  "Show Message Window\t\tToggle the Message Window on/off.",
539  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
540  new FXMenuCheck(myWindowsMenu,
541  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
542  myToolBar3, FXWindow::ID_TOGGLESHOWN);
543  new FXMenuCheck(myWindowsMenu,
544  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
545  myToolBar4, FXWindow::ID_TOGGLESHOWN);
547  new FXMenuSeparator(myWindowsMenu);
548  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
550  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
551  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
553  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
554  new FXMenuCommand(myWindowsMenu, "Cascade",
556  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
557  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
558  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
559  sep1 = new FXMenuSeparator(myWindowsMenu);
560  sep1->setTarget(myMDIClient);
561  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
562  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
563  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
564  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
565  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
566  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
567  new FXMenuSeparator(myWindowsMenu);
568  new FXMenuCommand(myWindowsMenu,
569  "Clear Message Window\t\tClear the message window.",
570  0, this, MID_CLEARMESSAGEWINDOW);
571 
572  // build help menu
573  myHelpMenu = new FXMenuPane(this);
574  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
575  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
576  new FXMenuCommand(myHelpMenu, "&About", GUIIconSubSys::getIcon(ICON_APP),
577  this, MID_ABOUT);
578 }
579 
580 
581 void
583  // build tool bars
584  {
585  // file and simulation tool bar
586  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
587  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
588  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
589  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
590  TOOLBARGRIP_DOUBLE);
591  // build file tools
592  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
594  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
595  new FXButton(myToolBar1, "\t\tOpen a network.",
597  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
598  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
600  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
601  }
602  {
603  // build simulation tools
604  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
605  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
606  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
607  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
608  TOOLBARGRIP_DOUBLE);
609  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
611  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
612  new FXButton(myToolBar2, "\t\tStop the running simulation.",
614  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
615  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
617  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
618  }
619  {
620  // Simulation Step Display
621  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
622  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
623  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
624  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
625  TOOLBARGRIP_DOUBLE);
626  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
627  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
628  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
632  myLCDLabel->setGroove(2);
633  myLCDLabel->setText("-------------");
634  }
635  {
636  // Simulation Delay
637  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
638  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
639  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
640  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
641  TOOLBARGRIP_DOUBLE);
642  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
643  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
646  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
648  mySimDelayTarget->setIncrements(1, 10, 10);
649  mySimDelayTarget->setRange(0, 1000);
651  }
652  {
653  // Views
654  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
655  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
656  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
657  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
658  TOOLBARGRIP_DOUBLE);
659  // build view tools
660  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
662  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
663 #ifdef HAVE_OSG
664  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
666  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
667 #endif
668  }
669  {
671  // total waitingTime
672  myToolBarDrag6 = new FXToolBarShell(this, FRAME_NORMAL);
673  myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
674  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
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, FRAME_NORMAL);
685  myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
686  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
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*) {
700  if (!myAmFullScreen) {
701  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
702  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
703  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
704  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
705  }
706  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
707  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
708  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
709  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", (int)myAlternateSimDelay);
710  getApp()->exit(0);
711  return 1;
712 }
713 
714 
715 long
716 GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
717  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
718  if (mc->getText() == "Edit Selected...") {
719  GUIDialog_GLChosenEditor* chooser =
721  chooser->create();
722  chooser->show();
723  } else {
725  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
726  for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
727  const std::vector<MSLane*>& lanes = (*i)->getLanes();
728  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
729  GUILane* lane = dynamic_cast<GUILane*>(*it);
730  assert(lane != 0);
731  if ((lane->getPermissions() & svc) != 0) {
732  gSelected.select(lane->getGlID());
733  }
734  }
735  }
736  if (myMDIClient->numChildren() > 0) {
737  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
738  if (w != 0) {
739  // color by selection
741  }
742  }
743  }
744  updateChildren();
745  }
746  return 1;
747 }
748 
749 
750 long
751 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
753  chooser->create();
754  chooser->show();
755  return 1;
756 }
757 
758 
759 long
760 GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
761  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/SUMO-GUI");
762  return 1;
763 }
764 
765 
766 long
767 GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
768  if (mySubWindows.empty()) {
769  return 1;
770  }
771  FXRegistry reg("Netedit", "DLR");
772  reg.read();
773  const GUISUMOAbstractView* const v = static_cast<GUIGlChildWindow*>(mySubWindows[0])->getView();
774  reg.writeRealEntry("viewport", "x", v->getChanger().getXPos());
775  reg.writeRealEntry("viewport", "y", v->getChanger().getYPos());
776  reg.writeRealEntry("viewport", "z", v->getChanger().getZPos());
777  reg.write();
778  std::string netedit = "netedit";
779  const char* sumoPath = getenv("SUMO_HOME");
780  if (sumoPath != 0) {
781  std::string newPath = std::string(sumoPath) + "/bin/netedit";
782  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
783  netedit = "\"" + newPath + "\"";
784  }
785  }
786  std::string cmd = netedit + " --registry-viewport -s " + OptionsCont::getOptions().getString("net-file");
787  // start in background
788 #ifndef WIN32
789  cmd = cmd + " &";
790 #else
791  // see "help start" for the parameters
792  cmd = "start /B \"\" " + cmd;
793 #endif
794  WRITE_MESSAGE("Running " + cmd + ".");
795  // yay! fun with dangerous commands... Never use this over the internet
797  return 1;
798 }
799 
800 
801 long
802 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
803  // get the new file name
804  FXFileDialog opendialog(this, "Open Simulation Configuration");
805  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
806  opendialog.setSelectMode(SELECTFILE_EXISTING);
807  opendialog.setPatternList(myConfigPattern.c_str());
808  if (gCurrentFolder.length() != 0) {
809  opendialog.setDirectory(gCurrentFolder);
810  }
811  if (opendialog.execute()) {
812  gCurrentFolder = opendialog.getDirectory();
813  std::string file = opendialog.getFilename().text();
814  loadConfigOrNet(file, false);
815  myRecentConfigs.appendFile(file.c_str());
816  }
817  return 1;
818 }
819 
820 
821 long
822 GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
823  // get the new file name
824  FXFileDialog opendialog(this, "Open Network");
825  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
826  opendialog.setSelectMode(SELECTFILE_EXISTING);
827  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
828  if (gCurrentFolder.length() != 0) {
829  opendialog.setDirectory(gCurrentFolder);
830  }
831  if (opendialog.execute()) {
832  gCurrentFolder = opendialog.getDirectory();
833  std::string file = opendialog.getFilename().text();
834  loadConfigOrNet(file, true);
835  myRecentNets.appendFile(file.c_str());
836  }
837  return 1;
838 }
839 
840 
841 long
842 GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
843  // get the shape file name
844  FXFileDialog opendialog(this, "Open Shapes");
845  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
846  opendialog.setSelectMode(SELECTFILE_EXISTING);
847  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
848  if (gCurrentFolder.length() != 0) {
849  opendialog.setDirectory(gCurrentFolder);
850  }
851  if (opendialog.execute()) {
852  gCurrentFolder = opendialog.getDirectory();
853  std::string file = opendialog.getFilename().text();
854 
856  if (!XMLSubSys::runParser(handler, file, false)) {
857  WRITE_MESSAGE("Loading of " + file + " failed.");
858  }
859  update();
860  }
861  return 1;
862 }
863 
864 long
865 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
866  getApp()->beginWaitCursor();
867  myAmLoading = true;
868  closeAllWindows();
869  myLoadThread->start();
870  setStatusBarText("Reloading.");
871  update();
872  return 1;
873 }
874 
875 
876 long
877 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
878  if (myAmLoading) {
879  myStatusbar->getStatusLine()->setText("Already loading!");
880  return 1;
881  }
882  std::string file((const char*)data);
883  loadConfigOrNet(file, sender == &myRecentNets);
884  return 1;
885 }
886 
887 
888 long
889 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
890  closeAllWindows();
891  return 1;
892 }
893 
894 
895 long
896 GUIApplicationWindow::onUpdOpen(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::onUpdReload(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::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
916  sender->handle(this,
917  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
918  ptr);
919  return 1;
920 }
921 
922 
923 long
924 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
925  sender->handle(this,
927  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
928  ptr);
929  return 1;
930 }
931 
932 
933 long
934 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
935  // check whether a net was loaded successfully
937  myStatusbar->getStatusLine()->setText("No simulation loaded!");
938  return 1;
939  }
940  // check whether it was started before and paused;
941  if (!myWasStarted) {
942  myRunThread->begin();
943  myWasStarted = true;
944  }
945  myRunThread->resume();
946  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
947  return 1;
948 }
949 
950 
951 long
952 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
953  myRunThread->stop();
954  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
955  return 1;
956 }
957 
958 
959 long
960 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
961  // check whether a net was loaded successfully
963  myStatusbar->getStatusLine()->setText("No simulation loaded!");
964  return 1;
965  }
966  // check whether it was started before and paused;
967  if (!myWasStarted) {
968  myRunThread->begin();
969  myWasStarted = true;
970  }
972  return 1;
973 }
974 
975 
976 long
977 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
981  }
982  return 1;
983 }
984 
985 
986 long
987 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
988  const SUMOTime tmp = myAlternateSimDelay;
990  mySimDelayTarget->setValue((FXdouble)tmp);
991  return 1;
992 }
993 
994 
995 long
996 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
998  return 1;
999 }
1000 
1001 
1002 long
1003 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
1004  sender->handle(this,
1006  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1007  ptr);
1008  return 1;
1009 }
1010 
1011 
1012 long
1013 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
1014  sender->handle(this,
1016  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1017  ptr);
1018  return 1;
1019 }
1020 
1021 
1022 long
1023 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
1024  sender->handle(this,
1026  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1027  ptr);
1028  return 1;
1029 }
1030 
1031 
1032 long
1033 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
1034  sender->handle(this,
1036  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1037  ptr);
1038  return 1;
1039 }
1040 
1041 
1042 long
1043 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1044  if (myMDIClient->numChildren() > 0) {
1045  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1046  if (w != 0) {
1047  w->onCmdLocate(0, sel, 0);
1048  }
1049  }
1050  return 1;
1051 }
1052 
1053 
1054 long
1055 GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1056  if (myMDIClient->numChildren() > 0) {
1057  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1059  }
1060  return 1;
1061 }
1062 
1063 
1064 long
1065 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1067  d->create();
1068  d->show(PLACEMENT_OWNER);
1069  return 1;
1070 }
1071 
1072 
1073 long
1074 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1076  if (myAmGaming) {
1077  myMenuBar->hide();
1078  myStatusbar->hide();
1079  myToolBar1->hide();
1080  myToolBar2->hide();
1081  myToolBar4->hide();
1082  myToolBar5->hide();
1083  myToolBar6->show();
1084  myToolBar7->show();
1085  myMessageWindow->hide();
1089  gSchemeStorage.getDefault().gaming = true;
1090  } else {
1091  myMenuBar->show();
1092  myStatusbar->show();
1093  myToolBar1->show();
1094  myToolBar2->show();
1095  myToolBar4->show();
1096  myToolBar5->show();
1097  myToolBar6->hide();
1098  myToolBar7->hide();
1099  myMessageWindow->show();
1101  gSchemeStorage.getDefault().gaming = false;
1102  }
1103  if (myMDIClient->numChildren() > 0) {
1104  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1105  if (w != 0) {
1107  }
1108  }
1109  update();
1110  return 1;
1111 }
1112 
1113 
1114 long
1115 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1117  if (myAmFullScreen) {
1118  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1119  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1120  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1121  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1122  maximize();
1123  setDecorations(DECOR_NONE);
1124  place(PLACEMENT_MAXIMIZED);
1125  myMenuBar->hide();
1126  myStatusbar->hide();
1127  myToolBar1->hide();
1128  myToolBar2->hide();
1129  myToolBar3->hide();
1130  myToolBar4->hide();
1131  myToolBar5->hide();
1132  myToolBar6->hide();
1133  myToolBar7->hide();
1134  myMessageWindow->hide();
1135  if (myMDIClient->numChildren() > 0) {
1136  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1137  if (w != 0) {
1138  w->setToolBarVisibility(false);
1139  }
1140  }
1141  update();
1142  } else {
1143  place(PLACEMENT_VISIBLE);
1144  setDecorations(DECOR_ALL);
1145  restore();
1146  myToolBar3->show();
1148  onCmdGaming(0, 0, 0);
1149  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1150  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1151  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1152  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1153  }
1154  return 1;
1155 }
1156 
1157 
1158 long
1159 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1161  return 1;
1162 }
1163 
1164 
1165 long
1166 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1168  return 1;
1169 }
1170 
1171 
1172 #ifdef HAVE_OSG
1173 long
1174 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1176  return 1;
1177 }
1178 #endif
1179 
1180 
1181 long
1182 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1183  GUIDialog_AboutSUMO* about =
1184  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
1185  about->create();
1186  about->show(PLACEMENT_OWNER);
1187  return 1;
1188 }
1189 
1190 
1191 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1192  FXEvent* event = (FXEvent*)ptr;
1193  FXString string = GUIUserIO::clipped.c_str();
1194  setDNDData(FROM_CLIPBOARD, event->target, string);
1195  return 1;
1196 }
1197 
1198 
1199 long
1200 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1201  eventOccured();
1202  return 1;
1203 }
1204 
1205 
1206 long
1207 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1208  eventOccured();
1209  return 1;
1210 }
1211 
1212 
1213 void
1215  while (!myEvents.empty()) {
1216  // get the next event
1217  GUIEvent* e = myEvents.top();
1218  myEvents.pop();
1219  // process
1220  switch (e->getOwnType()) {
1223  break;
1224  case EVENT_SIMULATION_STEP:
1225  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1227  }
1228  break;
1229  case EVENT_MESSAGE_OCCURED:
1230  case EVENT_WARNING_OCCURED:
1231  case EVENT_ERROR_OCCURED:
1232  case EVENT_STATUS_OCCURED:
1234  break;
1237  break;
1238  case EVENT_SCREENSHOT:
1240  break;
1241  default:
1242  break;
1243  }
1244  delete e;
1245  }
1246  myToolBar2->forceRefresh();
1247  myToolBar3->forceRefresh();
1248 }
1249 
1250 
1251 void
1253  myAmLoading = false;
1255  // check whether the loading was successfull
1256  if (ec->myNet == 0) {
1257  // report failure
1258  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1259  if (GUIGlobals::gQuitOnEnd) {
1260  closeAllWindows();
1261  getApp()->exit(1);
1262  }
1263  } else {
1264  // initialise simulation thread
1265  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1266  if (GUIGlobals::gQuitOnEnd) {
1267  closeAllWindows();
1268  getApp()->exit(1);
1269  }
1270  } else {
1271  // report success
1272  setStatusBarText("'" + ec->myFile + "' loaded.");
1273  myWasStarted = false;
1274  myHaveNotifiedAboutSimEnd = false;
1275  // initialise views
1276  myViewNumber = 0;
1278  if (ec->mySettingsFiles.size() > 0) {
1279  // open a view for each file and apply settings
1280  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1281  GUISettingsHandler settings(*it);
1282  GUISUMOViewParent::ViewType vt = defaultType;
1283  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1285  }
1286  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1288  }
1289  GUISUMOAbstractView* view = openNewView(vt);
1290  if (view == 0) {
1291  break;
1292  }
1293  std::string settingsName = settings.addSettings(view);
1294  view->addDecals(settings.getDecals());
1295  settings.applyViewport(view);
1296  settings.setSnapshots(view);
1297  if (settings.getDelay() > 0) {
1298  mySimDelayTarget->setValue(settings.getDelay());
1299  }
1300  if (settings.getBreakpoints().size() > 0) {
1301  myRunThread->getBreakpointLock().lock();
1302  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1303  myRunThread->getBreakpointLock().unlock();
1304  }
1305  myJamSounds = settings.getEventDistribution("jam");
1306  myCollisionSounds = settings.getEventDistribution("collision");
1307  if (settings.getJamSoundTime() > 0) {
1308  myJamSoundTime = settings.getJamSoundTime();
1309  }
1310  }
1311  } else {
1312  openNewView(defaultType);
1313  }
1314 
1315  if (isGaming()) {
1316  setTitle("SUMO Interactive Traffic Light");
1317  } else {
1318  // set simulation name on the caption
1319  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1320  }
1321  // set simulation step begin information
1322  myLCDLabel->setText("-------------");
1323  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1324  (*it)->setText("-");
1325  }
1326  }
1327  }
1328  getApp()->endWaitCursor();
1329  // start if wished
1331  onCmdStart(0, 0, 0);
1332  }
1333  update();
1334 }
1335 
1336 
1337 void
1339  updateChildren();
1341  const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1342  const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1343  if (backlog > running) {
1344  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_GREENVEHICLE)) {
1346  }
1347  } else {
1348  if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(ICON_YELLOWVEHICLE)) {
1350  }
1351  }
1352  myStatButtons.front()->setText(toString(running).c_str());
1353  if (myRunThread->getNet().hasPersons()) {
1354  if (!myStatButtons[1]->shown()) {
1355  myStatButtons[1]->show();
1356  }
1358  }
1359  if (myRunThread->getNet().hasContainers()) {
1360  if (!myStatButtons[2]->shown()) {
1361  myStatButtons[2]->show();
1362  }
1364  }
1365  if (myAmGaming) {
1367  }
1369  getApp()->forceRefresh(); // restores keyboard focus
1370  }
1371  update();
1372 }
1373 
1374 
1375 void
1377  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1378  if (ec->getOwnType() == EVENT_STATUS_OCCURED) {
1379  setStatusBarText(ec->getMsg());
1380  } else {
1381  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1382  }
1383 }
1384 
1385 
1386 void
1388  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1389  onCmdStop(0, 0, 0);
1390  if (GUIGlobals::gQuitOnEnd) {
1391  closeAllWindows();
1392  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1393  } else if (GUIGlobals::gDemoAutoReload) {
1394  onCmdReload(0, 0, 0);
1395  } else if (!myHaveNotifiedAboutSimEnd) {
1396  // build the text
1397  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1398  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1399  "\nDo you want to close all open files and views?";
1400  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1401  if (answer == 1) { //1:yes, 2:no, 4:esc
1402  closeAllWindows();
1403  }
1405  }
1406 }
1407 
1408 
1409 void
1411  GUIEvent_Screenshot* ec = static_cast<GUIEvent_Screenshot*>(e);
1412  myEventMutex.lock();
1413  const std::string error = ec->myView->makeSnapshot(ec->myFile);
1414  if (error != "") {
1415  WRITE_WARNING(error);
1416  }
1417  myEventCondition.signal();
1418  myEventMutex.unlock();
1419 }
1420 
1421 
1422 void
1427 #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1428  if (myJamSounds.getOverallProb() > 0) {
1429  // play honking sound if some vehicle is waiting too long
1430  for (; it != end; ++it) {
1431  // XXX use impatience instead of waiting time ?
1432  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1433  const std::string cmd = myJamSounds.get(&myGamingRNG);
1434  if (cmd != "") {
1435  // yay! fun with dangerous commands... Never use this over the internet
1437  // one sound per simulation step is enough
1438  break;
1439  }
1440  }
1441  }
1442  }
1443  if (myCollisionSounds.getOverallProb() > 0) {
1444  int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
1445  if (myPreviousCollisionNumber != collisions) {
1446  const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1447  if (cmd != "") {
1448  // yay! fun with dangerous commands... Never use this over the internet
1450  }
1451  myPreviousCollisionNumber = collisions;
1452  }
1453  }
1454 #endif
1455 
1456  // update performance indicators
1457  for (it = vc.loadedVehBegin(); it != end; ++it) {
1458  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1459  assert(veh != 0);
1460  if (veh->isOnRoad()) {
1461  const SUMOReal vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1462  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1464  }
1465  myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
1466  }
1467  }
1470 }
1471 
1472 
1473 void
1474 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1475  getApp()->beginWaitCursor();
1476  myAmLoading = true;
1477  closeAllWindows();
1478  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1479  myLoadThread->loadConfigOrNet(file, isNet);
1480  setStatusBarText("Loading '" + file + "'.");
1481  update();
1482 }
1483 
1484 
1487  if (!myRunThread->simulationAvailable()) {
1488  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1489  return 0;
1490  }
1491  GUISUMOAbstractView* oldView = 0;
1492  if (myMDIClient->numChildren() > 0) {
1493  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1494  if (w != 0) {
1495  oldView = w->getView();
1496  }
1497  }
1498  std::string caption = "View #" + toString(myViewNumber++);
1499  FXuint opts = MDI_TRACKING;
1500  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1501  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1503  if (oldView != 0) {
1504  // copy viewport
1505  oldView->copyViewportTo(v);
1506  }
1507  w->create();
1508  if (myMDIClient->numChildren() == 1) {
1509  w->maximize();
1510  } else {
1511  myMDIClient->vertical(true);
1512  }
1513  myMDIClient->setActiveChild(w);
1514 
1515  return v;
1516 }
1517 
1518 
1519 FXGLCanvas*
1521  if (myMDIClient->numChildren() == 0) {
1522  return 0;
1523  }
1524  GUISUMOViewParent* share_tmp1 =
1525  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1526  return share_tmp1->getBuildGLCanvas();
1527 }
1528 
1529 
1530 void
1532  myTrackerLock.lock();
1533  myLCDLabel->setText("-------------");
1534  for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1535  (*it)->setText("-");
1536  if (it != myStatButtons.begin()) {
1537  (*it)->hide();
1538  }
1539  }
1540  // remove trackers and other external windows
1541  int i;
1542  for (i = 0; i < (int)mySubWindows.size(); ++i) {
1543  mySubWindows[i]->destroy();
1544  }
1545  for (i = 0; i < (int)myTrackerWindows.size(); ++i) {
1546  myTrackerWindows[i]->destroy();
1547  }
1548  // delete the simulation
1550  // reset the caption
1551  setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
1552  // delete other children
1553  while (myTrackerWindows.size() != 0) {
1554  delete myTrackerWindows[0];
1555  }
1556  while (mySubWindows.size() != 0) {
1557  delete mySubWindows[0];
1558  }
1559  mySubWindows.clear();
1560  // clear selected items
1561  gSelected.clear();
1562  // add a separator to the log
1565  // remove coordinate information
1566  myGeoCoordinate->setText("N/A");
1567  myCartesianCoordinate->setText("N/A");
1568  //
1570  update();
1571 }
1572 
1573 
1574 FXCursor*
1576  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1577 }
1578 
1579 
1580 SUMOTime
1583 }
1584 
1585 
1586 void
1588  loadConfigOrNet("", false);
1589 }
1590 
1591 
1592 void
1593 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1594  myStatusbar->getStatusLine()->setText(text.c_str());
1595  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1596 }
1597 
1598 
1599 void
1600 GUIApplicationWindow::addRecentFile(const FX::FXString& f, const bool isNet) {
1601  if (isNet) {
1602  myRecentNets.appendFile(f);
1603  } else {
1604  myRecentConfigs.appendFile(f);
1605  }
1606 }
1607 
1608 
1609 void
1611  time -= DELTA_T; // synchronize displayed time with netstate output
1612  if (time < 0) {
1613  myLCDLabel->setText("-------------");
1614  return;
1615  }
1616  if (myAmGaming) {
1617  // show time counting backwards
1618  time = myRunThread->getSimEndTime() - time;
1619  }
1620  SUMOReal fracSeconds = STEPS2TIME(time);
1621  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1622  const int BuffSize = 100;
1623  char buffer[BuffSize];
1624  if (myShowTimeAsHMS) {
1625  const int hours = (int)fracSeconds / 3600;
1626  const int minutes = ((int)fracSeconds % 3600) / 60;
1627  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1628  const std::string format = (hideFraction ?
1629  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1630  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1631  } else {
1632  const std::string format = (hideFraction ?
1633  "%13.0f" : "%13.3f");
1634  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1635  }
1636  myLCDLabel->setText(buffer);
1637 }
1638 
1639 
1640 long
1641 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1642  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1643  if (handled == 0 && myMDIClient->numChildren() > 0) {
1644  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1645  if (w != 0) {
1646  w->onKeyPress(0, sel, data);
1647  }
1648  }
1649  return 0;
1650 }
1651 
1652 
1653 long
1654 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1655  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1656  if (handled == 0 && myMDIClient->numChildren() > 0) {
1657  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1658  if (w != 0) {
1659  w->onKeyRelease(0, sel, data);
1660  }
1661  }
1662  return 0;
1663 }
1664 
1665 
1666 void
1668  myEventMutex.lock();
1669  myEvents.add(event);
1672  myEventMutex.unlock();
1673 }
1674 
1675 
1676 /****************************************************************************/
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.
static bool _str2int(const std::string &data)
check if a String can be parsed into a int check overflows
Definition: TplCheck.h:48
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
GUISUMOAbstractView * getView() const
Locate vehicle - button.
Definition: GUIAppEnum.h:175
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
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:82
void handleEvent_SimulationLoaded(GUIEvent *e)
long long int SUMOTime
Definition: SUMOTime.h:43
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
Locate person - button.
Definition: GUIAppEnum.h:177
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:324
Open in netedit.
Definition: GUIAppEnum.h:133
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.
Show network statistics.
Definition: GUIAppEnum.h:156
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
virtual FXGLCanvas * getBuildGLCanvas() const
send when a message occured
Definition: GUIEvent.h:50
bool empty()
Definition: MFXEventQue.h:72
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
virtual void deleteSim()
FXSplitter * myMainSplitter
The splitter that divides the main window into vies and the log window.
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:58
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
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
Show vehicle statistics.
Definition: GUIAppEnum.h:158
bool gaming
whether the application is in gaming mode or not
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
GUIColorer laneColorer
The lane colorer.
const std::string & getFileName() const
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
void addRecentFile(const FX::FXString &f, const bool isNet)
GUINet & getNet() const
FXToolBarShell * myToolBarDrag4
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)
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.
virtual bool simulationIsStopable() const
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.
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
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
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
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
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
Open network - ID.
Definition: GUIAppEnum.h:75
virtual bool simulationIsStepable() const
void addDecals(const std::vector< Decal > &decals)
add decals
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
FXToolBarShell * myToolBarDrag2
void setFgColor(FXColor clr)
set/get forground color
Definition: FXLCDLabel.cpp: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
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:769
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
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
Locate addtional structure - button.
Definition: GUIAppEnum.h:185
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:509
bool myShowTimeAsHMS
whether to show time as hour:minute:second
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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.
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:416
FXCondition myEventCondition
the semaphore when waiting for event completion
void handleEvent_SimulationEnded(GUIEvent *e)
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.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:494
#define snprintf
SUMOReal myJamSoundTime
waiting time after which vehicles trigger jam sounds
std::vector< FXButton * > myStatButtons
Buttons showing and running values and triggering statistic windows.
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
SUMOReal getDelay() const
Returns the parsed delay.
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:430
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:169
Locate edge - button.
Definition: GUIAppEnum.h:173
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
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.
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
virtual bool simulationIsStartable() const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:187
static int _str2int(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
Definition: TplConvert.h:160
FXToolBarShell * myMenuBarDrag
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:488
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:340
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
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:85
GUIPerspectiveChanger & getChanger() const
get changer
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:254
bool simulationAvailable() const
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
T MIN2(T a, T b)
Definition: StdDefs.h:69
The application&#39;s "About" - dialog.
FXGLCanvas * getBuildGLCanvas() const
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.
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
send when a error occured
Definition: GUIEvent.h:56
Send when a screenshot is requested; View and file name are stored within the event.
Definition: GUIEvent.h:67
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
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
The dialog to change the application (gui) settings.
Send when the simulation is over; The reason and the time step are stored within the event...
Definition: GUIEvent.h:63
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
std::string makeSnapshot(const std::string &destFile)
Takes a snapshots and writes it into the given file.
FXMenuPane * mySelectByPermissions
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:119
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:124
toogle time display mode
Definition: GUIAppEnum.h:201
virtual void fillMenuBar()
Builds the menu bar.
T get(MTRand *which=0) const
Draw a sample of the distribution.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
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.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
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()
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
The loading thread.
Definition: GUIAppEnum.h:117
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:360
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:706
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.
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
A storage for options typed value containers)
Definition: OptionsCont.h:99
void setStatusBarText(const std::string &text)
Locate polygons - button.
Definition: GUIAppEnum.h:189
FXRecentFiles myRecentConfigs
List of recent config files.
Open editor for selections.
Definition: GUIAppEnum.h:129
SUMOReal getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
SUMOTime getCurrentSimTime() const
FXdouble getValue() const
Return current value.
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
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
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:125
send when a warning occured
Definition: GUIEvent.h:53
GUIGlID getGlID() const
Returns the numerical id of the object.
FXToolBar * myToolBar1
The application tool bar.
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
long onUpdNeedsSimulation(FXObject *, FXSelector, void *)
Determines whether some buttons which require an active simulation may be shown.
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
#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
const std::string & getViewType() const
Returns the parsed view type.
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:84
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
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 ...
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 onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:111
GUISelectedStorage gSelected
A global holder of selected objects.
static bool gUseMesoSim
Definition: MSGlobals.h:95
int getCollisionCount() const
return the number of collisions
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:441
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
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
virtual void addToWindowsMenu(FXMenuPane *)
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:133
The main window of the SUMO-gui.