Eclipse SUMO - Simulation of Urban MObility
GUIApplicationWindow.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// The main window of the SUMO-gui.
22/****************************************************************************/
23#include <config.h>
24
25#ifdef HAVE_VERSION_H
26#include <version.h>
27#endif
28
29#include <string>
30#include <sstream>
31#include <algorithm>
32#include <iomanip>
33#include <fxkeys.h>
34
35#include <guisim/GUINet.h>
36#include <guisim/GUILane.h>
37#include <netload/NLHandler.h>
39#include <microsim/MSGlobals.h>
40#include <microsim/MSEdge.h>
41#include <microsim/MSVehicle.h>
47
48#include "GUISUMOViewParent.h"
49#include "GUILoadThread.h"
50#include "GUIRunThread.h"
54
64
65#include <utils/xml/XMLSubSys.h>
91#include "GUIGlobals.h"
96
97
98#define MIN_DRAW_DELAY 20
99//#define HAVE_DANGEROUS_SOUNDS
100
101// ===========================================================================
102// FOX-declarations
103// ===========================================================================
104FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
108 FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
109
124 FXMAPFUNC(SEL_COMMAND, MID_NETEDIT, GUIApplicationWindow::onCmdNetedit),
125
134#ifdef HAVE_OSG
135 FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
136#endif
140 FXMAPFUNC(SEL_COMMAND, MID_DELAY_INC, GUIApplicationWindow::onCmdDelayInc),
141 FXMAPFUNC(SEL_COMMAND, MID_DELAY_DEC, GUIApplicationWindow::onCmdDelayDec),
142 FXMAPFUNC(SEL_COMMAND, MID_SIMSAVE, GUIApplicationWindow::onCmdSaveState),
143 FXMAPFUNC(SEL_COMMAND, MID_SIMLOAD, GUIApplicationWindow::onCmdLoadState),
148
152
153 // these functions do not assign shortcut keys to commands, but rather affect the button enable status upon other events (e.g. simulation loaded)
154 // since those events are invoked through pseudo key events (?), the same key shortcuts as in cmd must be supplied as well
155 FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GUIApplicationWindow::onUpdOpen),
164#ifdef HAVE_OSG
166#endif
183 FXMAPFUNC(SEL_COMMAND, MID_HOTKEYS, GUIApplicationWindow::onCmdHotkeys),
184 FXMAPFUNC(SEL_COMMAND, MID_TUTORIAL, GUIApplicationWindow::onCmdTutorial),
187
188 // forward requests to the active view
190 FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
194 FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GUIApplicationWindow::onCmdLocate),
195 FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GUIApplicationWindow::onCmdLocate),
196 FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
197 FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
207 FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
208 FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
209
210 FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
211
216};
217
218// Object implementation
219FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
220
221// ===========================================================================
222// static members
223// ===========================================================================
225
226// ===========================================================================
227// member method definitions
228// ===========================================================================
229GUIApplicationWindow::GUIApplicationWindow(FXApp* a, const std::string& configPattern) :
230 GUIMainWindow(a),
231 myLoadThread(nullptr), myRunThread(nullptr),
232 myAmLoading(false),
233 myIsReload(false),
234 myGuiSettingsFileMTime(-2),
235 myAlternateSimDelay(0.),
236 myRecentNetworksAndConfigs(a, "files"),
237 myConfigPattern(configPattern),
238 hadDependentBuild(false),
239 myShowTimeAsHMS(false),
240 myHaveNotifiedAboutSimEnd(false),
241 // game specific
242 myJamSoundTime(60),
243 myPreviousCollisionNumber(0),
244 myWaitingTime(0),
245 myTimeLoss(0),
246 myEmergencyVehicleCount(0),
247 myTotalDistance(0),
248 myLastStepEventMillis(SysUtils::getCurrentMillis() - MIN_DRAW_DELAY) {
249 // init icons
251 // init cursors
253 // disable tooltips
254 a->setTooltipTime(1000000000);
255 a->setTooltipPause(1000000000);
256}
257
258
259void
261 // don't do this twice
262 if (hadDependentBuild) {
263 return;
264 }
265 hadDependentBuild = true;
266
267 setTarget(this);
268 setSelector(MID_WINDOW);
269
270 // build menu bar
271 myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBar);
273 new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
275 // build the thread - io
280
281 // build the status bar
282 myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
283 {
284 // build TraCi info
286 auto button = new FXButton(myTraCiFrame, TL("TraCI"), nullptr, this, MID_TRACI_STATUS, GUIDesignButtonStatusBarFixed);
287 button->setBackColor(FXRGBA(253, 255, 206, 255));
288 if (TraCIServer::getInstance() == nullptr) {
289 myTraCiFrame->hide();
290 }
291 // build geo coordiantes
293 myGeoCoordinate = new FXLabel(myGeoFrame, TL("N/A\t\tOriginal coordinate (before coordinate transformation in netconvert)"), nullptr, LAYOUT_CENTER_Y);
294 // build cartesian coordinates
296 myCartesianCoordinate = new FXLabel(myCartesianFrame, TL("N/A\t\tNetwork coordinate"), nullptr, LAYOUT_CENTER_Y);
297 // build buttons
300 myStatButtons.back()->hide();
302 myStatButtons.back()->hide();
303 }
304
305 // make the window a mdi-window
306 myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
308 myMDIMenu = new FXMDIMenu(this, myMDIClient);
309 new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
310 new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
311 new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
312 new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
313
314 // build the message window
316 // fill menu and tool bar
317 fillMenuBar();
318 myToolBar6->hide();
319 myToolBar7->hide();
320 myToolBar9->hide();
321 myToolBar10->hide();
322 // build additional threads
323 myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent, isLibsumo);
325 // set the status bar
326 myStatusbar->getStatusLine()->setText(TL("Ready."));
327 // set the caption
328 setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
329
330 // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
331 myRunThread->start();
334}
335
336
337void
340 gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
341 FXMainWindow::create();
342 myMenuBarDrag->create();
343 myToolBarDrag1->create();
344 myToolBarDrag2->create();
345 myToolBarDrag3->create();
346 myToolBarDrag4->create();
347 myToolBarDrag5->create();
348 myToolBarDrag6->create();
349 myToolBarDrag7->create();
350 myFileMenu->create();
351 mySelectByPermissions->create();
352 myEditMenu->create();
353 mySettingsMenu->create();
354 myLocatorMenu->create();
355 myControlMenu->create();
356 myWindowMenu->create();
357 myHelpMenu->create();
358
359 FXint textWidth = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
360 myCartesianFrame->setWidth(textWidth);
361 myGeoFrame->setWidth(textWidth);
362 if (myTestFrame) {
363 myTestFrame->setWidth(textWidth);
364 }
365
366 show(PLACEMENT_DEFAULT);
367 if (!OptionsCont::getOptions().isSet("window-size")) {
368 if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
369 maximize();
370 }
371 }
372 myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
373 myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
374 const std::string& onlineMaps = getApp()->reg().readStringEntry("gui", "onlineMaps", "");
375 for (const std::string& entry : StringTokenizer(onlineMaps, "\n").getVector()) {
376 const std::vector<std::string> split = StringTokenizer(entry, "\t").getVector();
377 myOnlineMaps[split[0]] = split[1];
378 }
379 if (myOnlineMaps.empty()) {
380 myOnlineMaps["GeoHack"] = "https://geohack.toolforge.org/geohack.php?params=%lat;%lon_scale:1000";
381 myOnlineMaps["GoogleSat"] = "https://www.google.com/maps?ll=%lat,%lon&t=h&z=18";
382 myOnlineMaps["OSM"] = "https://www.openstreetmap.org/?mlat=%lat&mlon=%lon&zoom=18&layers=M";
383 }
385}
386
387
390 myRunThread->join();
392 //
394 delete myGLVisual;
395 // delete some non-parented windows
396 delete myToolBarDrag1;
397 //
398 delete myRunThread;
399 delete myFileMenu;
400 delete myEditMenu;
402 delete mySettingsMenu;
403 delete myLocatorMenu;
404 delete myControlMenu;
405 delete myWindowMenu;
406 delete myHelpMenu;
407
408 delete myLoadThread;
409
410 while (!myEvents.empty()) {
411 // get the next event
412 GUIEvent* e = myEvents.top();
413 myEvents.pop();
414 delete e;
415 }
416 for (auto item : myHotkeyPress) {
417 delete item.second;
418 }
419 for (auto item : myHotkeyRelease) {
420 delete item.second;
421 }
422}
423
424
425void
427 FXMainWindow::detach();
428 myMenuBarDrag->detach();
429 myToolBarDrag1->detach();
430}
431
432
433void
435 // build file menu
436 myFileMenu = new FXMenuPane(this);
439 TL("New Window"), "Ctrl+Shift+N", TL("Open a new sumo-gui window."),
440 nullptr, this, MID_HOTKEY_CTRL_SHIFT_N_NEWWINDOW);
441 new FXMenuSeparator(myFileMenu);
443 TL("&Open Simulation..."), "Ctrl+O", TL("Open a simulation (Configuration file)."),
446 TL("Open &Network..."), "Ctrl+N", TL("Open a network."),
449 TL("Open Shapes "), "Ctrl+P", TL("Load POIs and Polygons for visualization."),
452 TL("Open EdgeData "), "Ctrl+U", TL("Load edge related data for visualization."),
455 TL("&Reload"), "Ctrl+R", TL("Reloads the simulation / the network."),
458 TL("Quick-Reload"), "Ctrl+0", TL("Reloads the simulation (but not network)."),
460 new FXMenuSeparator(myFileMenu);
462 TL("Save Configuration"), "Ctrl+Shift+S", TL("Save current options as a configuration file."),
465 TL("Close"), "Ctrl+W", TL("Close the simulation."),
467 // Recent files
468 FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
469 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
470 // for whatever reason, sonar complains in the next line that sep1 may leak, but fox does the cleanup
471 GUIDesigns::buildFXMenuCommandRecentFile(myFileMenu, "", &myRecentNetworksAndConfigs, FXRecentFiles::ID_FILE_1); // NOSONAR
481 GUIDesigns::buildFXMenuCommand(myFileMenu, TL("C&lear Recent Files"), nullptr, &myRecentNetworksAndConfigs, FXRecentFiles::ID_CLEAR);
483 myRecentNetworksAndConfigs.setTarget(this);
485 new FXMenuSeparator(myFileMenu);
487 TL("&Quit"), "Ctrl+Q", TL("Quit the Application."),
488 nullptr, this, MID_HOTKEY_CTRL_Q_CLOSE);
489
490 // build edit menu
491 mySelectByPermissions = new FXMenuPane(this);
492 std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
493 for (const auto& vehicleClass : vehicleClasses) {
495 }
496
497 myEditMenu = new FXMenuPane(this);
500 TL("Edit Selected..."), "Ctrl+E", TL("Opens a dialog for editing the list of selected items."),
502 mySelectLanesMenuCascade = new FXMenuCascade(myEditMenu,
503 TL("Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes."),
505 new FXMenuSeparator(myEditMenu);
507 TL("Edit Breakpoints"), "Ctrl+B", TL("Opens a dialog for editing breakpoints."),
510 TL("Edit Visualisation"), "F9", TL("Opens a dialog for editing visualization settings."),
513 TL("Edit Viewport"), "Ctrl+I", TL("Opens a dialog for editing viewing area, zoom and rotation."),
515 new FXMenuSeparator(myEditMenu);
517 TL("Open in netedit"), "Ctrl+T", TL("Opens the netedit application with the current network."),
519
520 // build settings menu
521 mySettingsMenu = new FXMenuPane(this);
524 TL("Application Settings"), "Ctrl+H", TL("Open a Dialog for Application Settings editing."),
525 nullptr, this, MID_APPSETTINGS);
526 myGamingModeCheckbox = new FXMenuCheck(mySettingsMenu,
527 TL("Gaming Mode\tCtrl+G\tToggle gaming mode on/off."),
530 TL("Full Screen Mode"), "Ctrl+F", TL("Toggle full screen mode on/off."),
532
533 // build Locate menu
534 myLocatorMenu = new FXMenuPane(this);
537 TL("&Junctions"), "Shift+J", TL("Open a Dialog for Locating a Junction."),
540 TL("&Edges"), "Shift+E", TL("Open a Dialog for Locating an Edge."),
543 TL("&Vehicles"), "Shift+V", TL("Open a Dialog for Locating a Vehicle."),
546 TL("&Persons"), "Shift+P", TL("Open a Dialog for Locating a Person."),
549 TL("&Container"), "Shift+C", TL("Open a Dialog for Locating a Container."),
552 TL("&TLS"), "Shift+T", TL("Open a Dialog for Locating a Traffic Light."),
555 TL("&Additional"), "Shift+A", TL("Open a Dialog for Locating an Additional Structure."),
558 TL("P&oI"), "Shift+O", TL("Open a Dialog for Locating a Point of Interest."),
561 TL("Po&lygon"), "Shift+L", TL("Open a Dialog for Locating a Polygon."),
563 new FXMenuSeparator(myLocatorMenu);
564 new FXMenuCheck(myLocatorMenu,
565 TL("Show Internal Structures\t\tShow internal junctions and streets in locator dialog."),
566 this, MID_LISTINTERNAL);
567 FXMenuCheck* listParking = new FXMenuCheck(myLocatorMenu,
568 TL("Show Parking Vehicles\t\tShow parking vehicles in locator dialog."),
569 this, MID_LISTPARKING);
570 listParking->setCheck(myListParking);
571 new FXMenuCheck(myLocatorMenu,
572 TL("Show vehicles outside the road network\t\tShow vehicles that are teleporting or driving remote-controlled outside the road network in locator dialog."),
573 this, MID_LISTTELEPORTING);
574
575 // build control menu
576 // the shortcut designator is not only at text in the submenu but also defines the real shortcut key assigned with it!
577 // secondary shortcuts (ctrl+A, ctrl+S, ctrl+D) are defined in GUIShortcutsSubSys::buildSUMOAccelerators
578 myControlMenu = new FXMenuPane(this);
579 GUIDesigns::buildFXMenuTitle(myMenuBar, TL("Simulation"), nullptr, myControlMenu);
581 TL("Run"), "A,space", TL("Start/ Resume the simulation."),
584 TL("Stop"), "S,space", TL("Halt the simulation."),
587 TL("Step"), "D", TL("Perform one simulation step."),
590 TL("Delay+"), "PgUp", TL("Increase simulation step delay."), nullptr, this, MID_DELAY_INC);
592 TL("Delay-"), "PgDn", TL("Decrease simulation step delay."), nullptr, this, MID_DELAY_DEC);
594 TL("Save"), "", TL("Save the current simulation state to a file."),
597 TL("Load"), "", TL("Load simulation state for the current network from file."),
599
600 // build windows menu
601 myWindowMenu = new FXMenuPane(this);
603 new FXMenuCheck(myWindowMenu,
604 TL("Show Status Line\t\tToggle the Status Bar on/off."),
605 myStatusbar, FXWindow::ID_TOGGLESHOWN);
606 new FXMenuCheck(myWindowMenu,
607 TL("Show Message Window\t\tToggle the Message Window on/off."),
608 myMessageWindow, FXWindow::ID_TOGGLESHOWN);
609 new FXMenuCheck(myWindowMenu,
610 TL("Show Simulation Time\t\tToggle the Simulation Time on/off."),
611 myToolBar3, FXWindow::ID_TOGGLESHOWN);
612 new FXMenuCheck(myWindowMenu,
613 TL("Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off."),
614 myToolBar4, FXWindow::ID_TOGGLESHOWN);
616 new FXMenuSeparator(myWindowMenu);
618 TL("Tile &Horizontally"), "", "",
619 GUIIconSubSys::getIcon(GUIIcon::WINDOWS_TILE_HORI), myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
621 TL("Tile &Vertically"), "", "",
622 GUIIconSubSys::getIcon(GUIIcon::WINDOWS_TILE_VERT), myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
624 TL("Cascade"), "", "",
626 myMDIClient, FXMDIClient::ID_MDI_CASCADE);
628 TL("&Close"), "", "",
629 nullptr, myMDIClient, FXMDIClient::ID_MDI_CLOSE);
630 FXMenuSeparator* sep2 = new FXMenuSeparator(myWindowMenu);
631 sep2->setTarget(myMDIClient);
632 sep2->setSelector(FXMDIClient::ID_MDI_ANY);
633 // for whatever reason, sonar complains in the next line that sep2 may leak, but fox does the cleanup
634 GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_1); // NOSONAR
635 GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_2);
636 GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_3);
637 GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_4);
638 GUIDesigns::buildFXMenuCommand(myWindowMenu, TL("&Others..."), nullptr, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
639 new FXMenuSeparator(myWindowMenu);
641 TL("Clear Message Window"), "", TL("Clear the message window."),
643 // build help menu
644 myHelpMenu = new FXMenuPane(this);
646 TL("&Help"),
647 nullptr, myHelpMenu);
648 GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Online Documentation"), "F1", TL("Open Online documentation."),
649 nullptr, this, MID_HOTKEY_F1_ONLINEDOCUMENTATION);
650 new FXMenuSeparator(myEditMenu);
651 GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Changelog"), "", TL("Open Changelog."),
652 nullptr, this, MID_CHANGELOG);
653 GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Hotkeys"), "", TL("Open Hotkeys."),
654 nullptr, this, MID_HOTKEYS);
655 GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Tutorial"), "", TL("Open Tutorial."),
656 nullptr, this, MID_TUTORIAL);
657 new FXMenuSeparator(myEditMenu);
658 GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&About"), "F12", TL("About sumo-gui."),
660 // build SUMO Accelerators (hotkeys)
662}
663
664
665void
667 // build tool bars
668 {
669 // file and simulation tool bar
670 myToolBarDrag1 = new FXToolBarShell(this, GUIDesignToolBar);
672 new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
673 // build file tools
674 new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tOpen simulation\tOpen a simulation (Configuration file)."),
676 new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tOpen network\tOpen a network."),
678 new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tReload\tReloads the simulation / the network."),
680 }
681 {
682 // simulation toolbar
683 myToolBarDrag2 = new FXToolBarShell(this, GUIDesignToolBar);
685 new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
686 // build simulation tools
687 new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tRun\tStart/Resume the loaded simulation."),
689 new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tStop\tHalt the running simulation."),
691 new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tStep\tPerform a single simulation step."),
693 }
694 {
695 // Simulation Step Display
696 myToolBarDrag3 = new FXToolBarShell(this, GUIDesignToolBar);
698 new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
699 new MFXButtonTooltip(myToolBar3, myStaticTooltipMenu, TL("Time:\tToggle between time formats\tToggle between seconds and hour:minute:seconds display."), nullptr, this, MID_TIME_TOGGLE, GUIDesignButtonToolbarText);
700
701 myLCDLabel = new MFXLCDLabel(myToolBar3, myStaticTooltipMenu, 16, nullptr, 0, JUSTIFY_RIGHT);
706 myLCDLabel->setText("----------------");
707 }
708 {
709 // Simulation Delay
710 myToolBarDrag4 = new FXToolBarShell(this, GUIDesignToolBar);
712 new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
713 new MFXButtonTooltip(myToolBar4, myStaticTooltipMenu, TL("Delay (ms):\tDelay per simulated second\tDelay per simulated second. Click to toggle between the last two delay values."), nullptr, this, MID_DELAY_TOGGLE, GUIDesignButtonToolbarText);
714 // create spinner for delay
715 mySimDelay = 0;
716 mySimDelayTarget = new FXDataTarget(mySimDelay);
718 // create slider
719 mySimDelaySlider = new FXSlider(myToolBar4, mySimDelayTarget, FXDataTarget::ID_VALUE, GUIDesignSlider);
720 mySimDelaySlider->setRange(0, 1000);
721 mySimDelaySlider->setHeadSize(10);
722 mySimDelaySlider->setIncrement(50);
723 mySimDelaySlider->setTickDelta(100);
724 mySimDelaySlider->setValue((int)mySimDelay);
725 //mySimDelayTarget->setNumberFormat(0);
726 //mySimDelayTarget->setIncrements(1, 10, 10);
727 mySimDelaySpinner->setIncrement(10);
728 mySimDelaySpinner->setRange(0, 10000);
729 mySimDelaySpinner->setValue(mySimDelay);
730 }
731 {
732 // Scale traffic (flows and incrementally loaded vehicles)
733 myToolBarDrag8 = new FXToolBarShell(this, GUIDesignToolBar);
735 new FXToolBarGrip(myToolBar8, myToolBar8, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
736 new FXLabel(myToolBar8, TL("Scale Traffic:\t\tScale traffic from flows and vehicles that are loaded incrementally from route files."), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
738 myDemandScaleSpinner->setIncrement(0.5);
739 myDemandScaleSpinner->setRange(0, 1000);
740 myDemandScaleSpinner->setValue(1);
741 }
742 {
743 // Views
744 myToolBarDrag5 = new FXToolBarShell(this, GUIDesignToolBar);
746 new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
747 // build view tools
748 new MFXButtonTooltip(myToolBar5, myStaticTooltipMenu, TL("\tOpen new view\tOpen a new microscopic view."),
750#ifdef HAVE_OSG
751 new MFXButtonTooltip(myToolBar5, myStaticTooltipMenu, TL("\tOpen new 3D view\tOpen a new 3D view."),
753#endif
754 }
755 {
757 // total waitingTime
758 myToolBarDrag6 = new FXToolBarShell(this, GUIDesignToolBar);
760 new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
761 new FXLabel(myToolBar6, TL("Waiting Time:\t\tTime spent waiting accumulated for all vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
762 myWaitingTimeLabel = new MFXLCDLabel(myToolBar6, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
767 myWaitingTimeLabel->setText("-------------");
768
769 // idealistic time loss
770 myToolBarDrag7 = new FXToolBarShell(this, GUIDesignToolBar);
772 new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
773 new FXLabel(myToolBar7, TL("Time Loss:\t\tTime lost due to being unable to drive with maximum speed for all vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
774 myTimeLossLabel = new MFXLCDLabel(myToolBar7, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
779 myTimeLossLabel->setText("-------------");
780
781 // total driving distance
782 myToolBarDrag9 = new FXToolBarShell(this, GUIDesignToolBar);
784 new FXToolBarGrip(myToolBar9, myToolBar9, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
785 new FXLabel(myToolBar9, TL("Distance (km):\t\tTotal distance driven by DRT vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
786 myTotalDistanceLabel = new MFXLCDLabel(myToolBar9, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
791 myTotalDistanceLabel->setText("-------------");
792
793 // emergency vehicle counts
794 myToolBarDrag10 = new FXToolBarShell(this, GUIDesignToolBar);
796 new FXToolBarGrip(myToolBar10, myToolBar10, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
797 new FXLabel(myToolBar10, TL("Emergency Vehicle waiting time:\t\tTime spent waiting accumulated for emergency vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
798 myEmergencyVehicleLabel = new MFXLCDLabel(myToolBar10, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
803 myEmergencyVehicleLabel->setText("-------------");
804 }
805}
806
807
808long
809GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
811 getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
812 getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
813 getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
814 getApp()->reg().writeIntEntry("gui", "alternateSimDelay", (int)myAlternateSimDelay);
815 getApp()->exit(0);
816 return 1;
817}
818
819
820long
821GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
822 FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
823 if (mc->getText() == "Edit Selected...") {
824 GUIDialog_GLChosenEditor* chooser =
826 chooser->create();
827 chooser->show();
828 } else {
830 const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
831 for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
832 const std::vector<MSLane*>& lanes = (*i)->getLanes();
833 for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
834 GUILane* lane = dynamic_cast<GUILane*>(*it);
835 assert(lane != 0);
836 if ((lane->getPermissions() & svc) != 0) {
837 gSelected.select(lane->getGlID());
838 }
839 }
840 }
841 if (myMDIClient->numChildren() > 0) {
842 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
843 if (w != nullptr) {
844 // color by selection
846 }
847 }
848 }
850 }
851 return 1;
852}
853
854
855long
856GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
857 if (myBreakpointDialog == nullptr) {
859 } else {
860 myBreakpointDialog->restore();
861 myBreakpointDialog->setFocus();
862 myBreakpointDialog->raise();
863 }
864 return 1;
865}
866
867
868long
869GUIApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
870 if (!myGLWindows.empty()) {
871 myGLWindows[0]->getView()->showViewportEditor();
872 }
873 return 1;
874}
875
876
877long
878GUIApplicationWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
879 if (!myGLWindows.empty()) {
880 myGLWindows[0]->getView()->showViewschemeEditor();
881 }
882 return 1;
883}
884
885
886long
887GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
888 MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/sumo-gui.html");
889 return 1;
890}
891
892
893long
894GUIApplicationWindow::onCmdChangelog(FXObject*, FXSelector, void*) {
895 // update in every version
896 MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/ChangeLog.html");
897 return 1;
898}
899
900
901long
902GUIApplicationWindow::onCmdHotkeys(FXObject*, FXSelector, void*) {
903 MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/sumo-gui.html#keyboard_shortcuts");
904 return 1;
905}
906
907
908long
909GUIApplicationWindow::onCmdTutorial(FXObject*, FXSelector, void*) {
910 MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/Tutorials/index.html");
911 return 1;
912}
913
914
915long
916GUIApplicationWindow::onCmdNetedit(FXObject*, FXSelector, void*) {
917 if (myGLWindows.empty()) {
918 return 1;
919 }
920 FXRegistry reg("SUMO netedit", "netedit");
921 reg.read();
922 const GUISUMOAbstractView* const v = myGLWindows[0]->getView();
923 reg.writeRealEntry("viewport", "x", v->getChanger().getXPos());
924 reg.writeRealEntry("viewport", "y", v->getChanger().getYPos());
925 reg.writeRealEntry("viewport", "z", v->getChanger().getZPos());
926 reg.write();
927 std::string netedit = "netedit";
928 const char* sumoPath = getenv("SUMO_HOME");
929 if (sumoPath != nullptr) {
930 std::string newPath = std::string(sumoPath) + "/bin/netedit";
931 if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
932 netedit = "\"" + newPath + "\"";
933 }
934 }
935 std::string cmd = netedit + " --registry-viewport -s " + "\"" + OptionsCont::getOptions().getString("net-file") + "\"";
936 // start in background
937#ifndef WIN32
938 cmd = cmd + " &";
939#else
940 // see "help start" for the parameters
941 cmd = "start /B \"\" " + cmd;
942#endif
943 WRITE_MESSAGE("Running " + cmd + ".");
944 // yay! fun with dangerous commands... Never use this over the internet
946 return 1;
947}
948
949
950long
951GUIApplicationWindow::onCmdNewWindow(FXObject*, FXSelector, void*) {
952 FXRegistry reg("SUMO sumo-gui", "sumo-gui");
953 std::string sumo_gui = "sumo-gui";
954 const char* sumoPath = getenv("SUMO_HOME");
955 if (sumoPath != nullptr) {
956 std::string newPath = std::string(sumoPath) + "/bin/sumo_gui";
957 if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
958 sumo_gui = "\"" + newPath + "\"";
959 }
960 }
961 std::string cmd = sumo_gui;
962 // start in background
963#ifndef WIN32
964 cmd = cmd + " &";
965#else
966 // see "help start" for the parameters
967 cmd = "start /B \"\" " + cmd;
968#endif
969 WRITE_MESSAGE("Running " + cmd + ".");
970 // yay! fun with dangerous commands... Never use this over the internet
972 return 1;
973}
974
975
976long
977GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
978 // get the new file name
979 FXFileDialog opendialog(this, TL("Open Simulation Configuration"));
980 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_CONFIG));
981 opendialog.setSelectMode(SELECTFILE_EXISTING);
982 opendialog.setPatternList(myConfigPattern.c_str());
983 if (gCurrentFolder.length() != 0) {
984 opendialog.setDirectory(gCurrentFolder);
985 }
986 if (opendialog.execute()) {
987 gCurrentFolder = opendialog.getDirectory();
988 std::string file = opendialog.getFilename().text();
989 loadConfigOrNet(file);
990 myRecentNetworksAndConfigs.appendFile(file.c_str());
991 }
992 return 1;
993}
994
995
996long
997GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
998 // get the new file name
999 FXFileDialog opendialog(this, TL("Open Network"));
1000 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
1001 opendialog.setSelectMode(SELECTFILE_EXISTING);
1002 opendialog.setPatternList("SUMO nets (*.net.xml,*.net.xml.gz)\nAll files (*)");
1003 if (gCurrentFolder.length() != 0) {
1004 opendialog.setDirectory(gCurrentFolder);
1005 }
1006 if (opendialog.execute()) {
1007 gCurrentFolder = opendialog.getDirectory();
1008 std::string file = opendialog.getFilename().text();
1009 loadConfigOrNet(file);
1010 myRecentNetworksAndConfigs.appendFile(file.c_str());
1011 }
1012 return 1;
1013}
1014
1015
1016long
1017GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
1018 // get the shape file name
1019 FXFileDialog opendialog(this, TL("Open Shapes"));
1020 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_SHAPES));
1021 opendialog.setSelectMode(SELECTFILE_EXISTING);
1022 opendialog.setPatternList("Additional files (*.xml,*.xml.gz)\nAll files (*)");
1023 if (gCurrentFolder.length() != 0) {
1024 opendialog.setDirectory(gCurrentFolder);
1025 }
1026 if (opendialog.execute()) {
1027 gCurrentFolder = opendialog.getDirectory();
1028 std::string file = opendialog.getFilename().text();
1029
1030 dynamic_cast<GUIShapeContainer&>(myRunThread->getNet().getShapeContainer()).allowReplacement();
1032 if (!XMLSubSys::runParser(handler, file, false)) {
1033 WRITE_MESSAGE("Loading of " + file + " failed.");
1034 }
1035 update();
1036 if (myMDIClient->numChildren() > 0) {
1037 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1038 if (w != nullptr) {
1039 w->getView()->update();
1040 }
1041 }
1042 }
1043 return 1;
1044}
1045
1046long
1047GUIApplicationWindow::onCmdOpenEdgeData(FXObject*, FXSelector, void*) {
1048 // get the shape file name
1049 FXFileDialog opendialog(this, TL("Open EdgeData"));
1050 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
1051 opendialog.setSelectMode(SELECTFILE_EXISTING);
1052 opendialog.setPatternList("EdgeData files (*.xml,*.xml.gz)\nAll files (*)");
1053 if (gCurrentFolder.length() != 0) {
1054 opendialog.setDirectory(gCurrentFolder);
1055 }
1056 if (opendialog.execute()) {
1057 gCurrentFolder = opendialog.getDirectory();
1058 std::string file = opendialog.getFilename().text();
1059 if (!GUINet::getGUIInstance()->loadEdgeData(file)) {
1060 WRITE_MESSAGE("Loading of " + file + " failed.");
1061 }
1062 update();
1063 if (myMDIClient->numChildren() > 0) {
1064 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1065 if (w != nullptr) {
1066 w->getView()->update();
1067 }
1068 }
1069 }
1070 return 1;
1071}
1072
1073long
1074GUIApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
1075 if (!myAmLoading) {
1077 getApp()->beginWaitCursor();
1078 myAmLoading = true;
1079 myIsReload = true;
1081 myLoadThread->start();
1082 setStatusBarText("Reloading.");
1083 update();
1084 }
1085 return 1;
1086}
1087
1088
1089long
1090GUIApplicationWindow::onCmdQuickReload(FXObject*, FXSelector, void*) {
1091 if (!myAmLoading) {
1092 setStatusBarText("Quick-Reloading.");
1094 }
1095 return 1;
1096}
1097
1098
1099long
1100GUIApplicationWindow::onCmdOpenRecent(FXObject* /* sender */, FXSelector, void* ptr) {
1101 if (myAmLoading) {
1102 myStatusbar->getStatusLine()->setText(TL("Already loading!"));
1103 return 1;
1104 }
1105 std::string file((const char*)ptr);
1106 loadConfigOrNet(file);
1107 return 1;
1108}
1109
1110
1111long
1112GUIApplicationWindow::onCmdSaveConfig(FXObject*, FXSelector, void*) {
1113 // get the new file name
1114 FXFileDialog opendialog(this, TL("Save SUMO Configuration"));
1115 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::SAVE));
1116 opendialog.setSelectMode(SELECTFILE_ANY);
1117 opendialog.setPatternList("Config (*.sumocfg)");
1118 if (gCurrentFolder.length() != 0) {
1119 opendialog.setDirectory(gCurrentFolder);
1120 }
1121 if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1122 return 1;
1123 }
1124 std::string file = MFXUtils::assureExtension(opendialog.getFilename(),
1125 opendialog.getPatternText(opendialog.getCurrentPattern()).after('.').before(')')).text();
1126 std::ofstream out(StringUtils::transcodeToLocal(file));
1127 if (out.good()) {
1128 OptionsCont::getOptions().writeConfiguration(out, true, false, false, file, true);
1129 setStatusBarText("Configuration saved to " + file);
1130 } else {
1131 setStatusBarText("Could not save configuration to " + file);
1132 }
1133 out.close();
1134 return 1;
1135}
1136
1137
1138long
1139GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
1141 return 1;
1142}
1143
1144
1145long
1146GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
1147 sender->handle(this,
1148 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1149 ptr);
1150 return 1;
1151}
1152
1153
1154long
1155GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
1156 sender->handle(this,
1158 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1159 ptr);
1160 return 1;
1161}
1162
1163
1164long
1165GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
1166 sender->handle(this,
1167 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1168 ptr);
1169 return 1;
1170}
1171
1172
1173long
1174GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
1175 sender->handle(this,
1177 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1178 ptr);
1179 return 1;
1180}
1181
1182
1183long
1184GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
1185 // check whether a net was loaded successfully
1187 myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
1188 return 1;
1189 }
1190 // check whether it was started before and paused;
1191 if (!myWasStarted) {
1192 myRunThread->begin();
1193 myWasStarted = true;
1194 }
1196 getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
1197 return 1;
1198}
1199
1200
1201long
1202GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
1203 myRunThread->stop();
1204 getApp()->forceRefresh(); // only callking myToolBar2->forceRefresh somehow loses keyboard focus
1205 return 1;
1206}
1207
1208
1209long
1210GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
1211 // check whether a net was loaded successfully
1213 myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
1214 return 1;
1215 }
1216 // check whether it was started before and paused;
1217 if (!myWasStarted) {
1218 myRunThread->begin();
1219 myWasStarted = true;
1220 }
1222 return 1;
1223}
1224
1225
1226long
1227GUIApplicationWindow::onCmdSaveState(FXObject*, FXSelector, void*) {
1228 // get the new file name
1229 FXFileDialog opendialog(this, TL("Save Simulation State"));
1230 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::SAVE));
1231 opendialog.setSelectMode(SELECTFILE_ANY);
1232 opendialog.setPatternList("GZipped State (*.xml.gz)\nXML State (*.xml)");
1233 if (gCurrentFolder.length() != 0) {
1234 opendialog.setDirectory(gCurrentFolder);
1235 }
1236 if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1237 return 1;
1238 }
1239
1240 const std::string file = MFXUtils::assureExtension(opendialog.getFilename(),
1241 opendialog.getPatternText(opendialog.getCurrentPattern()).after('.').before(')')).text();
1242 MSStateHandler::saveState(file, MSNet::getInstance()->getCurrentTimeStep(), false);
1243 setStatusBarText("Simulation saved to " + file);
1244 return 1;
1245}
1246
1247long
1248GUIApplicationWindow::onCmdLoadState(FXObject*, FXSelector, void*) {
1249 // get the new file name
1250 FXFileDialog opendialog(this, TL("Load Simulation State"));
1251 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_CONFIG));
1252 opendialog.setSelectMode(SELECTFILE_ANY);
1253 opendialog.setPatternList("GZipped State (*.xml.gz)\nXML State (*.xml)");
1254 if (gCurrentFolder.length() != 0) {
1255 opendialog.setDirectory(gCurrentFolder);
1256 }
1257 if (opendialog.execute() && FXStat::exists(opendialog.getFilename())) {
1258 gCurrentFolder = opendialog.getDirectory();
1259 const std::string file = opendialog.getFilename().text();
1260 try {
1262 setStatusBarText("Simulation loaded from '" + file + "'");
1263 } catch (ProcessError& e) {
1264 setStatusBarText("Failed to load state from '" + file + "' (" + e.what() + ")");
1265 }
1266 }
1267 return 1;
1268}
1269
1270
1271long
1272GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
1273 // toogle show time as HMS
1278 }
1279 return 1;
1280}
1281
1282
1283long
1284GUIApplicationWindow::onCmdDelayInc(FXObject*, FXSelector, void*) {
1285 if (mySimDelay < 10) {
1286 mySimDelay = 10;
1287 } else if (mySimDelay >= 20 && mySimDelay < 50) {
1288 mySimDelay = 50;
1289 } else if (mySimDelay >= 200 && mySimDelay < 500) {
1290 mySimDelay = 500;
1291 } else {
1292 mySimDelay *= 2;
1293 }
1294 if (mySimDelay > 1000) {
1295 // setting high delay by pressing the key too often is hard to recover from
1296 mySimDelay = 1000;
1297 }
1298 mySimDelaySlider->setValue((int)mySimDelay);
1299 mySimDelaySpinner->setValue(mySimDelay);
1300 return 1;
1301}
1302
1303
1304long
1305GUIApplicationWindow::onCmdDelayDec(FXObject*, FXSelector, void*) {
1306 if (mySimDelay <= 10) {
1307 mySimDelay = 0;
1308 } else if (mySimDelay > 20 && mySimDelay <= 50) {
1309 mySimDelay = 20;
1310 } else if (mySimDelay > 200 && mySimDelay <= 500) {
1311 mySimDelay = 200;
1312 } else {
1313 mySimDelay /= 2;
1314 }
1315 mySimDelaySlider->setValue((int)mySimDelay);
1316 mySimDelaySpinner->setValue(mySimDelay);
1317 return 1;
1318}
1319
1320
1321long
1322GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
1323 const double tmp = myAlternateSimDelay;
1325 mySimDelay = tmp;
1326 return 1;
1327}
1328
1329
1330long
1331GUIApplicationWindow::onCmdDemandScale(FXObject*, FXSelector, void*) {
1334 }
1335 return 1;
1336}
1337
1338
1339long
1340GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
1342 return 1;
1343}
1344
1345
1346long
1347GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
1348 sender->handle(this,
1350 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1351 ptr);
1354 }
1355 return 1;
1356}
1357
1358
1359long
1360GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
1361 sender->handle(this,
1363 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1364 ptr);
1367 }
1368 return 1;
1369}
1370
1371
1372long
1373GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
1374 sender->handle(this,
1376 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1377 ptr);
1378 return 1;
1379}
1380
1381
1382long
1383GUIApplicationWindow::onUpdNeedsSimulation(FXObject* sender, FXSelector, void* ptr) {
1384 bool disable = !myRunThread->simulationAvailable() || myAmLoading;
1385 sender->handle(this, disable ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1386 // mySelectLanesMenuCascade has to be disabled manually
1387 if (disable) {
1388 mySelectLanesMenuCascade->disable();
1389 } else {
1390 mySelectLanesMenuCascade->enable();
1391 }
1392 return 1;
1393}
1394
1395
1396long
1397GUIApplicationWindow::onUpdTraCIStatus(FXObject* /*sender*/, FXSelector, void* /*ptr*/) {
1399 myTraCiFrame->show();
1400 } else {
1401 myTraCiFrame->hide();
1402 }
1403 return 1;
1404}
1405
1406
1407long
1408GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1409 if (myMDIClient->numChildren() > 0) {
1410 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1411 if (w != nullptr) {
1412 w->onCmdLocate(nullptr, sel, nullptr);
1413 }
1414 }
1415 return 1;
1416}
1417
1418
1419long
1420GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1421 if (myMDIClient->numChildren() > 0) {
1422 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1424 }
1425 return 1;
1426}
1427
1428
1429long
1430GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1432 d->create();
1433 d->show(PLACEMENT_OWNER);
1434 return 1;
1435}
1436
1437
1438long
1439GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1440 if (myGLWindows.empty()) {
1441 return 1;
1442 }
1444 myGLWindows[0]->getView()->editVisualisationSettings()->gaming = myAmGaming;
1445 if (myAmGaming) {
1446 myGamingModeCheckbox->setCheck(TRUE);
1447 myMenuBar->hide();
1448 myStatusbar->hide();
1449 myToolBar1->hide();
1450 myToolBar2->hide();
1451 myToolBar4->hide();
1452 myToolBar5->hide();
1453 myToolBar6->show();
1454 myToolBar8->hide();
1455 myToolBar10->show();
1456 if (myTLSGame) {
1457 myToolBar7->show();
1458 } else {
1459 myToolBar9->show();
1460 }
1461 myMessageWindow->hide();
1467 } else {
1468 myGamingModeCheckbox->setCheck(FALSE);
1469 myMenuBar->show();
1470 myStatusbar->show();
1471 myToolBar1->show();
1472 myToolBar2->show();
1473 myToolBar4->show();
1474 myToolBar5->show();
1475 myToolBar6->hide();
1476 myToolBar7->hide();
1477 myToolBar8->show();
1478 myToolBar9->hide();
1479 myToolBar10->hide();
1480 myMessageWindow->show();
1482 }
1483 if (myMDIClient->numChildren() > 0) {
1484 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1485 if (w != nullptr) {
1487 }
1488 }
1489 update();
1490 return 1;
1491}
1492
1493
1494long
1496 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1497 if (w != nullptr) {
1498 // show or hide grid depending of myNetworkViewOptions.menuCheckToggleGrid
1501 } else {
1503 }
1504 w->getView()->update();
1505 }
1506 return 1;
1507}
1508
1509
1510long
1511GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1512 if (myGLWindows.empty()) {
1513 return 1;
1514 }
1516 if (myAmFullScreen) {
1517 getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1518 getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1519 getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1520 getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1521 maximize();
1522 setDecorations(DECOR_NONE);
1523 place(PLACEMENT_MAXIMIZED);
1524 myMenuBar->hide();
1525 myStatusbar->hide();
1526 myToolBar1->hide();
1527 myToolBar2->hide();
1528 myToolBar3->hide();
1529 myToolBar4->hide();
1530 myToolBar5->hide();
1531 myToolBar6->hide();
1532 myToolBar7->hide();
1533 myToolBar8->hide();
1534 myMessageWindow->hide();
1535 if (myMDIClient->numChildren() > 0) {
1536 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1537 if (w != nullptr) {
1538 w->setToolBarVisibility(false);
1539 }
1540 }
1541 update();
1542 } else {
1543 place(PLACEMENT_VISIBLE);
1544 setDecorations(DECOR_ALL);
1545 restore();
1546 myToolBar3->show();
1548 onCmdGaming(nullptr, 0, nullptr);
1549 setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1550 setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1551 setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1552 setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1553 }
1554 return 1;
1555}
1556
1557
1558long
1559GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1561 return 1;
1562}
1563
1564
1565long
1566GUIApplicationWindow::onCmdListParking(FXObject*, FXSelector, void*) {
1568 return 1;
1569}
1570
1571long
1572GUIApplicationWindow::onCmdListTeleporting(FXObject*, FXSelector, void*) {
1574 return 1;
1575}
1576
1577
1578long
1579GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1581 return 1;
1582}
1583
1584
1585#ifdef HAVE_OSG
1586long
1587GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1589 return 1;
1590}
1591#endif
1592
1593
1594long
1595GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1596 GUIDialog_AboutSUMO* about = new GUIDialog_AboutSUMO(this);
1597 about->create();
1598 about->show(PLACEMENT_OWNER);
1599 return 1;
1600}
1601
1602long
1603GUIApplicationWindow::onCmdHallOfFame(FXObject*, FXSelector, void*) {
1605 hall->create();
1606 hall->show(PLACEMENT_OWNER);
1607 return 1;
1608}
1609
1610
1611long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1612 FXEvent* event = (FXEvent*)ptr;
1613 FXString string = GUIUserIO::clipped.c_str();
1614 setDNDData(FROM_CLIPBOARD, event->target, string);
1615 return 1;
1616}
1617
1618
1619long
1620GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1621 eventOccurred();
1622 return 1;
1623}
1624
1625
1626long
1627GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1628 eventOccurred();
1629 return 1;
1630}
1631
1632
1633void
1635 while (!myEvents.empty()) {
1636 // get the next event
1637 GUIEvent* e = myEvents.top();
1638 myEvents.pop();
1639 // process
1640 switch (e->getOwnType()) {
1643 setFocus();
1644 break;
1646 if (myRunThread->simulationAvailable()) { // avoid race-condition related crash if reload was pressed
1648 }
1649 break;
1657 break;
1659 GUIEvent_AddView* ave = dynamic_cast<GUIEvent_AddView*>(e);
1661 if (ave->getSchemeName() != "") {
1662 FXComboBox* sCombo = v->getColoringSchemesCombo();
1663 int index = sCombo->findItem(ave->getSchemeName().c_str());
1664 if (index >= 0) {
1665 sCombo->setCurrentItem(index);
1666 }
1667 v->setColorScheme(ave->getSchemeName());
1668 }
1669 break;
1670 }
1672 GUIEvent_CloseView* ave = dynamic_cast<GUIEvent_CloseView*>(e);
1673 removeViewByID(ave->getCaption());
1674 break;
1675 }
1678 break;
1679 default:
1680 break;
1681 }
1682 delete e;
1683 }
1684 myToolBar2->forceRefresh();
1685 myToolBar3->forceRefresh();
1686}
1687
1688
1689void
1691 myAmLoading = false;
1693 // check whether the loading was successfull
1694 if (ec->myNet == nullptr) {
1695 // report failure
1696 setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1699 getApp()->exit(1);
1700 }
1701 } else {
1702 // initialise simulation thread
1703 if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1706 getApp()->exit(1);
1707 }
1708 } else {
1709 // report success
1710 setStatusBarText("'" + ec->myFile + "' loaded.");
1712 myWasStarted = false;
1714 // initialise views
1715 myViewNumber = 0;
1717 // check/record settings file modification time
1718 long long mTime = myGuiSettingsFileMTime;
1719 if (ec->mySettingsFiles.size() > 0) {
1720 for (std::string fname : ec->mySettingsFiles) {
1721 mTime = MAX2(mTime, SysUtils::getModifiedTime(fname));
1722 }
1723 }
1724 // always reload if settings were modified or to restore multiple views
1725 if (ec->mySettingsFiles.size() > 0 && (!myIsReload || myGuiSettingsFileMTime < mTime || ec->mySettingsFiles.size() > 1)) {
1727
1728 // open a view for each file and apply settings
1729 for (std::string fname : ec->mySettingsFiles) {
1730 GUISettingsHandler settings(fname);
1731 GUISUMOViewParent::ViewType vt = defaultType;
1732 if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1734 }
1735 if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1737 }
1738 GUISUMOAbstractView* view = openNewView(vt);
1739 if (view == nullptr) {
1740 break;
1741 }
1742 if (settings.getSettingName() != "") {
1743 view->setColorScheme(settings.getSettingName());
1744 FXComboBox* sCombo = view->getColoringSchemesCombo();
1745 int index = sCombo->findItem(settings.getSettingName().c_str());
1746 if (index >= 0) {
1747 sCombo->setCurrentItem(index);
1748 }
1749 }
1750 view->addDecals(settings.getDecals());
1751 settings.applyViewport(view);
1752 settings.setSnapshots(view);
1753 if (settings.getDelay() > 0.) {
1754 mySimDelay = settings.getDelay();
1755 }
1756 if (settings.getBreakpoints().size() > 0) {
1758 myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1759 myRunThread->getBreakpointLock().unlock();
1760 }
1761 myJamSounds = settings.getEventDistribution("jam");
1762 myCollisionSounds = settings.getEventDistribution("collision");
1763 if (settings.getJamSoundTime() > 0) {
1764 myJamSoundTime = settings.getJamSoundTime();
1765 }
1766 }
1767 } else {
1768 openNewView(defaultType);
1769 }
1770 myGuiSettingsFileMTime = mTime;
1771
1772 if (!OptionsCont::getOptions().isDefault("delay")) {
1773 setDelay(OptionsCont::getOptions().getFloat("delay"));
1774 mySimDelaySlider->setValue((int)mySimDelay);
1775 mySimDelaySpinner->setValue(mySimDelay);
1776 }
1777 if (!OptionsCont::getOptions().isDefault("breakpoints") && !myIsReload) {
1778 std::vector<SUMOTime> breakpoints;
1779 for (const std::string& val : OptionsCont::getOptions().getStringVector("breakpoints")) {
1780 SUMOTime t = string2time(val);
1781 // round down to nearest reachable time step
1782 t -= t % DELTA_T;
1783 breakpoints.push_back(t);
1784 }
1785 std::sort(breakpoints.begin(), breakpoints.end());
1787 myRunThread->getBreakpoints().assign(breakpoints.begin(), breakpoints.end());
1788 myRunThread->getBreakpointLock().unlock();
1789 }
1790 myTLSGame = OptionsCont::getOptions().getString("game.mode") == "tls";
1791 if (OptionsCont::getOptions().getBool("game")) {
1792 if (myTLSGame) {
1793 setTitle("SUMO Interactive Traffic Light");
1794 } else {
1795 setTitle("SUMO Interactive Demand-Responsive-Transport");
1796 }
1797 onCmdGaming(nullptr, 0, nullptr);
1798 } else {
1799 // set simulation name on the caption
1800 setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
1801 }
1802 if (ec->myViewportFromRegistry) {
1803 Position off;
1804 off.set(getApp()->reg().readRealEntry("viewport", "x"),
1805 getApp()->reg().readRealEntry("viewport", "y"),
1806 getApp()->reg().readRealEntry("viewport", "z"));
1807 Position p(off.x(), off.y(), 0);
1808 GUISUMOAbstractView* view = myGLWindows[0]->getView();
1809 view->setViewportFromToRot(off, p, 0);
1810 }
1811 // set simulation step begin information
1812 myLCDLabel->setText("----------------");
1813 for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
1814 (*it)->setText("-");
1815 }
1816 // initialize scale from options unless already set in the UI
1817 if (myDemandScaleSpinner->getValue() == 1 || !OptionsCont::getOptions().isDefault("scale")) {
1818 myDemandScaleSpinner->setValue(OptionsCont::getOptions().getFloat("scale"));
1819 }
1821 }
1822 }
1823 getApp()->endWaitCursor();
1824 // start if wished
1826 onCmdStart(nullptr, 0, nullptr);
1827 }
1828 update();
1829}
1830
1831
1832void
1834#ifdef WIN32
1835 long t = SysUtils::getCurrentMillis();
1836 // only skip if the simulation is running
1837 if (t - myLastStepEventMillis < MIN_DRAW_DELAY && myRunThread->simulationIsStopable()) {
1838 // do not try to redraw with more than 50FPS (#6371)
1839 return;
1840 }
1842#endif
1844 const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
1845 const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
1846 if (backlog > running) {
1847 if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE)) {
1849 }
1850 } else {
1851 if (myStatButtons.front()->getIcon() == GUIIconSubSys::getIcon(GUIIcon::YELLOWVEHICLE)) {
1853 }
1854 }
1855 myStatButtons.front()->setText(toString(running).c_str());
1856 if (myRunThread->getNet().hasPersons()) {
1857 if (!myStatButtons[1]->shown()) {
1858 myStatButtons[1]->show();
1859 }
1861 }
1862 if (myRunThread->getNet().hasContainers()) {
1863 if (!myStatButtons[2]->shown()) {
1864 myStatButtons[2]->show();
1865 }
1867 }
1868 if (myAmGaming) {
1869 if (myTLSGame) {
1871 } else {
1873 }
1874 }
1876 getApp()->forceRefresh(); // restores keyboard focus
1877 }
1879 update();
1880}
1881
1882
1883void
1885 GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1887 setStatusBarText(ec->getMsg());
1888 } else {
1890 }
1891}
1892
1893
1894void
1897 onCmdStop(nullptr, 0, nullptr);
1898 if (ec->getReason() == MSNet::SIMSTATE_LOADING) {
1899 onCmdReload(nullptr, 0, nullptr);
1900 } else if (GUIGlobals::gQuitOnEnd) {
1902 getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
1903 } else if (GUIGlobals::gDemoAutoReload) {
1904 onCmdReload(nullptr, 0, nullptr);
1905 } else if (!myHaveNotifiedAboutSimEnd) {
1906 // build the text
1907 const std::string text = "Simulation ended at time: " + time2string(ec->getTimeStep()) +
1908 ".\nReason: " + MSNet::getStateMessage(ec->getReason()) +
1909 "\nDo you want to close all open files and views?";
1910 FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, TL("Simulation ended"), "%s", text.c_str());
1911 if (answer == 1) { //1:yes, 2:no, 4:esc
1913 }
1915 }
1916}
1917
1918
1919void
1924#ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
1925 if (myJamSounds.getOverallProb() > 0) {
1926 // play honking sound if some vehicle is waiting too long
1927 for (; it != end; ++it) {
1928 // XXX use impatience instead of waiting time ?
1929 if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
1930 const std::string cmd = myJamSounds.get(&myGamingRNG);
1931 if (cmd != "") {
1932 // yay! fun with dangerous commands... Never use this over the internet
1934 // one sound per simulation step is enough
1935 break;
1936 }
1937 }
1938 }
1939 }
1942 if (myPreviousCollisionNumber != collisions) {
1943 const std::string cmd = myCollisionSounds.get(&myGamingRNG);
1944 if (cmd != "") {
1945 // yay! fun with dangerous commands... Never use this over the internet
1947 }
1948 myPreviousCollisionNumber = collisions;
1949 }
1950 }
1951#endif
1952
1953 // update performance indicators
1954 for (it = vc.loadedVehBegin(); it != end; ++it) {
1955 const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1956 assert(veh != 0);
1957 if (veh->isOnRoad() && !veh->isStopped()) {
1958 const double vmax = veh->getLane()->getVehicleMaxSpeed(veh);
1959 if (veh->getSpeed() < SUMO_const_haltingSpeed) {
1961 if (veh->getVClass() == SVC_EMERGENCY) {
1963 }
1964 }
1965 myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
1966 }
1967
1968 }
1972}
1973
1974void
1976 // update performance indicators
1980
1983 for (auto it = vc.loadedVehBegin(); it != end; ++it) {
1984 const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
1985 assert(veh != 0);
1986 if (veh->isOnRoad() && !veh->isStopped()) {
1988 }
1989 }
1991}
1992
1993void
1995 if (!myAmLoading) {
1997 getApp()->beginWaitCursor();
1998 myAmLoading = true;
1999 myIsReload = false;
2001 gSchemeStorage.saveViewport(0, 0, -1, 0); // recenter view
2003 setStatusBarText("Loading '" + file + "'.");
2004 update();
2005 }
2006}
2007
2008
2012 myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
2013 return nullptr;
2014 }
2015 GUISUMOAbstractView* oldView = nullptr;
2016 if (myMDIClient->numChildren() > 0) {
2017 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2018 if (w != nullptr) {
2019 oldView = w->getView();
2020 }
2021 }
2022 if (caption == "") {
2023 caption = "View #" + toString(myViewNumber++);
2024 }
2025 FXuint opts = MDI_TRACKING;
2026 GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
2027 this, GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI), opts, 10, 10, 200, 100);
2029 if (oldView != nullptr) {
2030 // copy viewport
2031 oldView->copyViewportTo(v);
2032 }
2033 w->create();
2034 if (myMDIClient->numChildren() == 1) {
2035 w->maximize();
2036 } else {
2037 myMDIClient->vertical(true);
2038 }
2039 myMDIClient->setActiveChild(w);
2040
2041 return v;
2042}
2043
2044
2045FXGLCanvas*
2047 if (myMDIClient->numChildren() == 0) {
2048 return nullptr;
2049 }
2050 GUISUMOViewParent* share_tmp1 =
2051 static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
2052 return share_tmp1->getBuildGLCanvas();
2053}
2054
2055
2056void
2058 myTrackerLock.lock();
2059 myLCDLabel->setText("----------------");
2060 for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
2061 (*it)->setText("-");
2062 if (it != myStatButtons.begin()) {
2063 (*it)->hide();
2064 }
2065 }
2066 // delete the simulation
2068 // reset the caption
2069 setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
2070 // remove trackers and other external windows (must be delayed until deleteSim)
2071 while (!myGLWindows.empty()) {
2072 delete myGLWindows.front();
2073 }
2074 // make a copy because deleting modifyes the vector;
2075 std::vector<FXMainWindow*> trackerWindows = myTrackerWindows;
2076 for (FXMainWindow* const window : trackerWindows) {
2077 delete window;
2078 }
2079 myTrackerWindows.clear();
2080 // clear selected items
2081 gSelected.clear();
2082 // add a separator to the log
2084 myTrackerLock.unlock();
2085 // remove coordinate information
2086 myGeoCoordinate->setText(TL("N/A"));
2087 myCartesianCoordinate->setText(TL("N/A"));
2088 if (myTestCoordinate) {
2089 myTestCoordinate->setText(TL("N/A"));
2090 }
2091 //
2094 update();
2095}
2096
2097
2098FXCursor*
2100 return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
2101}
2102
2103
2107}
2108
2109
2110double
2113}
2114
2115
2116void
2118 loadConfigOrNet("");
2119 if (wait) {
2120 while (myAmLoading) {
2121 myRunThread->sleep(50);
2122 }
2123 }
2124}
2125
2126
2127void
2129 myStatusbar->getStatusLine()->setText(text.c_str());
2130 myStatusbar->getStatusLine()->setNormalText(text.c_str());
2131}
2132
2133
2134void
2136 myRecentNetworksAndConfigs.appendFile(f);
2137}
2138
2139void
2141 if (myShowTimeAsHMS) {
2142 myLCDLabel->setToolTipText("HH:MM:SS");
2143 } else {
2144 myLCDLabel->setToolTipText("seconds");
2145 }
2146}
2147
2148void
2150 time -= DELTA_T; // synchronize displayed time with netstate output
2151 if (time < 0) {
2152 myLCDLabel->setText("----------------");
2153 return;
2154 }
2155 if (myAmGaming) {
2156 // show time counting backwards
2157 time = myRunThread->getSimEndTime() - time;
2158 }
2159 std::ostringstream str;
2160 str << std::setfill('0');
2161 const bool hideFraction = myAmGaming || DELTA_T % 1000 == 0;
2162 if (myShowTimeAsHMS) {
2163 SUMOTime day = time / 86400000;
2164 if (day > 0) {
2165 str << day << '-';
2166 time %= 86400000;
2167 }
2168 str << std::setw(2);
2169 str << time / 3600000 << '-';
2170 time %= 3600000;
2171 str << std::setw(2) << time / 60000 << '-';
2172 time %= 60000;
2173 }
2174 str << std::setw(2) << time / 1000;
2175 if (!hideFraction) {
2176 str << '.' << std::setw(3) << time % 1000;
2177 }
2178 myLCDLabel->setText(str.str().c_str());
2179}
2180
2181void
2183 if (press != nullptr) {
2184 myHotkeyPress[key] = press;
2185 }
2186 if (release != nullptr) {
2187 myHotkeyRelease[key] = release;
2188 }
2189}
2190
2191long
2192GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* ptr) {
2193 FXEvent* e = (FXEvent*) ptr;
2194 // PgUp and PgDown switch between widgets by default and binding them via menu shortcuts does not work reliably
2195 // so we must intercept them before FXMainWindow can handle it
2196 if (e->code == FX::KEY_Page_Up) {
2197 onCmdDelayInc(nullptr, 0, nullptr);
2198 } else if (e->code == FX::KEY_Page_Down) {
2199 onCmdDelayDec(nullptr, 0, nullptr);
2200 } else {
2201 // disable hotkeys without modifiers for the game
2202 const bool ignoreSimple = myAmGaming && (e->state & (CONTROLMASK | SHIFTMASK | ALTMASK)) == 0;
2203 const long handled = ignoreSimple ? 0 : FXMainWindow::onKeyPress(o, sel, ptr);
2204 if (handled == 0 && myMDIClient->numChildren() > 0) {
2205 auto it = myHotkeyPress.find(e->code);
2206 if (it != myHotkeyPress.end()) {
2207 it->second->execute(SIMSTEP);
2208 }
2209 if (!ignoreSimple) {
2210 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2211 if (w != nullptr) {
2212 w->onKeyPress(nullptr, sel, ptr);
2213 }
2214 }
2215 }
2216 }
2217 return 0;
2218}
2219
2220
2221long
2222GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* ptr) {
2223 const long handled = FXMainWindow::onKeyRelease(o, sel, ptr);
2224 if (handled == 0 && myMDIClient->numChildren() > 0) {
2225 FXEvent* e = (FXEvent*) ptr;
2226 auto it = myHotkeyRelease.find(e->code);
2227 if (it != myHotkeyRelease.end()) {
2228 it->second->execute(SIMSTEP);
2229 }
2230 GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2231 if (w != nullptr) {
2232 w->onKeyRelease(nullptr, sel, ptr);
2233 }
2234 }
2235 return 0;
2236}
2237
2238
2239void
2241 myEventMutex.lock();
2242 myEvents.push_back(event);
2244 //myEventCondition.wait(myEventMutex);
2245 myEventMutex.unlock();
2246}
2247
2248void
2249GUIApplicationWindow::setBreakpoints(const std::vector<SUMOTime>& breakpoints) {
2250 if (myRunThread != nullptr) {
2252 myRunThread->getBreakpoints().assign(breakpoints.begin(), breakpoints.end());
2253 myRunThread->getBreakpointLock().unlock();
2255 }
2256}
2257
2258const std::vector<SUMOTime>
2261 std::vector<SUMOTime> result = myRunThread->getBreakpoints();
2262 myRunThread->getBreakpointLock().unlock();
2263 return result;
2264}
2265
2266
2267/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:105
@ ID_RUNTHREAD_EVENT
The Simulation execution thread.
Definition: GUIAppEnum.h:308
@ MID_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:369
@ MID_LISTINTERNAL
Locator configuration - menu entry.
Definition: GUIAppEnum.h:330
@ MID_NEW_MICROVIEW
Open a new microscopic view.
Definition: GUIAppEnum.h:296
@ MID_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:357
@ MID_OPEN_CONFIG
Open configuration - ID.
Definition: GUIAppEnum.h:270
@ MID_HOTKEY_CTRL_W_CLOSESIMULATION
Close simulation - ID.
Definition: GUIAppEnum.h:117
@ MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS
Perform a single simulation step in SUMO and open Demand Elements in NETEDIT.
Definition: GUIAppEnum.h:85
@ MID_HOTKEY_F9_EDIT_VIEWSCHEME
open edit scheme menu
Definition: GUIAppEnum.h:205
@ MID_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:379
@ MID_HOTKEY_CTRL_J_TOGGLEDRAWJUNCTIONSHAPE
toggle draw junction shape
Definition: GUIAppEnum.h:95
@ MID_TRACI_STATUS
update traci status
Definition: GUIAppEnum.h:347
@ MID_HOTKEY_CTRL_SHIFT_S_SAVENETWORK_AS
save network as
Definition: GUIAppEnum.h:173
@ MID_CHANGELOG
changelog button
Definition: GUIAppEnum.h:643
@ MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS
Edit simulation breakpoints in SUMO and open Data Elements in NETEDIT.
Definition: GUIAppEnum.h:81
@ MID_HOTKEY_F1_ONLINEDOCUMENTATION
open online documentation
Definition: GUIAppEnum.h:189
@ MID_HOTKEY_CTRL_R_RELOAD
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:109
@ MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK
Stop the simulation in SUMO and save network in NETEDIT.
Definition: GUIAppEnum.h:107
@ MID_LOCATEADD
Locate additional structure - button.
Definition: GUIAppEnum.h:375
@ MID_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:377
@ MID_OPEN_NETWORK
Open network - ID.
Definition: GUIAppEnum.h:272
@ MID_SIMLOAD
(quick)-load state from file
Definition: GUIAppEnum.h:288
@ MID_DEMAND_SCALE
scale traffic
Definition: GUIAppEnum.h:397
@ MID_HOTKEY_CTRL_I_EDITVIEWPORT
Open viewport editor.
Definition: GUIAppEnum.h:91
@ MID_RECENTFILE
Loads a file previously loaded.
Definition: GUIAppEnum.h:278
@ MID_APPSETTINGS
Application settings - menu entry.
Definition: GUIAppEnum.h:328
@ MID_HOTKEY_CTRL_SHIFT_N_NEWWINDOW
Open a New Window.
Definition: GUIAppEnum.h:169
@ MID_HOTKEY_SHIFT_F11_HALLOFFAME
show the hall of fame dialog
Definition: GUIAppEnum.h:211
@ MID_NETEDIT
Open in netedit.
Definition: GUIAppEnum.h:320
@ MID_CLEARMESSAGEWINDOW
Clear simulation output.
Definition: GUIAppEnum.h:339
@ MID_OPEN_EDGEDATA
Load edge data for visualization.
Definition: GUIAppEnum.h:276
@ MID_HOTKEY_CTRL_F_FULSCREENMODE
Fullscreen mode - menu entry.
Definition: GUIAppEnum.h:93
@ MID_SIMSAVE
Save state to file.
Definition: GUIAppEnum.h:286
@ MID_TUTORIAL
tutorial button
Definition: GUIAppEnum.h:647
@ MID_LISTTELEPORTING
Definition: GUIAppEnum.h:332
@ MID_HOTKEY_CTRL_G_GAMINGMODE_TOGGLEGRID
Toggle Gaming mode in SUMO and grid in NETEDIT.
Definition: GUIAppEnum.h:87
@ MID_SHOWNETSTATS
Show network statistics.
Definition: GUIAppEnum.h:341
@ ID_LOADTHREAD_EVENT
The loading thread.
Definition: GUIAppEnum.h:306
@ MID_EDITCHOSEN
Open editor for selections.
Definition: GUIAppEnum.h:318
@ MID_SHOWPERSONSTATS
Show person statistics.
Definition: GUIAppEnum.h:345
@ MID_DELAY_TOGGLE
toggle delay between alternative value
Definition: GUIAppEnum.h:395
@ MID_HOTKEYS
hotkeys button
Definition: GUIAppEnum.h:645
@ MID_TIMELINK_BREAKPOINT
Set breakpionts from messages - Option.
Definition: GUIAppEnum.h:562
@ MID_HOTKEY_ALT_F4_CLOSE
Main window closes.
Definition: GUIAppEnum.h:151
@ MID_TIME_TOGGLE
toggle time display mode
Definition: GUIAppEnum.h:389
@ MID_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:359
@ MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALS
Start the simulation in SUMO and open Additionals Elements in NETEDIT.
Definition: GUIAppEnum.h:79
@ MID_DELAY_DEC
decrease sim delay
Definition: GUIAppEnum.h:393
@ MID_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:363
@ MID_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:373
@ MID_LISTPARKING
Definition: GUIAppEnum.h:331
@ MID_NEW_OSGVIEW
Open a new microscopic 3D view.
Definition: GUIAppEnum.h:298
@ MID_HOTKEY_F12_ABOUT
open about dialog
Definition: GUIAppEnum.h:213
@ MID_DELAY_INC
increase sim delay
Definition: GUIAppEnum.h:391
@ MID_HOTKEY_CTRL_QUICK_RELOAD
Quick-Reload the previously loaded simulation (keep the net)
Definition: GUIAppEnum.h:111
@ MID_SHOWVEHSTATS
Show vehicle statistics.
Definition: GUIAppEnum.h:343
@ MID_HOTKEY_CTRL_P
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:274
@ MID_WINDOW
Main window-ID.
Definition: GUIAppEnum.h:251
@ MID_LOCATECONTAINER
Locate container - button.
Definition: GUIAppEnum.h:371
FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[]
#define MIN_DRAW_DELAY
GUICompleteSchemeStorage gSchemeStorage
#define GUIDesignSlider
Definition: GUIDesigns.h:491
#define GUIDesignSpinDial
Definition: GUIDesigns.h:474
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
Definition: GUIDesigns.h:438
#define GUIDesignButtonStatusBarFixed
button rectangular with thick and raise frame with a width of 100
Definition: GUIDesigns.h:101
#define GUIDesignMDIButtonLeft
Definition: GUIDesigns.h:192
#define GUIDesignToolBarRaisedSameTop
design for first toolbar shell positioned in the same position of dock
Definition: GUIDesigns.h:444
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:115
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:344
#define GUIDesignToolBar
design for default toolbar
Definition: GUIDesigns.h:426
#define GUIDesignSplitter
Definition: GUIDesigns.h:463
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:466
#define GUIDesignToolbarMenuBar
Definition: GUIDesigns.h:420
#define GUIDesignToolBarRaisedNextTop
design for first toolbar shell positioned in the next-top position of dock
Definition: GUIDesigns.h:441
#define GUIDesignButtonToolbarText
Definition: GUIDesigns.h:112
#define GUIDesignMDIButtonRight
MDIButton oriented to right.
Definition: GUIDesigns.h:195
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:435
@ SIMULATION_ENDED
Send when the simulation is over;.
@ MESSAGE_OCCURRED
send when a message occured
@ GLDEBUG_OCCURRED
send when a gldebug occured
@ ERROR_OCCURRED
send when a error occured
@ SIMULATION_STEP
send when a simulation step has been performed
@ ADD_VIEW
Send when a new should be opened (via TraCI)
@ CLOSE_VIEW
Send when a view should be closed (via TraCI)
@ SIMULATION_LOADED
send when a simulation has been loaded
@ STATUS_OCCURRED
send when a status change occured
@ DEBUG_OCCURRED
send when a debug occured
@ WARNING_OCCURRED
send when a warning occured
GUISelectedStorage gSelected
A global holder of selected objects.
FXString gCurrentFolder
The folder used as last.
@ EDITVIEWPORT
@ CLEARMESSAGEWINDOW
@ NETEDIT_MINI
@ GREENVEHICLE
@ LOCATEVEHICLE
@ LOCATEPERSON
@ WINDOWS_TILE_VERT
@ GREENCONTAINER
@ WINDOWS_CASCADE
@ LOCATECONTAINER
@ LOCATEJUNCTION
@ APP_BREAKPOINTS
@ WINDOWS_TILE_HORI
@ YELLOWVEHICLE
@ KEY_SPACE
Definition: GUIShortcuts.h:97
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:267
#define TL(string)
Definition: MsgHandler.h:282
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define SPEED2DIST(x)
Definition: SUMOTime.h:44
#define SIMSTEP
Definition: SUMOTime.h:60
#define TS
Definition: SUMOTime.h:41
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_EMERGENCY
public emergency vehicles
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:58
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Base (microsim) event class.
Definition: Command.h:50
void setSelector(FXSelector sel)
set the selector
void setTarget(FXObject *tgt)
set the target
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:51
static void resetFont()
to be called when the font context is invalidated
Definition: GLHelper.cpp:600
The main window of the SUMO-gui.
long onCmdDelayInc(FXObject *, FXSelector, void *)
Called on "delay inc".
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
long onCmdShowStats(FXObject *, FXSelector, void *)
Called on commands from the statistic buttons.
FXToolBarShell * myToolBarDrag2
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
virtual void sendBlockingEvent(GUIEvent *event)
Sends an event from the application thread to the GUI and waits until it is handled.
GUIDialog_Breakpoints * myBreakpointDialog
FXEX::MFXThreadEvent myLoadThreadEvent
io-event with the load-thread
void handleEvent_Message(GUIEvent *e)
GUILoadThread * myLoadThread
the thread that loads simulations
void handleEvent_SimulationEnded(GUIEvent *e)
FXMenuCheck * myGamingModeCheckbox
menu checkbox to activate game mode
int myViewNumber
The current view number.
FXToolBarShell * myToolBarDrag4
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
long onUpdTraCIStatus(FXObject *, FXSelector, void *)
Determines whether traci is active.
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void handleEvent_SimulationLoaded(GUIEvent *e)
FXToolBarShell * myToolBarDrag9
FXRealSpinner * mySimDelaySpinner
long onCmdChangelog(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Changelog
void handleEvent_SimulationStep(GUIEvent *e)
bool myHaveNotifiedAboutSimEnd
whether the simulation end was already announced
void setStatusBarText(const std::string &text)
get status bar text (can be implemented in children)
FXToolBarShell * myToolBarDrag10
void addRecentFile(const FX::FXString &f)
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
virtual void setDelay(double delay)
Sets the delay of the parent application.
double myJamSoundTime
waiting time after which vehicles trigger jam sounds
FXRealSpinner * myDemandScaleSpinner
the demand scale
long onCmdTutorial(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Tutorial
MFXLCDLabel * myEmergencyVehicleLabel
FXToolBarShell * myToolBarDrag7
double mySimDelay
the simulation delay in milliseconds
SUMOTime getCurrentSimTime() const
get current sim time (must be implemented in all children)
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
Called on menu Edit->Visualization.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
MFXLCDLabel * myTotalDistanceLabel
MFXRecentNetworks myRecentNetworksAndConfigs
List of recent networks and configs.
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
long onCmdListTeleporting(FXObject *, FXSelector, void *)
Toggle listing of teleporting vehicles.
long onCmdNewWindow(FXObject *, FXSelector, void *)
Called on menu File->New Window.
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
FXMutex myEventMutex
the mutex for the waiting semaphore
FXMenuPane * mySelectByPermissions
double getTrackerInterval() const
get tracker interval (must be implemented in all children)
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
virtual void buildToolBars()
Builds the tool bar.
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
FXMenuPane * myFileMenu
the submenus
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
void loadConfigOrNet(const std::string &file)
FXToolBar * myToolBar1
The application tool bar.
bool myWasStarted
the information whether the simulation was started before
virtual void addToWindowsMenu(FXMenuPane *)
FXSplitter * myMainSplitter
The splitter that divides the main window into views and the log window.
long onCmdListParking(FXObject *, FXSelector, void *)
Toggle listing of parking vehicles.
void loadOnStartup(const bool wait=false)
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
bool myTLSGame
current game mode
FXEX::MFXThreadEvent myRunThreadEvent
io-event with the run-thread
void dependentBuild(const bool isLibsumo)
long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
GUIApplicationWindow(FXApp *a, const std::string &configPattern)
Constructor.
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
long onCmdOpenShapes(FXObject *, FXSelector, void *)
Called on menu File->Load Shapes.
FXToolBarShell * myMenuBarDrag
const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
FXToolBarShell * myToolBarDrag8
long onUpdStart(FXObject *sender, FXSelector, void *ptr)
Determines whether "play" is enabled.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL, std::string caption="")
FXGLCanvas * getBuildGLCanvas() const
get build GL Canvas (must be implemented in all children)
RandomDistributor< std::string > myJamSounds
long onCmdNewView(FXObject *, FXSelector, void *)
Called if a new view shall be opened (2D view)
GUIRunThread * myRunThread
the thread that runs simulations
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
long onCmdToggleDrawJunctionShape(FXObject *, FXSelector, void *)
Toggle draw junction shape.
long onCmdNetedit(FXObject *, FXSelector, void *)
Called on menu Edit->Netedit.
virtual void create()
Creates the main window (required by FOX)
std::map< int, Command * > myHotkeyPress
custom hotkeys
FXToolBarShell * myToolBarDrag5
MFXLCDLabel * myWaitingTimeLabel
performance indicators
long onCmdDemandScale(FXObject *, FXSelector, void *)
Called on "demand scale".
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
RandomDistributor< std::string > myCollisionSounds
FXMenuCascade * mySelectLanesMenuCascade
the menu cascades
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
std::string myConfigPattern
Input file pattern.
virtual void setBreakpoints(const std::vector< SUMOTime > &breakpoints)
Sets the breakpoints of the parent application.
long onCmdLoadState(FXObject *, FXSelector, void *)
Called on "save state".
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
virtual void detach()
Detaches the tool/menu bar.
long onCmdDelayDec(FXObject *, FXSelector, void *)
Called on "delay dec".
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
MFXSynchQue< GUIEvent * > myEvents
List of got requests.
bool myShowTimeAsHMS
whether to show time as hour:minute:second
double myAlternateSimDelay
The alternate simulation delay in milliseconds for toggling.
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
FXDataTarget * mySimDelayTarget
long onCmdSaveConfig(FXObject *, FXSelector, void *)
Called on menu File->Close.
void updateTimeLCD(SUMOTime time)
updates the simulation time display
long onCmdSaveState(FXObject *, FXSelector, void *)
Called on "save state".
std::map< int, Command * > myHotkeyRelease
FXToolBarShell * myToolBarDrag3
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
long onUpdNeedsSimulation(FXObject *, FXSelector, void *)
Determines whether some buttons which require an active simulation may be shown.
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
long onCmdHallOfFame(FXObject *, FXSelector, void *)
Shows the Hall of Fame dialog.
long onCmdLocate(FXObject *, FXSelector, void *)
Called on menu commands from the Locator menu.
FXToolBarShell * myToolBarDrag6
long long myGuiSettingsFileMTime
last modification time of the gui setting file
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onCmdOpenEdgeData(FXObject *, FXSelector, void *)
Called on menu File->Load EdgeData.
long onCmdEditViewport(FXObject *, FXSelector, void *)
Called on menu Edit->Viewport.
MFXLCDLabel * myLCDLabel
the simulation step display
FXMenuBar * myMenuBar
The application menu bar.
static std::mt19937 myGamingRNG
A random number generator used to choose a gaming sound.
long onCmdHotkeys(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Hotkeys
long myLastStepEventMillis
last time the simulation view was redrawn due to a simStep
virtual ~GUIApplicationWindow()
Destructor.
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
void addHotkey(int key, Command *press, Command *release)
register custom hotkey action
virtual void fillMenuBar()
Builds the menu bar.
bool myIsReload
whether we are reloading the simulation
std::vector< FXButton * > myStatButtons
Buttons showing and running values and triggering statistic windows.
void checkGamingEvents()
handles additional game-related events
long onCmdQuickReload(FXObject *, FXSelector, void *)
Called on quick-reload.
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
void clearDecals()
Clear the default decals.
void saveViewport(const double x, const double y, const double z, const double rot)
Makes the given viewport the default.
static void initCursors(FXApp *a)
Initiate GUICursorSubSys.
static FXMenuTitle * buildFXMenuTitle(FXComposite *p, const std::string &text, FXIcon *icon, FXMenuPane *menuPane)
build menu title
Definition: GUIDesigns.cpp:31
static FXMenuCommand * buildFXMenuCommandRecentFile(FXComposite *p, const std::string &text, FXObject *tgt, FXSelector sel)
build menu command (for recent files)
Definition: GUIDesigns.cpp:86
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static FXMenuCommand * buildFXMenuCommandShortcut(FXComposite *p, const std::string &text, const std::string &shortcut, const std::string &info, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:53
The application's "About" - dialog.
void create()
Creates the widget.
The dialog to change the application (gui) settings.
Editor for simulation breakpoints.
Editor for the list of chosen objects.
The SUMO User Conference "Hall of Fame" - dialog / easter egg.
void create()
Creates the widget.
const std::string & getCaption() const
bool in3D() const
const std::string & getSchemeName() const
const std::string & getCaption() const
const std::string & getMsg() const
Returns the message.
Event sent when the the simulation is over.
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
const SUMOTime myBegin
the time the simulation shall start with
const std::vector< std::string > mySettingsFiles
the name of the settings file to load
const bool myOsgView
whether to load the OpenSceneGraph view
const SUMOTime myEnd
the time the simulation shall end with
const bool myViewportFromRegistry
whether loading viewport from registry
const std::string myFile
the name of the loaded file
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:83
virtual void create()
create GUIGlChildWindow
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
virtual FXGLCanvas * getBuildGLCanvas() const
get build GL Canvas
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
static double gTrackerInterval
the aggregation period for tracker windows in seconds
Definition: GUIGlobals.h:51
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:42
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:45
static bool gDemoAutoReload
the simulation shall reload when it has ended (demo)
Definition: GUIGlobals.h:48
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
static void close()
close GUIIconSubSys
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:60
void loadConfigOrNet(const std::string &file)
begins the loading of the given file
const std::string & getFileName() const
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call
bool myListParking
information whether the locator should list parking vehicles
void removeViewByID(const std::string &id)
std::vector< FXMainWindow * > myTrackerWindows
list of tracker windows
bool myListTeleporting
information whether the locator should list teleporting vehicles
FXLabel * myCartesianCoordinate
Labels for the current cartesian, geo-coordinate and test coordinates.
std::map< std::string, std::string > myOnlineMaps
online mapping services for the context menu
MFXStaticToolTip * myStaticTooltipMenu
static toolTip used in menus
FXMDIClient * myMDIClient
The multi view panel.
FXHorizontalFrame * myTraCiFrame
frames for coordinates
bool listParking() const
return whether to list parking vehicles
FXHorizontalFrame * myGeoFrame
FXHorizontalFrame * myTestFrame
FXHorizontalFrame * myCartesianFrame
FXLabel * myTestCoordinate
FXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
FXDockSite * myTopDock
dock sites
bool myListInternal
information whether the locator should list internal structures
void storeWindowSizeAndPos()
record window position and size in registry
bool myAmFullScreen
FOX need this.
FXLabel * myGeoCoordinate
FXStatusBar * myStatusbar
The status bar.
void updateChildren(int msg=MID_SIMSTEP)
update childrens
FXGLVisual * myGLVisual
The gl-visual used.
bool myAmGaming
information whether the gui is currently in gaming mode
std::vector< GUIGlChildWindow * > myGLWindows
list of GLWindows
A logging window for the gui.
void addSeparator()
Adds a a separator to this log window.
void clear()
Clears the window.
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:127
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:437
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:538
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:136
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
GUINet & getNet() const
virtual void begin()
virtual bool simulationIsStartable() const
virtual bool simulationIsStepable() const
std::vector< SUMOTime > & getBreakpoints()
Definition: GUIRunThread.h:107
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
FXMutex & getBreakpointLock()
Definition: GUIRunThread.h:111
SUMOTime getSimEndTime() const
Definition: GUIRunThread.h:103
virtual bool simulationIsStopable() const
bool simulationAvailable() const
virtual void deleteSim()
void prepareDestruction()
void addDecals(const std::vector< Decal > &decals)
add decals
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
GUIPerspectiveChanger & getChanger() const
get changer
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
GUIVisualizationSettings * editVisualisationSettings() const
edit visualization settings (allow modify VisualizationSetings, use carefully)
virtual void copyViewportTo(GUISUMOAbstractView *view)
copy the viewport to the given view
FXComboBox * getColoringSchemesCombo()
get coloring schemes combo
virtual bool setColorScheme(const std::string &)
set color scheme
A single child window which contains a view of the simulation area.
ViewType
Available view types.
@ VIEW_3D_OSG
plain 3D OSG view (
@ VIEW_2D_OPENGL
plain 2D openGL view (
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
void setToolBarVisibility(const bool value)
about toggled gaming status
long onKeyPress(FXObject *o, FXSelector sel, void *data)
handle keys
void clear()
Clears the list of selected objects.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
An XML-handler for visualisation schemes.
double getDelay() const
Returns the parsed delay.
const std::string & getSettingName() const
RandomDistributor< std::string > getEventDistribution(const std::string &id)
const std::string & getViewType() const
Returns the parsed view type.
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
Storage for geometrical objects extended by mutexes.
static void buildSUMOAccelerators(GUIApplicationWindow *GUIApp)
build SUMO Accelerators
static void alterSUMOAccelerator(GUIApplicationWindow *GUIApp, GUIShortcut keysym, long)
static void clearTextures()
clears loaded textures
static std::string clipped
Definition: GUIUserIO.h:58
bool drawJunctionShape
whether the shape of the junction should be drawn
GUIColorer laneColorer
The lane colorer.
A widget which has the seven-segment display used as the drawing object for each letter in the label....
Definition: MFXLCDLabel.h:34
void setVertical(const FXint len)
set segment vertical length - must be more than twice the segment width
void setGroove(const FXint w)
set groove width - must be less than segment width
void setThickness(const FXint w)
set segment width - must be less than half the segment length
void setToolTipText(const FXString &text)
set tooltip text
void setText(FXString lbl)
manipulate text in LCD label
void setHorizontal(const FXint len)
set segment horizontal length - must be more than twice the segment width
void setFgColor(FXColor clr)
set forground color
static void sleep(long ms)
void pop()
Definition: MFXSynchQue.h:65
bool empty()
Definition: MFXSynchQue.h:128
void push_back(T what)
Definition: MFXSynchQue.h:114
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:112
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:60
static FXbool userPermitsOverwritingWhenFileExists(FXWindow *const parent, const FXString &file)
Returns true if either the file given by its name does not exist or the user allows overwriting it.
Definition: MFXUtils.cpp:39
static FXString assureExtension(const FXString &filename, const FXString &defaultExtension)
Corrects missing extension.
Definition: MFXUtils.cpp:69
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
bool isStopped() const
Returns whether the vehicle is at a stop.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:984
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:583
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:547
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
@ SIMSTATE_LOADING
The simulation is loading.
Definition: MSNet.h:95
@ SIMSTATE_ERROR_IN_SIM
An error occurred during the simulation step.
Definition: MSNet.h:105
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:850
SUMOTime loadState(const std::string &fileName)
load state from file and return new time
Definition: MSNet.cpp:1576
void quickReload()
reset state to the beginning without reloading the network
Definition: MSNet.cpp:1556
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:412
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:396
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:432
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:502
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:379
static void saveState(const std::string &file, SUMOTime step, bool usePrefix=true)
Saves the current state.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
int getWaitingForVehicleNumber() const
Returns the number of transportables waiting for a ride.
The class responsible for building and deletion of vehicles.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
void setScale(double scale)
sets the demand scaling factor
int getCollisionCount() const
return the number of collisions
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:599
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:577
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:486
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:55
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void writeConfiguration(std::ostream &os, const bool filled, const bool complete, const bool addComments, const std::string &relativeTo="", const bool forceRelative=false, const bool inComment=false) const
Writes the configuration.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
void set(double x, double y)
set positions x and y
Definition: Position.h:85
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
static const RGBColor GREEN
Definition: RGBColor.h:186
static const RGBColor RED
named colors
Definition: RGBColor.h:185
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
T get(SumoRNG *which=nullptr) const
Draw a sample of the distribution.
std::vector< std::string > getVector()
return vector of strings
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage
A few system-specific functions.
Definition: SysUtils.h:30
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
Definition: SysUtils.cpp:72
static long long getModifiedTime(const std::string &fname)
Definition: SysUtils.cpp:112
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:47
static TraCIServer * getInstance()
Definition: TraCIServer.h:68
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:137
@ SEL_THREAD_EVENT
Definition: fxexdefs.h:173
@ SEL_THREAD
Definition: fxexdefs.h:155