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-sim.org/
13 // Copyright (C) 2001-2014 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 <microsim/MSEdge.h>
45 #include <microsim/MSVehicle.h>
46 
47 #include "GUISUMOViewParent.h"
48 #include "GUILoadThread.h"
49 #include "GUIRunThread.h"
50 #include "GUIApplicationWindow.h"
53 
54 #include <utils/common/ToString.h>
60 
76 #include "GUIGlobals.h"
80 
81 #ifdef CHECK_MEMORY_LEAKS
82 #include <foreign/nvwa/debug_new.h>
83 #endif
84 
85 
86 // ===========================================================================
87 // FOX-declarations
88 // ===========================================================================
89 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
90  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
91  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
92  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
93 
97  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
98  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
101 
103  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
105  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
106  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
107 #ifdef HAVE_OSG
108  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
109 #endif
110  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
111  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
112  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
116 
117  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
118  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
119  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
122 #ifdef HAVE_OSG
123  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
124 #endif
125  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
126  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
127  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
130 
131  // forward requests to the active view
132  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
133  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
134  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
135  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
136  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
137  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
138  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
146 
147  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
148 
153 };
154 
155 // Object implementation
156 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
157 
158 // ===========================================================================
159 // static members
160 // ===========================================================================
161 MTRand GUIApplicationWindow::myGamingRNG;
162 
163 // ===========================================================================
164 // member method definitions
165 // ===========================================================================
167  const std::string& configPattern)
168  : GUIMainWindow(a),
169  myLoadThread(0), myRunThread(0),
170  myAmLoading(false),
171  myAlternateSimDelay(0),
172  myRecentNets(a, "nets"), myConfigPattern(configPattern),
173  hadDependentBuild(false),
174  myShowTimeAsHMS(false),
175  // game specific
176  myJamSoundTime(60),
177  myWaitingTime(0),
178  myTimeLoss(0) {
180 }
181 
182 
183 void
185  // do this not twice
186  if (hadDependentBuild) {
187  return;
188  }
189  hadDependentBuild = true;
190 
191  setTarget(this);
192  setSelector(MID_WINDOW);
193 
194  // build menu bar
195  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
196  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
197  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
198  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
199  TOOLBARGRIP_DOUBLE);
200  buildToolBars();
201  // build the thread - io
206 
207  // build the status bar
208  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
209  {
210  myGeoFrame =
211  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
212  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
213  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A", 0, LAYOUT_CENTER_Y);
215  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
216  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
217  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A", 0, LAYOUT_CENTER_Y);
218  }
219 
220  // make the window a mdi-window
221  myMainSplitter = new FXSplitter(this,
222  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
223  myMDIClient = new FXMDIClient(myMainSplitter,
224  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
225  myMDIMenu = new FXMDIMenu(this, myMDIClient);
226  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
227  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
228  new FXMDIDeleteButton(myMenuBar, myMDIClient,
229  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
230  new FXMDIRestoreButton(myMenuBar, myMDIClient,
231  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
232  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
233  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
234 
235  // build the message window
237  // fill menu and tool bar
238  fillMenuBar();
239  if (game) {
240  onCmdGaming(0, 0, 0);
241  } else {
242  myToolBar6->hide();
243  myToolBar7->hide();
244  }
245  // build additional threads
246  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
247  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
249  // set the status bar
250  myStatusbar->getStatusLine()->setText("Ready.");
251  // set the caption
252  setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
253 
254  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
255  myRunThread->start();
257 }
258 
259 
260 void
262  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
263  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
264  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
265  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
266  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
267  }
268  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
269  FXMainWindow::create();
270  myMenuBarDrag->create();
271  myToolBarDrag1->create();
272  myToolBarDrag2->create();
273  myToolBarDrag3->create();
274  myToolBarDrag4->create();
275  myToolBarDrag5->create();
276  myToolBarDrag6->create();
277  myToolBarDrag7->create();
278  myFileMenu->create();
279  mySelectByPermissions->create();
280  myEditMenu->create();
281  mySettingsMenu->create();
282  myLocatorMenu->create();
283  myControlMenu->create();
284  myWindowsMenu->create();
285  myHelpMenu->create();
286 
287  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
288  myCartesianFrame->setWidth(width);
289  myGeoFrame->setWidth(width);
290 
291  show(PLACEMENT_SCREEN);
292  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
293  maximize();
294  }
295  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
296  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
297 }
298 
299 
302  myRunThread->join();
303  closeAllWindows();
304  //
306  delete myGLVisual;
307  // delete some non-parented windows
308  delete myToolBarDrag1;
309  //
310  delete myRunThread;
311  delete myFileMenu;
312  delete myEditMenu;
313  delete mySelectByPermissions;
314  delete mySettingsMenu;
315  delete myLocatorMenu;
316  delete myControlMenu;
317  delete myWindowsMenu;
318  delete myHelpMenu;
319 
320  delete myLoadThread;
321 
322  while (!myEvents.empty()) {
323  // get the next event
324  GUIEvent* e = static_cast<GUIEvent*>(myEvents.top());
325  myEvents.pop();
326  delete e;
327  }
328 }
329 
330 
331 void
333  FXMainWindow::detach();
334  myMenuBarDrag->detach();
335  myToolBarDrag1->detach();
336 }
337 
338 
339 void
341  // build file menu
342  myFileMenu = new FXMenuPane(this);
343  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
345  "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
348  "Open &Network...\tCtl-N\tOpen a network.",
351  "&Reload\tCtl-R\tReloads the simulation / the network.",
353  new FXMenuSeparator(myFileMenu);
355  "&Close\tCtl-W\tClose the simulation.",
357  // Recent files
358  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
359  sep1->setTarget(&myRecentConfigs);
360  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
361  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
362  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
363  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
364  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
365  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
366  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
367  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
368  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
369  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
370  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
371  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
372  myRecentConfigs.setTarget(this);
373  myRecentConfigs.setSelector(MID_RECENTFILE);
374  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
375  sep2->setTarget(&myRecentNets);
376  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
377  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
378  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
379  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
380  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
381  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
382  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
383  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
384  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
385  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
386  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
387  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
388  myRecentNets.setTarget(this);
389  myRecentNets.setSelector(MID_RECENTFILE);
390  new FXMenuSeparator(myFileMenu);
392  "&Quit\tCtl-Q\tQuit the Application.",
393  0, this, MID_QUIT, 0);
394 
395  // build edit menu
396  mySelectByPermissions = new FXMenuPane(this);
397  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
398  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
400  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
401  }
402 
403  myEditMenu = new FXMenuPane(this);
404  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
406  "Edit Selected...\tCtl-E\tOpens a Dialog for editing the List of Selected Items.",
408  new FXMenuCascade(myEditMenu,
409  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
411  new FXMenuSeparator(myEditMenu);
413  "Edit Breakpoints...\tCtl-B\tOpens a Dialog for editing breakpoints.",
414  0, this, MID_EDIT_BREAKPOINTS);
415 
416  // build settings menu
417  mySettingsMenu = new FXMenuPane(this);
418  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
420  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
421  NULL, this, MID_APPSETTINGS);
422  new FXMenuCheck(mySettingsMenu,
423  "Gaming Mode\tCtl-G\tToggle gaming mode on/off.",
424  this, MID_GAMING);
425  // build Locate menu
426  myLocatorMenu = new FXMenuPane(this);
427  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
429  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
432  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
434  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
436  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
438  }
440  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
443  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
446  "Locate &PoI\t\tOpen a Dialog for Locating a Point of Intereset.",
449  "Locate P&olygon\t\tOpen a Dialog for Locating a Polygon.",
451  new FXMenuSeparator(myLocatorMenu);
452  new FXMenuCheck(myLocatorMenu,
453  "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
454  this, MID_LISTINTERNAL);
455  // build control menu
456  myControlMenu = new FXMenuPane(this);
457  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
459  "Run\tCtl-A\tStart running the simulation.",
460  NULL, this, MID_START);
462  "Stop\tCtl-S\tStop running the simulation.",
463  NULL, this, MID_STOP);
465  "Step\tCtl-D\tPerform one simulation step.",
466  NULL, this, MID_STEP);
467 
468  // build windows menu
469  myWindowsMenu = new FXMenuPane(this);
470  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
471  new FXMenuCheck(myWindowsMenu,
472  "Show Status Line\t\tToggle the Status Bar on/off.",
473  myStatusbar, FXWindow::ID_TOGGLESHOWN);
474  new FXMenuCheck(myWindowsMenu,
475  "Show Message Window\t\tToggle the Message Window on/off.",
476  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
477  new FXMenuCheck(myWindowsMenu,
478  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
479  myToolBar3, FXWindow::ID_TOGGLESHOWN);
480  new FXMenuCheck(myWindowsMenu,
481  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
482  myToolBar4, FXWindow::ID_TOGGLESHOWN);
484  new FXMenuSeparator(myWindowsMenu);
485  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
487  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
488  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
490  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
491  new FXMenuCommand(myWindowsMenu, "Cascade",
493  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
494  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
495  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
496  sep1 = new FXMenuSeparator(myWindowsMenu);
497  sep1->setTarget(myMDIClient);
498  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
499  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
500  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
501  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
502  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
503  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
504  new FXMenuSeparator(myWindowsMenu);
506  "Clear Message Window\t\tClear the message window.",
507  0, this, MID_CLEARMESSAGEWINDOW);
508 
509  // build help menu
510  myHelpMenu = new FXMenuPane(this);
511  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
513  this, MID_ABOUT);
514 }
515 
516 
517 void
519  // build tool bars
520  {
521  // file and simulation tool bar
522  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
523  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
524  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
525  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
526  TOOLBARGRIP_DOUBLE);
527  // build file tools
528  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
530  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
531  new FXButton(myToolBar1, "\t\tOpen a network.",
533  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
534  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
536  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
537  }
538  {
539  // build simulation tools
540  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
541  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
542  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
543  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
544  TOOLBARGRIP_DOUBLE);
545  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
547  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
548  new FXButton(myToolBar2, "\t\tStop the running simulation.",
550  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
551  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
553  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
554  }
555  {
556  // Simulation Step Display
557  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
558  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
559  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
560  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
561  TOOLBARGRIP_DOUBLE);
562  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
563  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
564  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
568  myLCDLabel->setGroove(2);
569  myLCDLabel->setText("-------------");
570  }
571  {
572  // Simulation Delay
573  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
574  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
575  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
576  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
577  TOOLBARGRIP_DOUBLE);
578  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
579  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
582  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
584  mySimDelayTarget->setIncrements(1, 10, 10);
585  mySimDelayTarget->setRange(0, 1000);
587  }
588  {
589  // Views
590  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
591  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
592  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
593  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
594  TOOLBARGRIP_DOUBLE);
595  // build view tools
596  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
598  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
599 #ifdef HAVE_OSG
600  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
602  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
603 #endif
604  }
605  {
607  // total waitingTime
608  myToolBarDrag6 = new FXToolBarShell(this, FRAME_NORMAL);
609  myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
610  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
611  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
612  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, 0, 0, JUSTIFY_RIGHT);
617  myWaitingTimeLabel->setText("-------------");
618 
619  // idealistic time loss
620  myToolBarDrag7 = new FXToolBarShell(this, FRAME_NORMAL);
621  myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
622  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
623  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);
624  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, 0, 0, JUSTIFY_RIGHT);
629  myTimeLossLabel->setText("-------------");
630  }
631 }
632 
633 
634 long
636  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
637  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
638  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
639  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
640  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
641  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
642  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
643  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", myAlternateSimDelay);
644  getApp()->exit(0);
645  return 1;
646 }
647 
648 
649 long
651  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
652  if (mc->getText() == "Edit Selected...") {
653  GUIDialog_GLChosenEditor* chooser =
655  chooser->create();
656  chooser->show();
657  } else {
659  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
660  for (size_t i = 0; i < MSEdge::dictSize(); ++i) {
661  const std::vector<MSLane*>& lanes = MSEdge::dictionary(i)->getLanes();
662  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
663  GUILane* lane = dynamic_cast<GUILane*>(*it);
664  assert(lane != 0);
665  if ((lane->getPermissions() & svc) != 0) {
666  gSelected.select(lane->getGlID());
667  }
668  }
669  }
670  if (myMDIClient->numChildren() > 0) {
671  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
672  if (w != 0) {
673  // color by selection
675  }
676  }
677  }
678  updateChildren();
679  }
680  return 1;
681 }
682 
683 
684 long
687  chooser->create();
688  chooser->show();
689  return 1;
690 }
691 
692 
693 long
695  // get the new file name
696  FXFileDialog opendialog(this, "Open Simulation Configuration");
697  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
698  opendialog.setSelectMode(SELECTFILE_EXISTING);
699  opendialog.setPatternList(myConfigPattern.c_str());
700  if (gCurrentFolder.length() != 0) {
701  opendialog.setDirectory(gCurrentFolder);
702  }
703  if (opendialog.execute()) {
704  gCurrentFolder = opendialog.getDirectory();
705  std::string file = opendialog.getFilename().text();
706  load(file, false);
707  myRecentConfigs.appendFile(file.c_str());
708  }
709  return 1;
710 }
711 
712 
713 long
715  // get the new file name
716  FXFileDialog opendialog(this, "Open Network");
717  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
718  opendialog.setSelectMode(SELECTFILE_EXISTING);
719  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
720  if (gCurrentFolder.length() != 0) {
721  opendialog.setDirectory(gCurrentFolder);
722  }
723  if (opendialog.execute()) {
724  gCurrentFolder = opendialog.getDirectory();
725  std::string file = opendialog.getFilename().text();
726  load(file, true);
727  myRecentNets.appendFile(file.c_str());
728  }
729  return 1;
730 }
731 
732 
733 long
735  load("", false, true);
736  return 1;
737 }
738 
739 
740 long
741 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
742  if (myAmLoading) {
743  myStatusbar->getStatusLine()->setText("Already loading!");
744  return 1;
745  }
746  std::string file((const char*)data);
747  load(file, sender == &myRecentNets);
748  return 1;
749 }
750 
751 
752 long
754  closeAllWindows();
755  return 1;
756 }
757 
758 
759 long
760 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
761  sender->handle(this,
762  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
763  ptr);
764  return 1;
765 }
766 
767 
768 long
769 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
770  sender->handle(this,
772  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
773  ptr);
774  return 1;
775 }
776 
777 
778 long
779 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
780  sender->handle(this,
781  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
782  ptr);
783  return 1;
784 }
785 
786 
787 long
788 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
789  sender->handle(this,
791  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
792  ptr);
793  return 1;
794 }
795 
796 
797 long
799  // check whether a net was loaded successfully
801  myStatusbar->getStatusLine()->setText("No simulation loaded!");
802  return 1;
803  }
804  // check whether it was started before and paused;
805  if (!myWasStarted) {
806  myRunThread->begin();
807  myWasStarted = true;
808  }
809  myRunThread->resume();
810  return 1;
811 }
812 
813 
814 long
816  myRunThread->stop();
817  return 1;
818 }
819 
820 
821 long
823  // check whether a net was loaded successfully
825  myStatusbar->getStatusLine()->setText("No simulation loaded!");
826  return 1;
827  }
828  // check whether it was started before and paused;
829  if (!myWasStarted) {
830  myRunThread->begin();
831  myWasStarted = true;
832  }
834  return 1;
835 }
836 
837 
838 long
843  }
844  return 1;
845 }
846 
847 
848 long
850  const SUMOTime tmp = myAlternateSimDelay;
853  return 1;
854 }
855 
856 
857 long
860  return 1;
861 }
862 
863 
864 long
865 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
866  sender->handle(this,
868  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
869  ptr);
870  return 1;
871 }
872 
873 
874 long
875 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
876  sender->handle(this,
878  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
879  ptr);
880  return 1;
881 }
882 
883 
884 long
885 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
886  sender->handle(this,
888  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
889  ptr);
890  return 1;
891 }
892 
893 
894 long
895 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
896  sender->handle(this,
898  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
899  ptr);
900  return 1;
901 }
902 
903 
904 long
905 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
906  if (myMDIClient->numChildren() > 0) {
907  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
908  if (w != 0) {
909  w->onCmdLocate(0, sel, 0);
910  }
911  }
912  return 1;
913 }
914 
915 long
918  d->create();
919  d->show(PLACEMENT_OWNER);
920  return 1;
921 }
922 
923 
924 long
927  if (myAmGaming) {
928  myMenuBar->hide();
929  myStatusbar->hide();
930  myToolBar1->hide();
931  myToolBar2->hide();
932  myToolBar4->hide();
933  myToolBar5->hide();
934  myToolBar6->show();
935  myToolBar7->show();
936  myMessageWindow->hide();
941  } else {
942  myMenuBar->show();
943  myStatusbar->show();
944  myToolBar1->show();
945  myToolBar2->show();
946  myToolBar4->show();
947  myToolBar5->show();
948  myToolBar6->hide();
949  myToolBar7->hide();
950  myMessageWindow->show();
952  gSchemeStorage.getDefault().gaming = false;
953  }
954  update();
955  return 1;
956 }
957 
958 
959 long
962  return 1;
963 }
964 
965 
966 long
969  return 1;
970 }
971 
972 
973 #ifdef HAVE_OSG
974 long
975 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
977  return 1;
978 }
979 #endif
980 
981 
982 long
984  GUIDialog_AboutSUMO* about =
985  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
986  about->create();
987  about->show(PLACEMENT_OWNER);
988  return 1;
989 }
990 
991 
992 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
993  FXEvent* event = (FXEvent*)ptr;
994  FXString string = GUIUserIO::clipped.c_str();
995  setDNDData(FROM_CLIPBOARD, event->target, string);
996  return 1;
997 }
998 
999 
1000 long
1002  eventOccured();
1003  return 1;
1004 }
1005 
1006 
1007 long
1009  eventOccured();
1010  return 1;
1011 }
1012 
1013 
1014 void
1016  while (!myEvents.empty()) {
1017  // get the next event
1018  GUIEvent* e = static_cast<GUIEvent*>(myEvents.top());
1019  myEvents.pop();
1020  // process
1021  switch (e->getOwnType()) {
1024  break;
1025  case EVENT_SIMULATION_STEP:
1026  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1028  }
1029  break;
1030  case EVENT_MESSAGE_OCCURED:
1031  case EVENT_WARNING_OCCURED:
1032  case EVENT_ERROR_OCCURED:
1034  break;
1037  break;
1038  default:
1039  break;
1040  }
1041  delete e;
1042  }
1043  myToolBar2->forceRefresh();
1044  myToolBar3->forceRefresh();
1045 }
1046 
1047 
1048 void
1050  myAmLoading = false;
1052  // check whether the loading was successfull
1053  if (ec->myNet == 0) {
1054  // report failure
1055  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1056  if (GUIGlobals::gQuitOnEnd) {
1057  closeAllWindows();
1058  getApp()->exit(1);
1059  }
1060  } else {
1061  // initialise simulation thread
1062  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1063  if (GUIGlobals::gQuitOnEnd) {
1064  closeAllWindows();
1065  getApp()->exit(1);
1066  }
1067  } else {
1068  // report success
1069  setStatusBarText("'" + ec->myFile + "' loaded.");
1070  myWasStarted = false;
1071  // initialise views
1072  myViewNumber = 0;
1074  if (ec->mySettingsFiles.size() > 0) {
1075  // open a view for each file and apply settings
1076  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1077  GUISettingsHandler settings(*it);
1078  GUISUMOViewParent::ViewType vt = defaultType;
1079  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1081  }
1082  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1084  }
1085  GUISUMOAbstractView* view = openNewView(vt);
1086  if (view == 0) {
1087  break;
1088  }
1089  std::string settingsName = settings.addSettings(view);
1090  view->addDecals(settings.getDecals());
1091  settings.setViewport(view);
1092  settings.setSnapshots(view);
1093  if (settings.getDelay() > 0) {
1094  mySimDelayTarget->setValue(settings.getDelay());
1095  }
1096  if (settings.getBreakpoints().size() > 0) {
1098  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1100  }
1101  myJamSounds = settings.getEventDistribution("jam");
1102  if (settings.getJamSoundTime() > 0) {
1103  myJamSoundTime = settings.getJamSoundTime();
1104  }
1105  }
1106  } else {
1107  openNewView(defaultType);
1108  }
1109 
1110  if (isGaming()) {
1111  setTitle("SUMO Traffic Light Game");
1112  } else {
1113  // set simulation name on the caption
1114  std::string caption = "SUMO " + std::string(VERSION_STRING);
1115  setTitle(MFXUtils::getTitleText(caption.c_str(), ec->myFile.c_str()));
1116  }
1117  // set simulation step begin information
1118  myLCDLabel->setText("-------------");
1119  }
1120  }
1121  getApp()->endWaitCursor();
1122  // start if wished
1124  onCmdStart(0, 0, 0);
1125  }
1126  update();
1127 }
1128 
1129 
1130 void
1132  updateChildren();
1134  if (myAmGaming) {
1136  }
1137  update();
1138 }
1139 
1140 
1141 void
1143  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1145 }
1146 
1147 
1148 void
1150  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1151  onCmdStop(0, 0, 0);
1152  if (GUIGlobals::gQuitOnEnd) {
1153  closeAllWindows();
1154  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1155  } else {
1156  // build the text
1157  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1158  ".\nReason: " + MSNet::getStateMessage(ec->getReason());
1159  FXMessageBox::warning(this, MBOX_OK, "Simulation ended", "%s", text.c_str());
1160  }
1161 }
1162 
1163 
1164 void
1169  if (myJamSounds.getOverallProb() > 0) {
1170  // play honking sound if some vehicle is waiting too long
1171  for (; it != end; ++it) {
1172  // XXX use impatience instead of waiting time ?
1173  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1174  const std::string cmd = myJamSounds.get(&myGamingRNG);
1175  if (cmd != "") {
1176  // yay! fun with dangerous commands... Never use this over the internet
1178  // one sound per simulation step is enough
1179  break;
1180  }
1181  }
1182  }
1183  }
1184  // updated peformance indicators
1185 
1186  for (it = vc.loadedVehBegin(); it != end; ++it) {
1187  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1188  assert(veh != 0);
1189  const SUMOReal vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1190  if (veh->isOnRoad() && veh->getSpeed() < SUMO_const_haltingSpeed) {
1192  }
1193  myTimeLoss += TS * TIME2STEPS(vmax - veh->getSpeed()) / vmax; // may be negative with speedFactor > 1
1196  }
1197 
1198 }
1199 
1200 
1201 void
1202 GUIApplicationWindow::load(const std::string& file, bool isNet, bool isReload) {
1203  getApp()->beginWaitCursor();
1204  myAmLoading = true;
1205  closeAllWindows();
1206  if (isReload) {
1207  myLoadThread->start();
1208  setStatusBarText("Reloading.");
1209  } else {
1210  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1211  myLoadThread->load(file, isNet);
1212  setStatusBarText("Loading '" + file + "'.");
1213  }
1214  update();
1215 }
1216 
1217 
1220  if (!myRunThread->simulationAvailable()) {
1221  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1222  return 0;
1223  }
1224  std::string caption = "View #" + toString(myViewNumber++);
1225  FXuint opts = MDI_TRACKING;
1226  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1227  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1229  w->create();
1230  if (myMDIClient->numChildren() == 1) {
1231  w->maximize();
1232  } else {
1233  myMDIClient->vertical(true);
1234  }
1235  myMDIClient->setActiveChild(w);
1236  return v;
1237 }
1238 
1239 
1240 FXGLCanvas*
1242  if (myMDIClient->numChildren() == 0) {
1243  return 0;
1244  }
1245  GUISUMOViewParent* share_tmp1 =
1246  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1247  return share_tmp1->getBuildGLCanvas();
1248 }
1249 
1250 
1251 void
1253  myTrackerLock.lock();
1254  myLCDLabel->setText("-------------");
1255  // remove trackers and other external windows
1256  size_t i;
1257  for (i = 0; i < mySubWindows.size(); ++i) {
1258  mySubWindows[i]->destroy();
1259  }
1260  for (i = 0; i < myTrackerWindows.size(); ++i) {
1261  myTrackerWindows[i]->destroy();
1262  }
1263  // delete the simulation
1265  // reset the caption
1266  setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
1267  // delete other children
1268  while (myTrackerWindows.size() != 0) {
1269  delete myTrackerWindows[0];
1270  }
1271  while (mySubWindows.size() != 0) {
1272  delete mySubWindows[0];
1273  }
1274  mySubWindows.clear();
1275  // clear selected items
1276  gSelected.clear();
1277  // add a separator to the log
1280  // remove coordinate information
1281  myGeoCoordinate->setText("N/A");
1282  myCartesianCoordinate->setText("N/A");
1283  //
1285  update();
1286 }
1287 
1288 
1289 FXCursor*
1291  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1292 }
1293 
1294 
1295 SUMOTime
1298 }
1299 
1300 
1301 void
1303  load("", false);
1304 }
1305 
1306 
1307 void
1308 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1309  myStatusbar->getStatusLine()->setText(text.c_str());
1310  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1311 }
1312 
1313 
1314 void
1316  time -= DELTA_T; // synchronize displayed time with netstate output
1317  if (myAmGaming) {
1318  // show time counting backwards
1319  time = myRunThread->getSimEndTime() - time;
1320  }
1321  SUMOReal fracSeconds = STEPS2TIME(time);
1322  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1323  const int BuffSize = 100;
1324  char buffer[BuffSize];
1325  if (myShowTimeAsHMS) {
1326  const int hours = (int)fracSeconds / 3600;
1327  const int minutes = ((int)fracSeconds % 3600) / 60;
1328  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1329  const std::string format = (hideFraction ?
1330  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1331  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1332  } else {
1333  const std::string format = (hideFraction ?
1334  "%13.0f" : "%13.3f");
1335  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1336  }
1337  myLCDLabel->setText(buffer);
1338 }
1339 
1340 /****************************************************************************/
1341 
std::vector< FXMainWindow * > myTrackerWindows
Definition: GUIMainWindow.h:90
Event sent when the the simulation is over.
MFXMutex & getBreakpointLock()
Definition: GUIRunThread.h:118
RandomDistributor< std::string > myJamSounds
About SUMO - ID.
Definition: GUIAppEnum.h:83
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
GUICompleteSchemeStorage gSchemeStorage
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:77
void handleEvent_SimulationLoaded(GUIEvent *e)
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
virtual bool simulationIsStepable() const
Locate poi - button.
Definition: GUIAppEnum.h:167
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
The Simulation execution thread.
Definition: GUIAppEnum.h:115
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
GUIVisualizationSettings * getVisualisationSettings()
send when a message occured
Definition: GUIEvent.h:50
void * top()
Definition: MFXEventQue.cpp:39
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...
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
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.
MFXEventQue myEvents
List of got requests.
static MTRand myGamingRNG
A random number generator used to choose a gaming sound.
bool gaming
whether the application is in gaming mode or not
Locate vehicle - button.
Definition: GUIAppEnum.h:161
const bool myOsgView
whether to load the OpenSceneGraph view
const std::string & getMsg() const
Returns the message.
GUIColorer laneColorer
The lane colorer.
void load(const std::string &file, bool isNet)
begins the loading of the given file
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
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.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
Start the simulation.
Definition: GUIAppEnum.h:91
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:61
Locate TLS - button.
Definition: GUIAppEnum.h:163
Edit simulation breakpoints.
Definition: GUIAppEnum.h:127
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
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:77
FXGLVisual * myGLVisual
The gl-visual used.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
Definition: MSEdge.cpp:473
FXString gCurrentFolder
The folder used as last.
Open configuration - ID.
Definition: GUIAppEnum.h:73
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
Close simulation - ID.
Definition: GUIAppEnum.h:81
#define TS
Definition: SUMOTime.h:52
Loads a file previously loaded.
Definition: GUIAppEnum.h:79
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:216
Open network - ID.
Definition: GUIAppEnum.h:75
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:77
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)
Locate junction - button.
Definition: GUIAppEnum.h:157
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
virtual FXGLCanvas * getBuildGLCanvas() const
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
void addDecals(const std::vector< Decal > &decals)
FXToolBarShell * myToolBarDrag2
void setViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
void setFgColor(FXColor clr)
set/get forground color
Definition: FXLCDLabel.cpp:128
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:114
Main window closes.
Definition: GUIAppEnum.h:55
Application settings - menu entry.
Definition: GUIAppEnum.h:135
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
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
RandomDistributor< std::string > getEventDistribution(const std::string &id)
Editor for simulation breakpoints.
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
Definition: GUIMainWindow.h:89
static void clearTextures()
clears loaded textures
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:77
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
void setActive(size_t scheme)
Definition: GUIColorer.h:66
static const RGBColor GREEN
Definition: RGBColor.h:190
An error occured during the simulation step.
Definition: MSNet.h:106
void updateTimeLCD(SUMOTime time)
updates the simulation time display
void setRange(FXdouble lo, FXdouble hi)
Change the spinner's range.
Locator configuration - menu entry.
Definition: GUIAppEnum.h:139
void handleEvent_SimulationEnded(GUIEvent *e)
FXdouble getValue() const
Return current value.
Locate polygons - button.
Definition: GUIAppEnum.h:169
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.
#define snprintf
SUMOReal myJamSoundTime
waiting time after which vehicles trigger jam sounds
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:169
The loading thread.
Definition: GUIAppEnum.h:113
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:269
static void init(FXApp *a)
size_t myViewNumber
The current view number.
T get(MTRand *which=0) const
Draw a sample of the distribution.
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
void load(const std::string &file, bool isNet, bool isReload=false)
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:187
FXToolBarShell * myMenuBarDrag
SUMOTime getCurrentSimTime() const
ViewType
Available view types.
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
Gaming mode - menu entry.
Definition: GUIAppEnum.h:137
Perform a single simulation step.
Definition: GUIAppEnum.h:95
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:66
The application's "About" - dialog.
void setStatusBarText(const std::string &)
The Simulation delay control.
Definition: GUIAppEnum.h:141
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
void saveViewport(const SUMOReal x, const SUMOReal y, const SUMOReal zoom)
Makes the given viewport the default.
send when a error occured
Definition: GUIEvent.h:56
Open chosen editor - ID.
Definition: GUIAppEnum.h:125
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:378
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
bool myListInternal
information whether the locator should list internal structures
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
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:582
Send when the simulation is over; The reason and the time step are stored within the event...
Definition: GUIEvent.h:60
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
FXMenuPane * mySelectByPermissions
GUINet & getNet() const
virtual void fillMenuBar()
Builds the menu bar.
#define VERSION_STRING
Definition: config.h:227
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:105
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 appendText(GUIEventType eType, const std::string &msg)
Adds new text to the window.
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
GUIVisualizationSettings & getDefault()
Returns the default scheme.
FXToolBarShell * myToolBarDrag6
static const RGBColor RED
Definition: RGBColor.h:189
Locate addtional structure - button.
Definition: GUIAppEnum.h:165
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
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.
toogle time display mode
Definition: GUIAppEnum.h:181
void prepareDestruction()
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
Definition: GUIMainWindow.h:92
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
static void close()
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:110
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXEX::FXLCDLabel * myTimeLossLabel
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:507
FXDockSite * myTopDock
FXRecentFiles myRecentConfigs
List of recent config files.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:95
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:54
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's current speed.
Definition: MSVehicle.h:291
int SUMOTime
Definition: SUMOTime.h:43
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
toogle delay between alternative value
Definition: GUIAppEnum.h:183
FXMDIClient * myMDIClient
The multi view panel.
Definition: GUIMainWindow.h:98
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
Stop the simulation.
Definition: GUIAppEnum.h:93
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.
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:215
static const bool gUseMesoSim
Definition: MSGlobals.h:99
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:492
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:73
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
Locate edge - button.
Definition: GUIAppEnum.h:159
#define DELTA_T
Definition: SUMOTime.h:50
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The class responsible for building and deletion of vehicles.
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:154
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
const SUMOTime myEnd
the time the simulation shall end with
virtual void begin()
void clear()
Clears the window.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
bool empty()
Definition: MFXEventQue.cpp:74
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:336
Main window-ID.
Definition: GUIAppEnum.h:53
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
Open a new microscopic view.
Definition: GUIAppEnum.h:103
static FXIcon * getIcon(GUIIcon which)
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
virtual void addToWindowsMenu(FXMenuPane *)
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
The main window of the SUMO-gui.