SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The main window of the SUMO-gui.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #ifdef HAVE_VERSION_H
35 #include <version.h>
36 #endif
37 
38 #include <string>
39 #include <sstream>
40 #include <algorithm>
41 
42 #include <guisim/GUINet.h>
43 #include <guisim/GUILane.h>
44 #include <microsim/MSEdge.h>
45 
46 #include "GUISUMOViewParent.h"
47 #include "GUILoadThread.h"
48 #include "GUIRunThread.h"
49 #include "GUIApplicationWindow.h"
52 
53 #include <utils/common/ToString.h>
58 
74 #include "GUIGlobals.h"
78 
79 #ifndef NO_TRACI
81 #include "TraCIServerAPI_GUI.h"
82 #endif
83 
84 #ifdef CHECK_MEMORY_LEAKS
85 #include <foreign/nvwa/debug_new.h>
86 #endif
87 
88 
89 // ===========================================================================
90 // FOX-declarations
91 // ===========================================================================
92 FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
93  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GUIApplicationWindow::onCmdQuit),
94  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GUIApplicationWindow::onCmdQuit),
95  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
96 
100  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GUIApplicationWindow::onCmdReload),
101  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GUIApplicationWindow::onCmdClose),
102  FXMAPFUNC(SEL_COMMAND, MID_EDITCHOSEN, GUIApplicationWindow::onCmdEditChosen),
104 
106  FXMAPFUNC(SEL_COMMAND, MID_GAMING, GUIApplicationWindow::onCmdGaming),
108  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GUIApplicationWindow::onCmdAbout),
109  FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
110 #ifdef HAVE_OSG
111  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
112 #endif
113  FXMAPFUNC(SEL_COMMAND, MID_START, GUIApplicationWindow::onCmdStart),
114  FXMAPFUNC(SEL_COMMAND, MID_STOP, GUIApplicationWindow::onCmdStop),
115  FXMAPFUNC(SEL_COMMAND, MID_STEP, GUIApplicationWindow::onCmdStep),
119 
120  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
121  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GUIApplicationWindow::onUpdOpen),
122  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GUIApplicationWindow::onUpdReload),
125 #ifdef HAVE_OSG
126  FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
127 #endif
128  FXMAPFUNC(SEL_UPDATE, MID_START, GUIApplicationWindow::onUpdStart),
129  FXMAPFUNC(SEL_UPDATE, MID_STOP, GUIApplicationWindow::onUpdStop),
130  FXMAPFUNC(SEL_UPDATE, MID_STEP, GUIApplicationWindow::onUpdStep),
133 
134  // forward requests to the active view
135  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
136  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
137  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
138  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
139  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
140  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
141  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
149 
150  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
151 
156 };
157 
158 // Object implementation
159 FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
160 
161 // ===========================================================================
162 // member method definitions
163 // ===========================================================================
165  const std::string& configPattern)
166  : GUIMainWindow(a),
167  myLoadThread(0), myRunThread(0),
168  myAmLoading(false),
169  myAlternateSimDelay(0),
170  myRecentNets(a, "nets"), myConfigPattern(configPattern),
171  hadDependentBuild(false),
172  myShowTimeAsHMS(false) {
174 }
175 
176 
177 void
179  // do this not twice
180  if (hadDependentBuild) {
181  return;
182  }
183  hadDependentBuild = true;
184 
185  setTarget(this);
186  setSelector(MID_WINDOW);
187 
188  // build menu bar
189  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
190  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
191  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
192  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
193  TOOLBARGRIP_DOUBLE);
194  buildToolBars();
195  // build the thread - io
200 
201  // build the status bar
202  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
203  {
204  myGeoFrame =
205  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
206  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
207  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A", 0, LAYOUT_CENTER_Y);
209  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
210  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
211  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A", 0, LAYOUT_CENTER_Y);
212  }
213 
214  // make the window a mdi-window
215  myMainSplitter = new FXSplitter(this,
216  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
217  myMDIClient = new FXMDIClient(myMainSplitter,
218  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
219  myMDIMenu = new FXMDIMenu(this, myMDIClient);
220  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
221  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
222  new FXMDIDeleteButton(myMenuBar, myMDIClient,
223  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
224  new FXMDIRestoreButton(myMenuBar, myMDIClient,
225  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
226  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
227  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
228 
229  // build the message window
231  // fill menu and tool bar
232  fillMenuBar();
233  if (game) {
234  onCmdGaming(0, 0, 0);
235  myMenuBar->hide();
236  myToolBar1->hide();
237  myToolBar2->hide();
238  myToolBar4->hide();
239  myToolBar5->hide();
240  myMessageWindow->hide();
241  }
242  // build additional threads
243  myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent);
244  myRunThread = new GUIRunThread(getApp(), this, *mySimDelayTarget, myEvents,
246  // set the status bar
247  myStatusbar->getStatusLine()->setText("Ready.");
248  // set the caption
249  setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
250 
251  // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
252  myRunThread->start();
254 }
255 
256 
257 void
259  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
260  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
261  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
262  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
263  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
264  }
265  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
266  FXMainWindow::create();
267  myMenuBarDrag->create();
268  myToolBarDrag1->create();
269  myToolBarDrag2->create();
270  myFileMenu->create();
271  mySelectByPermissions->create();
272  myEditMenu->create();
273  mySettingsMenu->create();
274  myLocatorMenu->create();
275  myControlMenu->create();
276  myWindowsMenu->create();
277  myHelpMenu->create();
278 
279  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
280  myCartesianFrame->setWidth(width);
281  myGeoFrame->setWidth(width);
282 
283  show(PLACEMENT_SCREEN);
284  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
285  maximize();
286  }
287  myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
288  myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
289 }
290 
291 
294  myRunThread->join();
295  closeAllWindows();
296  //
298  delete myGLVisual;
299  // delete some non-parented windows
300  delete myToolBarDrag1;
301  //
302  delete myRunThread;
303  delete myFileMenu;
304  delete myEditMenu;
305  delete mySelectByPermissions;
306  delete mySettingsMenu;
307  delete myLocatorMenu;
308  delete myControlMenu;
309  delete myWindowsMenu;
310  delete myHelpMenu;
311 
312  delete myLoadThread;
313 
314  while (!myEvents.empty()) {
315  // get the next event
316  GUIEvent* e = static_cast<GUIEvent*>(myEvents.top());
317  myEvents.pop();
318  delete e;
319  }
320 }
321 
322 
323 void
325  FXMainWindow::detach();
326  myMenuBarDrag->detach();
327  myToolBarDrag1->detach();
328 }
329 
330 
331 void
333  // build file menu
334  myFileMenu = new FXMenuPane(this);
335  new FXMenuTitle(myMenuBar, "&File", NULL, myFileMenu);
337  "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
340  "Open &Network...\tCtl-N\tOpen a network.",
343  "&Reload\tCtl-R\tReloads the simulation / the network.",
345  new FXMenuSeparator(myFileMenu);
347  "&Close\tCtl-W\tClose the simulation.",
349  // Recent files
350  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
351  sep1->setTarget(&myRecentConfigs);
352  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
353  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
354  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
355  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
356  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
357  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
358  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
359  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
360  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
361  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
362  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
363  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", NULL, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
364  myRecentConfigs.setTarget(this);
365  myRecentConfigs.setSelector(MID_RECENTFILE);
366  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
367  sep2->setTarget(&myRecentNets);
368  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
369  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
370  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
371  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
372  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
373  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
374  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
375  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
376  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
377  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
378  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
379  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", NULL, &myRecentNets, FXRecentFiles::ID_CLEAR);
380  myRecentNets.setTarget(this);
381  myRecentNets.setSelector(MID_RECENTFILE);
382  new FXMenuSeparator(myFileMenu);
384  "&Quit\tCtl-Q\tQuit the Application.",
385  0, this, MID_QUIT, 0);
386 
387  // build edit menu
388  mySelectByPermissions = new FXMenuPane(this);
389  std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
390  for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
392  (*it).c_str(), NULL, this, MID_EDITCHOSEN);
393  }
394 
395  myEditMenu = new FXMenuPane(this);
396  new FXMenuTitle(myMenuBar, "&Edit", NULL, myEditMenu);
398  "Edit Selected...\tCtl-E\tOpens a Dialog for editing the List of Selected Items.",
400  new FXMenuCascade(myEditMenu,
401  "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
403  new FXMenuSeparator(myEditMenu);
405  "Edit Breakpoints...\tCtl-B\tOpens a Dialog for editing breakpoints.",
406  0, this, MID_EDIT_BREAKPOINTS);
407 
408  // build settings menu
409  mySettingsMenu = new FXMenuPane(this);
410  new FXMenuTitle(myMenuBar, "&Settings", NULL, mySettingsMenu);
412  "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
413  NULL, this, MID_APPSETTINGS);
414  new FXMenuCheck(mySettingsMenu,
415  "Gaming Mode\t\tToggle gaming mode on/off.",
416  this, MID_GAMING);
417  // build Locate menu
418  myLocatorMenu = new FXMenuPane(this);
419  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
421  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
424  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
426  if (!MSGlobals::gUseMesoSim) { // there are no gui-vehicles in mesosim
428  "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
430  }
432  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
435  "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
438  "Locate &PoI\t\tOpen a Dialog for Locating a Point of Intereset.",
441  "Locate P&olygon\t\tOpen a Dialog for Locating a Polygon.",
443  new FXMenuSeparator(myLocatorMenu);
444  new FXMenuCheck(myLocatorMenu,
445  "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
446  this, MID_LISTINTERNAL);
447  // build control menu
448  myControlMenu = new FXMenuPane(this);
449  new FXMenuTitle(myMenuBar, "Simulation", NULL, myControlMenu);
451  "Run\tCtl-A\tStart running the simulation.",
452  NULL, this, MID_START);
454  "Stop\tCtl-S\tStop running the simulation.",
455  NULL, this, MID_STOP);
457  "Step\tCtl-D\tPerform one simulation step.",
458  NULL, this, MID_STEP);
459 
460  // build windows menu
461  myWindowsMenu = new FXMenuPane(this);
462  new FXMenuTitle(myMenuBar, "&Windows", NULL, myWindowsMenu);
463  new FXMenuCheck(myWindowsMenu,
464  "Show Status Line\t\tToggle the Status Bar on/off.",
465  myStatusbar, FXWindow::ID_TOGGLESHOWN);
466  new FXMenuCheck(myWindowsMenu,
467  "Show Message Window\t\tToggle the Message Window on/off.",
468  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
469  new FXMenuCheck(myWindowsMenu,
470  "Show Simulation Time\t\tToggle the Simulation Time on/off.",
471  myToolBar3, FXWindow::ID_TOGGLESHOWN);
472  new FXMenuCheck(myWindowsMenu,
473  "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
474  myToolBar4, FXWindow::ID_TOGGLESHOWN);
476  new FXMenuSeparator(myWindowsMenu);
477  new FXMenuCommand(myWindowsMenu, "Tile &Horizontally",
479  myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
480  new FXMenuCommand(myWindowsMenu, "Tile &Vertically",
482  myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
483  new FXMenuCommand(myWindowsMenu, "Cascade",
485  myMDIClient, FXMDIClient::ID_MDI_CASCADE);
486  new FXMenuCommand(myWindowsMenu, "&Close", NULL,
487  myMDIClient, FXMDIClient::ID_MDI_CLOSE);
488  sep1 = new FXMenuSeparator(myWindowsMenu);
489  sep1->setTarget(myMDIClient);
490  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
491  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_1);
492  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_2);
493  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_3);
494  new FXMenuCommand(myWindowsMenu, "", 0, myMDIClient, FXMDIClient::ID_MDI_4);
495  new FXMenuCommand(myWindowsMenu, "&Others...", 0, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
496  new FXMenuSeparator(myWindowsMenu);
498  "Clear Message Window\t\tClear the message window.",
499  0, this, MID_CLEARMESSAGEWINDOW);
500 
501  // build help menu
502  myHelpMenu = new FXMenuPane(this);
503  new FXMenuTitle(myMenuBar, "&Help", NULL, myHelpMenu);
505  this, MID_ABOUT);
506 }
507 
508 
509 void
511  // build tool bars
512  {
513  // file and simulation tool bar
514  myToolBarDrag1 = new FXToolBarShell(this, FRAME_NORMAL);
515  myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1,
516  LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
517  new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP,
518  TOOLBARGRIP_DOUBLE);
519  // build file tools
520  new FXButton(myToolBar1, "\t\tOpen a simulation (Configuration file).",
522  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
523  new FXButton(myToolBar1, "\t\tOpen a network.",
525  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
526  new FXButton(myToolBar1, "\t\tReloads the simulation / the network.",
528  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
529  }
530  {
531  // build simulation tools
532  myToolBarDrag2 = new FXToolBarShell(this, FRAME_NORMAL);
533  myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2,
534  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
535  new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP,
536  TOOLBARGRIP_DOUBLE);
537  new FXButton(myToolBar2, "\t\tStart the loaded simulation.",
539  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
540  new FXButton(myToolBar2, "\t\tStop the running simulation.",
542  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
543  new FXButton(myToolBar2, "\t\tPerform a single simulation step.",
545  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
546  }
547  {
548  // Simulation Step Display
549  myToolBarDrag3 = new FXToolBarShell(this, FRAME_NORMAL);
550  myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3,
551  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
552  new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP,
553  TOOLBARGRIP_DOUBLE);
554  new FXButton(myToolBar3, "Time:\t\tToggle between seconds and hour:minute:seconds display", 0, this, MID_TIME_TOOGLE,
555  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
556  myLCDLabel = new FXEX::FXLCDLabel(myToolBar3, 13, 0, 0, JUSTIFY_RIGHT);
560  myLCDLabel->setGroove(2);
561  myLCDLabel->setText("-------------");
562  }
563  {
564  // Simulation Delay
565  myToolBarDrag4 = new FXToolBarShell(this, FRAME_NORMAL);
566  myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4,
567  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
568  new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP,
569  TOOLBARGRIP_DOUBLE);
570  new FXButton(myToolBar4, "Delay (ms):\t\tToggle between alternative delay values", 0, this, MID_DELAY_TOOGLE,
571  BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
574  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
576  mySimDelayTarget->setIncrements(1, 10, 10);
577  mySimDelayTarget->setRange(0, 1000);
579  }
580  {
581  // Views
582  myToolBarDrag5 = new FXToolBarShell(this, FRAME_NORMAL);
583  myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5,
584  LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
585  new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP,
586  TOOLBARGRIP_DOUBLE);
587  // build view tools
588  new FXButton(myToolBar5, "\t\tOpen a new microscopic view.",
590  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
591 #ifdef HAVE_OSG
592  new FXButton(myToolBar5, "\t\tOpen a new 3D view.",
594  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
595 #endif
596  }
597 }
598 
599 
600 long
602  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
603  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
604  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
605  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
606  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
607  getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
608  getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
609  getApp()->reg().writeIntEntry("gui", "alternateSimDelay", myAlternateSimDelay);
610  getApp()->exit(0);
611  return 1;
612 }
613 
614 
615 long
617  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
618  if (mc->getText() == "Edit Selected...") {
619  GUIDialog_GLChosenEditor* chooser =
621  chooser->create();
622  chooser->show();
623  } else {
625  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
626  for (size_t i = 0; i < MSEdge::dictSize(); ++i) {
627  const std::vector<MSLane*>& lanes = MSEdge::dictionary(i)->getLanes();
628  for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
629  GUILane* lane = dynamic_cast<GUILane*>(*it);
630  assert(lane != 0);
631  if ((lane->getPermissions() & svc) != 0) {
632  gSelected.select(lane->getGlID());
633  }
634  }
635  }
636  if (myMDIClient->numChildren() > 0) {
637  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
638  if (w != 0) {
639  // color by selection
641  }
642  }
643  }
644  updateChildren();
645  }
646  return 1;
647 }
648 
649 
650 long
652  GUIDialog_Breakpoints* chooser = new GUIDialog_Breakpoints(this);
653  chooser->create();
654  chooser->show();
655  return 1;
656 }
657 
658 
659 long
661  // get the new file name
662  FXFileDialog opendialog(this, "Open Simulation Configuration");
663  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
664  opendialog.setSelectMode(SELECTFILE_EXISTING);
665  opendialog.setPatternList(myConfigPattern.c_str());
666  if (gCurrentFolder.length() != 0) {
667  opendialog.setDirectory(gCurrentFolder);
668  }
669  if (opendialog.execute()) {
670  gCurrentFolder = opendialog.getDirectory();
671  std::string file = opendialog.getFilename().text();
672  load(file, false);
673  myRecentConfigs.appendFile(file.c_str());
674  }
675  return 1;
676 }
677 
678 
679 long
681  // get the new file name
682  FXFileDialog opendialog(this, "Open Network");
683  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
684  opendialog.setSelectMode(SELECTFILE_EXISTING);
685  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
686  if (gCurrentFolder.length() != 0) {
687  opendialog.setDirectory(gCurrentFolder);
688  }
689  if (opendialog.execute()) {
690  gCurrentFolder = opendialog.getDirectory();
691  std::string file = opendialog.getFilename().text();
692  load(file, true);
693  myRecentNets.appendFile(file.c_str());
694  }
695  return 1;
696 }
697 
698 
699 long
701  load("", false, true);
702  return 1;
703 }
704 
705 
706 long
707 GUIApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
708  if (myAmLoading) {
709  myStatusbar->getStatusLine()->setText("Already loading!");
710  return 1;
711  }
712  std::string file((const char*)data);
713  load(file, sender == &myRecentNets);
714  return 1;
715 }
716 
717 
718 long
720  closeAllWindows();
721  return 1;
722 }
723 
724 
725 long
726 GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
727  sender->handle(this,
728  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
729  ptr);
730  return 1;
731 }
732 
733 
734 long
735 GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
736  sender->handle(this,
738  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
739  ptr);
740  return 1;
741 }
742 
743 
744 long
745 GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
746  sender->handle(this,
747  myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
748  ptr);
749  return 1;
750 }
751 
752 
753 long
754 GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
755  sender->handle(this,
757  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
758  ptr);
759  return 1;
760 }
761 
762 
763 long
765  // check whether a net was loaded successfully
767  myStatusbar->getStatusLine()->setText("No simulation loaded!");
768  return 1;
769  }
770  // check whether it was started before and paused;
771  if (!myWasStarted) {
772  myRunThread->begin();
773  myWasStarted = true;
774  }
775  myRunThread->resume();
776  return 1;
777 }
778 
779 
780 long
782  myRunThread->stop();
783  return 1;
784 }
785 
786 
787 long
789  // check whether a net was loaded successfully
791  myStatusbar->getStatusLine()->setText("No simulation loaded!");
792  return 1;
793  }
794  // check whether it was started before and paused;
795  if (!myWasStarted) {
796  myRunThread->begin();
797  myWasStarted = true;
798  }
800  return 1;
801 }
802 
803 
804 long
809  }
810  return 1;
811 }
812 
813 
814 long
816  const SUMOTime tmp = myAlternateSimDelay;
819  return 1;
820 }
821 
822 
823 long
826  return 1;
827 }
828 
829 
830 long
831 GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
832  sender->handle(this,
834  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
835  ptr);
836  return 1;
837 }
838 
839 
840 long
841 GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
842  sender->handle(this,
844  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
845  ptr);
846  return 1;
847 }
848 
849 
850 long
851 GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
852  sender->handle(this,
854  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
855  ptr);
856  return 1;
857 }
858 
859 
860 long
861 GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
862  sender->handle(this,
864  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
865  ptr);
866  return 1;
867 }
868 
869 
870 long
871 GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
872  if (myMDIClient->numChildren() > 0) {
873  GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
874  if (w != 0) {
875  w->onCmdLocate(0, sel, 0);
876  }
877  }
878  return 1;
879 }
880 
881 long
884  d->create();
885  d->show(PLACEMENT_OWNER);
886  return 1;
887 }
888 
889 
890 long
893  if (myAmGaming) {
894  mySimDelayTarget->setValue(1000);
895  }
896  return 1;
897 }
898 
899 
900 long
903  return 1;
904 }
905 
906 
907 long
910  return 1;
911 }
912 
913 
914 #ifdef HAVE_OSG
915 long
916 GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
918  return 1;
919 }
920 #endif
921 
922 
923 long
925  GUIDialog_AboutSUMO* about =
926  new GUIDialog_AboutSUMO(this, "About SUMO", 0, 0);
927  about->create();
928  about->show(PLACEMENT_OWNER);
929  return 1;
930 }
931 
932 
933 long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
934  FXEvent* event = (FXEvent*)ptr;
935  FXString string = GUIUserIO::clipped.c_str();
936  setDNDData(FROM_CLIPBOARD, event->target, string);
937  return 1;
938 }
939 
940 
941 long
943  eventOccured();
944  return 1;
945 }
946 
947 
948 long
950  eventOccured();
951  return 1;
952 }
953 
954 
955 void
957  while (!myEvents.empty()) {
958  // get the next event
959  GUIEvent* e = static_cast<GUIEvent*>(myEvents.top());
960  myEvents.pop();
961  // process
962  switch (e->getOwnType()) {
965  break;
967  if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
969  }
970  break;
973  case EVENT_ERROR_OCCURED:
975  break;
978  break;
979  default:
980  break;
981  }
982  delete e;
983  }
984  myToolBar2->forceRefresh();
985  myToolBar3->forceRefresh();
986 }
987 
988 
989 void
991  myAmLoading = false;
993  if (ec->myNet != 0) {
994 #ifndef NO_TRACI
995  std::map<int, TraCIServer::CmdExecutor> execs;
998  try {
1000  } catch (ProcessError& e) {
1002  WRITE_ERROR(e.what());
1003  delete ec->myNet;
1004  ec->myNet = 0;
1005  }
1006 #endif
1007  }
1008 
1009  // check whether the loading was successfull
1010  if (ec->myNet == 0) {
1011  // report failure
1012  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1013  if (GUIGlobals::gQuitOnEnd) {
1014  closeAllWindows();
1015  getApp()->exit(1);
1016  }
1017  } else {
1018  // initialise simulation thread
1019  if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1020  if (GUIGlobals::gQuitOnEnd) {
1021  closeAllWindows();
1022  getApp()->exit(1);
1023  }
1024  } else {
1025  // report success
1026  setStatusBarText("'" + ec->myFile + "' loaded.");
1027  myWasStarted = false;
1028  // initialise views
1029  myViewNumber = 0;
1031  if (ec->mySettingsFiles.size() > 0) {
1032  // open a view for each file and apply settings
1033  for (std::vector<std::string>::const_iterator it = ec->mySettingsFiles.begin(); it != ec->mySettingsFiles.end(); ++it) {
1034  GUISettingsHandler settings(*it);
1035  GUISUMOViewParent::ViewType vt = defaultType;
1036  if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1038  }
1039  if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1041  }
1042  GUISUMOAbstractView* view = openNewView(vt);
1043  if (view == 0) {
1044  break;
1045  }
1046  std::string settingsName = settings.addSettings(view);
1047  view->addDecals(settings.getDecals());
1048  settings.setViewport(view);
1049  settings.setSnapshots(view);
1050  if (settings.getDelay() > 0) {
1051  mySimDelayTarget->setValue(settings.getDelay());
1052  }
1053  if (settings.getBreakpoints().size() > 0) {
1055  }
1056  }
1057  } else {
1058  openNewView(defaultType);
1059  }
1060 
1061  if (isGaming()) {
1062  setTitle("SUMO Traffic Light Game");
1063  } else {
1064  // set simulation name on the caption
1065  std::string caption = "SUMO " + std::string(VERSION_STRING);
1066  setTitle(MFXUtils::getTitleText(caption.c_str(), ec->myFile.c_str()));
1067  }
1068  // set simulation step begin information
1070  }
1071  }
1072  getApp()->endWaitCursor();
1073  // start if wished
1075  onCmdStart(0, 0, 0);
1076  }
1077  update();
1078 }
1079 
1080 
1081 void
1083  updateChildren();
1085  update();
1086 }
1087 
1088 
1089 void
1091  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1093 }
1094 
1095 
1096 void
1098  GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
1099  onCmdStop(0, 0, 0);
1100  if (GUIGlobals::gQuitOnEnd) {
1101  closeAllWindows();
1102  getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1103  } else {
1104  // build the text
1105  const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1106  ".\nReason: " + MSNet::getStateMessage(ec->getReason());
1107  FXMessageBox::warning(this, MBOX_OK, "Simulation ended", "%s", text.c_str());
1108  }
1109 }
1110 
1111 
1112 
1113 void
1114 GUIApplicationWindow::load(const std::string& file, bool isNet, bool isReload) {
1115  getApp()->beginWaitCursor();
1116  myAmLoading = true;
1117  closeAllWindows();
1118  if (isReload) {
1119  myLoadThread->start();
1120  setStatusBarText("Reloading.");
1121  } else {
1122  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1123  myLoadThread->load(file, isNet);
1124  setStatusBarText("Loading '" + file + "'.");
1125  }
1126  update();
1127 }
1128 
1129 
1132  if (!myRunThread->simulationAvailable()) {
1133  myStatusbar->getStatusLine()->setText("No simulation loaded!");
1134  return 0;
1135  }
1136  std::string caption = "View #" + toString(myViewNumber++);
1137  FXuint opts = MDI_TRACKING;
1138  GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
1139  this, GUIIconSubSys::getIcon(ICON_APP), opts, 10, 10, 300, 200);
1141  w->create();
1142  if (myMDIClient->numChildren() == 1) {
1143  w->maximize();
1144  } else {
1145  myMDIClient->vertical(true);
1146  }
1147  myMDIClient->setActiveChild(w);
1148  return v;
1149 }
1150 
1151 
1152 FXGLCanvas*
1154  if (myMDIClient->numChildren() == 0) {
1155  return 0;
1156  }
1157  GUISUMOViewParent* share_tmp1 =
1158  static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
1159  return share_tmp1->getBuildGLCanvas();
1160 }
1161 
1162 
1163 void
1165  myTrackerLock.lock();
1166  myLCDLabel->setText("-------------");
1167  // remove trackers and other external windows
1168  size_t i;
1169  for (i = 0; i < mySubWindows.size(); ++i) {
1170  mySubWindows[i]->destroy();
1171  }
1172  for (i = 0; i < myTrackerWindows.size(); ++i) {
1173  myTrackerWindows[i]->destroy();
1174  }
1175  // delete the simulation
1177  // reset the caption
1178  setTitle(MFXUtils::getTitleText(("SUMO " + std::string(VERSION_STRING)).c_str()));
1179  // delete other children
1180  while (myTrackerWindows.size() != 0) {
1181  delete myTrackerWindows[0];
1182  }
1183  while (mySubWindows.size() != 0) {
1184  delete mySubWindows[0];
1185  }
1186  mySubWindows.clear();
1187  // clear selected items
1188  gSelected.clear();
1189  // add a separator to the log
1192  // remove coordinate information
1193  myGeoCoordinate->setText("N/A");
1194  myCartesianCoordinate->setText("N/A");
1195  //
1197  update();
1198 }
1199 
1200 
1201 FXCursor*
1203  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1204 }
1205 
1206 
1207 SUMOTime
1210 }
1211 
1212 
1213 void
1215  load("", false);
1216 }
1217 
1218 
1219 void
1220 GUIApplicationWindow::setStatusBarText(const std::string& text) {
1221  myStatusbar->getStatusLine()->setText(text.c_str());
1222  myStatusbar->getStatusLine()->setNormalText(text.c_str());
1223 }
1224 
1225 
1226 void
1228  SUMOReal fracSeconds = STEPS2TIME(time);
1229  const bool hideFraction = myAmGaming || fmod(TS, 1.) == 0.;
1230  const int BuffSize = 100;
1231  char buffer[BuffSize];
1232  if (myShowTimeAsHMS) {
1233  const int hours = (int)fracSeconds / 3600;
1234  const int minutes = ((int)fracSeconds % 3600) / 60;
1235  fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1236  const std::string format = (hideFraction ?
1237  "%02d-%02d-%02.0f" : "%02d-%02d-%06.3f");
1238  snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1239  } else {
1240  const std::string format = (hideFraction ?
1241  "%13.0f" : "%13.3f");
1242  snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
1243  }
1244  myLCDLabel->setText(buffer);
1245 }
1246 
1247 /****************************************************************************/
1248 
std::vector< FXMainWindow * > myTrackerWindows
Definition: GUIMainWindow.h:90
Event sent when the the simulation is over.
About SUMO - ID.
Definition: GUIAppEnum.h:83
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
GUICompleteSchemeStorage gSchemeStorage
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
static std::string clipped
Definition: GUIUserIO.h:64
void handleEvent_SimulationLoaded(GUIEvent *e)
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
virtual bool simulationIsStepable() const
Locate poi - button.
Definition: GUIAppEnum.h:167
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
The Simulation execution thread.
Definition: GUIAppEnum.h:115
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
GUIVisualizationSettings * getVisualisationSettings()
send when a message occured
Definition: GUIEvent.h:50
void * top()
Definition: MFXEventQue.cpp:39
virtual void deleteSim()
FXSplitter * myMainSplitter
The splitter that divides the main window into vies and the log window.
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
const std::string & getViewType() const
Returns the parsed view type.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
MFXEventQue myEvents
List of got requests.
Locate vehicle - button.
Definition: GUIAppEnum.h:161
const bool myOsgView
whether to load the OpenSceneGraph view
const std::string & getMsg() const
Returns the message.
GUIColorer laneColorer
The lane colorer.
void load(const std::string &file, bool isNet)
begins the loading of the given file
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
FXToolBarShell * myToolBarDrag4
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
virtual void setValue(FXdouble value)
Change current value.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
Start the simulation.
Definition: GUIAppEnum.h:91
virtual bool simulationIsStartable() const
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:52
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
Locate TLS - button.
Definition: GUIAppEnum.h:163
Edit simulation breakpoints.
Definition: GUIAppEnum.h:127
virtual void detach()
Detaches the tool/menu bar.
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:203
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:77
FXGLVisual * myGLVisual
The gl-visual used.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
Definition: MSEdge.cpp:465
FXString gCurrentFolder
The folder used as last.
Open configuration - ID.
Definition: GUIAppEnum.h:73
Close simulation - ID.
Definition: GUIAppEnum.h:81
#define TS
Definition: SUMOTime.h:52
#define CMD_SET_GUI_VARIABLE
Loads a file previously loaded.
Definition: GUIAppEnum.h:79
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:210
Open network - ID.
Definition: GUIAppEnum.h:75
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:77
const SUMOTime myBegin
the time the simulation shall start with
long onCmdNewView(FXObject *, FXSelector, void *)
Called if a new view shall be opened (2D view)
Locate junction - button.
Definition: GUIAppEnum.h:157
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
virtual FXGLCanvas * getBuildGLCanvas() const
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcc: Change GUI State)
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
void addDecals(const std::vector< Decal > &decals)
FXToolBarShell * myToolBarDrag2
void setViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
FXMenuPane * myFileMenu
the submenus
void addSeparator()
Adds a a separator to this log window.
static std::vector< SUMOTime > gBreakpoints
List of breakpoints.
Definition: GUIGlobals.h:58
Main window closes.
Definition: GUIAppEnum.h:55
Application settings - menu entry.
Definition: GUIAppEnum.h:135
virtual void create()
Creates the main window (required by FOX)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
FXHorizontalFrame * myCartesianFrame
SUMOReal getDelay() const
Returns the parsed delay.
FXRecentFiles myRecentNets
List of recent nets.
const std::vector< std::string > mySettingsFiles
the name of the settings file to load
Editor for simulation breakpoints.
bool myAmGaming
information whether the gui is currently in gaming mode
bool myShowTimeAsHMS
whether to show time as hour:minute:second
void handleEvent_Message(GUIEvent *e)
std::vector< FXMDIChild * > mySubWindows
Definition: GUIMainWindow.h:89
static void clearTextures()
clears loaded textures
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:77
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
void setActive(size_t scheme)
Definition: GUIColorer.h:66
An error occured during the simulation step.
Definition: MSNet.h:104
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2)
void setRange(FXdouble lo, FXdouble hi)
Change the spinner's range.
Locator configuration - menu entry.
Definition: GUIAppEnum.h:139
void handleEvent_SimulationEnded(GUIEvent *e)
FXdouble getValue() const
Return current value.
Locate polygons - button.
Definition: GUIAppEnum.h:169
std::string myConfigPattern
Input file pattern.
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
#define snprintf
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:167
The loading thread.
Definition: GUIAppEnum.h:113
static void init(FXApp *a)
size_t myViewNumber
The current view number.
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
void load(const std::string &file, bool isNet, bool isReload=false)
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
Definition: FXLCDLabel.cpp:185
FXToolBarShell * myMenuBarDrag
SUMOTime getCurrentSimTime() const
ViewType
Available view types.
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
Gaming mode - menu entry.
Definition: GUIAppEnum.h:137
Perform a single simulation step.
Definition: GUIAppEnum.h:95
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
The application's "About" - dialog.
void setStatusBarText(const std::string &)
The Simulation delay control.
Definition: GUIAppEnum.h:141
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
#define CMD_GET_GUI_VARIABLE
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
void saveViewport(const SUMOReal x, const SUMOReal y, const SUMOReal zoom)
Makes the given viewport the default.
send when a error occured
Definition: GUIEvent.h:56
Open chosen editor - ID.
Definition: GUIAppEnum.h:125
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:378
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:136
bool myListInternal
information whether the locator should list internal structures
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:52
virtual bool simulationIsStopable() const
The dialog to change the application (gui) settings.
Send when the simulation is over; The reason and the time step are stored within the event...
Definition: GUIEvent.h:60
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
FXMenuPane * mySelectByPermissions
GUINet & getNet() const
virtual void fillMenuBar()
Builds the menu bar.
#define VERSION_STRING
Definition: config.h:227
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:105
A single child window which contains a view of the simulation area.
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:55
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void appendText(GUIEventType eType, const std::string &msg)
Adds new text to the window.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
FXMenuBar * myMenuBar
The application menu bar.
FXToolBarShell * myToolBarDrag5
FXGLCanvas * getBuildGLCanvas() const
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
Locate addtional structure - button.
Definition: GUIAppEnum.h:165
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
void setGroove(const FXint width)
set/get groove width - must be less than segment width
Definition: FXLCDLabel.cpp:221
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
toogle time display mode
Definition: GUIAppEnum.h:181
void prepareDestruction()
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
Definition: GUIMainWindow.h:92
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:146
void updateTimeLCD(const SUMOTime time)
updates the simulation time display
static void close()
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:499
FXDockSite * myTopDock
FXRecentFiles myRecentConfigs
List of recent config files.
void create()
Creates the widget (and the icons)
void clear()
Clears the list of selected objects.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
int SUMOTime
Definition: SUMOTime.h:43
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
void lock()
lock mutex
Definition: MFXMutex.cpp:84
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
toogle delay between alternative value
Definition: GUIAppEnum.h:183
FXMDIClient * myMDIClient
The multi view panel.
Definition: GUIMainWindow.h:98
send when a simulation has been loaded
Definition: GUIEvent.h:44
bool simulationAvailable() const
Stop the simulation.
Definition: GUIAppEnum.h:93
send when a warning occured
Definition: GUIEvent.h:53
FXToolBar * myToolBar1
The application tool bar.
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
long onUpdNeedsSimulation(FXObject *, FXSelector, void *)
Determines whether some buttons which require an active simulation may be shown.
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
#define SUMOReal
Definition: config.h:215
static const bool gUseMesoSim
Definition: MSGlobals.h:98
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:483
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:73
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
Locate edge - button.
Definition: GUIAppEnum.h:159
void setText(FXString lbl)
manipulate text in LCD label
Definition: FXLCDLabel.cpp:152
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
const SUMOTime myEnd
the time the simulation shall end with
virtual void begin()
void clear()
Clears the window.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
bool empty()
Definition: MFXEventQue.cpp:74
Main window-ID.
Definition: GUIAppEnum.h:53
void handleEvent_SimulationStep(GUIEvent *e)
Spinner control.
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
A logging window for the gui.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xac: Get GUI Variable)
send when a simulation step has been performed
Definition: GUIEvent.h:47
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
Open a new microscopic view.
Definition: GUIAppEnum.h:103
static FXIcon * getIcon(GUIIcon which)
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
virtual void addToWindowsMenu(FXMenuPane *)
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
The main window of the SUMO-gui.