SUMO - Simulation of Urban MObility
GUIApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The main window of the SUMO-gui.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #ifdef HAVE_VERSION_H
35 #include <version.h>
36 #endif
37 
38 #include <string>
39 #include <sstream>
40 #include <algorithm>
41 
42 #include <guisim/GUINet.h>
43 #include <guisim/GUILane.h>
44 #include <netload/NLHandler.h>
45 #include <microsim/MSGlobals.h>
46 #include <microsim/MSEdge.h>
47 #include <microsim/MSVehicle.h>
48 
49 #include "GUISUMOViewParent.h"
50 #include "GUILoadThread.h"
51 #include "GUIRunThread.h"
52 #include "GUIApplicationWindow.h"
55 #include "GUIEvent_Screenshot.h"
56 
57 #include <utils/common/ToString.h>
64 
65 #include <utils/xml/XMLSubSys.h>
84 #include "GUIGlobals.h"
88 
89 #ifdef CHECK_MEMORY_LEAKS
90 #include <foreign/nvwa/debug_new.h>
91 #endif
92 
93 
94 // ===========================================================================
95 // FOX-declarations
96 // ===========================================================================
97 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
98  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
99  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
100  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
101 
105  FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
106  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
107  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
108  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
110  FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
111 
113  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
114  FXMAPFUNC(SEL_COMMAND, MID_FULLSCREEN, GUIApplicationWindow::onCmdFullScreen),
116  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
117  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
118 #ifdef HAVE_OSG
119  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
120 #endif
121  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
122  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
123  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
127 
128  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
129  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
130  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
131  FXMAPFUNC(SEL_UPDATE, MID_OPEN_SHAPES, GUIApplicationWindow::onUpdReload),
132  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
135 #ifdef HAVE_OSG
136  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
137 #endif
138  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
139  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
140  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
144  FXMAPFUNC(SEL_COMMAND, MID_HELP, GUIApplicationWindow::onCmdHelp),
145 
146  // forward requests to the active view
147  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
148  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
149  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
150  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
151  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
152  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
153  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
154  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
163  FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
164  FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
165 
166  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
167 
172 };
173 
174 // Object implementation
175 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
176 
177 // ===========================================================================
178 // static members
179 // ===========================================================================
180 MTRand GUIApplicationWindow::myGamingRNG;
181 
182 // ===========================================================================
183 // member method definitions
184 // ===========================================================================
186  const std::string& configPattern)
187  : GUIMainWindow(a),
188  myLoadThread(0), myRunThread(0),
189  myAmLoading(false),
190  myAlternateSimDelay(0),
191  myRecentNets(a, "nets"), myConfigPattern(configPattern),
192  hadDependentBuild(false),
193  myShowTimeAsHMS(false),
194  myAmFullScreen(false),
195  myHaveNotifiedAboutSimEnd(false),
196  // game specific
197  myJamSoundTime(60),
198  myWaitingTime(0),
199  myTimeLoss(0) {
201 }
202 
203 
204 void
206  // don't do this twice
207  if (hadDependentBuild) {
208  return;
209  }
210  hadDependentBuild = true;
211 
212  setTarget(this);
213  setSelector(MID_WINDOW);
214 
215  // build menu bar
216  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
217  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
218  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
219  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
220  TOOLBARGRIP_DOUBLE);
221  buildToolBars();
222  // build the thread - io
227 
228  // build the status bar
229  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
230  {
231  myGeoFrame =
232  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
233  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
234  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
236  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
237  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
238  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
239  }
240 
241  // make the window a mdi-window
242  myMainSplitter = new FXSplitter(this,
243  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
244  myMDIClient = new FXMDIClient(myMainSplitter,
245  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
246  myMDIMenu = new FXMDIMenu(this, myMDIClient);
247  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
248  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
249  new FXMDIDeleteButton(myMenuBar, myMDIClient,
250  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
251  new FXMDIRestoreButton(myMenuBar, myMDIClient,
252  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
253  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
254  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
255 
256  // build the message window
258  // fill menu and tool bar
259  fillMenuBar();
260  myToolBar6->hide();
261  myToolBar7->hide();
262  // build additional threads
263  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
264  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
266  // set the status bar
267  myStatusbar->getStatusLine()->setText("Ready.");
268  // set the caption
269  setTitle(MFXUtils::getTitleText(("SUMO " + getBuildName(VERSION_STRING)).c_str()));
270 
271  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
272  myRunThread->start();
274 }
275 
276 
277 void
279  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
280  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
281  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
282  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
283  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
284  }
285  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
286  FXMainWindow::create();
287  myMenuBarDrag->create();
288  myToolBarDrag1->create();
289  myToolBarDrag2->create();
290  myToolBarDrag3->create();
291  myToolBarDrag4->create();
292  myToolBarDrag5->create();
293  myToolBarDrag6->create();
294  myToolBarDrag7->create();
295  myFileMenu->create();
296  mySelectByPermissions->create();
297  myEditMenu->create();
298  mySettingsMenu->create();
299  myLocatorMenu->create();
300  myControlMenu->create();
301  myWindowsMenu->create();
302  myHelpMenu->create();
303 
304  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
305  myCartesianFrame->setWidth(width);
306  myGeoFrame->setWidth(width);
307 
308  show(PLACEMENT_SCREEN);
309  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
310  maximize();
311  }
312  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
313  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
314 }
315 
316 
319  myRunThread->join();
320  closeAllWindows();
321  //
323  delete myGLVisual;
324  // delete some non-parented windows
325  delete myToolBarDrag1;
326  //
327  delete myRunThread;
328  delete myFileMenu;
329  delete myEditMenu;
330  delete mySelectByPermissions;
331  delete mySettingsMenu;
332  delete myLocatorMenu;
333  delete myControlMenu;
334  delete myWindowsMenu;
335  delete myHelpMenu;
336 
337  delete myLoadThread;
338 
339  while (!myEvents.empty()) {
340  // get the next event
341  GUIEvent* e = myEvents.top();
342  myEvents.pop();
343  delete e;
344  }
345 }
346 
347 
348 void
350  FXMainWindow::detach();
351  myMenuBarDrag->detach();
352  myToolBarDrag1->detach();
353 }
354 
355 
356 void
358  // build file menu
359  myFileMenu = new FXMenuPane(this);
360  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
361  new FXMenuCommand(myFileMenu,
362  "&Open Simulation...\tCtrl+O\tOpen a simulation (Configuration file).",
364  new FXMenuCommand(myFileMenu,
365  "Open &Network...\tCtrl+N\tOpen a network.",
367  new FXMenuCommand(myFileMenu,
368  "Open Shapes \tCtrl+P\tLoad POIs and Polygons for visualization.",
370  new FXMenuCommand(myFileMenu,
371  "&Reload\tCtrl+R\tReloads the simulation / the network.",
373  new FXMenuSeparator(myFileMenu);
374  new FXMenuCommand(myFileMenu,
375  "Close\tCtrl+W\tClose the simulation.",
377  // Recent files
378  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
379  sep1->setTarget(&myRecentConfigs);
380  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
381  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
382  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
383  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
384  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
385  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
386  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
387  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
388  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
389  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
390  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
391  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
392  myRecentConfigs.setTarget(this);
393  myRecentConfigs.setSelector(MID_RECENTFILE);
394  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
395  sep2->setTarget(&myRecentNets);
396  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
397  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
398  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
399  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
400  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
401  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
402  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
405  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
406  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
407  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
408  myRecentNets.setTarget(this);
409  myRecentNets.setSelector(MID_RECENTFILE);
410  new FXMenuSeparator(myFileMenu);
411  new FXMenuCommand(myFileMenu,
412  "&Quit\tCtrl+Q\tQuit the Application.",
413  0, this, MID_QUIT, 0);
414 
415  // build edit menu
416  mySelectByPermissions = new FXMenuPane(this);
417  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
418  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
419  new FXMenuCommand(mySelectByPermissions,
420  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
421  }
422 
423  myEditMenu = new FXMenuPane(this);
424  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
425  new FXMenuCommand(myEditMenu,
426  "Edit Selected...\tCtrl+E\tOpens a dialog for editing the list of selected items.",
428  new FXMenuCascade(myEditMenu,
429  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
431  new FXMenuSeparator(myEditMenu);
432  new FXMenuCommand(myEditMenu,
433  "Edit Breakpoints...\tCtrl+B\tOpens a dialog for editing breakpoints.",
434  0, this, MID_EDIT_BREAKPOINTS);
435  new FXMenuSeparator(myEditMenu);
436  new FXMenuCommand(myEditMenu,
437  "Open in Netedit...\tCtrl+T\tOpens the netedit application with the current network.",
438  0, this, MID_NETEDIT);
439 
440  // build settings menu
441  mySettingsMenu = new FXMenuPane(this);
442  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
443  new FXMenuCommand(mySettingsMenu,
444  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
445  NULL, this, MID_APPSETTINGS);
446  new FXMenuCheck(mySettingsMenu,
447  "Gaming Mode\tCtrl+G\tToggle gaming mode on/off.",
448  this, MID_GAMING);
449  new FXMenuCheck(mySettingsMenu,
450  "Full Screen Mode\tCtrl+F\tToggle full screen mode on/off.",
451  this, MID_FULLSCREEN);
452  // build Locate menu
453  myLocatorMenu = new FXMenuPane(this);
454  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
455  new FXMenuCommand(myLocatorMenu,
456  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
458  new FXMenuCommand(myLocatorMenu,
459  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
461  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
462  new FXMenuCommand(myLocatorMenu,
463  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
465  }
466  new FXMenuCommand(myLocatorMenu,
467  "Locate &Persons\t\tOpen a Dialog for Locating a Person.",
469  new FXMenuCommand(myLocatorMenu,
470  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
472  new FXMenuCommand(myLocatorMenu,
473  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
475  new FXMenuCommand(myLocatorMenu,
476  "Locate P&oI\t\tOpen a Dialog for Locating a Point of Intereset.",
478  new FXMenuCommand(myLocatorMenu,
479  "Locate Po&lygon\t\tOpen a Dialog for Locating a Polygon.",
481  new FXMenuSeparator(myLocatorMenu);
482  new FXMenuCheck(myLocatorMenu,
483  "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
484  this, MID_LISTINTERNAL);
485  // build control menu
486  myControlMenu = new FXMenuPane(this);
487  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
488  new FXMenuCommand(myControlMenu,
489  "Run\tCtrl+A\tStart running the simulation.",
490  NULL, this, MID_START);
491  new FXMenuCommand(myControlMenu,
492  "Stop\tCtrl+S\tStop running the simulation.",
493  NULL, this, MID_STOP);
494  new FXMenuCommand(myControlMenu,
495  "Step\tCtrl+D\tPerform one simulation step.",
496  NULL, this, MID_STEP);
497 
498  // build windows menu
499  myWindowsMenu = new FXMenuPane(this);
500  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
501  new FXMenuCheck(myWindowsMenu,
502  "Show Status Line\t\tToggle the Status Bar on/off.",
503  myStatusbar, FXWindow::ID_TOGGLESHOWN);
504  new FXMenuCheck(myWindowsMenu,
505  "Show Message Window\t\tToggle the Message Window on/off.",
506  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
507  new FXMenuCheck(myWindowsMenu,
508  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
509  myToolBar3, FXWindow::ID_TOGGLESHOWN);
510  new FXMenuCheck(myWindowsMenu,
511  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
512  myToolBar4, FXWindow::ID_TOGGLESHOWN);
514  new FXMenuSeparator(myWindowsMenu);
515  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
517  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
518  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
520  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
521  new FXMenuCommand(myWindowsMenu, "Cascade",
523  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
524  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
525  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
526  sep1 = new FXMenuSeparator(myWindowsMenu);
527  sep1->setTarget(myMDIClient);
528  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
529  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
530  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
531  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
532  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
533  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
534  new FXMenuSeparator(myWindowsMenu);
535  new FXMenuCommand(myWindowsMenu,
536  "Clear Message Window\t\tClear the message window.",
537  0, this, MID_CLEARMESSAGEWINDOW);
538 
539  // build help menu
540  myHelpMenu = new FXMenuPane(this);
541  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
542  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
543  new FXMenuCommand(myHelpMenu, "&About", GUIIconSubSys::getIcon(ICON_APP),
544  this, MID_ABOUT);
545 }
546 
547 
548 void
550  // build tool bars
551  {
552  // file and simulation tool bar
553  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
554  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
555  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
556  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
557  TOOLBARGRIP_DOUBLE);
558  // build file tools
559  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
561  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
562  new FXButton(myToolBar1, "\t\tOpen a network.",
564  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
565  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
567  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
568  }
569  {
570  // build simulation tools
571  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
572  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
573  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
574  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
575  TOOLBARGRIP_DOUBLE);
576  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
578  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
579  new FXButton(myToolBar2, "\t\tStop the running simulation.",
581  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
582  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
584  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
585  }
586  {
587  // Simulation Step Display
588  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
589  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
590  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
591  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
592  TOOLBARGRIP_DOUBLE);
593  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
594  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
595  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
599  myLCDLabel->setGroove(2);
600  myLCDLabel->setText("-------------");
601  }
602  {
603  // Simulation Delay
604  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
605  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
606  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
607  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
608  TOOLBARGRIP_DOUBLE);
609  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
610  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
613  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
615  mySimDelayTarget->setIncrements(1, 10, 10);
616  mySimDelayTarget->setRange(0, 1000);
618  }
619  {
620  // Views
621  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
622  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
623  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
624  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
625  TOOLBARGRIP_DOUBLE);
626  // build view tools
627  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
629  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
630 #ifdef HAVE_OSG
631  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
633  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
634 #endif
635  }
636  {
638  // total waitingTime
639  myToolBarDrag6 = new FXToolBarShell(this, FRAME_NORMAL);
640  myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
641  new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
642  new FXLabel(myToolBar6, "Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
643  myWaitingTimeLabel = new FXEX::FXLCDLabel(myToolBar6, 13, 0, 0, JUSTIFY_RIGHT);
648  myWaitingTimeLabel->setText("-------------");
649 
650  // idealistic time loss
651  myToolBarDrag7 = new FXToolBarShell(this, FRAME_NORMAL);
652  myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
653  new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
654  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);
655  myTimeLossLabel = new FXEX::FXLCDLabel(myToolBar7, 13, 0, 0, JUSTIFY_RIGHT);
660  myTimeLossLabel->setText("-------------");
661  }
662 }
663 
664 
665 long
666 GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
667  if (!myAmFullScreen) {
668  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
669  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
670  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
671  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
672  }
673  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
674  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
675  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
676  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", myAlternateSimDelay);
677  getApp()->exit(0);
678  return 1;
679 }
680 
681 
682 long
683 GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
684  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
685  if (mc->getText() == "Edit Selected...") {
686  GUIDialog_GLChosenEditor* chooser =
688  chooser->create();
689  chooser->show();
690  } else {
692  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
693  for (size_t i = 0; i < MSEdge::dictSize(); ++i) {
694  const std::vector<MSLane*>& lanes = MSEdge::dictionary(i)->getLanes();
695  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
696  GUILane* lane = dynamic_cast<GUILane*>(*it);
697  assert(lane != 0);
698  if ((lane->getPermissions() & svc) != 0) {
699  gSelected.select(lane->getGlID());
700  }
701  }
702  }
703  if (myMDIClient->numChildren() > 0) {
704  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
705  if (w != 0) {
706  // color by selection
708  }
709  }
710  }
711  updateChildren();
712  }
713  return 1;
714 }
715 
716 
717 long
718 GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
720  chooser->create();
721  chooser->show();
722  return 1;
723 }
724 
725 
726 long
727 GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
728  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/SUMO-GUI");
729  return 1;
730 }
731 
732 
733 long
734 GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
735  if (mySubWindows.empty()) {
736  return 1;
737  }
738  FXRegistry reg("Netedit", "DLR");
739  reg.read();
740  const GUISUMOAbstractView* const v = static_cast<GUIGlChildWindow*>(mySubWindows[0])->getView();
741  reg.writeIntEntry("viewport", "x", v->getChanger().getXPos());
742  reg.writeIntEntry("viewport", "y", v->getChanger().getYPos());
743  reg.writeIntEntry("viewport", "z", v->getChanger().getZoom());
744  reg.write();
745  std::string netedit = "netedit";
746  const char* sumoPath = getenv("SUMO_HOME");
747  if (sumoPath != 0) {
748  std::string newPath = std::string(sumoPath) + "/bin/netedit";
749  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
750  netedit = newPath;
751  }
752  }
753  std::string cmd = netedit + " --registry-viewport -s " + OptionsCont::getOptions().getString("net-file");
754  // start in background
755 #ifndef WIN32
756  cmd = cmd + " &";
757 #else
758  cmd = "start " + cmd;
759 #endif
760  WRITE_MESSAGE("Running " + cmd + ".");
761  // yay! fun with dangerous commands... Never use this over the internet
763  return 1;
764 }
765 
766 
767 long
768 GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
769  // get the new file name
770  FXFileDialog opendialog(this, "Open Simulation Configuration");
771  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
772  opendialog.setSelectMode(SELECTFILE_EXISTING);
773  opendialog.setPatternList(myConfigPattern.c_str());
774  if (gCurrentFolder.length() != 0) {
775  opendialog.setDirectory(gCurrentFolder);
776  }
777  if (opendialog.execute()) {
778  gCurrentFolder = opendialog.getDirectory();
779  std::string file = opendialog.getFilename().text();
780  loadConfigOrNet(file, false);
781  myRecentConfigs.appendFile(file.c_str());
782  }
783  return 1;
784 }
785 
786 
787 long
788 GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
789  // get the new file name
790  FXFileDialog opendialog(this, "Open Network");
791  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
792  opendialog.setSelectMode(SELECTFILE_EXISTING);
793  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
794  if (gCurrentFolder.length() != 0) {
795  opendialog.setDirectory(gCurrentFolder);
796  }
797  if (opendialog.execute()) {
798  gCurrentFolder = opendialog.getDirectory();
799  std::string file = opendialog.getFilename().text();
800  loadConfigOrNet(file, true);
801  myRecentNets.appendFile(file.c_str());
802  }
803  return 1;
804 }
805 
806 
807 long
808 GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
809  // get the shape file name
810  FXFileDialog opendialog(this, "Open Shapes");
811  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
812  opendialog.setSelectMode(SELECTFILE_EXISTING);
813  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
814  if (gCurrentFolder.length() != 0) {
815  opendialog.setDirectory(gCurrentFolder);
816  }
817  if (opendialog.execute()) {
818  gCurrentFolder = opendialog.getDirectory();
819  std::string file = opendialog.getFilename().text();
820 
822  if (!XMLSubSys::runParser(handler, file, false)) {
823  WRITE_MESSAGE("Loading of " + file + " failed.");
824  }
825  update();
826  }
827  return 1;
828 }
829 
830 
831 long
832 GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
833  getApp()->beginWaitCursor();
834  myAmLoading = true;
835  closeAllWindows();
836  myLoadThread->start();
837  setStatusBarText("Reloading.");
838  update();
839  return 1;
840 }
841 
842 
843 long
844 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
845  if (myAmLoading) {
846  myStatusbar->getStatusLine()->setText("Already loading!");
847  return 1;
848  }
849  std::string file((const char*)data);
850  loadConfigOrNet(file, sender == &myRecentNets);
851  return 1;
852 }
853 
854 
855 long
856 GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
857  closeAllWindows();
858  return 1;
859 }
860 
861 
862 long
863 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
864  sender->handle(this,
865  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
866  ptr);
867  return 1;
868 }
869 
870 
871 long
872 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
873  sender->handle(this,
875  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
876  ptr);
877  return 1;
878 }
879 
880 
881 long
882 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
883  sender->handle(this,
884  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
885  ptr);
886  return 1;
887 }
888 
889 
890 long
891 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
892  sender->handle(this,
894  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
895  ptr);
896  return 1;
897 }
898 
899 
900 long
901 GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
902  // check whether a net was loaded successfully
904  myStatusbar->getStatusLine()->setText("No simulation loaded!");
905  return 1;
906  }
907  // check whether it was started before and paused;
908  if (!myWasStarted) {
909  myRunThread->begin();
910  myWasStarted = true;
911  }
912  myRunThread->resume();
913  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
914  return 1;
915 }
916 
917 
918 long
919 GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
920  myRunThread->stop();
921  getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
922  return 1;
923 }
924 
925 
926 long
927 GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
928  // check whether a net was loaded successfully
930  myStatusbar->getStatusLine()->setText("No simulation loaded!");
931  return 1;
932  }
933  // check whether it was started before and paused;
934  if (!myWasStarted) {
935  myRunThread->begin();
936  myWasStarted = true;
937  }
939  return 1;
940 }
941 
942 
943 long
944 GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
948  }
949  return 1;
950 }
951 
952 
953 long
954 GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
955  const SUMOTime tmp = myAlternateSimDelay;
958  return 1;
959 }
960 
961 
962 long
963 GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
965  return 1;
966 }
967 
968 
969 long
970 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
971  sender->handle(this,
973  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
974  ptr);
975  return 1;
976 }
977 
978 
979 long
980 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
981  sender->handle(this,
983  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
984  ptr);
985  return 1;
986 }
987 
988 
989 long
990 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
991  sender->handle(this,
993  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
994  ptr);
995  return 1;
996 }
997 
998 
999 long
1000 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
1001  sender->handle(this,
1003  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1004  ptr);
1005  return 1;
1006 }
1007 
1008 
1009 long
1010 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1011  if (myMDIClient->numChildren() > 0) {
1012  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1013  if (w != 0) {
1014  w->onCmdLocate(0, sel, 0);
1015  }
1016  }
1017  return 1;
1018 }
1019 
1020 long
1021 GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1023  d->create();
1024  d->show(PLACEMENT_OWNER);
1025  return 1;
1026 }
1027 
1028 
1029 long
1030 GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1032  if (myAmGaming) {
1033  myMenuBar->hide();
1034  myStatusbar->hide();
1035  myToolBar1->hide();
1036  myToolBar2->hide();
1037  myToolBar4->hide();
1038  myToolBar5->hide();
1039  myToolBar6->show();
1040  myToolBar7->show();
1041  myMessageWindow->hide();
1045  gSchemeStorage.getDefault().gaming = true;
1046  } else {
1047  myMenuBar->show();
1048  myStatusbar->show();
1049  myToolBar1->show();
1050  myToolBar2->show();
1051  myToolBar4->show();
1052  myToolBar5->show();
1053  myToolBar6->hide();
1054  myToolBar7->hide();
1055  myMessageWindow->show();
1057  gSchemeStorage.getDefault().gaming = false;
1058  }
1059  if (myMDIClient->numChildren() > 0) {
1060  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1061  if (w != 0) {
1063  }
1064  }
1065  update();
1066  return 1;
1067 }
1068 
1069 
1070 long
1071 GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1073  if (myAmFullScreen) {
1074  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1075  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1076  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1077  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1078  maximize();
1079  setDecorations(DECOR_NONE);
1080  place(PLACEMENT_MAXIMIZED);
1081  myMenuBar->hide();
1082  myStatusbar->hide();
1083  myToolBar1->hide();
1084  myToolBar2->hide();
1085  myToolBar3->hide();
1086  myToolBar4->hide();
1087  myToolBar5->hide();
1088  myToolBar6->hide();
1089  myToolBar7->hide();
1090  myMessageWindow->hide();
1091  if (myMDIClient->numChildren() > 0) {
1092  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1093  if (w != 0) {
1094  w->setToolBarVisibility(false);
1095  }
1096  }
1097  update();
1098  } else {
1099  place(PLACEMENT_VISIBLE);
1100  setDecorations(DECOR_ALL);
1101  restore();
1102  myToolBar3->show();
1104  onCmdGaming(0, 0, 0);
1105  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1106  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1107  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1108  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1109  }
1110  return 1;
1111 }
1112 
1113 
1114 long
1115 GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1117  return 1;
1118 }
1119 
1120 
1121 long
1122 GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1124  return 1;
1125 }
1126 
1127 
1128 #ifdef HAVE_OSG
1129 long
1130 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1132  return 1;
1133 }
1134 #endif
1135 
1136 
1137 long
1138 GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1139  GUIDialog_AboutSUMO* about =
1140  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
1141  about->create();
1142  about->show(PLACEMENT_OWNER);
1143  return 1;
1144 }
1145 
1146 
1147 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1148  FXEvent* event = (FXEvent*)ptr;
1149  FXString string = GUIUserIO::clipped.c_str();
1150  setDNDData(FROM_CLIPBOARD, event->target, string);
1151  return 1;
1152 }
1153 
1154 
1155 long
1156 GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1157  eventOccured();
1158  return 1;
1159 }
1160 
1161 
1162 long
1163 GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1164  eventOccured();
1165  return 1;
1166 }
1167 
1168 
1169 void
1171  while (!myEvents.empty()) {
1172  // get the next event
1173  GUIEvent* e = myEvents.top();
1174  myEvents.pop();
1175  // process
1176  switch (e->getOwnType()) {
1179  break;
1180  case EVENT_SIMULATION_STEP:
1181  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1183  }
1184  break;
1185  case EVENT_MESSAGE_OCCURED:
1186  case EVENT_WARNING_OCCURED:
1187  case EVENT_ERROR_OCCURED:
1189  break;
1192  break;
1193  case EVENT_SCREENSHOT:
1195  break;
1196  default:
1197  break;
1198  }
1199  delete e;
1200  }
1201  myToolBar2->forceRefresh();
1202  myToolBar3->forceRefresh();
1203 }
1204 
1205 
1206 void
1208  myAmLoading = false;
1210  // check whether the loading was successfull
1211  if (ec->myNet == 0) {
1212  // report failure
1213  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1214  if (GUIGlobals::gQuitOnEnd) {
1215  closeAllWindows();
1216  getApp()->exit(1);
1217  }
1218  } else {
1219  // initialise simulation thread
1220  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1221  if (GUIGlobals::gQuitOnEnd) {
1222  closeAllWindows();
1223  getApp()->exit(1);
1224  }
1225  } else {
1226  // report success
1227  setStatusBarText("'" + ec->myFile + "' loaded.");
1228  myWasStarted = false;
1229  myHaveNotifiedAboutSimEnd = false;
1230  // initialise views
1231  myViewNumber = 0;
1233  if (ec->mySettingsFiles.size() > 0) {
1234  // open a view for each file and apply settings
1235  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1236  GUISettingsHandler settings(*it);
1237  GUISUMOViewParent::ViewType vt = defaultType;
1238  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1240  }
1241  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1243  }
1244  GUISUMOAbstractView* view = openNewView(vt);
1245  if (view == 0) {
1246  break;
1247  }
1248  std::string settingsName = settings.addSettings(view);
1249  view->addDecals(settings.getDecals());
1250  settings.setViewport(view);
1251  settings.setSnapshots(view);
1252  if (settings.getDelay() > 0) {
1253  mySimDelayTarget->setValue(settings.getDelay());
1254  }
1255  if (settings.getBreakpoints().size() > 0) {
1257  myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1259  }
1260  myJamSounds = settings.getEventDistribution("jam");
1261  if (settings.getJamSoundTime() > 0) {
1262  myJamSoundTime = settings.getJamSoundTime();
1263  }
1264  }
1265  } else {
1266  openNewView(defaultType);
1267  }
1268 
1269  if (isGaming()) {
1270  setTitle("SUMO Interactive Traffic Light");
1271  } else {
1272  // set simulation name on the caption
1273  std::string caption = "SUMO " + getBuildName(VERSION_STRING);
1274  setTitle(MFXUtils::getTitleText(caption.c_str(), ec->myFile.c_str()));
1275  }
1276  // set simulation step begin information
1277  myLCDLabel->setText("-------------");
1278  }
1279  }
1280  getApp()->endWaitCursor();
1281  // start if wished
1283  onCmdStart(0, 0, 0);
1284  }
1285  update();
1286 }
1287 
1288 
1289 void
1291  updateChildren();
1293  if (myAmGaming) {
1295  }
1297  getApp()->forceRefresh(); // restores keyboard focus
1298  }
1299  update();
1300 }
1301 
1302 
1303 void
1305  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1306  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1307 }
1308 
1309 
1310 void
1312  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1313  onCmdStop(0, 0, 0);
1314  if (GUIGlobals::gQuitOnEnd) {
1315  closeAllWindows();
1316  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1317  } else if (!myHaveNotifiedAboutSimEnd) {
1318  // build the text
1319  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1320  ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1321  "\nDo you want to close all open files and views?";
1322  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, "Simulation ended", "%s", text.c_str());
1323  if (answer == 1) { //1:yes, 2:no, 4:esc
1324  closeAllWindows();
1325  }
1327  }
1328 }
1329 
1330 
1331 void
1333  GUIEvent_Screenshot* ec = static_cast<GUIEvent_Screenshot*>(e);
1334  myEventMutex.lock();
1335  const std::string error = ec->myView->makeSnapshot(ec->myFile);
1336  if (error != "") {
1337  WRITE_WARNING(error);
1338  }
1339  myEventCondition.signal();
1340  myEventMutex.unlock();
1341 }
1342 
1343 
1344 void
1349 #ifdef HAVE_INTERNAL
1350  if (myJamSounds.getOverallProb() > 0) {
1351  // play honking sound if some vehicle is waiting too long
1352  for (; it != end; ++it) {
1353  // XXX use impatience instead of waiting time ?
1354  if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1355  const std::string cmd = myJamSounds.get(&myGamingRNG);
1356  if (cmd != "") {
1357  // yay! fun with dangerous commands... Never use this over the internet
1359  // one sound per simulation step is enough
1360  break;
1361  }
1362  }
1363  }
1364  }
1365 #endif
1366 
1367  // update performance indicators
1368  for (it = vc.loadedVehBegin(); it != end; ++it) {
1369  const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1370  assert(veh != 0);
1371  if (veh->isOnRoad()) {
1372  const SUMOReal vmax = MIN2(veh->getVehicleType().getMaxSpeed(), veh->getEdge()->getSpeedLimit());
1373  if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1375  }
1376  myTimeLoss += TS * TIME2STEPS(vmax - veh->getSpeed()) / vmax; // may be negative with speedFactor > 1
1377  }
1378  }
1381 }
1382 
1383 
1384 void
1385 GUIApplicationWindow::loadConfigOrNet(const std::string& file, bool isNet) {
1386  getApp()->beginWaitCursor();
1387  myAmLoading = true;
1388  closeAllWindows();
1389  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1390  myLoadThread->loadConfigOrNet(file, isNet);
1391  setStatusBarText("Loading '" + file + "'.");
1392  update();
1393 }
1394 
1395 
1398  if (!myRunThread->simulationAvailable()) {
1399  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1400  return 0;
1401  }
1402  std::string caption = "View #" + toString(myViewNumber++);
1403  FXuint opts = MDI_TRACKING;
1404  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1405  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1407  w->create();
1408  if (myMDIClient->numChildren() == 1) {
1409  w->maximize();
1410  } else {
1411  myMDIClient->vertical(true);
1412  }
1413  myMDIClient->setActiveChild(w);
1414  return v;
1415 }
1416 
1417 
1418 FXGLCanvas*
1420  if (myMDIClient->numChildren() == 0) {
1421  return 0;
1422  }
1423  GUISUMOViewParent* share_tmp1 =
1424  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1425  return share_tmp1->getBuildGLCanvas();
1426 }
1427 
1428 
1429 void
1431  myTrackerLock.lock();
1432  myLCDLabel->setText("-------------");
1433  // remove trackers and other external windows
1434  size_t i;
1435  for (i = 0; i < mySubWindows.size(); ++i) {
1436  mySubWindows[i]->destroy();
1437  }
1438  for (i = 0; i < myTrackerWindows.size(); ++i) {
1439  myTrackerWindows[i]->destroy();
1440  }
1441  // delete the simulation
1443  // reset the caption
1444  setTitle(MFXUtils::getTitleText(("SUMO " + getBuildName(VERSION_STRING)).c_str()));
1445  // delete other children
1446  while (myTrackerWindows.size() != 0) {
1447  delete myTrackerWindows[0];
1448  }
1449  while (mySubWindows.size() != 0) {
1450  delete mySubWindows[0];
1451  }
1452  mySubWindows.clear();
1453  // clear selected items
1454  gSelected.clear();
1455  // add a separator to the log
1458  // remove coordinate information
1459  myGeoCoordinate->setText("N/A");
1460  myCartesianCoordinate->setText("N/A");
1461  //
1463  update();
1464 }
1465 
1466 
1467 FXCursor*
1469  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1470 }
1471 
1472 
1473 SUMOTime
1476 }
1477 
1478 
1479 void
1481  loadConfigOrNet("", false);
1482 }
1483 
1484 
1485 void
1486 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1487  myStatusbar->getStatusLine()->setText(text.c_str());
1488  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1489 }
1490 
1491 
1492 void
1494  time -= DELTA_T; // synchronize displayed time with netstate output
1495  if (myAmGaming) {
1496  // show time counting backwards
1497  time = myRunThread->getSimEndTime() - time;
1498  }
1499  SUMOReal fracSeconds = STEPS2TIME(time);
1500  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1501  const int BuffSize = 100;
1502  char buffer[BuffSize];
1503  if (myShowTimeAsHMS) {
1504  const int hours = (int)fracSeconds / 3600;
1505  const int minutes = ((int)fracSeconds % 3600) / 60;
1506  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1507  const std::string format = (hideFraction ?
1508  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1509  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1510  } else {
1511  const std::string format = (hideFraction ?
1512  "%13.0f" : "%13.3f");
1513  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1514  }
1515  myLCDLabel->setText(buffer);
1516 }
1517 
1518 
1519 long
1520 GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1521  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1522  if (handled == 0 && myMDIClient->numChildren() > 0) {
1523  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1524  if (w != 0) {
1525  w->onKeyPress(0, sel, data);
1526  }
1527  }
1528  return 0;
1529 }
1530 
1531 
1532 long
1533 GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1534  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1535  if (handled == 0 && myMDIClient->numChildren() > 0) {
1536  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1537  if (w != 0) {
1538  w->onKeyRelease(0, sel, data);
1539  }
1540  }
1541  return 0;
1542 }
1543 
1544 
1545 void
1547  myEventMutex.lock();
1548  myEvents.add(event);
1551  myEventMutex.unlock();
1552 }
1553 
1554 
1555 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
Event sent when the the simulation is over.
MFXMutex & getBreakpointLock()
Definition: GUIRunThread.h:119
RandomDistributor< std::string > myJamSounds
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
Locate vehicle - button.
Definition: GUIAppEnum.h:167
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
void pop()
Definition: MFXEventQue.h:53
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
static std::string clipped
Definition: GUIUserIO.h:64
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
void handleEvent_SimulationLoaded(GUIEvent *e)
SUMOReal getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
long long int SUMOTime
Definition: SUMOTime.h:43
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
Locate person - button.
Definition: GUIAppEnum.h:169
virtual bool simulationIsStepable() const
Open in netedit.
Definition: GUIAppEnum.h:131
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.
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...
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:58
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
const std::string & getViewType() const
Returns the parsed view type.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
static MTRand myGamingRNG
A random number generator used to choose a gaming sound.
Locate TLS - button.
Definition: GUIAppEnum.h:171
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
bool gaming
whether the application is in gaming mode or not
virtual SUMOReal getZoom() const =0
Returns the zoom factor computed stored in this changer.
Gaming mode - menu entry.
Definition: GUIAppEnum.h:141
const bool myOsgView
whether to load the OpenSceneGraph view
void add(T what)
Definition: MFXEventQue.h:59
Loads a file previously loaded.
Definition: GUIAppEnum.h:81
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 "stop" is enabled.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
virtual void setValue(FXdouble value)
Change current value.
Locate poi - button.
Definition: GUIAppEnum.h:175
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
virtual bool simulationIsStartable() const
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:52
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
void setToolBarVisibility(const bool value)
about toggled gaming status
Start the simulation.
Definition: GUIAppEnum.h:93
Edit simulation breakpoints.
Definition: GUIAppEnum.h:129
virtual void detach()
Detaches the tool/menu bar.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:162
Editor for the list of chosen objects.
void setThickness(const FXint width)
set/get segment width - must be less than half the segment length
Definition: FXLCDLabel.cpp:205
FXGLVisual * myGLVisual
The gl-visual used.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
FXMutex myEventMutex
the mutex for the waiting semaphore
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
Main window-ID.
Definition: GUIAppEnum.h:53
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:579
toogle delay between alternative value
Definition: GUIAppEnum.h:191
long onCmdNetedit(FXObject *, FXSelector, void *)
Called on menu Edit->Netedit.
Stop the simulation.
Definition: GUIAppEnum.h:95
FXString gCurrentFolder
The folder used as last.
void handleEvent_Screenshot(GUIEvent *e)
void loadConfigOrNet(const std::string &file, bool isNet)
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
#define TS
Definition: SUMOTime.h:52
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:107
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:79
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:255
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:84
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:114
const SUMOTime myBegin
the time the simulation shall start with
long onCmdNewView(FXObject *, FXSelector, void *)
Called if a new view shall be opened (2D view)
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
Open network - ID.
Definition: GUIAppEnum.h:75
virtual FXGLCanvas * getBuildGLCanvas() const
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
void addDecals(const std::vector< Decal > &decals)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
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
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void checkGamingEvents()
handles additional game-related events
FXMenuPane * myFileMenu
the submenus
void addSeparator()
Adds a a separator to this log window.
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:115
Open configuration - ID.
Definition: GUIAppEnum.h:73
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
FXHorizontalFrame * myCartesianFrame
SUMOReal getDelay() const
Returns the parsed delay.
FXRecentFiles myRecentNets
List of recent nets.
const std::vector< std::string > mySettingsFiles
the name of the settings file to load
void loadConfigOrNet(const std::string &file, bool isNet)
begins the loading of the given file
RandomDistributor< std::string > getEventDistribution(const std::string &id)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Editor for simulation breakpoints.
const std::string myFile
the name of the file to save to
Locate addtional structure - button.
Definition: GUIAppEnum.h:173
GUIPerspectiveChanger & getChanger() const
bool myAmGaming
information whether the gui is currently in gaming mode
bool myShowTimeAsHMS
whether to show time as hour:minute:second
void handleEvent_Message(GUIEvent *e)
std::vector< FXMDIChild * > mySubWindows
static void clearTextures()
clears loaded textures
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:81
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:109
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
Locator configuration - menu entry.
Definition: GUIAppEnum.h:145
void updateTimeLCD(SUMOTime time)
updates the simulation time display
void setRange(FXdouble lo, FXdouble hi)
Change the spinner&#39;s range.
FXCondition myEventCondition
the semaphore when waiting for event completion
void handleEvent_SimulationEnded(GUIEvent *e)
FXdouble getValue() const
Return current value.
bool myHaveNotifiedAboutSimEnd
whether the simulation end was already announced
virtual SUMOReal getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
std::string myConfigPattern
Input file pattern.
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
Definition: SysUtils.cpp:75
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
#define snprintf
SUMOReal myJamSoundTime
waiting time after which vehicles trigger jam sounds
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:419
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:169
Locate edge - button.
Definition: GUIAppEnum.h:165
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:308
The Simulation delay control.
Definition: GUIAppEnum.h:147
The Simulation execution thread.
Definition: GUIAppEnum.h:117
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:91
SUMOTime getCurrentSimTime() const
ViewType
Available view types.
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
T MIN2(T a, T b)
Definition: StdDefs.h:73
The application&#39;s "About" - dialog.
void setStatusBarText(const std::string &)
bool myAmFullScreen
whether to show the window in full screen mode
Locate junction - button.
Definition: GUIAppEnum.h:163
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
const std::string & getFileName() const
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
Send when a screenshot is requested; View and file name are stored within the event.
Definition: GUIEvent.h:64
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:384
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
bool myListInternal
information whether the locator should list internal structures
long onCmdOpenShapes(FXObject *, FXSelector, void *)
Called on menu File->Load Shapes.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h: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:682
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.
std::string makeSnapshot(const std::string &destFile)
Takes a snapshots and writes it into the given file.
FXMenuPane * mySelectByPermissions
GUINet & getNet() const
toogle time display mode
Definition: GUIAppEnum.h:189
virtual void fillMenuBar()
Builds the menu bar.
Application settings - menu entry.
Definition: GUIAppEnum.h:139
#define VERSION_STRING
Definition: config.h:226
A single child window which contains a view of the simulation area.
FXEX::FXLCDLabel * myWaitingTimeLabel
performance indicators
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:55
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
FXGLCanvas * getBuildGLCanvas() const
FXToolBarShell * myToolBarDrag7
long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
GUIVisualizationSettings & getDefault()
Returns the default scheme.
GUISUMOAbstractView *const myView
the view to save
FXToolBarShell * myToolBarDrag6
static const RGBColor RED
Definition: RGBColor.h:189
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:64
void setGroove(const FXint width)
set/get groove width - must be less than segment width
Definition: FXLCDLabel.cpp:223
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
About SUMO - ID.
Definition: GUIAppEnum.h:85
void prepareDestruction()
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
The loading thread.
Definition: GUIAppEnum.h:115
MFXEventQue< GUIEvent * > myEvents
List of got requests.
static void close()
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:143
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:613
Open a new microscopic view.
Definition: GUIAppEnum.h:105
FXDockSite * myTopDock
Locate polygons - button.
Definition: GUIAppEnum.h:177
FXRecentFiles myRecentConfigs
List of recent config files.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:93
Open editor for selections.
Definition: GUIAppEnum.h:127
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
void create()
Creates the widget (and the icons)
void clear()
Clears the list of selected objects.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:294
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void lock()
lock mutex
Definition: MFXMutex.cpp:86
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
Definition: GUIEvent.h:44
bool simulationAvailable() const
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:125
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:214
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:552
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:73
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
#define DELTA_T
Definition: SUMOTime.h:50
Close simulation - ID.
Definition: GUIAppEnum.h:83
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The class responsible for building and deletion of vehicles.
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:154
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
const SUMOTime myEnd
the time the simulation shall end with
virtual void begin()
void clear()
Clears the window.
virtual SUMOReal getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:339
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
A logging window for the gui.
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
static FXIcon * getIcon(GUIIcon which)
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
Perform a single simulation step.
Definition: GUIAppEnum.h:97
virtual void addToWindowsMenu(FXMenuPane *)
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
The main window of the SUMO-gui.