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