SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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/MSGlobals.h>
45 #include <microsim/MSEdge.h>
46 #include <microsim/MSVehicle.h>
47 
48 #include "GUISUMOViewParent.h"
49 #include "GUILoadThread.h"
50 #include "GUIRunThread.h"
51 #include "GUIApplicationWindow.h"
54 
55 #include <utils/common/ToString.h>
61 
77 #include "GUIGlobals.h"
81 
82 #ifdef CHECK_MEMORY_LEAKS
83 #include <foreign/nvwa/debug_new.h>
84 #endif
85 
86 
87 // ===========================================================================
88 // FOX-declarations
89 // ===========================================================================
90 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
91  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
92  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
93  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
94 
98  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
99  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
100  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
102 
104  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
106  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
107  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
108 #ifdef HAVE_OSG
109  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
110 #endif
111  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
112  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
113  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
117 
118  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
119  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
120  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
123 #ifdef HAVE_OSG
124  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
125 #endif
126  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
127  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
128  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
131 
132  // forward requests to the active view
133  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
134  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
135  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
136  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
137  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
138  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
139  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
147 
148  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
149 
154 };
155 
156 // Object implementation
157 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
158 
159 // ===========================================================================
160 // static members
161 // ===========================================================================
162 MTRand GUIApplicationWindow::myGamingRNG;
163 
164 // ===========================================================================
165 // member method definitions
166 // ===========================================================================
168  const std::string& configPattern)
169  : GUIMainWindow(a),
170  myLoadThread(0), myRunThread(0),
171  myAmLoading(false),
172  myAlternateSimDelay(0),
173  myRecentNets(a, "nets"), myConfigPattern(configPattern),
174  hadDependentBuild(false),
175  myShowTimeAsHMS(false),
176  // game specific
177  myJamSoundTime(60),
178  myWaitingTime(0),
179  myTimeLoss(0) {
181 }
182 
183 
184 void
186  // do this not twice
187  if (hadDependentBuild) {
188  return;
189  }
190  hadDependentBuild = true;
191 
192  setTarget(this);
193  setSelector(MID_WINDOW);
194 
195  // build menu bar
196  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
197  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
198  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
199  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
200  TOOLBARGRIP_DOUBLE);
201  buildToolBars();
202  // build the thread - io
207 
208  // build the status bar
209  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
210  {
211  myGeoFrame =
212  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
213  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
214  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A", 0, LAYOUT_CENTER_Y);
216  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
217  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
218  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A", 0, LAYOUT_CENTER_Y);
219  }
220 
221  // make the window a mdi-window
222  myMainSplitter = new FXSplitter(this,
223  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
224  myMDIClient = new FXMDIClient(myMainSplitter,
225  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
226  myMDIMenu = new FXMDIMenu(this, myMDIClient);
227  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
228  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
229  new FXMDIDeleteButton(myMenuBar, myMDIClient,
230  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
231  new FXMDIRestoreButton(myMenuBar, myMDIClient,
232  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
233  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
234  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
235 
236  // build the message window
238  // fill menu and tool bar
239  fillMenuBar();
240  if (game) {
241  onCmdGaming(0, 0, 0);
242  } else {
243  myToolBar6->hide();
244  myToolBar7->hide();
245  }
246  // build additional threads
247  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
248  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
250  // set the status bar
251  myStatusbar->getStatusLine()->setText("Ready.");
252  // set the caption
253  setTitle(MFXUtils::getTitleText(("SUMO " + getBuildName(VERSION_STRING)).c_str()));
254 
255  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
256  myRunThread->start();
258 }
259 
260 
261 void
263  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
264  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
265  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
266  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
267  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
268  }
269  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
270  FXMainWindow::create();
271  myMenuBarDrag->create();
272  myToolBarDrag1->create();
273  myToolBarDrag2->create();
274  myToolBarDrag3->create();
275  myToolBarDrag4->create();
276  myToolBarDrag5->create();
277  myToolBarDrag6->create();
278  myToolBarDrag7->create();
279  myFileMenu->create();
280  mySelectByPermissions->create();
281  myEditMenu->create();
282  mySettingsMenu->create();
283  myLocatorMenu->create();
284  myControlMenu->create();
285  myWindowsMenu->create();
286  myHelpMenu->create();
287 
288  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
289  myCartesianFrame->setWidth(width);
290  myGeoFrame->setWidth(width);
291 
292  show(PLACEMENT_SCREEN);
293  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
294  maximize();
295  }
296  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
297  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
298 }
299 
300 
303  myRunThread->join();
304  closeAllWindows();
305  //
307  delete myGLVisual;
308  // delete some non-parented windows
309  delete myToolBarDrag1;
310  //
311  delete myRunThread;
312  delete myFileMenu;
313  delete myEditMenu;
314  delete mySelectByPermissions;
315  delete mySettingsMenu;
316  delete myLocatorMenu;
317  delete myControlMenu;
318  delete myWindowsMenu;
319  delete myHelpMenu;
320 
321  delete myLoadThread;
322 
323  while (!myEvents.empty()) {
324  // get the next event
325  GUIEvent* e = myEvents.top();
326  myEvents.pop();
327  delete e;
328  }
329 }
330 
331 
332 void
334  FXMainWindow::detach();
335  myMenuBarDrag->detach();
336  myToolBarDrag1->detach();
337 }
338 
339 
340 void
342  // build file menu
343  myFileMenu = new FXMenuPane(this);
344  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
346  "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
349  "Open &Network...\tCtl-N\tOpen a network.",
352  "&Reload\tCtl-R\tReloads the simulation / the network.",
354  new FXMenuSeparator(myFileMenu);
356  "&Close\tCtl-W\tClose the simulation.",
358  // Recent files
359  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
360  sep1->setTarget(&myRecentConfigs);
361  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
362  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
363  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
364  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
365  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
366  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
367  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
368  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
369  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
370  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
371  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
372  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
373  myRecentConfigs.setTarget(this);
374  myRecentConfigs.setSelector(MID_RECENTFILE);
375  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
376  sep2->setTarget(&myRecentNets);
377  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
378  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
379  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
380  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
381  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
382  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
383  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
384  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
385  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
386  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
387  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
388  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
389  myRecentNets.setTarget(this);
390  myRecentNets.setSelector(MID_RECENTFILE);
391  new FXMenuSeparator(myFileMenu);
393  "&Quit\tCtl-Q\tQuit the Application.",
394  0, this, MID_QUIT, 0);
395 
396  // build edit menu
397  mySelectByPermissions = new FXMenuPane(this);
398  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
399  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
401  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
402  }
403 
404  myEditMenu = new FXMenuPane(this);
405  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
407  "Edit Selected...\tCtl-E\tOpens a Dialog for editing the List of Selected Items.",
409  new FXMenuCascade(myEditMenu,
410  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
412  new FXMenuSeparator(myEditMenu);
414  "Edit Breakpoints...\tCtl-B\tOpens a Dialog for editing breakpoints.",
415  0, this, MID_EDIT_BREAKPOINTS);
416 
417  // build settings menu
418  mySettingsMenu = new FXMenuPane(this);
419  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
421  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
422  NULL, this, MID_APPSETTINGS);
423  new FXMenuCheck(mySettingsMenu,
424  "Gaming Mode\tCtl-G\tToggle gaming mode on/off.",
425  this, MID_GAMING);
426  // build Locate menu
427  myLocatorMenu = new FXMenuPane(this);
428  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
430  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
433  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
435  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
437  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
439  }
441  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
444  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
447  "Locate &PoI\t\tOpen a Dialog for Locating a Point of Intereset.",
450  "Locate P&olygon\t\tOpen a Dialog for Locating a Polygon.",
452  new FXMenuSeparator(myLocatorMenu);
453  new FXMenuCheck(myLocatorMenu,
454  "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
455  this, MID_LISTINTERNAL);
456  // build control menu
457  myControlMenu = new FXMenuPane(this);
458  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
460  "Run\tCtl-A\tStart running the simulation.",
461  NULL, this, MID_START);
463  "Stop\tCtl-S\tStop running the simulation.",
464  NULL, this, MID_STOP);
466  "Step\tCtl-D\tPerform one simulation step.",
467  NULL, this, MID_STEP);
468 
469  // build windows menu
470  myWindowsMenu = new FXMenuPane(this);
471  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
472  new FXMenuCheck(myWindowsMenu,
473  "Show Status Line\t\tToggle the Status Bar on/off.",
474  myStatusbar, FXWindow::ID_TOGGLESHOWN);
475  new FXMenuCheck(myWindowsMenu,
476  "Show Message Window\t\tToggle the Message Window on/off.",
477  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
478  new FXMenuCheck(myWindowsMenu,
479  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
480  myToolBar3, FXWindow::ID_TOGGLESHOWN);
481  new FXMenuCheck(myWindowsMenu,
482  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
483  myToolBar4, FXWindow::ID_TOGGLESHOWN);
485  new FXMenuSeparator(myWindowsMenu);
486  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
488  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
489  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
491  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
492  new FXMenuCommand(myWindowsMenu, "Cascade",
494  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
495  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
496  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
497  sep1 = new FXMenuSeparator(myWindowsMenu);
498  sep1->setTarget(myMDIClient);
499  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
500  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
501  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
502  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
503  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
504  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
505  new FXMenuSeparator(myWindowsMenu);
507  "Clear Message Window\t\tClear the message window.",
508  0, this, MID_CLEARMESSAGEWINDOW);
509 
510  // build help menu
511  myHelpMenu = new FXMenuPane(this);
512  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
514  this, MID_ABOUT);
515 }
516 
517 
518 void
520  // build tool bars
521  {
522  // file and simulation tool bar
523  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
524  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
525  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
526  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
527  TOOLBARGRIP_DOUBLE);
528  // build file tools
529  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
531  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
532  new FXButton(myToolBar1, "\t\tOpen a network.",
534  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
535  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
537  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
538  }
539  {
540  // build simulation tools
541  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
542  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
543  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
544  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
545  TOOLBARGRIP_DOUBLE);
546  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
548  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
549  new FXButton(myToolBar2, "\t\tStop the running simulation.",
551  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
552  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
554  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
555  }
556  {
557  // Simulation Step Display
558  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
559  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
560  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
561  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
562  TOOLBARGRIP_DOUBLE);
563  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
564  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
565  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
569  myLCDLabel->setGroove(2);
570  myLCDLabel->setText("-------------");
571  }
572  {
573  // Simulation Delay
574  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
575  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
576  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
577  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
578  TOOLBARGRIP_DOUBLE);
579  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
580  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
583  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
585  mySimDelayTarget->setIncrements(1, 10, 10);
586  mySimDelayTarget->setRange(0, 1000);
588  }
589  {
590  // Views
591  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
592  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
593  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
594  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
595  TOOLBARGRIP_DOUBLE);
596  // build view tools
597  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
599  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
600 #ifdef HAVE_OSG
601  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
603  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
604 #endif
605  }
606  {
608  // total waitingTime
609  myToolBarDrag6 = new FXToolBarShell(this, FRAME_NORMAL);
610  myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
611  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
612  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
613  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, 0, 0, JUSTIFY_RIGHT);
618  myWaitingTimeLabel->setText("-------------");
619 
620  // idealistic time loss
621  myToolBarDrag7 = new FXToolBarShell(this, FRAME_NORMAL);
622  myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
623  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
624  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);
625  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, 0, 0, JUSTIFY_RIGHT);
630  myTimeLossLabel->setText("-------------");
631  }
632 }
633 
634 
635 long
637  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
638  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
639  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
640  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
641  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
642  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
643  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
644  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", myAlternateSimDelay);
645  getApp()->exit(0);
646  return 1;
647 }
648 
649 
650 long
652  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
653  if (mc->getText() == "Edit Selected...") {
654  GUIDialog_GLChosenEditor* chooser =
656  chooser->create();
657  chooser->show();
658  } else {
660  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
661  for (size_t i = 0; i < MSEdge::dictSize(); ++i) {
662  const std::vector<MSLane*>& lanes = MSEdge::dictionary(i)->getLanes();
663  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
664  GUILane* lane = dynamic_cast<GUILane*>(*it);
665  assert(lane != 0);
666  if ((lane->getPermissions() & svc) != 0) {
667  gSelected.select(lane->getGlID());
668  }
669  }
670  }
671  if (myMDIClient->numChildren() > 0) {
672  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
673  if (w != 0) {
674  // color by selection
676  }
677  }
678  }
679  updateChildren();
680  }
681  return 1;
682 }
683 
684 
685 long
688  chooser->create();
689  chooser->show();
690  return 1;
691 }
692 
693 
694 long
696  // get the new file name
697  FXFileDialog opendialog(this, "Open Simulation Configuration");
698  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
699  opendialog.setSelectMode(SELECTFILE_EXISTING);
700  opendialog.setPatternList(myConfigPattern.c_str());
701  if (gCurrentFolder.length() != 0) {
702  opendialog.setDirectory(gCurrentFolder);
703  }
704  if (opendialog.execute()) {
705  gCurrentFolder = opendialog.getDirectory();
706  std::string file = opendialog.getFilename().text();
707  loadConfigOrNet(file, false);
708  myRecentConfigs.appendFile(file.c_str());
709  }
710  return 1;
711 }
712 
713 
714 long
716  // get the new file name
717  FXFileDialog opendialog(this, "Open Network");
718  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
719  opendialog.setSelectMode(SELECTFILE_EXISTING);
720  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
721  if (gCurrentFolder.length() != 0) {
722  opendialog.setDirectory(gCurrentFolder);
723  }
724  if (opendialog.execute()) {
725  gCurrentFolder = opendialog.getDirectory();
726  std::string file = opendialog.getFilename().text();
727  loadConfigOrNet(file, true);
728  myRecentNets.appendFile(file.c_str());
729  }
730  return 1;
731 }
732 
733 
734 long
736  loadConfigOrNet("", false, true);
737  return 1;
738 }
739 
740 
741 long
742 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
743  if (myAmLoading) {
744  myStatusbar->getStatusLine()->setText("Already loading!");
745  return 1;
746  }
747  std::string file((const char*)data);
748  loadConfigOrNet(file, sender == &myRecentNets);
749  return 1;
750 }
751 
752 
753 long
755  closeAllWindows();
756  return 1;
757 }
758 
759 
760 long
761 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
762  sender->handle(this,
763  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
764  ptr);
765  return 1;
766 }
767 
768 
769 long
770 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
771  sender->handle(this,
773  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
774  ptr);
775  return 1;
776 }
777 
778 
779 long
780 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
781  sender->handle(this,
782  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
783  ptr);
784  return 1;
785 }
786 
787 
788 long
789 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
790  sender->handle(this,
792  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
793  ptr);
794  return 1;
795 }
796 
797 
798 long
800  // check whether a net was loaded successfully
802  myStatusbar->getStatusLine()->setText("No simulation loaded!");
803  return 1;
804  }
805  // check whether it was started before and paused;
806  if (!myWasStarted) {
807  myRunThread->begin();
808  myWasStarted = true;
809  }
810  myRunThread->resume();
811  return 1;
812 }
813 
814 
815 long
817  myRunThread->stop();
818  return 1;
819 }
820 
821 
822 long
824  // check whether a net was loaded successfully
826  myStatusbar->getStatusLine()->setText("No simulation loaded!");
827  return 1;
828  }
829  // check whether it was started before and paused;
830  if (!myWasStarted) {
831  myRunThread->begin();
832  myWasStarted = true;
833  }
835  return 1;
836 }
837 
838 
839 long
844  }
845  return 1;
846 }
847 
848 
849 long
851  const SUMOTime tmp = myAlternateSimDelay;
854  return 1;
855 }
856 
857 
858 long
861  return 1;
862 }
863 
864 
865 long
866 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
867  sender->handle(this,
869  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
870  ptr);
871  return 1;
872 }
873 
874 
875 long
876 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
877  sender->handle(this,
879  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
880  ptr);
881  return 1;
882 }
883 
884 
885 long
886 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
887  sender->handle(this,
889  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
890  ptr);
891  return 1;
892 }
893 
894 
895 long
896 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
897  sender->handle(this,
899  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
900  ptr);
901  return 1;
902 }
903 
904 
905 long
906 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
907  if (myMDIClient->numChildren() > 0) {
908  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
909  if (w != 0) {
910  w->onCmdLocate(0, sel, 0);
911  }
912  }
913  return 1;
914 }
915 
916 long
919  d->create();
920  d->show(PLACEMENT_OWNER);
921  return 1;
922 }
923 
924 
925 long
928  if (myAmGaming) {
929  myMenuBar->hide();
930  myStatusbar->hide();
931  myToolBar1->hide();
932  myToolBar2->hide();
933  myToolBar4->hide();
934  myToolBar5->hide();
935  myToolBar6->show();
936  myToolBar7->show();
937  myMessageWindow->hide();
942  } else {
943  myMenuBar->show();
944  myStatusbar->show();
945  myToolBar1->show();
946  myToolBar2->show();
947  myToolBar4->show();
948  myToolBar5->show();
949  myToolBar6->hide();
950  myToolBar7->hide();
951  myMessageWindow->show();
953  gSchemeStorage.getDefault().gaming = false;
954  }
955  update();
956  return 1;
957 }
958 
959 
960 long
963  return 1;
964 }
965 
966 
967 long
970  return 1;
971 }
972 
973 
974 #ifdef HAVE_OSG
975 long
976 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
978  return 1;
979 }
980 #endif
981 
982 
983 long
985  GUIDialog_AboutSUMO* about =
986  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
987  about->create();
988  about->show(PLACEMENT_OWNER);
989  return 1;
990 }
991 
992 
993 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
994  FXEvent* event = (FXEvent*)ptr;
995  FXString string = GUIUserIO::clipped.c_str();
996  setDNDData(FROM_CLIPBOARD, event->target, string);
997  return 1;
998 }
999 
1000 
1001 long
1003  eventOccured();
1004  return 1;
1005 }
1006 
1007 
1008 long
1010  eventOccured();
1011  return 1;
1012 }
1013 
1014 
1015 void
1017  while (!myEvents.empty()) {
1018  // get the next event
1019  GUIEvent* e = myEvents.top();
1020  myEvents.pop();
1021  // process
1022  switch (e->getOwnType()) {
1025  break;
1026  case EVENT_SIMULATION_STEP:
1027  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1029  }
1030  break;
1031  case EVENT_MESSAGE_OCCURED:
1032  case EVENT_WARNING_OCCURED:
1033  case EVENT_ERROR_OCCURED:
1035  break;
1038  break;
1039  default:
1040  break;
1041  }
1042  delete e;
1043  }
1044  myToolBar2->forceRefresh();
1045  myToolBar3->forceRefresh();
1046 }
1047 
1048 
1049 void
1051  myAmLoading = false;
1053  // check whether the loading was successfull
1054  if (ec->myNet == 0) {
1055  // report failure
1056  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1057  if (GUIGlobals::gQuitOnEnd) {
1058  closeAllWindows();
1059  getApp()->exit(1);
1060  }
1061  } else {
1062  // initialise simulation thread
1063  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1064  if (GUIGlobals::gQuitOnEnd) {
1065  closeAllWindows();
1066  getApp()->exit(1);
1067  }
1068  } else {
1069  // report success
1070  setStatusBarText("'" + ec->myFile + "' loaded.");
1071  myWasStarted = false;
1072  // initialise views
1073  myViewNumber = 0;
1075  if (ec->mySettingsFiles.size() > 0) {
1076  // open a view for each file and apply settings
1077  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1078  GUISettingsHandler settings(*it);
1079  GUISUMOViewParent::ViewType vt = defaultType;
1080  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1082  }
1083  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1085  }
1086  GUISUMOAbstractView* view = openNewView(vt);
1087  if (view == 0) {
1088  break;
1089  }
1090  std::string settingsName = settings.addSettings(view);
1091  view->addDecals(settings.getDecals());
1092  settings.setViewport(view);
1093  settings.setSnapshots(view);
1094  if (settings.getDelay() > 0) {
1095  mySimDelayTarget->setValue(settings.getDelay());
1096  }
1097  if (settings.getBreakpoints().size() > 0) {
1099  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1101  }
1102  myJamSounds = settings.getEventDistribution("jam");
1103  if (settings.getJamSoundTime() > 0) {
1104  myJamSoundTime = settings.getJamSoundTime();
1105  }
1106  }
1107  } else {
1108  openNewView(defaultType);
1109  }
1110 
1111  if (isGaming()) {
1112  setTitle("SUMO Traffic Light Game");
1113  } else {
1114  // set simulation name on the caption
1115  std::string caption = "SUMO " + getBuildName(VERSION_STRING);
1116  setTitle(MFXUtils::getTitleText(caption.c_str(), ec->myFile.c_str()));
1117  }
1118  // set simulation step begin information
1119  myLCDLabel->setText("-------------");
1120  }
1121  }
1122  getApp()->endWaitCursor();
1123  // start if wished
1125  onCmdStart(0, 0, 0);
1126  }
1127  update();
1128 }
1129 
1130 
1131 void
1133  updateChildren();
1135  if (myAmGaming) {
1137  }
1138  update();
1139 }
1140 
1141 
1142 void
1144  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1145  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1146 }
1147 
1148 
1149 void
1151  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1152  onCmdStop(0, 0, 0);
1153  if (GUIGlobals::gQuitOnEnd) {
1154  closeAllWindows();
1155  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1156  } else {
1157  // build the text
1158  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1159  ".\nReason: " + MSNet::getStateMessage(ec->getReason());
1160  FXMessageBox::warning(this, MBOX_OK, "Simulation ended", "%s", text.c_str());
1161  }
1162 }
1163 
1164 
1165 void
1170 #ifdef HAVE_INTERNAL
1171  if (myJamSounds.getOverallProb() > 0) {
1172  // play honking sound if some vehicle is waiting too long
1173  for (; it != end; ++it) {
1174  // XXX use impatience instead of waiting time ?
1175  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1176  const std::string cmd = myJamSounds.get(&myGamingRNG);
1177  if (cmd != "") {
1178  // yay! fun with dangerous commands... Never use this over the internet
1180  // one sound per simulation step is enough
1181  break;
1182  }
1183  }
1184  }
1185  }
1186 #endif
1187  // updated peformance indicators
1188 
1189  for (it = vc.loadedVehBegin(); it != end; ++it) {
1190  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1191  assert(veh != 0);
1192  const SUMOReal vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1193  if (veh->isOnRoad() && veh->getSpeed() < SUMO_const_haltingSpeed) {
1195  }
1196  myTimeLoss += TS * TIME2STEPS(vmax - veh->getSpeed()) / vmax; // may be negative with speedFactor > 1
1199  }
1200 
1201 }
1202 
1203 
1204 void
1205 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet, bool isReload) {
1206  getApp()->beginWaitCursor();
1207  myAmLoading = true;
1208  closeAllWindows();
1209  if (isReload) {
1210  myLoadThread->start();
1211  setStatusBarText("Reloading.");
1212  } else {
1213  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1214  myLoadThread->loadConfigOrNet(file, isNet);
1215  setStatusBarText("Loading '" + file + "'.");
1216  }
1217  update();
1218 }
1219 
1220 
1223  if (!myRunThread->simulationAvailable()) {
1224  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1225  return 0;
1226  }
1227  std::string caption = "View #" + toString(myViewNumber++);
1228  FXuint opts = MDI_TRACKING;
1229  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1230  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1232  w->create();
1233  if (myMDIClient->numChildren() == 1) {
1234  w->maximize();
1235  } else {
1236  myMDIClient->vertical(true);
1237  }
1238  myMDIClient->setActiveChild(w);
1239  return v;
1240 }
1241 
1242 
1243 FXGLCanvas*
1245  if (myMDIClient->numChildren() == 0) {
1246  return 0;
1247  }
1248  GUISUMOViewParent* share_tmp1 =
1249  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1250  return share_tmp1->getBuildGLCanvas();
1251 }
1252 
1253 
1254 void
1256  myTrackerLock.lock();
1257  myLCDLabel->setText("-------------");
1258  // remove trackers and other external windows
1259  size_t i;
1260  for (i = 0; i < mySubWindows.size(); ++i) {
1261  mySubWindows[i]->destroy();
1262  }
1263  for (i = 0; i < myTrackerWindows.size(); ++i) {
1264  myTrackerWindows[i]->destroy();
1265  }
1266  // delete the simulation
1268  // reset the caption
1269  setTitle(MFXUtils::getTitleText(("SUMO " + getBuildName(VERSION_STRING)).c_str()));
1270  // delete other children
1271  while (myTrackerWindows.size() != 0) {
1272  delete myTrackerWindows[0];
1273  }
1274  while (mySubWindows.size() != 0) {
1275  delete mySubWindows[0];
1276  }
1277  mySubWindows.clear();
1278  // clear selected items
1279  gSelected.clear();
1280  // add a separator to the log
1283  // remove coordinate information
1284  myGeoCoordinate->setText("N/A");
1285  myCartesianCoordinate->setText("N/A");
1286  //
1288  update();
1289 }
1290 
1291 
1292 FXCursor*
1294  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1295 }
1296 
1297 
1298 SUMOTime
1301 }
1302 
1303 
1304 void
1306  loadConfigOrNet("", false);
1307 }
1308 
1309 
1310 void
1312  myStatusbar->getStatusLine()->setText(text.c_str());
1313  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1314 }
1315 
1316 
1317 void
1319  time -= DELTA_T; // synchronize displayed time with netstate output
1320  if (myAmGaming) {
1321  // show time counting backwards
1322  time = myRunThread->getSimEndTime() - time;
1323  }
1324  SUMOReal fracSeconds = STEPS2TIME(time);
1325  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1326  const int BuffSize = 100;
1327  char buffer[BuffSize];
1328  if (myShowTimeAsHMS) {
1329  const int hours = (int)fracSeconds / 3600;
1330  const int minutes = ((int)fracSeconds % 3600) / 60;
1331  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1332  const std::string format = (hideFraction ?
1333  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1334  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1335  } else {
1336  const std::string format = (hideFraction ?
1337  "%13.0f" : "%13.3f");
1338  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1339  }
1340  myLCDLabel->setText(buffer);
1341 }
1342 
1343 /****************************************************************************/
1344 
std::vector< FXMainWindow * > myTrackerWindows
Definition: GUIMainWindow.h:90
Event sent when the the simulation is over.
MFXMutex & getBreakpointLock()
Definition: GUIRunThread.h:119
RandomDistributor< std::string > myJamSounds
About SUMO - ID.
Definition: GUIAppEnum.h:83
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
GUICompleteSchemeStorage gSchemeStorage
void pop()
Definition: MFXEventQue.h:53
long onCmdStep(FXObject *, FXSelector, void *)
Called on &quot;step&quot;.
static std::string clipped
Definition: GUIUserIO.h:64
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:78
void handleEvent_SimulationLoaded(GUIEvent *e)
SUMOReal getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
virtual bool simulationIsStepable() const
Locate poi - button.
Definition: GUIAppEnum.h:167
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
The Simulation execution thread.
Definition: GUIAppEnum.h:115
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
GUIVisualizationSettings * getVisualisationSettings()
send when a message occured
Definition: GUIEvent.h:50
bool empty()
Definition: MFXEventQue.h:72
virtual void deleteSim()
FXSplitter * myMainSplitter
The splitter that divides the main window into vies and the log window.
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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-&gt;Edit Chosen.
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 select(GUIGlID id, bool update=true)
Adds the object with the given id.
FXToolBarShell * myToolBarDrag4
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether &quot;stop&quot; 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:156
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 &quot;stop&quot;.
void setActive(size_t scheme)
Definition: GUIColorer.h:67
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&#39;t already in the dictionary...
Definition: MSEdge.cpp:523
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:230
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)
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
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:115
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
void loadConfigOrNet(const std::string &file, bool isNet)
begins the loading of the given file
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.
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&#39;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-&gt;Edit Breakpoints.
#define snprintf
SUMOReal myJamSoundTime
waiting time after which vehicles trigger jam sounds
long onCmdStart(FXObject *, FXSelector, void *)
Called on &quot;play&quot;.
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings-&gt;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:283
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 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
const std::string getBuildName(const std::string &version)
attach some build flags to the version string
Definition: StdDefs.cpp:88
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 &quot;delay toggle&quot;.
#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:68
The application&#39;s &quot;About&quot; - 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-&gt;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
#define VERSION_STRING
Definition: version.h:1
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:626
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.
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 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-&gt;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()
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
MFXEventQue< GUIEvent * > myEvents
List of got requests.
void loadConfigOrNet(const std::string &file, bool isNet, bool isReload=false)
static void close()
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:111
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXEX::FXLCDLabel * myTimeLossLabel
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:557
FXDockSite * myTopDock
FXRecentFiles myRecentConfigs
List of recent config files.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:90
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&#39;s current speed.
Definition: MSVehicle.h:292
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
void text()
Definition: gl2psTest.c:260
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-&gt;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:218
static const bool gUseMesoSim
Definition: MSGlobals.h:102
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:503
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)
&quot;Initialises&quot; 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 &quot;time toggle&quot;.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:337
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 &quot;step&quot; 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 &quot;play&quot; is enabled.
The main window of the SUMO-gui.