Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 : /****************************************************************************/
14 : /// @file GUIApplicationWindow.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @author Andreas Gaubatz
19 : /// @author Mirko Barthauer
20 : /// @date Sept 2002
21 : ///
22 : // The main window of the SUMO-gui.
23 : /****************************************************************************/
24 : #include <config.h>
25 :
26 : #ifdef HAVE_VERSION_H
27 : #include <version.h>
28 : #endif
29 :
30 : #include <fxkeys.h>
31 :
32 : #include <guisim/GUILane.h>
33 : #include <guisim/GUINet.h>
34 : #include <guisim/GUITrafficLightLogicWrapper.h>
35 : #include <microsim/MSEdgeControl.h>
36 : #include <microsim/MSInsertionControl.h>
37 : #include <microsim/MSStateHandler.h>
38 : #include <microsim/transportables/MSTransportableControl.h>
39 : #include <microsim/devices/MSRoutingEngine.h>
40 : #include <microsim/traffic_lights/MSTLLogicControl.h>
41 : #include <netload/NLHandler.h>
42 : #include <traci-server/TraCIServer.h>
43 : #include <utils/common/MsgHandler.h>
44 : #include <utils/common/StringUtils.h>
45 : #include <utils/foxtools/MFXButtonTooltip.h>
46 : #include <utils/foxtools/MFXCheckableButton.h>
47 : #include <utils/foxtools/MFXLabelTooltip.h>
48 : #include <utils/foxtools/MFXLCDLabel.h>
49 : #include <utils/foxtools/MFXLinkLabel.h>
50 : #include <utils/foxtools/MFXRealSpinner.h>
51 : #include <utils/foxtools/MFXStaticToolTip.h>
52 : #include <utils/gui/cursors/GUICursorSubSys.h>
53 : #include <utils/gui/div/GLHelper.h>
54 : #include <utils/gui/div/GUIDesigns.h>
55 : #include <utils/gui/div/GUIDialog_GLChosenEditor.h>
56 : #include <utils/gui/div/GUIGlobalSelection.h>
57 : #include <utils/gui/div/GUIMessageWindow.h>
58 : #include <utils/gui/div/GUIUserIO.h>
59 : #include <utils/gui/events/GUIEvent_AddView.h>
60 : #include <utils/gui/events/GUIEvent_CloseView.h>
61 : #include <utils/gui/events/GUIEvent_Message.h>
62 : #include <utils/gui/globjects/GUIShapeContainer.h>
63 : #include <utils/gui/images/GUITexturesHelper.h>
64 : #include <utils/gui/images/VClassIcons.h>
65 : #include <utils/gui/images/GUITextureSubSys.h>
66 : #include <utils/gui/settings/GUICompleteSchemeStorage.h>
67 : #include <utils/gui/settings/GUISettingsHandler.h>
68 : #include <utils/gui/shortcuts/GUIShortcutsSubSys.h>
69 : #include <utils/gui/windows/GUIPerspectiveChanger.h>
70 : #include <utils/xml/XMLSubSys.h>
71 :
72 : #include "GUIApplicationWindow.h"
73 : #include "GUIEvent_SimulationEnded.h"
74 : #include "GUIEvent_SimulationLoaded.h"
75 : #include "GUIGlobals.h"
76 : #include "GUILoadThread.h"
77 : #include "GUIRunThread.h"
78 : #include "dialogs/GUIDialog_AboutSUMO.h"
79 : #include "dialogs/GUIDialog_Feedback.h"
80 : #include "dialogs/GUIDialog_AppSettings.h"
81 : #include "dialogs/GUIDialog_Breakpoints.h"
82 : #include "dialogs/GUIDialog_HallOfFame.h"
83 :
84 :
85 : #define MIN_DRAW_DELAY 20
86 : //#define HAVE_DANGEROUS_SOUNDS
87 :
88 : #define STAT_VEHS 0
89 : #define STAT_DELAYED 1
90 : #define STAT_TELEPORTS 2
91 : #define STAT_PERSONS 3
92 : #define STAT_CONTAINERS 4
93 :
94 : // ===========================================================================
95 : // FOX-declarations
96 : // ===========================================================================
97 : FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
98 : // close
99 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_Q_CLOSE, GUIApplicationWindow::onCmdQuit),
100 : FXMAPFUNC(SEL_SIGNAL, MID_HOTKEY_CTRL_Q_CLOSE, GUIApplicationWindow::onCmdQuit),
101 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_ALT_F4_CLOSE, GUIApplicationWindow::onCmdQuit),
102 : FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GUIApplicationWindow::onCmdQuit),
103 : // toolbar
104 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_N_NEWWINDOW, GUIApplicationWindow::onCmdNewWindow),
105 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_O_OPENSIMULATION_OPENNETWORK, GUIApplicationWindow::onCmdOpenConfiguration),
106 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_N_OPENNETWORK_NEWNETWORK, GUIApplicationWindow::onCmdOpenNetwork),
107 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_P_OPENSHAPES, GUIApplicationWindow::onCmdOpenShapes),
108 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_U_OPENEDGEDATA, GUIApplicationWindow::onCmdOpenEdgeData),
109 : FXMAPFUNC(SEL_COMMAND, MID_RECENTFILE, GUIApplicationWindow::onCmdOpenRecent),
110 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_R_RELOAD, GUIApplicationWindow::onCmdReload),
111 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_QUICK_RELOAD, GUIApplicationWindow::onCmdQuickReload),
112 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_S_SAVESUMOCONFIG, GUIApplicationWindow::onCmdSaveConfig),
113 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_W_CLOSESIMULATION, GUIApplicationWindow::onCmdClose),
114 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_E_EDITSELECTION_LOADNETEDITCONFIG, GUIApplicationWindow::onCmdEditChosen),
115 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS, GUIApplicationWindow::onCmdEditBreakpoints),
116 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_F9_EDIT_VIEWSCHEME, GUIApplicationWindow::onCmdEditViewScheme),
117 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_I_EDITVIEWPORT, GUIApplicationWindow::onCmdEditViewport),
118 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_T_OPENNETEDIT_OPENSUMO, GUIApplicationWindow::onCmdOpenInNetedit),
119 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_T_OPEN_NET, GUIApplicationWindow::onCmdOpenInNetedit),
120 : // gaming
121 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_H_APPSETTINGS_OPENEDGETYPES, GUIApplicationWindow::onCmdAppSettings),
122 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_G_GAMINGMODE_TOGGLEGRID, GUIApplicationWindow::onCmdGaming),
123 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_J_TOGGLEDRAWJUNCTIONSHAPE, GUIApplicationWindow::onCmdToggleDrawJunctionShape),
124 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_K_OPENTLSPROGRAMS, GUIApplicationWindow::onCmdToggleSecondaryShape),
125 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_F_FULSCREENMODE, GUIApplicationWindow::onCmdFullScreen),
126 : FXMAPFUNC(SEL_COMMAND, MID_LISTINTERNAL, GUIApplicationWindow::onCmdListInternal),
127 : FXMAPFUNC(SEL_COMMAND, MID_LISTPARKING, GUIApplicationWindow::onCmdListParking),
128 : FXMAPFUNC(SEL_COMMAND, MID_LISTTELEPORTING, GUIApplicationWindow::onCmdListTeleporting),
129 : FXMAPFUNC(SEL_COMMAND, MID_NEW_MICROVIEW, GUIApplicationWindow::onCmdNewView),
130 : // OSG
131 : #ifdef HAVE_OSG
132 : FXMAPFUNC(SEL_COMMAND, MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
133 : FXMAPFUNC(SEL_UPDATE, MID_NEW_OSGVIEW, GUIApplicationWindow::onUpdAddView),
134 :
135 : #endif
136 : FXMAPFUNC(SEL_COMMAND, MID_SHOWTOOLTIPS_VIEW, GUIApplicationWindow::onCmdShowToolTipsView),
137 : FXMAPFUNC(SEL_COMMAND, MID_SHOWTOOLTIPS_MENU, GUIApplicationWindow::onCmdShowToolTipsMenu),
138 : // Time
139 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_A_MODE_STARTSIMULATION_ADDITIONALS_STOPS, GUIApplicationWindow::onCmdStart),
140 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS, GUIApplicationWindow::onCmdStart),
141 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_S_MODE_STOPSIMULATION_SELECT, GUIApplicationWindow::onCmdStop),
142 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK, GUIApplicationWindow::onCmdStop),
143 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_D_MODE_SINGLESIMULATIONSTEP_DELETE, GUIApplicationWindow::onCmdStep),
144 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS, GUIApplicationWindow::onCmdStep),
145 : FXMAPFUNC(SEL_COMMAND, MID_DELAY_INC, GUIApplicationWindow::onCmdDelayInc),
146 : FXMAPFUNC(SEL_COMMAND, MID_DELAY_DEC, GUIApplicationWindow::onCmdDelayDec),
147 : FXMAPFUNC(SEL_COMMAND, MID_SIMSAVE, GUIApplicationWindow::onCmdSaveState),
148 : FXMAPFUNC(SEL_COMMAND, MID_SIMLOAD, GUIApplicationWindow::onCmdLoadState),
149 : FXMAPFUNC(SEL_COMMAND, MID_TIME_TOGGLE, GUIApplicationWindow::onCmdTimeToggle),
150 : FXMAPFUNC(SEL_COMMAND, MID_DELAY_TOGGLE, GUIApplicationWindow::onCmdDelayToggle),
151 : FXMAPFUNC(SEL_COMMAND, MID_DEMAND_SCALE, GUIApplicationWindow::onCmdDemandScale),
152 : FXMAPFUNC(SEL_COMMAND, MID_CLEARMESSAGEWINDOW, GUIApplicationWindow::onCmdClearMsgWindow),
153 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_B_BREAKPOINT, GUIApplicationWindow::onCmdBreakpoint),
154 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY, GUIApplicationWindow::onCmdBreakpointEarly),
155 : // Stats
156 : FXMAPFUNC(SEL_COMMAND, MID_SHOWNETSTATS, GUIApplicationWindow::onCmdShowStats),
157 : FXMAPFUNC(SEL_COMMAND, MID_SHOWVEHSTATS, GUIApplicationWindow::onCmdShowStats),
158 : FXMAPFUNC(SEL_COMMAND, MID_SHOWPERSONSTATS, GUIApplicationWindow::onCmdShowStats),
159 : // these functions do not assign shortcut keys to commands, but rather affect the button enable status upon other events (e.g. simulation loaded)
160 : // since those events are invoked through pseudo key events (?), the same key shortcuts as in cmd must be supplied as well
161 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_O_OPENSIMULATION_OPENNETWORK, GUIApplicationWindow::onUpdOpen),
162 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_N_OPENNETWORK_NEWNETWORK, GUIApplicationWindow::onUpdOpen),
163 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_P_OPENSHAPES, GUIApplicationWindow::onUpdNeedsNetwork),
164 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_U_OPENEDGEDATA, GUIApplicationWindow::onUpdNeedsNetwork),
165 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_R_RELOAD, GUIApplicationWindow::onUpdReload),
166 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_QUICK_RELOAD, GUIApplicationWindow::onUpdReload),
167 : FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GUIApplicationWindow::onUpdOpenRecent),
168 : FXMAPFUNC(SEL_UPDATE, MID_NEW_MICROVIEW, GUIApplicationWindow::onUpdAddView),
169 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS, GUIApplicationWindow::onUpdStart),
170 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK, GUIApplicationWindow::onUpdStop),
171 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS, GUIApplicationWindow::onUpdStep),
172 : FXMAPFUNC(SEL_UPDATE, MID_SIMSAVE, GUIApplicationWindow::onUpdNeedsNetwork),
173 : FXMAPFUNC(SEL_UPDATE, MID_SIMLOAD, GUIApplicationWindow::onUpdNeedsNetwork),
174 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_E_EDITSELECTION_LOADNETEDITCONFIG, GUIApplicationWindow::onUpdNeedsNetwork),
175 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS, GUIApplicationWindow::onUpdNeedsNetwork),
176 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_B_BREAKPOINT, GUIApplicationWindow::onUpdNeedsNetwork),
177 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY, GUIApplicationWindow::onUpdNeedsNetwork),
178 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_F9_EDIT_VIEWSCHEME, GUIApplicationWindow::onUpdNeedsNetwork),
179 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_I_EDITVIEWPORT, GUIApplicationWindow::onUpdNeedsNetwork),
180 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_T_OPENNETEDIT_OPENSUMO, GUIApplicationWindow::onUpdNeedsNetwork),
181 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_SHIFT_T_OPEN_NET, GUIApplicationWindow::onUpdNeedsNetwork),
182 : FXMAPFUNC(SEL_UPDATE, MID_TOOLBAREDIT_LOADADDITIONALS, GUIApplicationWindow::onUpdNeedsSumoConfig),
183 : FXMAPFUNC(SEL_UPDATE, MID_TOOLBAREDIT_LOADDEMAND, GUIApplicationWindow::onUpdNeedsSumoConfig),
184 : FXMAPFUNC(SEL_UPDATE, MID_DEMAND_SCALE, GUIApplicationWindow::onUpdNeedsNetwork),
185 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_G_GAMINGMODE_TOGGLEGRID, GUIApplicationWindow::onUpdNeedsNetwork),
186 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_CTRL_F_FULSCREENMODE, GUIApplicationWindow::onUpdNeedsNetwork),
187 : FXMAPFUNC(SEL_UPDATE, MID_TRACI_STATUS, GUIApplicationWindow::onUpdTraCIStatus),
188 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_F1_ONLINEDOCUMENTATION, GUIApplicationWindow::onCmdHelp),
189 : FXMAPFUNC(SEL_COMMAND, MID_CHANGELOG, GUIApplicationWindow::onCmdChangelog),
190 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEYS, GUIApplicationWindow::onCmdHotkeys),
191 : FXMAPFUNC(SEL_COMMAND, MID_TUTORIAL, GUIApplicationWindow::onCmdTutorial),
192 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_F11_HALLOFFAME, GUIApplicationWindow::onCmdHallOfFame),
193 : FXMAPFUNC(SEL_COMMAND, MID_FEEDBACK, GUIApplicationWindow::onCmdFeedback),
194 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_F12_ABOUT, GUIApplicationWindow::onCmdAbout),
195 : // forward requests to the active view
196 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_J_LOCATEJUNCTION, GUIApplicationWindow::onCmdLocate),
197 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_E_LOCATEEDGE, GUIApplicationWindow::onCmdLocate),
198 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_V_LOCATEVEHICLE, GUIApplicationWindow::onCmdLocate),
199 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_P_LOCATEPERSON, GUIApplicationWindow::onCmdLocate),
200 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_C_LOCATECONTAINER, GUIApplicationWindow::onCmdLocate),
201 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_T_LOCATETLS, GUIApplicationWindow::onCmdLocate),
202 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL, GUIApplicationWindow::onCmdLocate),
203 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_O_LOCATEPOI, GUIApplicationWindow::onCmdLocate),
204 : FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_L_LOCATEPOLY, GUIApplicationWindow::onCmdLocate),
205 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_J_LOCATEJUNCTION, GUIApplicationWindow::onUpdNeedsNetwork),
206 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_E_LOCATEEDGE, GUIApplicationWindow::onUpdNeedsNetwork),
207 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_V_LOCATEVEHICLE, GUIApplicationWindow::onUpdNeedsNetwork),
208 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_P_LOCATEPERSON, GUIApplicationWindow::onUpdNeedsNetwork),
209 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_C_LOCATECONTAINER, GUIApplicationWindow::onUpdNeedsNetwork),
210 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_T_LOCATETLS, GUIApplicationWindow::onUpdNeedsNetwork),
211 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL, GUIApplicationWindow::onUpdNeedsNetwork),
212 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_O_LOCATEPOI, GUIApplicationWindow::onUpdNeedsNetwork),
213 : FXMAPFUNC(SEL_UPDATE, MID_HOTKEY_SHIFT_L_LOCATEPOLY, GUIApplicationWindow::onUpdNeedsNetwork),
214 : // languages
215 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_EN, GUIApplicationWindow::onCmdChangeLanguage),
216 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_EN, GUIApplicationWindow::onUpdChangeLanguage),
217 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_DE, GUIApplicationWindow::onCmdChangeLanguage),
218 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_DE, GUIApplicationWindow::onUpdChangeLanguage),
219 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_ES, GUIApplicationWindow::onCmdChangeLanguage),
220 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_ES, GUIApplicationWindow::onUpdChangeLanguage),
221 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_FR, GUIApplicationWindow::onCmdChangeLanguage),
222 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_FR, GUIApplicationWindow::onUpdChangeLanguage),
223 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_IT, GUIApplicationWindow::onCmdChangeLanguage),
224 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_IT, GUIApplicationWindow::onUpdChangeLanguage),
225 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_ZH, GUIApplicationWindow::onCmdChangeLanguage),
226 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_ZH, GUIApplicationWindow::onUpdChangeLanguage),
227 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_ZHT, GUIApplicationWindow::onCmdChangeLanguage),
228 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_ZHT, GUIApplicationWindow::onUpdChangeLanguage),
229 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_TR, GUIApplicationWindow::onCmdChangeLanguage),
230 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_TR, GUIApplicationWindow::onUpdChangeLanguage),
231 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_JA, GUIApplicationWindow::onCmdChangeLanguage),
232 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_JA, GUIApplicationWindow::onUpdChangeLanguage),
233 : FXMAPFUNC(SEL_COMMAND, MID_LANGUAGE_KO, GUIApplicationWindow::onCmdChangeLanguage),
234 : FXMAPFUNC(SEL_UPDATE, MID_LANGUAGE_KO, GUIApplicationWindow::onUpdChangeLanguage),
235 : // coordinate inputs
236 : FXMAPFUNC(SEL_COMMAND, MID_GEO_COORDINATE, GUIApplicationWindow::onCmdSetGeoCoordinate),
237 : FXMAPFUNC(SEL_COMMAND, MID_CARTESIAN_COORDINATE, GUIApplicationWindow::onCmdSetCartesianCoordinate),
238 : FXMAPFUNC(SEL_FOCUSIN, MID_GEO_COORDINATE, GUIApplicationWindow::onCmdFocusCoordinate),
239 : FXMAPFUNC(SEL_FOCUSIN, MID_CARTESIAN_COORDINATE, GUIApplicationWindow::onCmdFocusCoordinate),
240 : FXMAPFUNC(SEL_FOCUSOUT, MID_GEO_COORDINATE, GUIApplicationWindow::onCmdUnfocusCoordinate),
241 : FXMAPFUNC(SEL_FOCUSOUT, MID_CARTESIAN_COORDINATE, GUIApplicationWindow::onCmdUnfocusCoordinate),
242 : // keys
243 : FXMAPFUNC(SEL_KEYPRESS, 0, GUIApplicationWindow::onKeyPress),
244 : FXMAPFUNC(SEL_KEYRELEASE, 0, GUIApplicationWindow::onKeyRelease),
245 : // clipboard
246 : FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GUIApplicationWindow::onClipboardRequest),
247 : // events
248 : FXMAPFUNC(FXEX::SEL_THREAD_EVENT, ID_LOADTHREAD_EVENT, GUIApplicationWindow::onLoadThreadEvent),
249 : FXMAPFUNC(FXEX::SEL_THREAD_EVENT, ID_RUNTHREAD_EVENT, GUIApplicationWindow::onRunThreadEvent),
250 : FXMAPFUNC(FXEX::SEL_THREAD, ID_LOADTHREAD_EVENT, GUIApplicationWindow::onLoadThreadEvent),
251 : FXMAPFUNC(FXEX::SEL_THREAD, ID_RUNTHREAD_EVENT, GUIApplicationWindow::onRunThreadEvent),
252 : };
253 :
254 : // Object implementation
255 121124993 : FXIMPLEMENT(GUIApplicationWindow, FXMainWindow, GUIApplicationWindowMap, ARRAYNUMBER(GUIApplicationWindowMap))
256 :
257 : // ===========================================================================
258 : // static members
259 : // ===========================================================================
260 : std::mt19937 GUIApplicationWindow::myGamingRNG;
261 :
262 :
263 : // ===========================================================================
264 : // member method definitions
265 : // ===========================================================================
266 : #ifdef _MSC_VER
267 : #pragma warning(push)
268 : #pragma warning(disable: 4355) // mask warning about "this" in initializers
269 : #endif
270 9020 : GUIApplicationWindow::GUIApplicationWindow(FXApp* a) :
271 : GUIMainWindow(a),
272 9020 : myFileMenuRecentNetworks(new FXMenuPane(this)),
273 9020 : myFileMenuRecentConfigs(new FXMenuPane(this)),
274 9020 : myRecentNetworks(a, "networks"),
275 9020 : myRecentConfigs(a, "configs"),
276 27060 : myLastStepEventMillis(SysUtils::getCurrentMillis() - MIN_DRAW_DELAY) {
277 : // init icons
278 9020 : GUIIconSubSys::initIcons(a);
279 : // init Textures
280 9020 : GUITextureSubSys::initTextures(a);
281 : // init cursors
282 9020 : GUICursorSubSys::initCursors(a);
283 : // disable tooltips
284 9020 : a->setTooltipTime(1000000000);
285 9020 : a->setTooltipPause(1000000000);
286 9020 : }
287 : #ifdef _MSC_VER
288 : #pragma warning(pop)
289 : #endif
290 :
291 :
292 : GUIRunThread*
293 101291 : GUIApplicationWindow::getRunner() {
294 101291 : return myRunThread;
295 : }
296 :
297 :
298 : void
299 9020 : GUIApplicationWindow::dependentBuild(const bool isLibsumo) {
300 : // don't do this twice
301 9020 : if (hadDependentBuild) {
302 : return;
303 : }
304 9020 : hadDependentBuild = true;
305 9020 : setTarget(this);
306 : setSelector(MID_WINDOW);
307 : // build menu bar
308 9020 : myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBar);
309 9020 : myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignToolbarMenuBar);
310 9020 : new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
311 9020 : buildToolBars();
312 : // build the thread - io
313 : myLoadThreadEvent.setTarget(this);
314 : myLoadThreadEvent.setSelector(ID_LOADTHREAD_EVENT);
315 : myRunThreadEvent.setTarget(this);
316 : myRunThreadEvent.setSelector(ID_RUNTHREAD_EVENT);
317 : // build the status bar
318 9020 : myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
319 : {
320 : // build TraCi info
321 9020 : myTraCiFrame = new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
322 18040 : auto button = GUIDesigns::buildFXButton(myTraCiFrame, "TraCI", "", "", nullptr, this, MID_TRACI_STATUS, GUIDesignButtonStatusBarFixed);
323 9020 : button->setBackColor(FXRGBA(253, 255, 206, 255));
324 9020 : if (TraCIServer::getInstance() == nullptr) {
325 9020 : myTraCiFrame->hide();
326 : }
327 : // build geo coordiantes
328 9020 : myGeoFrame = new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
329 9020 : myGeoCoordinate = new FXTextField(myGeoFrame, 26, this, MID_GEO_COORDINATE, FRAME_NONE | LAYOUT_CENTER_Y | TEXTFIELD_ENTER_ONLY, 0, 0, 0, GUIDesignHeight, 2, 2, 1, 1);
330 18040 : myGeoCoordinate->setHelpText(TL("Original coordinate (before coordinate transformation in netconvert). Enter 'lat, lon' or 'lat:... lon:...' to center view"));
331 18040 : myGeoCoordinate->setTipText(TL("Enter 'lat, lon' to center view"));
332 9020 : myGeoCoordinate->setBackColor(myGeoFrame->getBackColor());
333 9020 : myGeoCoordinate->setText(TL("N/A"));
334 9020 : myGeoCoordinate->disable();
335 9020 : myGeoCoordinate->setEditable(false);
336 : // build cartesian coordinates
337 9020 : myCartesianFrame = new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
338 9020 : myCartesianCoordinate = new FXTextField(myCartesianFrame, 22, this, MID_CARTESIAN_COORDINATE, FRAME_NONE | LAYOUT_CENTER_Y | TEXTFIELD_ENTER_ONLY, 0, 0, 0, GUIDesignHeight, 2, 2, 1, 1);
339 18040 : myCartesianCoordinate->setHelpText(TL("Network coordinate. Enter 'x, y' to center view"));
340 18040 : myCartesianCoordinate->setTipText(TL("Enter 'x, y' to center view"));
341 9020 : myCartesianCoordinate->setBackColor(myCartesianFrame->getBackColor());
342 9020 : myCartesianCoordinate->setText(TL("N/A"));
343 : // build buttons
344 : std::vector<std::string> help({
345 9020 : TL("number of running vehicles"),
346 9020 : TL("number of insertion backlogged vehicles"),
347 9020 : TL("percentage of teleports per departed vehicles"),
348 9020 : TL("number of active persons"),
349 54120 : TL("number of active containers")});
350 :
351 9020 : myStatButtons.push_back(GUIDesigns::buildFXButton(myStatusbar, "-", help[STAT_VEHS], help[STAT_VEHS], GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE), this, MID_SHOWVEHSTATS));
352 18040 : myStatButtons.push_back(GUIDesigns::buildFXButton(myStatusbar, "-", help[STAT_DELAYED], help[STAT_DELAYED], GUIIconSubSys::getIcon(GUIIcon::INSERTION_DELAY), this, MID_SHOWVEHSTATS));
353 9020 : myStatButtons.back()->hide();
354 18040 : myStatButtons.push_back(GUIDesigns::buildFXButton(myStatusbar, "-", help[STAT_TELEPORTS], help[STAT_TELEPORTS], GUIIconSubSys::getIcon(GUIIcon::TELEPORT), this, MID_SHOWVEHSTATS));
355 9020 : myStatButtons.back()->hide();
356 18040 : myStatButtons.push_back(GUIDesigns::buildFXButton(myStatusbar, "-", help[STAT_PERSONS], help[STAT_PERSONS], GUIIconSubSys::getIcon(GUIIcon::GREENPERSON), this, MID_SHOWPERSONSTATS));
357 9020 : myStatButtons.back()->hide();
358 18040 : myStatButtons.push_back(GUIDesigns::buildFXButton(myStatusbar, "-", help[STAT_CONTAINERS], help[STAT_CONTAINERS], GUIIconSubSys::getIcon(GUIIcon::GREENCONTAINER), this, MID_SHOWVEHSTATS));
359 9020 : myStatButtons.back()->hide();
360 9020 : }
361 : // make the window a mdi-window
362 9020 : myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
363 9020 : myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
364 9020 : myMDIMenu = new FXMDIMenu(this, myMDIClient);
365 9020 : new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
366 9020 : new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
367 9020 : new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
368 9020 : new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
369 : // build the message window
370 9020 : myMessageWindow = new GUIMessageWindow(myMainSplitter, this);
371 : // fill menu and tool bar
372 9020 : fillMenuBar();
373 9020 : myToolBar6->hide();
374 9020 : myToolBar7->hide();
375 9020 : myToolBar9->hide();
376 9020 : myToolBar10->hide();
377 : // build additional threads
378 9020 : myLoadThread = new GUILoadThread(getApp(), this, myEvents, myLoadThreadEvent, isLibsumo);
379 9020 : myRunThread = new GUIRunThread(getApp(), this, mySimDelay, myEvents, myRunThreadEvent);
380 : // set the status bar
381 9020 : setStatusBarText(TL("Ready."));
382 : // set the caption
383 9020 : setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
384 : // start the simulation-thread (it will loop until the application ends deciding by itself whether to perform a step or not)
385 9020 : myRunThread->start();
386 9020 : setIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO));
387 9020 : setMiniIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI));
388 18040 : }
389 :
390 :
391 : void
392 9020 : GUIApplicationWindow::create() {
393 9020 : setWindowSizeAndPos();
394 9020 : gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
395 9020 : FXMainWindow::create();
396 9020 : myMenuBarDrag->create();
397 9020 : myToolBarDrag1->create();
398 9020 : myToolBarDrag2->create();
399 9020 : myToolBarDrag3->create();
400 9020 : myToolBarDrag4->create();
401 9020 : myToolBarDrag5->create();
402 9020 : myToolBarDrag6->create();
403 9020 : myToolBarDrag7->create();
404 9020 : myFileMenu->create();
405 9020 : mySelectByPermissions->create();
406 9020 : myEditMenu->create();
407 9020 : mySettingsMenu->create();
408 9020 : myLocatorMenu->create();
409 9020 : myControlMenu->create();
410 9020 : myWindowMenu->create();
411 9020 : myLanguageMenu->create();
412 9020 : myHelpMenu->create();
413 9020 : FXint textWidth = getApp()->getNormalFont()->getTextWidth("8", 1) * 24;
414 9020 : myCartesianFrame->setWidth(textWidth);
415 9020 : myGeoFrame->setWidth(textWidth);
416 9020 : if (myTestFrame) {
417 0 : myTestFrame->setWidth(textWidth);
418 : }
419 :
420 9020 : show(PLACEMENT_DEFAULT);
421 18040 : if (!OptionsCont::getOptions().isSet("window-size")) {
422 9016 : if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
423 0 : maximize();
424 : }
425 : }
426 9020 : myShowTimeAsHMS = (getApp()->reg().readIntEntry("gui", "timeasHMS", 0) == 1);
427 9020 : myAlternateSimDelay = getApp()->reg().readIntEntry("gui", "alternateSimDelay", 100);
428 9020 : const std::string& onlineMaps = getApp()->reg().readStringEntry("gui", "onlineMaps", "");
429 27060 : for (const std::string& entry : StringTokenizer(onlineMaps, "\n").getVector()) {
430 0 : const std::vector<std::string> split = StringTokenizer(entry, "\t").getVector();
431 0 : if (split.size() == 2) {
432 0 : myOnlineMaps[split[0]] = split[1];
433 : }
434 9020 : }
435 9020 : if (myOnlineMaps.empty()) {
436 9020 : myOnlineMaps["GeoHack"] = "https://geohack.toolforge.org/geohack.php?params=%lat;%lon_scale:1000";
437 9020 : myOnlineMaps["Google Maps"] = "https://www.google.com/maps/search/?api=1&query=%lat,%lon&zoom=19";
438 18040 : myOnlineMaps["OSM"] = "https://www.openstreetmap.org/?mlat=%lat&mlon=%lon&zoom=18&layers=M";
439 : }
440 9020 : updateTimeLCDTooltip();
441 9020 : }
442 :
443 :
444 17988 : GUIApplicationWindow::~GUIApplicationWindow() {
445 8994 : myRunThread->prepareDestruction();
446 8994 : myRunThread->join();
447 8993 : closeAllWindows();
448 : // close icons
449 8993 : GUIIconSubSys::close();
450 8993 : GUICursorSubSys::close();
451 : // delete visual
452 8993 : delete myGLVisual;
453 : // delete some non-parented windows
454 8993 : delete myToolBarDrag1;
455 8993 : delete mySimDelayTarget;
456 : // delete rest of elements
457 8993 : delete myFileMenuRecentNetworks;
458 8993 : delete myFileMenuRecentConfigs;
459 8993 : delete myRunThread;
460 8993 : delete myFileMenu;
461 8993 : delete myEditMenu;
462 8993 : delete mySelectByPermissions;
463 8993 : delete mySettingsMenu;
464 8993 : delete myLocatorMenu;
465 8993 : delete myControlMenu;
466 8993 : delete myLanguageMenu;
467 8993 : delete myWindowMenu;
468 8993 : delete myHelpMenu;
469 8993 : delete myLoadThread;
470 :
471 17375 : while (!myEvents.empty()) {
472 : // get the next event
473 8382 : GUIEvent* e = myEvents.top();
474 8382 : myEvents.pop();
475 8382 : delete e;
476 : }
477 9091 : for (auto item : myHotkeyPress) {
478 98 : delete item.second;
479 : }
480 9089 : for (auto item : myHotkeyRelease) {
481 96 : delete item.second;
482 : }
483 26980 : }
484 :
485 :
486 : void
487 0 : GUIApplicationWindow::detach() {
488 0 : FXMainWindow::detach();
489 0 : myMenuBarDrag->detach();
490 0 : myToolBarDrag1->detach();
491 0 : }
492 :
493 :
494 : void
495 9020 : GUIApplicationWindow::addToWindowsMenu(FXMenuPane* /*menuPane*/) {
496 : // unused, implement in children
497 9020 : }
498 :
499 :
500 : void
501 9020 : GUIApplicationWindow::fillMenuBar() {
502 : // build file menu
503 9020 : myFileMenu = new FXMenuPane(this);
504 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("&File"), nullptr, myFileMenu);
505 27060 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
506 18040 : TL("New Window"), "Ctrl+Shift+N", TL("Open a new sumo-gui window."),
507 : nullptr, this, MID_HOTKEY_CTRL_SHIFT_N_NEWWINDOW);
508 9020 : new FXMenuSeparator(myFileMenu);
509 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
510 18040 : TL("&Open Simulation..."), "Ctrl+O", TL("Open a simulation (Configuration file)."),
511 : GUIIconSubSys::getIcon(GUIIcon::OPEN_SUMOCONFIG), this, MID_HOTKEY_CTRL_O_OPENSIMULATION_OPENNETWORK);
512 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
513 18040 : TL("Open &Network..."), "Ctrl+N", TL("Open a network."),
514 : GUIIconSubSys::getIcon(GUIIcon::OPEN_NET), this, MID_HOTKEY_CTRL_N_OPENNETWORK_NEWNETWORK);
515 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
516 18040 : TL("Open Shapes "), "Ctrl+P", TL("Load POIs and Polygons for visualization."),
517 : GUIIconSubSys::getIcon(GUIIcon::OPEN_SHAPES), this, MID_HOTKEY_CTRL_P_OPENSHAPES);
518 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
519 18040 : TL("Open EdgeData "), "Ctrl+U", TL("Load edge related data for visualization."),
520 : GUIIconSubSys::getIcon(GUIIcon::OPEN_NET), this, MID_HOTKEY_CTRL_U_OPENEDGEDATA);
521 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
522 18040 : TL("&Reload"), "Ctrl+R", TL("Reloads the simulation / the network."),
523 : GUIIconSubSys::getIcon(GUIIcon::RELOAD), this, MID_HOTKEY_CTRL_R_RELOAD);
524 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
525 18040 : TL("Quick-Reload"), "Ctrl+0", TL("Reloads the simulation (but not network)."),
526 : GUIIconSubSys::getIcon(GUIIcon::RELOAD), this, MID_HOTKEY_CTRL_QUICK_RELOAD);
527 9020 : new FXMenuSeparator(myFileMenu);
528 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
529 18040 : TL("Save Configuration"), "Ctrl+Shift+S", TL("Save current options as a configuration file."),
530 : GUIIconSubSys::getIcon(GUIIcon::SAVE_SUMOCONFIG), this, MID_HOTKEY_CTRL_SHIFT_S_SAVESUMOCONFIG);
531 36080 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
532 18040 : TL("Close"), "Ctrl+W", TL("Close the simulation."),
533 : GUIIconSubSys::getIcon(GUIIcon::CLOSE), this, MID_HOTKEY_CTRL_W_CLOSESIMULATION);
534 9020 : new FXMenuSeparator(myFileMenu);
535 : // build recent files
536 9020 : buildRecentNetworks(myFileMenu, myFileMenuRecentNetworks);
537 9020 : buildRecentConfigs(myFileMenu, myFileMenuRecentConfigs);
538 9020 : new FXMenuSeparator(myFileMenu);
539 27060 : GUIDesigns::buildFXMenuCommandShortcut(myFileMenu,
540 18040 : TL("&Quit"), "Ctrl+Q", TL("Quit the Application."),
541 : nullptr, this, MID_HOTKEY_CTRL_Q_CLOSE);
542 : // build edit menu
543 9020 : mySelectByPermissions = new FXMenuPane(this);
544 9020 : std::vector<std::string> vehicleClasses = SumoVehicleClassStrings.getStrings();
545 315700 : for (const auto& vehicleClass : vehicleClasses) {
546 306680 : GUIDesigns::buildFXMenuCommand(mySelectByPermissions, vehicleClass, VClassIcons::getVClassIcon(SumoVehicleClassStrings.get(vehicleClass)), this, MID_HOTKEY_CTRL_E_EDITSELECTION_LOADNETEDITCONFIG);
547 : }
548 9020 : myEditMenu = new FXMenuPane(this);
549 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("&Edit"), nullptr, myEditMenu);
550 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
551 18040 : TL("Edit Selected..."), "Ctrl+E", TL("Opens a dialog for editing the list of selected items."),
552 : GUIIconSubSys::getIcon(GUIIcon::FLAG), this, MID_HOTKEY_CTRL_E_EDITSELECTION_LOADNETEDITCONFIG);
553 9020 : mySelectLanesMenuCascade = new FXMenuCascade(myEditMenu, TL("Select lanes which allow..."), GUIIconSubSys::getIcon(GUIIcon::FLAG), mySelectByPermissions);
554 9020 : mySelectLanesMenuCascade->setHelpText(TL("Opens a menu for selecting a vehicle class by which to selected lanes."));
555 9020 : new FXMenuSeparator(myEditMenu);
556 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
557 18040 : TL("Set Breakpoint"), "B", TL("Sets a breakpoint at the current simulation step"),
558 : GUIIconSubSys::getIcon(GUIIcon::APP_BREAKPOINTS), this, MID_HOTKEY_B_BREAKPOINT);
559 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
560 18040 : TL("Set Breakpoint with offset"), "Alt+B", TL("Sets a breakpoint at the current simulation step + offset configured in application settings"),
561 : GUIIconSubSys::getIcon(GUIIcon::APP_BREAKPOINTS), this, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY);
562 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
563 18040 : TL("Edit Breakpoints"), "Ctrl+B", TL("Opens a dialog for editing breakpoints."),
564 : GUIIconSubSys::getIcon(GUIIcon::APP_BREAKPOINTS), this, MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS);
565 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
566 18040 : TL("Edit Visualisation"), "F9", TL("Opens a dialog for editing visualization settings."),
567 : GUIIconSubSys::getIcon(GUIIcon::COLORWHEEL), this, MID_HOTKEY_F9_EDIT_VIEWSCHEME);
568 36080 : GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
569 18040 : TL("Edit Viewport"), "Ctrl+I", TL("Opens a dialog for editing viewing area, zoom and rotation."),
570 : GUIIconSubSys::getIcon(GUIIcon::EDITVIEWPORT), this, MID_HOTKEY_CTRL_I_EDITVIEWPORT);
571 9020 : new FXMenuSeparator(myEditMenu);
572 : // add open in sumo options
573 9020 : myLoadAdditionalsInNetedit = GUIDesigns::buildFXMenuCheckbox(myEditMenu, TL("Load additionals in netedit"), TL("Load additionals in netedit."), this, MID_TOOLBAREDIT_LOADADDITIONALS);
574 9020 : myLoadAdditionalsInNetedit->setCheck(TRUE);
575 9020 : myLoadDemandInNetedit = GUIDesigns::buildFXMenuCheckbox(myEditMenu, TL("Load demand in netedit"), TL("Load demand in netedit."), this, MID_TOOLBAREDIT_LOADDEMAND);
576 9020 : myLoadDemandInNetedit->setCheck(FALSE);
577 27060 : myOpenInNetedit = GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
578 18040 : TL("Open in netedit"), "Ctrl+T", TL("Opens current simulation in NETEDIT."),
579 : GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI), this, MID_HOTKEY_CTRL_T_OPENNETEDIT_OPENSUMO);
580 27060 : myOpenNetInNetedit = GUIDesigns::buildFXMenuCommandShortcut(myEditMenu,
581 18040 : TL("Open network in netedit"), "Ctrl+Shift+T", TL("Opens current network in NETEDIT."),
582 : GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI), this, MID_HOTKEY_CTRL_SHIFT_T_OPEN_NET);
583 : // build settings menu
584 9020 : mySettingsMenu = new FXMenuPane(this);
585 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("&Settings"), nullptr, mySettingsMenu);
586 27060 : GUIDesigns::buildFXMenuCommandShortcut(mySettingsMenu,
587 18040 : TL("Application Settings"), "Ctrl+H", TL("Open a Dialog for Application Settings editing."),
588 : nullptr, this, MID_HOTKEY_CTRL_H_APPSETTINGS_OPENEDGETYPES);
589 18040 : myGamingModeCheckbox = new FXMenuCheck(mySettingsMenu,
590 9020 : TL("Gaming Mode\tCtrl+G\tToggle gaming mode on/off."),
591 9020 : this, MID_HOTKEY_CTRL_G_GAMINGMODE_TOGGLEGRID);
592 36080 : GUIDesigns::buildFXMenuCommandShortcut(mySettingsMenu,
593 18040 : TL("Full Screen Mode"), "Ctrl+F", TL("Toggle full screen mode on/off."),
594 : GUIIconSubSys::getIcon(GUIIcon::FULL_SCREEN), this, MID_HOTKEY_CTRL_F_FULSCREENMODE);
595 : // build Locate menu
596 9020 : myLocatorMenu = new FXMenuPane(this);
597 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("&Locate"), nullptr, myLocatorMenu);
598 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
599 18040 : TL("&Junctions"), "Shift+J", TL("Open a dialog for locating a Junction."),
600 : GUIIconSubSys::getIcon(GUIIcon::LOCATEJUNCTION), this, MID_HOTKEY_SHIFT_J_LOCATEJUNCTION);
601 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
602 18040 : TL("&Edges"), "Shift+E", TL("Open a dialog for locating an Edge."),
603 : GUIIconSubSys::getIcon(GUIIcon::LOCATEEDGE), this, MID_HOTKEY_SHIFT_E_LOCATEEDGE);
604 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
605 18040 : TL("&Vehicles"), "Shift+V", TL("Open a dialog for locating a Vehicle."),
606 : GUIIconSubSys::getIcon(GUIIcon::LOCATEVEHICLE), this, MID_HOTKEY_SHIFT_V_LOCATEVEHICLE);
607 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
608 18040 : TL("&Persons"), "Shift+P", TL("Open a dialog for locating a Person."),
609 : GUIIconSubSys::getIcon(GUIIcon::LOCATEPERSON), this, MID_HOTKEY_SHIFT_P_LOCATEPERSON);
610 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
611 18040 : TL("&Container"), "Shift+C", TL("Open a dialog for locating a Container."),
612 : GUIIconSubSys::getIcon(GUIIcon::LOCATECONTAINER), this, MID_HOTKEY_SHIFT_C_LOCATECONTAINER);
613 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
614 18040 : TL("&TLS"), "Shift+T", TL("Open a dialog for locating a Traffic Light."),
615 : GUIIconSubSys::getIcon(GUIIcon::LOCATETLS), this, MID_HOTKEY_SHIFT_T_LOCATETLS);
616 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
617 18040 : TL("&Additional"), "Shift+A", TL("Open a dialog for locating an Additional Structure."),
618 : GUIIconSubSys::getIcon(GUIIcon::LOCATEADD), this, MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL);
619 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
620 18040 : TL("P&oI"), "Shift+O", TL("Open a dialog for locating a Point of Interest."),
621 : GUIIconSubSys::getIcon(GUIIcon::LOCATEPOI), this, MID_HOTKEY_SHIFT_O_LOCATEPOI);
622 36080 : GUIDesigns::buildFXMenuCommandShortcut(myLocatorMenu,
623 18040 : TL("Po&lygon"), "Shift+L", TL("Open a dialog for locating a Polygon."),
624 : GUIIconSubSys::getIcon(GUIIcon::LOCATEPOLY), this, MID_HOTKEY_SHIFT_L_LOCATEPOLY);
625 9020 : new FXMenuSeparator(myLocatorMenu);
626 18040 : GUIDesigns::buildFXMenuCheckbox(myLocatorMenu, TL("Show Internal Structures"), TL("Show internal junctions and streets in locator dialog."), this, MID_LISTINTERNAL);
627 18040 : FXMenuCheck* listParking = GUIDesigns::buildFXMenuCheckbox(myLocatorMenu, TL("Show Parking Vehicles"), TL("Show parking vehicles in locator dialog."), this, MID_LISTPARKING);
628 9020 : listParking->setCheck(myListParking);
629 18040 : GUIDesigns::buildFXMenuCheckbox(myLocatorMenu, TL("Show vehicles outside the road network"), TL("Show vehicles that are teleporting or driving remote-controlled outside the road network in locator dialog."), this, MID_LISTTELEPORTING);
630 : // build control menu
631 : // the shortcut designator is not only at text in the submenu but also defines the real shortcut key assigned with it!
632 : // secondary shortcuts (ctrl+A, ctrl+S, ctrl+D) are defined in GUIShortcutsSubSys::buildSUMOAccelerators
633 9020 : myControlMenu = new FXMenuPane(this);
634 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("Simulation"), nullptr, myControlMenu);
635 36080 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
636 18040 : TL("Run"), "A,space", TL("Start/ Resume the simulation."),
637 : GUIIconSubSys::getIcon(GUIIcon::START), this, MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS);
638 36080 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
639 9020 : TLC("Simulation", "Stop"), "S,space", TL("Halt the simulation."),
640 : GUIIconSubSys::getIcon(GUIIcon::STOP), this, MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK);
641 36080 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
642 18040 : TL("Step"), "D", TL("Perform one simulation step."),
643 : GUIIconSubSys::getIcon(GUIIcon::STEP), this, MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS);
644 27060 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
645 18040 : TL("Delay+"), "PgUp", TL("Increase simulation step delay."), nullptr, this, MID_DELAY_INC);
646 27060 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
647 18040 : TL("Delay-"), "PgDn", TL("Decrease simulation step delay."), nullptr, this, MID_DELAY_DEC);
648 36080 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
649 18040 : TL("Save"), "", TL("Save the current simulation state to a file."),
650 : GUIIconSubSys::getIcon(GUIIcon::SAVE), this, MID_SIMSAVE);
651 36080 : GUIDesigns::buildFXMenuCommandShortcut(myControlMenu,
652 18040 : TL("Load"), "", TL("Load simulation state for the current network from file."),
653 : GUIIconSubSys::getIcon(GUIIcon::OPEN), this, MID_SIMLOAD);
654 : // build windows menu
655 9020 : myWindowMenu = new FXMenuPane(this);
656 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar, TL("&Window"), nullptr, myWindowMenu);
657 18040 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu, TL("Open new view"), "", TL("Open a new microscopic view."), GUIIconSubSys::getIcon(GUIIcon::MICROVIEW), this, MID_NEW_MICROVIEW);
658 : #ifdef HAVE_OSG
659 18040 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu, TL("Open new 3D view"), "", TL("Open a new 3D view."), GUIIconSubSys::getIcon(GUIIcon::OSGVIEW), this, MID_NEW_OSGVIEW);
660 : #endif
661 27060 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu,
662 18040 : TL("Tile &Horizontally"), "", TL("Tile the views horizontally."),
663 9020 : GUIIconSubSys::getIcon(GUIIcon::WINDOWS_TILE_HORI), myMDIClient, FXMDIClient::ID_MDI_TILEHORIZONTAL);
664 27060 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu,
665 18040 : TL("Tile &Vertically"), "", TL("Tile the views vertically."),
666 9020 : GUIIconSubSys::getIcon(GUIIcon::WINDOWS_TILE_VERT), myMDIClient, FXMDIClient::ID_MDI_TILEVERTICAL);
667 27060 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu,
668 18040 : TL("Cascade"), "", TL("Cascade the views."),
669 : GUIIconSubSys::getIcon(GUIIcon::WINDOWS_CASCADE),
670 9020 : myMDIClient, FXMDIClient::ID_MDI_CASCADE);
671 27060 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu,
672 9020 : TL("&Close"), "", TL("Close the selected view."),
673 9020 : nullptr, myMDIClient, FXMDIClient::ID_MDI_CLOSE);
674 9020 : FXMenuSeparator* sep2 = new FXMenuSeparator(myWindowMenu);
675 9020 : sep2->setTarget(myMDIClient);
676 : sep2->setSelector(FXMDIClient::ID_MDI_ANY);
677 : // for whatever reason, sonar complains in the next line that sep2 may leak, but fox does the cleanup
678 9020 : GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_1); // NOSONAR
679 9020 : GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_2);
680 9020 : GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_3);
681 9020 : GUIDesigns::buildFXMenuCommand(myWindowMenu, "", nullptr, myMDIClient, FXMDIClient::ID_MDI_4);
682 9020 : GUIDesigns::buildFXMenuCommand(myWindowMenu, TL("&Others..."), nullptr, myMDIClient, FXMDIClient::ID_MDI_OVER_5);
683 :
684 9020 : new FXMenuSeparator(myWindowMenu);
685 18040 : GUIDesigns::buildFXMenuCheckbox(myWindowMenu, TL("Show Status Line"), TL("Toggle the Status Bar on/off."), myStatusbar, FXWindow::ID_TOGGLESHOWN);
686 18040 : GUIDesigns::buildFXMenuCheckbox(myWindowMenu, TL("Show Message Window"), TL("Toggle the Message Window on/off."), myMessageWindow, FXWindow::ID_TOGGLESHOWN);
687 18040 : GUIDesigns::buildFXMenuCheckbox(myWindowMenu, TL("Show Simulation Time"), TL("Toggle the Simulation Time on/off."), myToolBar3, FXWindow::ID_TOGGLESHOWN);
688 18040 : GUIDesigns::buildFXMenuCheckbox(myWindowMenu, TL("Show Simulation Delay"), TL("Toggle the Simulation Delay Entry on/off."), myToolBar4, FXWindow::ID_TOGGLESHOWN);
689 9020 : addToWindowsMenu(myWindowMenu);
690 :
691 9020 : new FXMenuSeparator(myWindowMenu);
692 36080 : GUIDesigns::buildFXMenuCommandShortcut(myWindowMenu,
693 18040 : TL("Clear Message Window"), "", TL("Clear the message window."),
694 : GUIIconSubSys::getIcon(GUIIcon::CLEARMESSAGEWINDOW), this, MID_CLEARMESSAGEWINDOW);
695 : // build windows menu
696 9020 : buildLanguageMenu(myMenuBar);
697 : // build help menu
698 9020 : myHelpMenu = new FXMenuPane(this);
699 9020 : GUIDesigns::buildFXMenuTitle(myMenuBar,
700 9020 : TL("&Help"),
701 : nullptr, myHelpMenu);
702 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Online Documentation"), "F1", TL("Open Online documentation."),
703 : nullptr, this, MID_HOTKEY_F1_ONLINEDOCUMENTATION);
704 9020 : new FXMenuSeparator(myHelpMenu);
705 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Changelog"), "", TL("Open Changelog."),
706 : nullptr, this, MID_CHANGELOG);
707 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Hotkeys"), "", TL("Open Hotkeys."),
708 : nullptr, this, MID_HOTKEYS);
709 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Tutorial"), "", TL("Open Tutorial."),
710 : nullptr, this, MID_TUTORIAL);
711 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&Feedback"), "", TL("Open feedback dialog."),
712 : nullptr, this, MID_FEEDBACK);
713 9020 : new FXMenuSeparator(myHelpMenu);
714 18040 : GUIDesigns::buildFXMenuCommandShortcut(myHelpMenu, TL("&About"), "F12", TL("About sumo-gui."),
715 : GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI), this, MID_HOTKEY_F12_ABOUT);
716 : // build SUMO Accelerators (hotkeys)
717 9020 : GUIShortcutsSubSys::buildAccelerators(getAccelTable(), this, true);
718 9020 : }
719 :
720 :
721 : void
722 9020 : GUIApplicationWindow::buildToolBars() {
723 : // file and simulation tool bar
724 : {
725 9020 : myToolBarDrag1 = new FXToolBarShell(this, GUIDesignToolBar);
726 9020 : myToolBar1 = new FXToolBar(myTopDock, myToolBarDrag1, GUIDesignToolBarRaisedNextTop);
727 9020 : new FXToolBarGrip(myToolBar1, myToolBar1, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
728 : // build file tools
729 18040 : new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tOpen simulation\tOpen a simulation (Configuration file)."),
730 9020 : GUIIconSubSys::getIcon(GUIIcon::OPEN_SUMOCONFIG), this, MID_HOTKEY_CTRL_O_OPENSIMULATION_OPENNETWORK, GUIDesignButtonToolbar);
731 18040 : new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tOpen network\tOpen a network."),
732 9020 : GUIIconSubSys::getIcon(GUIIcon::OPEN_NET), this, MID_HOTKEY_CTRL_N_OPENNETWORK_NEWNETWORK, GUIDesignButtonToolbar);
733 18040 : new MFXButtonTooltip(myToolBar1, myStaticTooltipMenu, TL("\tReload\tReloads the simulation / the network."),
734 9020 : GUIIconSubSys::getIcon(GUIIcon::RELOAD), this, MID_HOTKEY_CTRL_R_RELOAD, GUIDesignButtonToolbar);
735 : }
736 : // simulation toolbar
737 : {
738 9020 : myToolBarDrag2 = new FXToolBarShell(this, GUIDesignToolBar);
739 9020 : myToolBar2 = new FXToolBar(myTopDock, myToolBarDrag2, GUIDesignToolBarRaisedSameTop);
740 9020 : new FXToolBarGrip(myToolBar2, myToolBar2, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
741 : // build simulation tools
742 18040 : new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tRun\tStart/Resume the loaded simulation."),
743 9020 : GUIIconSubSys::getIcon(GUIIcon::START), this, MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS, GUIDesignButtonToolbar);
744 18040 : new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tStop\tHalt the running simulation."),
745 9020 : GUIIconSubSys::getIcon(GUIIcon::STOP), this, MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK, GUIDesignButtonToolbar);
746 18040 : new MFXButtonTooltip(myToolBar2, myStaticTooltipMenu, TL("\tStep\tPerform a single simulation step."),
747 9020 : GUIIconSubSys::getIcon(GUIIcon::STEP), this, MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS, GUIDesignButtonToolbar);
748 : }
749 : // Simulation Step Display
750 : {
751 9020 : myToolBarDrag3 = new FXToolBarShell(this, GUIDesignToolBar);
752 9020 : myToolBar3 = new FXToolBar(myTopDock, myToolBarDrag3, GUIDesignToolBarRaisedSameTop);
753 9020 : new FXToolBarGrip(myToolBar3, myToolBar3, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
754 9020 : new MFXButtonTooltip(myToolBar3, myStaticTooltipMenu, TL("Time:\tToggle between time formats\tToggle between seconds and hour:minute:seconds display."), nullptr, this, MID_TIME_TOGGLE, GUIDesignButtonToolbarText);
755 :
756 9020 : myLCDLabel = new MFXLCDLabel(myToolBar3, myStaticTooltipMenu, 16, nullptr, 0, JUSTIFY_RIGHT);
757 9020 : myLCDLabel->setHorizontal(2);
758 9020 : myLCDLabel->setVertical(6);
759 9020 : myLCDLabel->setThickness(2);
760 9020 : myLCDLabel->setGroove(2);
761 9020 : myLCDLabel->setText("----------------");
762 : }
763 : // Simulation Delay
764 : {
765 9020 : myToolBarDrag4 = new FXToolBarShell(this, GUIDesignToolBar);
766 9020 : myToolBar4 = new FXToolBar(myTopDock, myToolBarDrag4, GUIDesignToolBarRaisedSameTop);
767 9020 : new FXToolBarGrip(myToolBar4, myToolBar4, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
768 9020 : 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);
769 : // create spinner for delay
770 9020 : mySimDelay = 0;
771 9020 : mySimDelayTarget = new FXDataTarget(mySimDelay);
772 9020 : mySimDelaySpinner = new MFXRealSpinner(myToolBar4, 7, mySimDelayTarget, FXDataTarget::ID_VALUE, GUIDesignSpinDial);
773 : // create slider
774 9020 : mySimDelaySlider = new FXSlider(myToolBar4, mySimDelayTarget, FXDataTarget::ID_VALUE, GUIDesignSlider);
775 9020 : mySimDelaySlider->setRange(0, 1000);
776 9020 : mySimDelaySlider->setHeadSize(10);
777 9020 : mySimDelaySlider->setIncrement(50);
778 9020 : mySimDelaySlider->setTickDelta(100);
779 9020 : mySimDelaySlider->setValue((int)mySimDelay);
780 : //mySimDelayTarget->setNumberFormat(0);
781 : //mySimDelayTarget->setIncrements(1, 10, 10);
782 9020 : mySimDelaySpinner->setIncrement(10);
783 9020 : mySimDelaySpinner->setRange(0, 10000);
784 9020 : mySimDelaySpinner->setValue(mySimDelay);
785 : }
786 : // Scale traffic (flows and incrementally loaded vehicles)
787 : {
788 9020 : myToolBarDrag8 = new FXToolBarShell(this, GUIDesignToolBar);
789 9020 : myToolBar8 = new FXToolBar(myTopDock, myToolBarDrag8, GUIDesignToolBarRaisedSameTop);
790 9020 : new FXToolBarGrip(myToolBar8, myToolBar8, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
791 9020 : myScaleTrafficTooltip = new MFXLabelTooltip(myToolBar8, myStaticTooltipMenu, TL("Scale Traffic:"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
792 18040 : myScaleTrafficTooltip->setHelpText(TL("Scale traffic volume from running flows and from vehicles that are loaded incrementally from route files."));
793 9020 : myDemandScaleSpinner = new MFXRealSpinner(myToolBar8, 7, this, MID_DEMAND_SCALE, GUIDesignSpinDial);
794 9020 : myDemandScaleSpinner->setIncrement(0.5);
795 9020 : myDemandScaleSpinner->setRange(0, 1000);
796 9020 : myDemandScaleSpinner->setValue(1);
797 : }
798 : // Views
799 : {
800 9020 : myToolBarDrag5 = new FXToolBarShell(this, GUIDesignToolBar);
801 9020 : myToolBar5 = new FXToolBar(myTopDock, myToolBarDrag5, GUIDesignToolBarRaisedSameTop);
802 9020 : new FXToolBarGrip(myToolBar5, myToolBar5, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
803 : // build view tools
804 18040 : new MFXButtonTooltip(myToolBar5, myStaticTooltipMenu, (std::string("\t") + TL("Open new view") + std::string("\t") + TL("Open a new microscopic view.")).c_str(),
805 18040 : GUIIconSubSys::getIcon(GUIIcon::MICROVIEW), this, MID_NEW_MICROVIEW, GUIDesignButtonToolbar);
806 : #ifdef HAVE_OSG
807 27060 : new MFXButtonTooltip(myToolBar5, myStaticTooltipMenu, (std::string("\t") + TL("Open new 3D view") + std::string("\t") + TL("Open a new 3D view.")).c_str(),
808 18040 : GUIIconSubSys::getIcon(GUIIcon::OSGVIEW), this, MID_NEW_OSGVIEW, GUIDesignButtonToolbar);
809 : #endif
810 : // add toggle button for tooltips in view on/off (by default unchecked)
811 9020 : myShowToolTipsView = new MFXCheckableButton(false, myToolBar5,
812 27060 : myStaticTooltipMenu, (std::string("\t") + TL("Toggle View Tooltips") + std::string("\t") + TL("Toggles whether tooltips in the view shall be shown.")).c_str(),
813 18040 : GUIIconSubSys::getIcon(GUIIcon::SHOWTOOLTIPS_VIEW), this, MID_SHOWTOOLTIPS_VIEW, GUIDesignMFXCheckableButtonSquare);
814 9020 : myShowToolTipsView->setChecked(getApp()->reg().readIntEntry("gui", "viewToolTips", 0) == 1);
815 9020 : myStaticTooltipView->enableStaticToolTip(myShowToolTipsView->amChecked());
816 : // add toggle button for tooltips in menu on/off (by default checked)
817 9020 : myShowToolTipsMenu = new MFXCheckableButton(false, myToolBar5,
818 27060 : myStaticTooltipMenu, (std::string("\t") + TL("Toggle Menu Tooltips") + std::string("\t") + TL("Toggles whether tooltips in the menu shall be shown.")).c_str(),
819 18040 : GUIIconSubSys::getIcon(GUIIcon::SHOWTOOLTIPS_MENU), this, MID_SHOWTOOLTIPS_MENU, GUIDesignMFXCheckableButtonSquare);
820 9020 : myShowToolTipsMenu->setChecked(getApp()->reg().readIntEntry("gui", "menuToolTips", 0) != 1);
821 9020 : myStaticTooltipMenu->enableStaticToolTip(myShowToolTipsMenu->amChecked());
822 : }
823 : /// game specific stuff
824 : {
825 : // total waitingTime
826 9020 : myToolBarDrag6 = new FXToolBarShell(this, GUIDesignToolBar);
827 9020 : myToolBar6 = new FXToolBar(myTopDock, myToolBarDrag6, GUIDesignToolBarRaisedSameTop);
828 9020 : new FXToolBarGrip(myToolBar6, myToolBar6, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
829 18040 : GUIDesigns::buildFXLabel(myToolBar6, TL("Waiting Time:"), "", TL("Time spent waiting accumulated for all vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
830 9020 : myWaitingTimeLabel = new MFXLCDLabel(myToolBar6, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
831 9020 : myWaitingTimeLabel->setHorizontal(2);
832 9020 : myWaitingTimeLabel->setVertical(6);
833 9020 : myWaitingTimeLabel->setThickness(2);
834 9020 : myWaitingTimeLabel->setGroove(2);
835 9020 : myWaitingTimeLabel->setText("-------------");
836 : // idealistic time loss
837 9020 : myToolBarDrag7 = new FXToolBarShell(this, GUIDesignToolBar);
838 9020 : myToolBar7 = new FXToolBar(myTopDock, myToolBarDrag7, GUIDesignToolBarRaisedSameTop);
839 9020 : new FXToolBarGrip(myToolBar7, myToolBar7, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
840 18040 : GUIDesigns::buildFXLabel(myToolBar7, TL("Time Loss:"), "", TL("Time lost due to being unable to drive with maximum speed for all vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
841 9020 : myTimeLossLabel = new MFXLCDLabel(myToolBar7, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
842 9020 : myTimeLossLabel->setHorizontal(2);
843 9020 : myTimeLossLabel->setVertical(6);
844 9020 : myTimeLossLabel->setThickness(2);
845 9020 : myTimeLossLabel->setGroove(2);
846 9020 : myTimeLossLabel->setText("-------------");
847 : // total driving distance
848 9020 : myToolBarDrag9 = new FXToolBarShell(this, GUIDesignToolBar);
849 9020 : myToolBar9 = new FXToolBar(myTopDock, myToolBarDrag9, GUIDesignToolBarRaisedSameTop);
850 9020 : new FXToolBarGrip(myToolBar9, myToolBar9, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
851 18040 : GUIDesigns::buildFXLabel(myToolBar9, TL("Distance (km):"), "", TL("Total distance driven by DRT vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
852 9020 : myTotalDistanceLabel = new MFXLCDLabel(myToolBar9, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
853 9020 : myTotalDistanceLabel->setHorizontal(2);
854 9020 : myTotalDistanceLabel->setVertical(6);
855 9020 : myTotalDistanceLabel->setThickness(2);
856 9020 : myTotalDistanceLabel->setGroove(2);
857 9020 : myTotalDistanceLabel->setText("-------------");
858 : // emergency vehicle counts
859 9020 : myToolBarDrag10 = new FXToolBarShell(this, GUIDesignToolBar);
860 9020 : myToolBar10 = new FXToolBar(myTopDock, myToolBarDrag10, GUIDesignToolBarRaisedSameTop);
861 9020 : new FXToolBarGrip(myToolBar10, myToolBar10, FXToolBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
862 18040 : GUIDesigns::buildFXLabel(myToolBar10, TL("Emergency Vehicle waiting time:"), "", TL("Time spent waiting accumulated for emergency vehicles"), nullptr, LAYOUT_TOP | LAYOUT_LEFT);
863 9020 : myEmergencyVehicleLabel = new MFXLCDLabel(myToolBar10, myStaticTooltipMenu, 13, nullptr, 0, JUSTIFY_RIGHT);
864 9020 : myEmergencyVehicleLabel->setHorizontal(2);
865 9020 : myEmergencyVehicleLabel->setVertical(6);
866 9020 : myEmergencyVehicleLabel->setThickness(2);
867 9020 : myEmergencyVehicleLabel->setGroove(2);
868 9020 : myEmergencyVehicleLabel->setText("-------------");
869 : }
870 9020 : }
871 :
872 :
873 : void
874 9020 : GUIApplicationWindow::buildRecentNetworks(FXMenuPane* fileMenu, FXMenuPane* fileMenuRecentNetworks) {
875 : // for whatever reason, sonar complains in the next line that sep1 may leak, but fox does the cleanup
876 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_1);
877 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_2);
878 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_3);
879 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_4);
880 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_5);
881 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_6);
882 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_7);
883 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_8);
884 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_9);
885 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentNetworks, "", &myRecentNetworks, FXRecentFiles::ID_FILE_10);
886 9020 : new FXMenuSeparator(fileMenuRecentNetworks); // NOSONAR, Fox does the cleanup
887 9020 : GUIDesigns::buildFXMenuCommand(fileMenuRecentNetworks, TL("Cl&ear Recent Networks"), nullptr, &myRecentNetworks, FXRecentFiles::ID_CLEAR);
888 9020 : GUIDesigns::buildFXMenuCommand(fileMenuRecentNetworks, TL("No Recent Networks"), nullptr, &myRecentNetworks, MFXRecentNetworks::ID_NOFILES);
889 : // set target
890 9020 : myRecentNetworks.setTarget(this);
891 : myRecentNetworks.setSelector(MID_RECENTFILE);
892 9020 : new FXMenuCascade(fileMenu, TL("Recent Networks"), nullptr, fileMenuRecentNetworks);
893 9020 : }
894 :
895 :
896 : void
897 9020 : GUIApplicationWindow::buildRecentConfigs(FXMenuPane* fileMenu, FXMenuPane* fileMenuRecentConfigs) {
898 : // for whatever reason, sonar complains in the next line that sep1 may leak, but fox does the cleanup
899 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_1);
900 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_2);
901 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_3);
902 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_4);
903 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_5);
904 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_6);
905 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_7);
906 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_8);
907 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_9);
908 9020 : GUIDesigns::buildFXMenuCommandRecentFile(fileMenuRecentConfigs, "", &myRecentConfigs, FXRecentFiles::ID_FILE_10);
909 9020 : new FXMenuSeparator(fileMenuRecentConfigs); // NOSONAR, Fox does the cleanup
910 9020 : GUIDesigns::buildFXMenuCommand(fileMenuRecentConfigs, TL("Cl&ear Recent Configs"), nullptr, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
911 9020 : GUIDesigns::buildFXMenuCommand(fileMenuRecentConfigs, TL("No Recent Configs"), nullptr, &myRecentConfigs, MFXRecentNetworks::ID_NOFILES);
912 : // set target
913 9020 : myRecentConfigs.setTarget(this);
914 : myRecentConfigs.setSelector(MID_RECENTFILE);
915 9020 : new FXMenuCascade(fileMenu, TL("Recent Configs"), nullptr, fileMenuRecentConfigs);
916 9020 : }
917 :
918 :
919 : long
920 0 : GUIApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
921 0 : storeWindowSizeAndPos();
922 0 : getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
923 0 : getApp()->reg().writeIntEntry("SETTINGS", "maximized", isMaximized() ? 1 : 0);
924 0 : getApp()->reg().writeIntEntry("gui", "timeasHMS", myShowTimeAsHMS ? 1 : 0);
925 0 : getApp()->reg().writeIntEntry("gui", "alternateSimDelay", (int)myAlternateSimDelay);
926 0 : closeAllWindows();
927 0 : getApp()->exit(0);
928 0 : return 1;
929 : }
930 :
931 :
932 : long
933 0 : GUIApplicationWindow::onCmdEditChosen(FXObject* menu, FXSelector, void*) {
934 0 : FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
935 0 : if (mc->getText() == StringUtils::replace(TL("Edit Selected..."), "&", "").c_str()) {
936 0 : GUIDialog_GLChosenEditor* chooser = new GUIDialog_GLChosenEditor(this, &gSelected);
937 0 : chooser->create();
938 0 : chooser->show();
939 : } else {
940 0 : if (!myAmLoading && myRunThread->networkAvailable()) {
941 0 : const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
942 0 : for (MSEdgeVector::const_iterator i = MSEdge::getAllEdges().begin(); i != MSEdge::getAllEdges().end(); ++i) {
943 0 : const std::vector<MSLane*>& lanes = (*i)->getLanes();
944 0 : for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
945 0 : GUILane* lane = dynamic_cast<GUILane*>(*it);
946 : assert(lane != 0);
947 0 : if ((lane->getPermissions() & svc) != 0) {
948 0 : gSelected.select(lane->getGlID());
949 : }
950 : }
951 : }
952 0 : if (myMDIClient->numChildren() > 0) {
953 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
954 0 : if (w != nullptr) {
955 : // color by selection
956 0 : w->getView()->editVisualisationSettings()->laneColorer.setActive(1);
957 : }
958 : }
959 : }
960 0 : updateChildren();
961 : }
962 0 : return 1;
963 : }
964 :
965 :
966 : long
967 0 : GUIApplicationWindow::onCmdEditBreakpoints(FXObject*, FXSelector, void*) {
968 0 : if (myBreakpointDialog == nullptr) {
969 0 : myBreakpointDialog = new GUIDialog_Breakpoints(this, myRunThread->getBreakpoints(), myRunThread->getBreakpointLock(), myRunThread->getSimBegin());
970 : } else {
971 0 : myBreakpointDialog->restore();
972 0 : myBreakpointDialog->setFocus();
973 0 : myBreakpointDialog->raise();
974 : }
975 0 : return 1;
976 : }
977 :
978 :
979 : long
980 0 : GUIApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
981 0 : if (!myGLWindows.empty()) {
982 0 : myGLWindows[0]->getView()->showViewportEditor();
983 : }
984 0 : return 1;
985 : }
986 :
987 :
988 : long
989 0 : GUIApplicationWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
990 0 : if (!myGLWindows.empty()) {
991 0 : myGLWindows[0]->getView()->showViewschemeEditor();
992 : }
993 0 : return 1;
994 : }
995 :
996 :
997 : long
998 0 : GUIApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
999 0 : MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/sumo-gui.html");
1000 0 : return 1;
1001 : }
1002 :
1003 :
1004 : long
1005 0 : GUIApplicationWindow::onCmdChangelog(FXObject*, FXSelector, void*) {
1006 : // update in every version
1007 0 : MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/ChangeLog.html");
1008 0 : return 1;
1009 : }
1010 :
1011 :
1012 : long
1013 0 : GUIApplicationWindow::onCmdHotkeys(FXObject*, FXSelector, void*) {
1014 0 : MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/sumo-gui.html#keyboard_shortcuts");
1015 0 : return 1;
1016 : }
1017 :
1018 :
1019 : long
1020 0 : GUIApplicationWindow::onCmdTutorial(FXObject*, FXSelector, void*) {
1021 0 : MFXLinkLabel::fxexecute("https://sumo.dlr.de/docs/Tutorials/index.html");
1022 0 : return 1;
1023 : }
1024 :
1025 :
1026 : long
1027 0 : GUIApplicationWindow::onCmdOpenInNetedit(FXObject* sender, FXSelector, void* ptr) {
1028 0 : if (myGLWindows.empty()) {
1029 : return 1;
1030 : }
1031 : bool onlyNet;
1032 0 : if (sender == myOpenNetInNetedit) {
1033 : onlyNet = true;
1034 0 : } else if (sender == myOpenInNetedit) {
1035 : onlyNet = false;
1036 : } else {
1037 : // we have to check (menu-item) sender first because ptr is only valid when
1038 : // triggered via hotkey
1039 : FXEvent* e = (FXEvent*) ptr;
1040 0 : onlyNet = (e->state & SHIFTMASK) != 0;
1041 : }
1042 0 : FXRegistry reg("SUMO netedit", "netedit");
1043 0 : reg.read();
1044 0 : const GUISUMOAbstractView* const v = myGLWindows[0]->getView();
1045 0 : reg.writeRealEntry("viewport", "x", v->getChanger().getXPos());
1046 0 : reg.writeRealEntry("viewport", "y", v->getChanger().getYPos());
1047 0 : reg.writeRealEntry("viewport", "z", v->getChanger().getZPos());
1048 0 : reg.write();
1049 0 : std::string netedit = "netedit";
1050 0 : const char* sumoPath = getenv("SUMO_HOME");
1051 0 : if (sumoPath != nullptr) {
1052 0 : std::string newPath = std::string(sumoPath) + "/bin/netedit";
1053 0 : if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
1054 0 : netedit = "\"" + newPath + "\"";
1055 : }
1056 : }
1057 : // declare command for calling netedit using the viewport saved in registry
1058 0 : std::string cmd = netedit + " --registry-viewport";
1059 : // continue depending if we're loading only a network or the entire sumo config
1060 0 : if (myLoadAdditionalsInNetedit->shown() && !onlyNet) {
1061 0 : cmd += " --sumocfg-file \"" + OptionsCont::getOptions().getString("configuration-file") + "\"";
1062 : // check if ignore additional or demand elements
1063 0 : if (myLoadAdditionalsInNetedit->getCheck() == FALSE) {
1064 : cmd += " --ignore.additionalelements";
1065 : }
1066 0 : if (myLoadDemandInNetedit->getCheck() == FALSE) {
1067 : cmd += " --ignore.routeelements";
1068 : }
1069 : } else {
1070 0 : cmd += " -s \"" + OptionsCont::getOptions().getString("net-file") + "\"";
1071 : }
1072 : // start in background
1073 : #ifndef WIN32
1074 0 : cmd = cmd + " &";
1075 : #else
1076 : // see "help start" for the parameters
1077 : cmd = "start /B \"\" " + cmd;
1078 : #endif
1079 0 : WRITE_MESSAGEF(TL("Running %."), cmd);
1080 : // yay! fun with dangerous commands... Never use this over the internet
1081 0 : SysUtils::runHiddenCommand(cmd);
1082 : return 1;
1083 0 : }
1084 :
1085 :
1086 : long
1087 0 : GUIApplicationWindow::onCmdNewWindow(FXObject*, FXSelector, void*) {
1088 0 : FXRegistry reg("SUMO sumo-gui", "sumo-gui");
1089 0 : std::string sumo_gui = "sumo-gui";
1090 0 : const char* sumoPath = getenv("SUMO_HOME");
1091 0 : if (sumoPath != nullptr) {
1092 0 : std::string newPath = std::string(sumoPath) + "/bin/sumo_gui";
1093 0 : if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
1094 0 : sumo_gui = "\"" + newPath + "\"";
1095 : }
1096 : }
1097 : std::string cmd = sumo_gui;
1098 : // start in background
1099 : #ifndef WIN32
1100 0 : cmd = cmd + " &";
1101 : #else
1102 : // see "help start" for the parameters
1103 : cmd = "start /B \"\" " + cmd;
1104 : #endif
1105 0 : WRITE_MESSAGEF(TL("Running %."), cmd);
1106 : // yay! fun with dangerous commands... Never use this over the internet
1107 0 : SysUtils::runHiddenCommand(cmd);
1108 0 : return 1;
1109 0 : }
1110 :
1111 :
1112 : long
1113 0 : GUIApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
1114 : // get the new file name
1115 0 : FXFileDialog opendialog(this, TL("Open Simulation Configuration"));
1116 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_SUMOCONFIG));
1117 0 : opendialog.setSelectMode(SELECTFILE_EXISTING);
1118 0 : opendialog.setPatternList(SUMOXMLDefinitions::SumoConfigFileExtensions.getMultilineString().c_str());
1119 0 : if (gCurrentFolder.length() != 0) {
1120 0 : opendialog.setDirectory(gCurrentFolder);
1121 : }
1122 0 : if (opendialog.execute()) {
1123 0 : gCurrentFolder = opendialog.getDirectory();
1124 0 : std::string file = opendialog.getFilename().text();
1125 0 : loadConfigOrNet(file);
1126 0 : myRecentConfigs.appendFile(file.c_str());
1127 : }
1128 0 : return 1;
1129 0 : }
1130 :
1131 :
1132 : long
1133 0 : GUIApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
1134 : // get the new file name
1135 0 : FXFileDialog opendialog(this, TL("Open Network"));
1136 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
1137 0 : opendialog.setSelectMode(SELECTFILE_EXISTING);
1138 0 : opendialog.setPatternList(SUMOXMLDefinitions::NetFileExtensions.getMultilineString().c_str());
1139 0 : if (gCurrentFolder.length() != 0) {
1140 0 : opendialog.setDirectory(gCurrentFolder);
1141 : }
1142 0 : if (opendialog.execute()) {
1143 0 : gCurrentFolder = opendialog.getDirectory();
1144 0 : std::string file = opendialog.getFilename().text();
1145 0 : loadConfigOrNet(file);
1146 0 : myRecentNetworks.appendFile(file.c_str());
1147 : }
1148 0 : return 1;
1149 0 : }
1150 :
1151 :
1152 : long
1153 0 : GUIApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
1154 : // get the shape file name
1155 0 : FXFileDialog opendialog(this, TL("Open Shapes"));
1156 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_SHAPES));
1157 0 : opendialog.setSelectMode(SELECTFILE_EXISTING);
1158 0 : opendialog.setPatternList(SUMOXMLDefinitions::ShapesFileExtensions.getMultilineString().c_str());
1159 0 : if (gCurrentFolder.length() != 0) {
1160 0 : opendialog.setDirectory(gCurrentFolder);
1161 : }
1162 0 : if (opendialog.execute()) {
1163 0 : gCurrentFolder = opendialog.getDirectory();
1164 0 : std::string file = opendialog.getFilename().text();
1165 :
1166 0 : dynamic_cast<GUIShapeContainer&>(myRunThread->getNet().getShapeContainer()).allowReplacement();
1167 0 : NLShapeHandler handler(file, myRunThread->getNet().getShapeContainer());
1168 0 : if (!XMLSubSys::runParser(handler, file, false)) {
1169 0 : WRITE_MESSAGEF(TL("Loading of % failed."), file);
1170 : }
1171 0 : update();
1172 0 : if (myMDIClient->numChildren() > 0) {
1173 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1174 0 : if (w != nullptr) {
1175 0 : w->getView()->update();
1176 : }
1177 : }
1178 : }
1179 0 : return 1;
1180 0 : }
1181 :
1182 :
1183 : long
1184 0 : GUIApplicationWindow::onCmdOpenEdgeData(FXObject*, FXSelector, void*) {
1185 : // get the shape file name
1186 0 : FXFileDialog opendialog(this, TL("Open EdgeData"));
1187 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
1188 0 : opendialog.setSelectMode(SELECTFILE_EXISTING);
1189 0 : opendialog.setPatternList(SUMOXMLDefinitions::EdgeDataFileExtensions.getMultilineString().c_str());
1190 0 : if (gCurrentFolder.length() != 0) {
1191 0 : opendialog.setDirectory(gCurrentFolder);
1192 : }
1193 0 : if (opendialog.execute()) {
1194 0 : gCurrentFolder = opendialog.getDirectory();
1195 0 : std::string file = opendialog.getFilename().text();
1196 0 : if (!GUINet::getGUIInstance()->loadEdgeData(file)) {
1197 0 : WRITE_MESSAGEF(TL("Loading of % failed."), file);
1198 : }
1199 0 : update();
1200 0 : if (myMDIClient->numChildren() > 0) {
1201 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1202 0 : if (w != nullptr) {
1203 0 : w->getView()->update();
1204 : }
1205 : }
1206 : }
1207 0 : return 1;
1208 0 : }
1209 :
1210 :
1211 : long
1212 0 : GUIApplicationWindow::onCmdReload(FXObject* sender, FXSelector sel, void*) {
1213 0 : if (!myAmLoading && (sender == nullptr || (myRunThread->networkAvailable() && myLoadThread->getFileName() != "" && TraCIServer::getInstance() == nullptr))) {
1214 0 : storeWindowSizeAndPos();
1215 0 : getApp()->beginWaitCursor();
1216 0 : myAmLoading = true;
1217 0 : myIsReload = sender != nullptr || sel == 1;
1218 0 : closeAllWindows();
1219 0 : myLoadThread->start();
1220 0 : if (sender == nullptr) {
1221 0 : setStatusBarText(sel == 1 ? TL("Auto-Reloading.") : TL("TraCI-Loading."));
1222 : } else {
1223 0 : setStatusBarText(TL("Reloading."));
1224 : }
1225 0 : update();
1226 : }
1227 0 : return 1;
1228 : }
1229 :
1230 :
1231 : long
1232 0 : GUIApplicationWindow::onCmdQuickReload(FXObject*, FXSelector, void*) {
1233 0 : if (!myAmLoading) {
1234 0 : setStatusBarText(TL("Quick-Reloading."));
1235 0 : MSNet::getInstance()->quickReload();
1236 : }
1237 0 : return 1;
1238 : }
1239 :
1240 :
1241 : long
1242 0 : GUIApplicationWindow::onCmdOpenRecent(FXObject* /* sender */, FXSelector, void* ptr) {
1243 0 : if (myAmLoading) {
1244 0 : myStatusbar->getStatusLine()->setText(TL("Already loading!"));
1245 0 : return 1;
1246 : }
1247 0 : std::string file((const char*)ptr);
1248 0 : loadConfigOrNet(file);
1249 : return 1;
1250 : }
1251 :
1252 :
1253 : long
1254 0 : GUIApplicationWindow::onCmdSaveConfig(FXObject*, FXSelector, void*) {
1255 : // get the new file name
1256 0 : FXFileDialog opendialog(this, TL("Save SUMO Configuration"));
1257 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::SAVE));
1258 0 : opendialog.setSelectMode(SELECTFILE_ANY);
1259 0 : opendialog.setPatternList(SUMOXMLDefinitions::SumoConfigFileExtensions.getMultilineString().c_str());
1260 0 : if (gCurrentFolder.length() != 0) {
1261 0 : opendialog.setDirectory(gCurrentFolder);
1262 : }
1263 0 : if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1264 : return 1;
1265 : }
1266 0 : const std::string file = MFXUtils::assureExtension(opendialog).text();
1267 0 : std::ofstream out(XMLSubSys::transcodeToLocal(file));
1268 0 : if (out.good()) {
1269 0 : OptionsCont::getOptions().writeConfiguration(out, true, false, false, file, true);
1270 0 : setStatusBarText(TLF("Configuration saved to %.", file));
1271 : } else {
1272 0 : setStatusBarText(TLF("Could not save configuration to %.", file));
1273 : }
1274 0 : out.close();
1275 : return 1;
1276 0 : }
1277 :
1278 :
1279 : long
1280 0 : GUIApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
1281 0 : closeAllWindows();
1282 0 : return 1;
1283 : }
1284 :
1285 :
1286 : long
1287 1907110 : GUIApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void* ptr) {
1288 1907110 : sender->handle(this,
1289 1907110 : myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1290 : ptr);
1291 1907110 : return 1;
1292 : }
1293 :
1294 :
1295 : long
1296 1429173 : GUIApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void* ptr) {
1297 1429173 : sender->handle(this,
1298 1429173 : myAmLoading || !myRunThread->networkAvailable() || TraCIServer::getInstance() != nullptr
1299 : ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1300 : ptr);
1301 1429173 : return 1;
1302 : }
1303 :
1304 :
1305 : long
1306 0 : GUIApplicationWindow::onUpdOpenRecent(FXObject* sender, FXSelector, void* ptr) {
1307 0 : sender->handle(this,
1308 0 : myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1309 : ptr);
1310 0 : return 1;
1311 : }
1312 :
1313 :
1314 : long
1315 1903940 : GUIApplicationWindow::onUpdAddView(FXObject* sender, FXSelector, void* ptr) {
1316 1903940 : sender->handle(this,
1317 1903940 : myAmLoading || !myRunThread->networkAvailable()
1318 : ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1319 : ptr);
1320 1903940 : return 1;
1321 : }
1322 :
1323 :
1324 : long
1325 8531 : GUIApplicationWindow::onCmdStart(FXObject*, FXSelector, void*) {
1326 : // check whether a net was loaded successfully
1327 8531 : if (!myRunThread->networkAvailable()) {
1328 0 : myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
1329 0 : return 1;
1330 : }
1331 : // check whether it was started before and paused;
1332 8531 : if (!myWasStarted) {
1333 8531 : myRunThread->begin();
1334 8531 : myWasStarted = true;
1335 : }
1336 8531 : myRunThread->resume();
1337 8531 : getApp()->forceRefresh(); // only calling myToolBar2->forceRefresh somehow looses keyboard focus
1338 8531 : return 1;
1339 : }
1340 :
1341 :
1342 : long
1343 7985 : GUIApplicationWindow::onCmdStop(FXObject*, FXSelector, void*) {
1344 7985 : myRunThread->stop();
1345 7985 : getApp()->forceRefresh(); // only calling myToolBar2->forceRefresh somehow looses keyboard focus
1346 7985 : return 1;
1347 : }
1348 :
1349 :
1350 : long
1351 0 : GUIApplicationWindow::onCmdStep(FXObject*, FXSelector, void*) {
1352 : // check whether a net was loaded successfully
1353 0 : if (!myRunThread->networkAvailable()) {
1354 0 : myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
1355 0 : return 1;
1356 : }
1357 : // check whether it was started before and paused;
1358 0 : if (!myWasStarted) {
1359 0 : myRunThread->begin();
1360 0 : myWasStarted = true;
1361 : }
1362 0 : myRunThread->singleStep();
1363 0 : return 1;
1364 : }
1365 :
1366 :
1367 : long
1368 0 : GUIApplicationWindow::onCmdSaveState(FXObject*, FXSelector, void*) {
1369 : // get the new file name
1370 0 : FXFileDialog opendialog(this, TL("Save Simulation State"));
1371 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::SAVE));
1372 0 : opendialog.setSelectMode(SELECTFILE_ANY);
1373 0 : opendialog.setPatternList(SUMOXMLDefinitions::StateFileExtensions.getMultilineString().c_str());
1374 0 : if (gCurrentFolder.length() != 0) {
1375 0 : opendialog.setDirectory(gCurrentFolder);
1376 : }
1377 0 : if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1378 : return 1;
1379 : }
1380 0 : const std::string file = MFXUtils::assureExtension(opendialog).text();
1381 0 : MSStateHandler::saveState(file, MSNet::getInstance()->getCurrentTimeStep(), false);
1382 0 : setStatusBarText(TLF("Simulation state saved to '%'.", file));
1383 : return 1;
1384 0 : }
1385 :
1386 :
1387 : long
1388 0 : GUIApplicationWindow::onCmdLoadState(FXObject*, FXSelector, void*) {
1389 : // get the new file name
1390 0 : FXFileDialog opendialog(this, TL("Load Simulation State"));
1391 0 : opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN));
1392 0 : opendialog.setSelectMode(SELECTFILE_ANY);
1393 0 : opendialog.setPatternList(SUMOXMLDefinitions::StateFileExtensions.getMultilineString().c_str());
1394 0 : if (gCurrentFolder.length() != 0) {
1395 0 : opendialog.setDirectory(gCurrentFolder);
1396 : }
1397 0 : if (opendialog.execute() && FXStat::exists(opendialog.getFilename())) {
1398 0 : gCurrentFolder = opendialog.getDirectory();
1399 0 : const std::string file = opendialog.getFilename().text();
1400 : try {
1401 0 : MSNet::getInstance()->loadState(file, true);
1402 0 : setStatusBarText(TLF("State loaded from '%'.", file));
1403 0 : } catch (ProcessError& e) {
1404 0 : setStatusBarText(TLF("Failed to load state from '%' (%).", file, e.what()));
1405 0 : }
1406 : }
1407 0 : return 1;
1408 0 : }
1409 :
1410 :
1411 : long
1412 0 : GUIApplicationWindow::onCmdTimeToggle(FXObject*, FXSelector, void*) {
1413 : // toggle show time as HMS
1414 0 : myShowTimeAsHMS = !myShowTimeAsHMS;
1415 0 : updateTimeLCDTooltip();
1416 0 : if (myRunThread->networkAvailable()) {
1417 0 : updateTimeLCD(myRunThread->getNet().getCurrentTimeStep());
1418 : }
1419 0 : return 1;
1420 : }
1421 :
1422 :
1423 : long
1424 0 : GUIApplicationWindow::onCmdDelayInc(FXObject*, FXSelector, void*) {
1425 0 : if (mySimDelay < 10) {
1426 0 : mySimDelay = 10;
1427 0 : } else if (mySimDelay >= 20 && mySimDelay < 50) {
1428 0 : mySimDelay = 50;
1429 0 : } else if (mySimDelay >= 200 && mySimDelay < 500) {
1430 0 : mySimDelay = 500;
1431 : } else {
1432 0 : mySimDelay *= 2;
1433 : }
1434 0 : if (mySimDelay > 1000) {
1435 : // setting high delay by pressing the key too often is hard to recover from
1436 0 : mySimDelay = 1000;
1437 : }
1438 0 : mySimDelaySlider->setValue((int)mySimDelay);
1439 0 : mySimDelaySpinner->setValue(mySimDelay);
1440 0 : return 1;
1441 : }
1442 :
1443 :
1444 : long
1445 0 : GUIApplicationWindow::onCmdDelayDec(FXObject*, FXSelector, void*) {
1446 0 : if (mySimDelay <= 10) {
1447 0 : mySimDelay = 0;
1448 0 : } else if (mySimDelay > 20 && mySimDelay <= 50) {
1449 0 : mySimDelay = 20;
1450 0 : } else if (mySimDelay > 200 && mySimDelay <= 500) {
1451 0 : mySimDelay = 200;
1452 : } else {
1453 0 : mySimDelay /= 2;
1454 : }
1455 0 : mySimDelaySlider->setValue((int)mySimDelay);
1456 0 : mySimDelaySpinner->setValue(mySimDelay);
1457 0 : return 1;
1458 : }
1459 :
1460 :
1461 : long
1462 0 : GUIApplicationWindow::onCmdDelayToggle(FXObject*, FXSelector, void*) {
1463 0 : const double tmp = myAlternateSimDelay;
1464 0 : myAlternateSimDelay = mySimDelay;
1465 0 : mySimDelay = tmp;
1466 0 : return 1;
1467 : }
1468 :
1469 :
1470 : long
1471 0 : GUIApplicationWindow::onCmdDemandScale(FXObject*, FXSelector, void*) {
1472 0 : if (myRunThread->networkAvailable()) {
1473 0 : myRunThread->getNet().getVehicleControl().setScale(myDemandScaleSpinner->getValue());
1474 : }
1475 0 : return 1;
1476 : }
1477 :
1478 :
1479 : long
1480 0 : GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
1481 0 : myMessageWindow->clear();
1482 0 : return 1;
1483 : }
1484 :
1485 :
1486 : long
1487 0 : GUIApplicationWindow::onCmdBreakpoint(FXObject*, FXSelector, void*) {
1488 : // see updateTimeLCD for the DELTA_T
1489 0 : if (myRunThread->networkAvailable()) {
1490 0 : addBreakpoint(SIMSTEP - DELTA_T);
1491 : }
1492 0 : return 1;
1493 : }
1494 :
1495 :
1496 : long
1497 0 : GUIApplicationWindow::onCmdBreakpointEarly(FXObject*, FXSelector, void*) {
1498 : // see updateTimeLCD for the DELTA_T
1499 0 : if (myRunThread->networkAvailable()) {
1500 0 : addBreakpoint(SIMSTEP - DELTA_T + GUIMessageWindow::getBreakPointOffset());
1501 : }
1502 0 : return 1;
1503 : }
1504 :
1505 :
1506 : long
1507 13145954 : GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
1508 26291908 : sender->handle(this,
1509 14043559 : !myRunThread->simulationIsStartable() || myAmLoading
1510 : ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1511 : ptr);
1512 13145954 : if (myRunThread->simulationIsStartable() && !myAmLoading) {
1513 : // bind start simulation with space key
1514 897614 : GUIShortcutsSubSys::changeAccelerator(getAccelTable(), this, KEY_SPACE, MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS);
1515 : }
1516 13145954 : return 1;
1517 : }
1518 :
1519 :
1520 : long
1521 13145931 : GUIApplicationWindow::onUpdStop(FXObject* sender, FXSelector, void* ptr) {
1522 26291862 : sender->handle(this,
1523 25329184 : !myRunThread->simulationIsStopable() || myAmLoading
1524 : ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1525 : ptr);
1526 13145931 : if (myRunThread->simulationIsStopable() && !myAmLoading) {
1527 : // bind stop simulation with space key
1528 12183249 : GUIShortcutsSubSys::changeAccelerator(getAccelTable(), this, KEY_SPACE, MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK);
1529 : }
1530 13145931 : return 1;
1531 : }
1532 :
1533 :
1534 : long
1535 13145905 : GUIApplicationWindow::onUpdStep(FXObject* sender, FXSelector, void* ptr) {
1536 26291810 : sender->handle(this,
1537 14043543 : !myRunThread->simulationIsStepable() || myAmLoading
1538 : ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1539 : ptr);
1540 13145905 : return 1;
1541 : }
1542 :
1543 :
1544 : long
1545 27566434 : GUIApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void* ptr) {
1546 : // check if there is a loaded network and gui isn't loading
1547 27566434 : if (myRunThread->networkAvailable() && !myAmLoading) {
1548 27216831 : sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1549 : // enable certain elements manually
1550 27216831 : mySelectLanesMenuCascade->enable();
1551 54433662 : myScaleTrafficTooltip->setTipText(TL("Scale number of vehicles in simulation"));
1552 : } else {
1553 349603 : sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
1554 : // disable certain elements manually
1555 349603 : mySelectLanesMenuCascade->disable();
1556 699206 : myScaleTrafficTooltip->setTipText("");
1557 : }
1558 27566434 : return 1;
1559 : }
1560 :
1561 :
1562 : long
1563 950108 : GUIApplicationWindow::onUpdNeedsSumoConfig(FXObject* sender, FXSelector, void* ptr) {
1564 : // check if there is a loaded network and gui isn't loading
1565 1888503 : if (myRunThread->networkAvailable() && !myAmLoading && OptionsCont::getOptions().isSet("configuration-file")) {
1566 5300 : sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1567 5300 : sender->handle(this, FXSEL(SEL_COMMAND, ID_SHOW), ptr);
1568 5300 : myOpenInNetedit->setText(TL("Open sumo config in netedit"));
1569 : } else {
1570 944808 : sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
1571 944808 : sender->handle(this, FXSEL(SEL_COMMAND, ID_HIDE), ptr);
1572 944808 : myOpenInNetedit->setText(TL("Open network in netedit"));
1573 : }
1574 950108 : return 1;
1575 : }
1576 :
1577 :
1578 : long
1579 476941 : GUIApplicationWindow::onUpdTraCIStatus(FXObject* /*sender*/, FXSelector, void* /*ptr*/) {
1580 476941 : if (TraCIServer::getInstance()) {
1581 1110 : myTraCiFrame->show();
1582 : } else {
1583 475831 : myTraCiFrame->hide();
1584 : }
1585 476941 : return 1;
1586 : }
1587 :
1588 :
1589 : long
1590 0 : GUIApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
1591 0 : if (myMDIClient->numChildren() > 0) {
1592 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1593 0 : if (w != nullptr) {
1594 0 : w->onCmdLocate(nullptr, sel, nullptr);
1595 : }
1596 : }
1597 0 : return 1;
1598 : }
1599 :
1600 :
1601 : long
1602 0 : GUIApplicationWindow::onCmdShowStats(FXObject*, FXSelector, void*) {
1603 0 : if (myMDIClient->numChildren() > 0) {
1604 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1605 0 : GUINet::getGUIInstance()->getParameterWindow(*this, *w->getView());
1606 : }
1607 0 : return 1;
1608 : }
1609 :
1610 :
1611 : long
1612 0 : GUIApplicationWindow::onCmdAppSettings(FXObject*, FXSelector, void*) {
1613 0 : GUIDialog_AppSettings* d = new GUIDialog_AppSettings(this);
1614 0 : d->create();
1615 0 : d->show(PLACEMENT_OWNER);
1616 0 : return 1;
1617 : }
1618 :
1619 :
1620 : long
1621 0 : GUIApplicationWindow::onCmdGaming(FXObject*, FXSelector, void*) {
1622 0 : if (myGLWindows.empty()) {
1623 : return 1;
1624 : }
1625 0 : myAmGaming = !myAmGaming;
1626 0 : myGLWindows[0]->getView()->editVisualisationSettings()->gaming = myAmGaming;
1627 0 : if (myAmGaming) {
1628 0 : myGamingModeCheckbox->setCheck(TRUE);
1629 0 : myMenuBar->hide();
1630 0 : myStatusbar->hide();
1631 0 : myToolBar1->hide();
1632 0 : myToolBar2->hide();
1633 0 : myToolBar4->hide();
1634 0 : myToolBar5->hide();
1635 0 : myToolBar6->show();
1636 0 : myToolBar8->hide();
1637 0 : myToolBar10->show();
1638 0 : if (myTLSGame) {
1639 0 : myToolBar7->show();
1640 : } else {
1641 0 : myToolBar9->show();
1642 : }
1643 0 : myMessageWindow->hide();
1644 0 : myLCDLabel->setFgColor(MFXUtils::getFXColor(RGBColor::RED));
1645 0 : myWaitingTimeLabel->setFgColor(MFXUtils::getFXColor(RGBColor::RED));
1646 0 : myTimeLossLabel->setFgColor(MFXUtils::getFXColor(RGBColor::RED));
1647 0 : myEmergencyVehicleLabel->setFgColor(MFXUtils::getFXColor(RGBColor::RED));
1648 0 : myTotalDistanceLabel->setFgColor(MFXUtils::getFXColor(RGBColor::RED));
1649 : } else {
1650 0 : myGamingModeCheckbox->setCheck(FALSE);
1651 0 : myMenuBar->show();
1652 0 : myStatusbar->show();
1653 0 : myToolBar1->show();
1654 0 : myToolBar2->show();
1655 0 : myToolBar4->show();
1656 0 : myToolBar5->show();
1657 0 : myToolBar6->hide();
1658 0 : myToolBar7->hide();
1659 0 : myToolBar8->show();
1660 0 : myToolBar9->hide();
1661 0 : myToolBar10->hide();
1662 0 : myMessageWindow->show();
1663 0 : myLCDLabel->setFgColor(MFXUtils::getFXColor(RGBColor::GREEN));
1664 : }
1665 0 : if (myMDIClient->numChildren() > 0) {
1666 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1667 0 : if (w != nullptr) {
1668 0 : w->setToolBarVisibility(!myAmGaming && !myAmFullScreen);
1669 : }
1670 : }
1671 0 : update();
1672 0 : return 1;
1673 : }
1674 :
1675 :
1676 : long
1677 0 : GUIApplicationWindow::onCmdToggleDrawJunctionShape(FXObject*, FXSelector, void*) {
1678 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1679 0 : if (w != nullptr) {
1680 : // show or hide grid depending of myNetworkViewOptions.menuCheckToggleGrid
1681 0 : if (w->getView()->getVisualisationSettings().drawJunctionShape) {
1682 0 : w->getView()->editVisualisationSettings()->drawJunctionShape = false;
1683 : } else {
1684 0 : w->getView()->editVisualisationSettings()->drawJunctionShape = true;
1685 : }
1686 0 : w->getView()->update();
1687 : }
1688 0 : return 1;
1689 : }
1690 :
1691 :
1692 : long
1693 0 : GUIApplicationWindow::onCmdToggleSecondaryShape(FXObject*, FXSelector, void*) {
1694 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1695 0 : if (w != nullptr) {
1696 : // toggle secondary shape visualization
1697 0 : w->getView()->editVisualisationSettings()->secondaryShape = !w->getView()->getVisualisationSettings().secondaryShape;
1698 0 : w->getView()->update();
1699 : }
1700 0 : return 1;
1701 : }
1702 :
1703 :
1704 : long
1705 0 : GUIApplicationWindow::onCmdFullScreen(FXObject*, FXSelector, void*) {
1706 0 : if (myGLWindows.empty()) {
1707 : return 1;
1708 : }
1709 0 : myAmFullScreen = !myAmFullScreen;
1710 0 : if (myAmFullScreen) {
1711 0 : getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
1712 0 : getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
1713 0 : getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
1714 0 : getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
1715 0 : maximize();
1716 0 : setDecorations(DECOR_NONE);
1717 0 : place(PLACEMENT_MAXIMIZED);
1718 0 : myMenuBar->hide();
1719 0 : myStatusbar->hide();
1720 0 : myToolBar1->hide();
1721 0 : myToolBar2->hide();
1722 0 : myToolBar3->hide();
1723 0 : myToolBar4->hide();
1724 0 : myToolBar5->hide();
1725 0 : myToolBar6->hide();
1726 0 : myToolBar7->hide();
1727 0 : myToolBar8->hide();
1728 0 : myMessageWindow->hide();
1729 0 : if (myMDIClient->numChildren() > 0) {
1730 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
1731 0 : if (w != nullptr) {
1732 0 : w->setToolBarVisibility(false);
1733 : }
1734 : }
1735 0 : update();
1736 : } else {
1737 0 : place(PLACEMENT_VISIBLE);
1738 0 : setDecorations(DECOR_ALL);
1739 0 : restore();
1740 0 : myToolBar3->show();
1741 0 : myAmGaming = !myAmGaming;
1742 0 : onCmdGaming(nullptr, 0, nullptr);
1743 0 : setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
1744 0 : setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
1745 0 : setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
1746 0 : setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
1747 : }
1748 : return 1;
1749 : }
1750 :
1751 :
1752 : long
1753 0 : GUIApplicationWindow::onCmdListInternal(FXObject*, FXSelector, void*) {
1754 0 : myListInternal = !myListInternal;
1755 0 : return 1;
1756 : }
1757 :
1758 :
1759 : long
1760 0 : GUIApplicationWindow::onCmdListParking(FXObject*, FXSelector, void*) {
1761 0 : myListParking = !myListParking;
1762 0 : return 1;
1763 : }
1764 :
1765 : long
1766 0 : GUIApplicationWindow::onCmdListTeleporting(FXObject*, FXSelector, void*) {
1767 0 : myListTeleporting = !myListTeleporting;
1768 0 : return 1;
1769 : }
1770 :
1771 :
1772 : long
1773 0 : GUIApplicationWindow::onCmdNewView(FXObject*, FXSelector, void*) {
1774 0 : openNewView(GUISUMOViewParent::VIEW_2D_OPENGL);
1775 0 : return 1;
1776 : }
1777 :
1778 :
1779 : #ifdef HAVE_OSG
1780 : long
1781 0 : GUIApplicationWindow::onCmdNewOSG(FXObject*, FXSelector, void*) {
1782 0 : openNewView(GUISUMOViewParent::VIEW_3D_OSG);
1783 0 : return 1;
1784 : }
1785 : #endif
1786 :
1787 :
1788 : long
1789 0 : GUIApplicationWindow::onCmdShowToolTipsView(FXObject*, FXSelector, void*) {
1790 : // invert check
1791 0 : myShowToolTipsView->setChecked(!myShowToolTipsView->amChecked());
1792 : // update parent
1793 0 : myStaticTooltipView->enableStaticToolTip(myShowToolTipsView->amChecked());
1794 : // save in registry
1795 0 : getApp()->reg().writeIntEntry("gui", "viewToolTips", myShowToolTipsView->amChecked() ? 1 : 0);
1796 0 : return 1;
1797 : }
1798 :
1799 :
1800 : long
1801 0 : GUIApplicationWindow::onCmdShowToolTipsMenu(FXObject*, FXSelector, void*) {
1802 : // invert check
1803 0 : myShowToolTipsMenu->setChecked(!myShowToolTipsMenu->amChecked());
1804 : // update parent
1805 0 : myStaticTooltipMenu->enableStaticToolTip(myShowToolTipsMenu->amChecked());
1806 : // save in registry
1807 0 : getApp()->reg().writeIntEntry("gui", "menuToolTips", myShowToolTipsMenu->amChecked() ? 0 : 1);
1808 0 : return 1;
1809 : }
1810 :
1811 :
1812 : long
1813 0 : GUIApplicationWindow::onCmdFeedback(FXObject*, FXSelector, void*) {
1814 : // create and open feedback dialog
1815 0 : GUIDialog_Feedback* feedback = new GUIDialog_Feedback(this);
1816 0 : feedback->create();
1817 0 : feedback->show(PLACEMENT_OWNER);
1818 0 : return 1;
1819 : }
1820 :
1821 :
1822 : long
1823 0 : GUIApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
1824 0 : GUIDialog_AboutSUMO* about = new GUIDialog_AboutSUMO(this);
1825 0 : about->create();
1826 0 : about->show(PLACEMENT_OWNER);
1827 0 : return 1;
1828 : }
1829 :
1830 :
1831 : long
1832 0 : GUIApplicationWindow::onCmdHallOfFame(FXObject*, FXSelector, void*) {
1833 0 : GUIDialog_HallOfFame* hall = new GUIDialog_HallOfFame(this);
1834 0 : hall->create();
1835 0 : hall->show(PLACEMENT_OWNER);
1836 0 : return 1;
1837 : }
1838 :
1839 :
1840 0 : long GUIApplicationWindow::onClipboardRequest(FXObject* /* sender */, FXSelector /* sel */, void* ptr) {
1841 : FXEvent* event = (FXEvent*)ptr;
1842 0 : FXString string = GUIUserIO::clipped.c_str();
1843 0 : setDNDData(FROM_CLIPBOARD, event->target, string);
1844 0 : return 1;
1845 0 : }
1846 :
1847 :
1848 : long
1849 67512 : GUIApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
1850 67512 : eventOccurred();
1851 67512 : return 1;
1852 : }
1853 :
1854 :
1855 : long
1856 12126006 : GUIApplicationWindow::onRunThreadEvent(FXObject*, FXSelector, void*) {
1857 12126006 : eventOccurred();
1858 12126006 : return 1;
1859 : }
1860 :
1861 :
1862 : void
1863 12193518 : GUIApplicationWindow::eventOccurred() {
1864 25464689 : while (!myEvents.empty()) {
1865 : // get the next event
1866 13271171 : GUIEvent* e = myEvents.top();
1867 13271171 : myEvents.pop();
1868 : // process
1869 13271171 : switch (e->getOwnType()) {
1870 9020 : case GUIEventType::SIMULATION_LOADED:
1871 9020 : handleEvent_SimulationLoaded(e);
1872 9020 : setFocus();
1873 9020 : break;
1874 13164708 : case GUIEventType::SIMULATION_STEP:
1875 13164708 : if (myRunThread->networkAvailable()) { // avoid race-condition related crash if reload was pressed
1876 13164708 : handleEvent_SimulationStep(e);
1877 : }
1878 : break;
1879 89452 : case GUIEventType::MESSAGE_OCCURRED:
1880 : case GUIEventType::WARNING_OCCURRED:
1881 : case GUIEventType::ERROR_OCCURRED:
1882 : case GUIEventType::DEBUG_OCCURRED:
1883 : case GUIEventType::GLDEBUG_OCCURRED:
1884 : case GUIEventType::STATUS_OCCURRED:
1885 89452 : handleEvent_Message(e);
1886 89452 : break;
1887 : case GUIEventType::ADD_VIEW: {
1888 3 : GUIEvent_AddView* ave = dynamic_cast<GUIEvent_AddView*>(e);
1889 9 : auto v = openNewView(ave->in3D() ? GUISUMOViewParent::VIEW_3D_OSG : GUISUMOViewParent::VIEW_2D_OPENGL, ave->getCaption());
1890 3 : if (ave->getSchemeName() != "") {
1891 3 : MFXComboBoxIcon* sCombo = v->getColoringSchemesCombo();
1892 3 : int index = sCombo->findItem(ave->getSchemeName().c_str());
1893 3 : if (index >= 0) {
1894 3 : sCombo->setCurrentItem(index);
1895 : }
1896 3 : v->setColorScheme(ave->getSchemeName());
1897 : }
1898 : break;
1899 : }
1900 : case GUIEventType::CLOSE_VIEW: {
1901 3 : GUIEvent_CloseView* ave = dynamic_cast<GUIEvent_CloseView*>(e);
1902 3 : removeViewByID(ave->getCaption());
1903 3 : break;
1904 : }
1905 7985 : case GUIEventType::SIMULATION_ENDED:
1906 7985 : handleEvent_SimulationEnded(e);
1907 7985 : break;
1908 : default:
1909 : break;
1910 : }
1911 13271171 : delete e;
1912 : }
1913 12193518 : myToolBar2->forceRefresh();
1914 12193518 : myToolBar3->forceRefresh();
1915 12193518 : }
1916 :
1917 :
1918 : void
1919 9020 : GUIApplicationWindow::handleEvent_SimulationLoaded(GUIEvent* e) {
1920 9020 : myAmLoading = false;
1921 : GUIEvent_SimulationLoaded* ec = static_cast<GUIEvent_SimulationLoaded*>(e);
1922 : // check whether the loading was successful
1923 9020 : if (ec->myNet == nullptr) {
1924 : // report failure
1925 634 : setStatusBarText(TLF("Loading of '%' failed!", ec->myFile));
1926 317 : if (GUIGlobals::gQuitOnEnd) {
1927 317 : closeAllWindows();
1928 317 : getApp()->exit(1);
1929 : }
1930 : } else {
1931 : // initialise simulation thread
1932 8703 : if (!myRunThread->init(ec->myNet, ec->myBegin, ec->myEnd)) {
1933 172 : if (GUIGlobals::gQuitOnEnd) {
1934 172 : closeAllWindows();
1935 172 : getApp()->exit(1);
1936 : }
1937 : } else {
1938 : // report success
1939 17062 : setStatusBarText(TLF("'%' loaded.", ec->myFile));
1940 8531 : setWindowSizeAndPos();
1941 8531 : myWasStarted = false;
1942 8531 : myHaveNotifiedAboutSimEnd = false;
1943 : // initialise views
1944 8531 : myViewNumber = 0;
1945 8531 : const GUISUMOViewParent::ViewType defaultType = ec->myOsgView ? GUISUMOViewParent::VIEW_3D_OSG : GUISUMOViewParent::VIEW_2D_OPENGL;
1946 : // check/record settings file modification time
1947 8531 : long long mTime = myGuiSettingsFileMTime;
1948 8531 : if (ec->mySettingsFiles.size() > 0) {
1949 73 : for (std::string fname : ec->mySettingsFiles) {
1950 37 : mTime = MAX2(mTime, SysUtils::getModifiedTime(fname));
1951 : }
1952 : }
1953 : // always reload if settings were modified or to restore multiple views
1954 8531 : if (!myIsReload) {
1955 : gSchemeStorage.clearDecals();
1956 : }
1957 8531 : if (ec->mySettingsFiles.size() > 0 && (!myIsReload || myGuiSettingsFileMTime < mTime || ec->mySettingsFiles.size() > 1)) {
1958 : // open a view for each file and apply settings
1959 73 : for (std::string fname : ec->mySettingsFiles) {
1960 37 : GUISettingsHandler settings(getApp(), fname);
1961 : GUISUMOViewParent::ViewType vt = defaultType;
1962 37 : if (settings.getViewType() == "osg" || settings.getViewType() == "3d") {
1963 : vt = GUISUMOViewParent::VIEW_3D_OSG;
1964 : }
1965 37 : if (settings.getViewType() == "opengl" || settings.getViewType() == "2d") {
1966 : vt = GUISUMOViewParent::VIEW_2D_OPENGL;
1967 : }
1968 37 : GUISUMOAbstractView* view = openNewView(vt);
1969 37 : if (view == nullptr) {
1970 : break;
1971 : }
1972 37 : if (settings.getSettingName() != "") {
1973 37 : view->setColorScheme(settings.getSettingName());
1974 37 : MFXComboBoxIcon* sCombo = view->getColoringSchemesCombo();
1975 37 : int index = sCombo->findItem(settings.getSettingName().c_str());
1976 37 : if (index >= 0) {
1977 34 : sCombo->setCurrentItem(index);
1978 : }
1979 : }
1980 37 : view->addDecals(settings.getDecals());
1981 37 : settings.applyViewport(view);
1982 37 : settings.setSnapshots(view);
1983 37 : if (settings.getDelay() > 0.) {
1984 5 : mySimDelay = settings.getDelay();
1985 : }
1986 37 : if (settings.getBreakpoints().size() > 0) {
1987 0 : myRunThread->getBreakpointLock().lock();
1988 0 : myRunThread->getBreakpoints().assign(settings.getBreakpoints().begin(), settings.getBreakpoints().end());
1989 0 : myRunThread->getBreakpointLock().unlock();
1990 : }
1991 37 : myJamSounds = settings.getEventDistribution("jam");
1992 74 : myCollisionSounds = settings.getEventDistribution("collision");
1993 37 : if (settings.getJamSoundTime() > 0) {
1994 0 : myJamSoundTime = settings.getJamSoundTime();
1995 : }
1996 37 : for (const std::string& tlsID : settings.getTrackers()) {
1997 0 : if (MSNet::getInstance()->getTLSControl().knows(tlsID)) {
1998 0 : MSTrafficLightLogic* tll = MSNet::getInstance()->getTLSControl().get(tlsID).getActive();
1999 0 : GUITrafficLightLogicWrapper* tllW = GUINet::getGUIInstance()->getTLLWrapper(tll);
2000 0 : if (tllW) {
2001 0 : tllW->begin2TrackPhases(this);
2002 : }
2003 : } else {
2004 0 : WRITE_WARNINGF("Tracker for unknown tlLogic '%' in settings file '%'", tlsID, fname);
2005 : }
2006 37 : }
2007 37 : }
2008 : } else {
2009 16990 : openNewView(defaultType);
2010 : }
2011 8531 : myGuiSettingsFileMTime = mTime;
2012 17062 : if (!OptionsCont::getOptions().isDefault("delay")) {
2013 4 : setDelay(OptionsCont::getOptions().getFloat("delay"));
2014 4 : mySimDelaySlider->setValue((int)mySimDelay);
2015 4 : mySimDelaySpinner->setValue(mySimDelay);
2016 : }
2017 17062 : if (!OptionsCont::getOptions().isDefault("breakpoints") && !myIsReload) {
2018 : std::vector<SUMOTime> breakpoints;
2019 0 : for (const std::string& val : OptionsCont::getOptions().getStringVector("breakpoints")) {
2020 0 : SUMOTime t = string2time(val);
2021 : // round down to nearest reachable time step
2022 0 : t -= t % DELTA_T;
2023 0 : breakpoints.push_back(t);
2024 : }
2025 0 : std::sort(breakpoints.begin(), breakpoints.end());
2026 0 : myRunThread->getBreakpointLock().lock();
2027 0 : myRunThread->getBreakpoints().assign(breakpoints.begin(), breakpoints.end());
2028 0 : myRunThread->getBreakpointLock().unlock();
2029 0 : }
2030 17062 : if (!OptionsCont::getOptions().isDefault("selection-file")) {
2031 0 : delete myDynamicSelection;
2032 0 : myDynamicSelection = new std::stringstream();
2033 0 : std::string msg = gSelected.load(OptionsCont::getOptions().getString("selection-file"), GLO_MAX, myDynamicSelection);
2034 0 : if (msg != "") {
2035 0 : WRITE_ERRORF("Errors while loading selection: %", msg.c_str());
2036 : }
2037 0 : if (!myDynamicSelection->str().empty()) {
2038 : std::string dummy;
2039 : int numNotFound = 0;
2040 0 : while (myDynamicSelection->good()) {
2041 0 : (*myDynamicSelection) >> dummy;
2042 0 : numNotFound++;
2043 : }
2044 0 : myDynamicSelection->clear(); // first clear error state before seek works
2045 0 : myDynamicSelection->seekg(0);
2046 : // @note for some reason the last line is read twice
2047 0 : WRITE_MESSAGEF("% dynamic objects not present while loading selection", numNotFound - 1);
2048 : }
2049 : }
2050 8531 : myTLSGame = OptionsCont::getOptions().getString("game.mode") == "tls";
2051 17062 : if (OptionsCont::getOptions().getBool("game")) {
2052 0 : if (myTLSGame) {
2053 0 : setTitle(TL("SUMO Interactive Traffic Light"));
2054 : } else {
2055 0 : setTitle(TL("SUMO Interactive Demand-Responsive-Transport"));
2056 : }
2057 0 : onCmdGaming(nullptr, 0, nullptr);
2058 : } else {
2059 : // set simulation name on the caption
2060 8531 : setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING, ec->myFile.c_str()));
2061 : }
2062 8531 : if (ec->myViewportFromRegistry) {
2063 : Position off;
2064 0 : off.set(getApp()->reg().readRealEntry("viewport", "x"),
2065 : getApp()->reg().readRealEntry("viewport", "y"),
2066 : getApp()->reg().readRealEntry("viewport", "z"));
2067 : Position p(off.x(), off.y(), 0);
2068 0 : GUISUMOAbstractView* view = myGLWindows[0]->getView();
2069 0 : view->setViewportFromToRot(off, p, 0);
2070 : }
2071 : // set simulation step begin information
2072 8531 : myLCDLabel->setText("----------------");
2073 51186 : for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
2074 42655 : (*it)->setText("-");
2075 : }
2076 : // initialize scale from options unless already set in the UI
2077 8531 : if (myDemandScaleSpinner->getValue() == 1 || !OptionsCont::getOptions().isDefault("scale")) {
2078 17062 : myDemandScaleSpinner->setValue(OptionsCont::getOptions().getFloat("scale"));
2079 : }
2080 8531 : myRunThread->getNet().getVehicleControl().setScale(myDemandScaleSpinner->getValue());
2081 : }
2082 : }
2083 9020 : getApp()->endWaitCursor();
2084 : // start if wished
2085 9020 : if (GUIGlobals::gRunAfterLoad && ec->myNet != nullptr && myRunThread->simulationIsStartable()) {
2086 8531 : onCmdStart(nullptr, 0, nullptr);
2087 : }
2088 9020 : update();
2089 9020 : }
2090 :
2091 :
2092 : void
2093 13164752 : GUIApplicationWindow::handleEvent_SimulationStep(GUIEvent*) {
2094 : #ifdef WIN32
2095 : long t = SysUtils::getCurrentMillis();
2096 : // only skip if the simulation is running
2097 : if (t - myLastStepEventMillis < MIN_DRAW_DELAY && myRunThread->simulationIsStopable()) {
2098 : // do not try to redraw with more than 50FPS (#6371)
2099 : return;
2100 : }
2101 : myLastStepEventMillis = t;
2102 : #endif
2103 13164752 : updateTimeLCD(myRunThread->getNet().getCurrentTimeStep());
2104 13164752 : FXButton* vehStats = myStatButtons[STAT_VEHS];
2105 13164752 : FXButton* delayStats = myStatButtons[STAT_DELAYED];
2106 13164752 : FXButton* teleStats = myStatButtons[STAT_TELEPORTS];
2107 13164752 : FXButton* personStats = myStatButtons[STAT_PERSONS];
2108 13164752 : FXButton* containerStats = myStatButtons[STAT_CONTAINERS];
2109 :
2110 13164752 : const int running = myRunThread->getNet().getVehicleControl().getRunningVehicleNo();
2111 13164752 : const int backlog = myRunThread->getNet().getInsertionControl().getWaitingVehicleNo();
2112 13164752 : const int teleports = myRunThread->getNet().getVehicleControl().getTeleportCount();
2113 13164752 : const int departed = myRunThread->getNet().getVehicleControl().getDepartedVehicleNo();
2114 13164752 : if (backlog > running) {
2115 1350546 : if (vehStats->getIcon() == GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE)) {
2116 1980 : vehStats->setIcon(GUIIconSubSys::getIcon(GUIIcon::YELLOWVEHICLE));
2117 : }
2118 : } else {
2119 11814206 : if (vehStats->getIcon() == GUIIconSubSys::getIcon(GUIIcon::YELLOWVEHICLE)) {
2120 1871 : vehStats->setIcon(GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE));
2121 : }
2122 : }
2123 13164752 : vehStats->setText(toString(running).c_str());
2124 13164752 : if (backlog > 0) {
2125 1936265 : if (!delayStats->shown()) {
2126 18770 : delayStats->show();
2127 : }
2128 3872530 : delayStats->setText(toString(backlog).c_str());
2129 : } else {
2130 11228487 : if (delayStats->shown()) {
2131 18575 : delayStats->hide();
2132 : }
2133 : }
2134 13164752 : if (teleports > 0) {
2135 468718 : if (!teleStats->shown()) {
2136 255 : teleStats->show();
2137 : }
2138 1406154 : teleStats->setText((toString(100.00 * teleports / departed) + "%").c_str());
2139 : }
2140 13164752 : if (myRunThread->getNet().hasPersons()) {
2141 1272604 : if (!personStats->shown()) {
2142 1568 : personStats->show();
2143 : }
2144 2545208 : personStats->setText(toString(myRunThread->getNet().getPersonControl().getRunningNumber()).c_str());
2145 : }
2146 13164752 : if (myRunThread->getNet().hasContainers()) {
2147 107576 : if (!containerStats->shown()) {
2148 169 : containerStats->show();
2149 : }
2150 215152 : containerStats->setText(toString(myRunThread->getNet().getContainerControl().getRunningNumber()).c_str());
2151 : }
2152 13164752 : if (myAmGaming) {
2153 0 : if (myTLSGame) {
2154 0 : checkGamingEvents();
2155 : } else {
2156 0 : checkGamingEventsDRT();
2157 : }
2158 : }
2159 13164752 : if (myRunThread->simulationIsStartable()) {
2160 440886 : getApp()->forceRefresh(); // restores keyboard focus
2161 : }
2162 : // try to load dynamic selection
2163 13164752 : if (myDynamicSelection != nullptr) {
2164 0 : std::stringstream tmp;
2165 0 : gSelected.load(*myDynamicSelection, GLO_MAX, &tmp);
2166 0 : if (tmp.str().empty()) {
2167 0 : delete myDynamicSelection;
2168 0 : myDynamicSelection = nullptr;
2169 : } else {
2170 0 : myDynamicSelection->str(tmp.str());
2171 0 : myDynamicSelection->clear(); // first clear error state before seek works
2172 0 : myDynamicSelection->seekg(0);
2173 : }
2174 0 : }
2175 13164752 : updateChildren();
2176 13164752 : update();
2177 13164752 : }
2178 :
2179 :
2180 : void
2181 89452 : GUIApplicationWindow::handleEvent_Message(GUIEvent* e) {
2182 : GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
2183 89452 : if (ec->getOwnType() == GUIEventType::STATUS_OCCURRED) {
2184 9018 : setStatusBarText(ec->getMsg());
2185 : } else {
2186 80434 : myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
2187 : }
2188 89452 : }
2189 :
2190 :
2191 : void
2192 7985 : GUIApplicationWindow::handleEvent_SimulationEnded(GUIEvent* e) {
2193 : GUIEvent_SimulationEnded* ec = static_cast<GUIEvent_SimulationEnded*>(e);
2194 7985 : onCmdStop(nullptr, 0, nullptr);
2195 7985 : if (ec->getReason() == MSNet::SIMSTATE_LOADING) {
2196 0 : onCmdReload(nullptr, 0, nullptr);
2197 7985 : } else if (GUIGlobals::gQuitOnEnd) {
2198 7985 : closeAllWindows();
2199 7985 : getApp()->exit(ec->getReason() == MSNet::SIMSTATE_ERROR_IN_SIM);
2200 0 : } else if (GUIGlobals::gDemoAutoReload) {
2201 0 : onCmdReload(nullptr, 1, nullptr);
2202 0 : } else if (!myHaveNotifiedAboutSimEnd) {
2203 : // GUIRunThread::deleteSim() triggers the final message to the log file
2204 : // (this will never reach the GUI but we cannot use WRITE_MESSAGE here
2205 : // to avoid a duplicate log entry)
2206 0 : myMessageWindow->appendMsg(GUIEventType::MESSAGE_OCCURRED,
2207 0 : TLF("Simulation ended at time: %. (%)",
2208 0 : time2string(ec->getTimeStep()), MSNet::getStateMessage(ec->getReason())) + "\n");
2209 : // build the text
2210 0 : const std::string text = TLF("Simulation ended at time: %.", time2string(ec->getTimeStep())) + "\n" +
2211 0 : TL("Reason:") + MSNet::getStateMessage(ec->getReason()) + "\n" +
2212 0 : TL("Do you want to close all open files and views?");
2213 0 : FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, TL("Simulation ended"), "%s", text.c_str());
2214 0 : if (answer == 1) { //1:yes, 2:no, 4:esc
2215 0 : closeAllWindows();
2216 : } else {
2217 0 : GUINet::getGUIInstance()->flushOutputsAtEnd();
2218 0 : updateChildren();
2219 0 : update();
2220 : }
2221 0 : myHaveNotifiedAboutSimEnd = true;
2222 : }
2223 7985 : }
2224 :
2225 :
2226 : void
2227 0 : GUIApplicationWindow::checkGamingEvents() {
2228 0 : MSVehicleControl& vc = MSNet::getInstance()->getVehicleControl();
2229 : MSVehicleControl::constVehIt it = vc.loadedVehBegin();
2230 : MSVehicleControl::constVehIt end = vc.loadedVehEnd();
2231 : #ifdef HAVE_DANGEROUS_SOUNDS // disable user-configurable command execution for public build
2232 : if (myJamSounds.getOverallProb() > 0) {
2233 : // play honking sound if some vehicle is waiting too long
2234 : for (; it != end; ++it) {
2235 : // XXX use impatience instead of waiting time ?
2236 : if (it->second->getWaitingTime() > TIME2STEPS(myJamSoundTime)) {
2237 : const std::string cmd = myJamSounds.get(&myGamingRNG);
2238 : if (cmd != "") {
2239 : // yay! fun with dangerous commands... Never use this over the internet
2240 : SysUtils::runHiddenCommand(cmd);
2241 : // one sound per simulation step is enough
2242 : break;
2243 : }
2244 : }
2245 : }
2246 : }
2247 : if (myCollisionSounds.getOverallProb() > 0) {
2248 : int collisions = MSNet::getInstance()->getVehicleControl().getCollisionCount();
2249 : if (myPreviousCollisionNumber != collisions) {
2250 : const std::string cmd = myCollisionSounds.get(&myGamingRNG);
2251 : if (cmd != "") {
2252 : // yay! fun with dangerous commands... Never use this over the internet
2253 : SysUtils::runHiddenCommand(cmd);
2254 : }
2255 : myPreviousCollisionNumber = collisions;
2256 : }
2257 : }
2258 : #endif
2259 : // update performance indicators
2260 0 : for (it = vc.loadedVehBegin(); it != end; ++it) {
2261 0 : const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
2262 : assert(veh != 0);
2263 0 : if (veh->isOnRoad() && !veh->isStopped()) {
2264 0 : const double vmax = veh->getLane()->getVehicleMaxSpeed(veh);
2265 0 : if (veh->getSpeed() < SUMO_const_haltingSpeed) {
2266 0 : myWaitingTime += DELTA_T;
2267 0 : if (veh->getVClass() == SVC_EMERGENCY) {
2268 0 : myEmergencyVehicleCount += DELTA_T;
2269 : }
2270 : }
2271 0 : myTimeLoss += TIME2STEPS(TS * (vmax - veh->getSpeed()) / vmax); // may be negative with speedFactor > 1
2272 : }
2273 :
2274 : }
2275 0 : myWaitingTimeLabel->setText(time2string(myWaitingTime, myShowTimeAsHMS).c_str());
2276 0 : myTimeLossLabel->setText(time2string(myTimeLoss, myShowTimeAsHMS).c_str());
2277 0 : myEmergencyVehicleLabel->setText(time2string(myEmergencyVehicleCount, myShowTimeAsHMS).c_str());
2278 0 : }
2279 :
2280 :
2281 : void
2282 0 : GUIApplicationWindow::checkGamingEventsDRT() {
2283 : // update performance indicators
2284 0 : MSTransportableControl& pc = myRunThread->getNet().getPersonControl();
2285 0 : myWaitingTime += pc.getWaitingForVehicleNumber() * DELTA_T;
2286 0 : myWaitingTimeLabel->setText(time2string(myWaitingTime).c_str());
2287 :
2288 0 : MSVehicleControl& vc = MSNet::getInstance()->getVehicleControl();
2289 : MSVehicleControl::constVehIt end = vc.loadedVehEnd();
2290 0 : for (auto it = vc.loadedVehBegin(); it != end; ++it) {
2291 0 : const MSVehicle* veh = dynamic_cast<MSVehicle*>(it->second);
2292 : assert(veh != 0);
2293 0 : if (veh->isOnRoad() && !veh->isStopped()) {
2294 0 : myTotalDistance += SPEED2DIST(veh->getSpeed());
2295 : }
2296 : }
2297 0 : myTotalDistanceLabel->setText(toString(myTotalDistance / 100).c_str());
2298 0 : }
2299 :
2300 :
2301 : void
2302 9020 : GUIApplicationWindow::loadConfigOrNet(const std::string& file) {
2303 9020 : if (!myAmLoading) {
2304 9020 : storeWindowSizeAndPos();
2305 9020 : getApp()->beginWaitCursor();
2306 9020 : myAmLoading = true;
2307 9020 : myIsReload = false;
2308 9020 : closeAllWindows();
2309 9020 : gSchemeStorage.saveViewport(0, 0, -1, 0); // recenter view
2310 9020 : myLoadThread->loadConfigOrNet(file);
2311 18040 : setStatusBarText(TLF("Loading '%'.", file));
2312 9020 : update();
2313 : }
2314 9020 : }
2315 :
2316 :
2317 : GUISUMOAbstractView*
2318 8535 : GUIApplicationWindow::openNewView(GUISUMOViewParent::ViewType vt, std::string caption) {
2319 8535 : if (!myRunThread->networkAvailable()) {
2320 0 : myStatusbar->getStatusLine()->setText(TL("No simulation loaded!"));
2321 0 : return nullptr;
2322 : }
2323 : GUISUMOAbstractView* oldView = nullptr;
2324 8535 : if (myMDIClient->numChildren() > 0) {
2325 4 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2326 4 : if (w != nullptr) {
2327 4 : oldView = w->getView();
2328 : }
2329 : }
2330 8535 : if (caption == "") {
2331 25596 : caption = "View #" + toString(myViewNumber++);
2332 : }
2333 : FXuint opts = MDI_TRACKING;
2334 17070 : GUISUMOViewParent* w = new GUISUMOViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()),
2335 8535 : this, GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI), opts, 10, 10, 200, 100);
2336 8535 : GUISUMOAbstractView* v = w->init(getBuildGLCanvas(), myRunThread->getNet(), vt);
2337 8535 : if (oldView != nullptr) {
2338 : // copy viewport
2339 4 : oldView->copyViewportTo(v);
2340 : }
2341 8535 : w->create();
2342 8535 : if (myMDIClient->numChildren() == 1) {
2343 8531 : w->maximize();
2344 : } else {
2345 4 : myMDIClient->vertical(true);
2346 : }
2347 8535 : myMDIClient->setActiveChild(w);
2348 :
2349 8535 : return v;
2350 : }
2351 :
2352 :
2353 : FXGLCanvas*
2354 8535 : GUIApplicationWindow::getBuildGLCanvas() const {
2355 8535 : if (myMDIClient->numChildren() == 0) {
2356 : return nullptr;
2357 : }
2358 : GUISUMOViewParent* share_tmp1 =
2359 8535 : static_cast<GUISUMOViewParent*>(myMDIClient->childAtIndex(0));
2360 8535 : return share_tmp1->getBuildGLCanvas();
2361 : }
2362 :
2363 :
2364 : void
2365 26487 : GUIApplicationWindow::closeAllWindows() {
2366 26487 : myTrackerLock.lock();
2367 26487 : myLCDLabel->setText("----------------");
2368 158922 : for (std::vector<FXButton*>::const_iterator it = myStatButtons.begin(); it != myStatButtons.end(); ++it) {
2369 132435 : (*it)->setText("-");
2370 132435 : if (it != myStatButtons.begin()) {
2371 105948 : (*it)->hide();
2372 : }
2373 : }
2374 : // save decals and viewport
2375 34992 : for (GUIGlChildWindow* window : myGLWindows) {
2376 8505 : GUISUMOAbstractView* view = window->getView();
2377 8505 : gSchemeStorage.saveDecals(view->getDecals());
2378 8505 : gSchemeStorage.saveViewport(view->getChanger().getXPos(), view->getChanger().getYPos(),
2379 8505 : view->getChanger().getZPos(), view->getChanger().getRotation());
2380 : }
2381 : // delete the simulation
2382 26487 : myRunThread->deleteSim();
2383 : // reset the caption
2384 26487 : setTitle(MFXUtils::getTitleText("SUMO " VERSION_STRING));
2385 : // clear decals and release GPU textures
2386 34992 : for (GUIGlChildWindow* window : myGLWindows) {
2387 8505 : GUISUMOAbstractView* view = window->getView();
2388 8505 : if (view->makeCurrent()) {
2389 8505 : view->clearDecals();
2390 8505 : view->processPendingTextureDeletes();
2391 8505 : GUITextureSubSys::resetTextures();
2392 8505 : GLHelper::resetFont();
2393 8505 : view->makeNonCurrent();
2394 : }
2395 : }
2396 : // remove trackers and other external windows (must be delayed until deleteSim)
2397 34992 : while (!myGLWindows.empty()) {
2398 8505 : delete myGLWindows.front();
2399 : }
2400 : // make a copy because deleting modifyes the vector;
2401 26487 : std::vector<FXMainWindow*> trackerWindows = myTrackerWindows;
2402 26487 : for (FXMainWindow* const window : trackerWindows) {
2403 0 : delete window;
2404 : }
2405 : myTrackerWindows.clear();
2406 : // clear selected items
2407 26487 : gSelected.clear();
2408 : // add a separator to the log
2409 26487 : myMessageWindow->addSeparator();
2410 26487 : myTrackerLock.unlock();
2411 : // remove coordinate information
2412 26487 : myGeoCoordinate->setText(TL("N/A"));
2413 26487 : myGeoCoordinate->disable();
2414 26487 : myGeoCoordinate->setEditable(false);
2415 26487 : myCartesianCoordinate->setText(TL("N/A"));
2416 26487 : if (myTestCoordinate) {
2417 0 : myTestCoordinate->setText(TL("N/A"));
2418 : }
2419 26487 : update();
2420 26487 : }
2421 :
2422 :
2423 : FXCursor*
2424 0 : GUIApplicationWindow::getDefaultCursor() {
2425 0 : return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
2426 : }
2427 :
2428 :
2429 : SUMOTime
2430 0 : GUIApplicationWindow::getCurrentSimTime() const {
2431 0 : return myRunThread->getNet().getCurrentTimeStep();
2432 : }
2433 :
2434 :
2435 : double
2436 0 : GUIApplicationWindow::getTrackerInterval() const {
2437 0 : return GUIGlobals::gTrackerInterval;
2438 : }
2439 :
2440 :
2441 : void
2442 9020 : GUIApplicationWindow::loadOnStartup(const bool wait) {
2443 9020 : loadConfigOrNet("");
2444 9020 : if (wait) {
2445 1499 : while (myAmLoading) {
2446 953 : myRunThread->sleep(50);
2447 : }
2448 : }
2449 9020 : }
2450 :
2451 :
2452 : void
2453 35906 : GUIApplicationWindow::setStatusBarText(const std::string& text) {
2454 35906 : myStatusbar->getStatusLine()->setText(text.c_str());
2455 35906 : myStatusbar->getStatusLine()->setNormalText(text.c_str());
2456 35906 : }
2457 :
2458 :
2459 : void
2460 8665 : GUIApplicationWindow::addRecentNetwork(const FX::FXString& f) {
2461 8665 : myRecentNetworks.appendFile(f);
2462 8665 : }
2463 :
2464 :
2465 : void
2466 353 : GUIApplicationWindow::addRecentConfig(const FX::FXString& f) {
2467 353 : myRecentConfigs.appendFile(f);
2468 353 : }
2469 :
2470 :
2471 : void
2472 9020 : GUIApplicationWindow::updateTimeLCDTooltip() {
2473 9020 : if (myShowTimeAsHMS) {
2474 0 : myLCDLabel->setToolTipText("HH:MM:SS");
2475 0 : if (myAmGaming) {
2476 0 : myWaitingTimeLabel->setToolTipText("HH:MM:SS");
2477 0 : myTimeLossLabel->setToolTipText("HH:MM:SS");
2478 0 : myEmergencyVehicleLabel->setToolTipText("HH:MM:SS");
2479 : }
2480 : } else {
2481 9020 : myLCDLabel->setToolTipText(TL("seconds"));
2482 9020 : if (myAmGaming) {
2483 0 : myWaitingTimeLabel->setToolTipText(TL("seconds"));
2484 0 : myTimeLossLabel->setToolTipText(TL("seconds"));
2485 0 : myEmergencyVehicleLabel->setToolTipText(TL("seconds"));
2486 : }
2487 : }
2488 9020 : }
2489 :
2490 :
2491 : void
2492 13164752 : GUIApplicationWindow::updateTimeLCD(SUMOTime time) {
2493 13164752 : time -= DELTA_T; // synchronize displayed time with netstate output
2494 13164752 : if (time < 0) {
2495 5 : myLCDLabel->setText("----------------");
2496 5 : return;
2497 : }
2498 13164747 : if (myAmGaming) {
2499 : // show time counting backwards
2500 0 : time = myRunThread->getSimEndTime() - time;
2501 : }
2502 13164747 : std::ostringstream str;
2503 : str << std::setfill('0');
2504 13164747 : const bool hideFraction = myAmGaming || DELTA_T % 1000 == 0;
2505 13164747 : if (myShowTimeAsHMS) {
2506 0 : SUMOTime day = time / SUMOTime_DAY;
2507 0 : if (day > 0) {
2508 0 : str << day << '-';
2509 0 : time %= SUMOTime_DAY;
2510 : }
2511 : str << std::setw(2);
2512 0 : str << time / SUMOTime_HOUR << '-';
2513 0 : time %= SUMOTime_HOUR;
2514 0 : str << std::setw(2) << time / SUMOTime_MINUTE << '-';
2515 0 : time %= SUMOTime_MINUTE;
2516 : }
2517 13164747 : str << std::setw(2) << time / 1000;
2518 13164747 : if (!hideFraction) {
2519 1609821 : str << '.' << std::setw(3) << time % 1000;
2520 : }
2521 13164747 : myLCDLabel->setText(str.str().c_str());
2522 13164747 : }
2523 :
2524 :
2525 : void
2526 98 : GUIApplicationWindow::addHotkey(int key, Command* press, Command* release) {
2527 98 : if (press != nullptr) {
2528 98 : myHotkeyPress[key] = press;
2529 : }
2530 98 : if (release != nullptr) {
2531 96 : myHotkeyRelease[key] = release;
2532 : }
2533 98 : }
2534 :
2535 :
2536 : long
2537 0 : GUIApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* ptr) {
2538 : FXEvent* e = (FXEvent*) ptr;
2539 0 : if (e->code == KEY_Escape) {
2540 0 : if (myGeoCoordinate && myGeoCoordinate->hasFocus()) {
2541 0 : myGeoCoordinate->killFocus();
2542 0 : if (getActiveView()) {
2543 0 : getActiveView()->updatePositionInformationLabel();
2544 : }
2545 0 : return 1;
2546 : }
2547 0 : if (myCartesianCoordinate && myCartesianCoordinate->hasFocus()) {
2548 0 : myCartesianCoordinate->killFocus();
2549 0 : if (getActiveView()) {
2550 0 : getActiveView()->updatePositionInformationLabel();
2551 : }
2552 0 : return 1;
2553 : }
2554 : }
2555 : // PgUp and PgDown switch between widgets by default and binding them via menu shortcuts does not work reliably
2556 : // so we must intercept them before FXMainWindow can handle it
2557 0 : if (e->code == FX::KEY_Page_Up) {
2558 0 : onCmdDelayInc(nullptr, 0, nullptr);
2559 0 : } else if (e->code == FX::KEY_Page_Down) {
2560 0 : onCmdDelayDec(nullptr, 0, nullptr);
2561 : } else {
2562 : // disable hotkeys without modifiers for the game
2563 0 : const bool ignoreSimple = myAmGaming && (e->state & (CONTROLMASK | SHIFTMASK | ALTMASK)) == 0;
2564 0 : const long handled = ignoreSimple ? 0 : FXMainWindow::onKeyPress(o, sel, ptr);
2565 0 : if (handled == 0 && myMDIClient->numChildren() > 0) {
2566 : auto it = myHotkeyPress.find(e->code);
2567 0 : if (it != myHotkeyPress.end()) {
2568 0 : it->second->execute(SIMSTEP);
2569 : }
2570 0 : if (!ignoreSimple) {
2571 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2572 0 : if (w != nullptr) {
2573 0 : w->onKeyPress(nullptr, sel, ptr);
2574 : }
2575 : }
2576 : }
2577 : }
2578 : return 0;
2579 : }
2580 :
2581 :
2582 : long
2583 0 : GUIApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* ptr) {
2584 0 : const long handled = FXMainWindow::onKeyRelease(o, sel, ptr);
2585 0 : if (handled == 0 && myMDIClient->numChildren() > 0) {
2586 : FXEvent* e = (FXEvent*) ptr;
2587 : auto it = myHotkeyRelease.find(e->code);
2588 0 : if (it != myHotkeyRelease.end()) {
2589 0 : it->second->execute(SIMSTEP);
2590 : }
2591 0 : GUISUMOViewParent* w = dynamic_cast<GUISUMOViewParent*>(myMDIClient->getActiveChild());
2592 0 : if (w != nullptr) {
2593 0 : w->onKeyRelease(nullptr, sel, ptr);
2594 : }
2595 : }
2596 0 : return 0;
2597 : }
2598 :
2599 :
2600 : double
2601 0 : GUIApplicationWindow::getDelay() const {
2602 0 : return mySimDelay;
2603 : }
2604 :
2605 :
2606 : void
2607 4 : GUIApplicationWindow::setDelay(double delay) {
2608 4 : mySimDelay = delay;
2609 4 : }
2610 :
2611 :
2612 : void
2613 6 : GUIApplicationWindow::sendBlockingEvent(GUIEvent* event) {
2614 6 : myEventMutex.lock();
2615 6 : myEvents.push_back(event);
2616 6 : myRunThreadEvent.signal();
2617 : //myEventCondition.wait(myEventMutex);
2618 6 : myEventMutex.unlock();
2619 6 : }
2620 :
2621 :
2622 : void
2623 0 : GUIApplicationWindow::setBreakpoints(const std::vector<SUMOTime>& breakpoints) {
2624 0 : if (myRunThread != nullptr) {
2625 0 : myRunThread->getBreakpointLock().lock();
2626 0 : myRunThread->getBreakpoints().assign(breakpoints.begin(), breakpoints.end());
2627 0 : myRunThread->getBreakpointLock().unlock();
2628 0 : updateChildren(MID_TIMELINK_BREAKPOINT);
2629 : }
2630 0 : }
2631 :
2632 :
2633 : void
2634 0 : GUIApplicationWindow::addBreakpoint(SUMOTime time) {
2635 0 : const SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
2636 0 : if (time >= begin) {
2637 : // ensure breakpoint is valid
2638 0 : time -= (time - begin) % DELTA_T;
2639 0 : std::vector<SUMOTime> breakpoints = retrieveBreakpoints();
2640 0 : if (std::find(breakpoints.begin(), breakpoints.end(), time) == breakpoints.end()) {
2641 0 : breakpoints.push_back(time);
2642 0 : std::sort(breakpoints.begin(), breakpoints.end());
2643 0 : setBreakpoints(breakpoints);
2644 0 : setStatusBarText(TLF("Set breakpoint at %", time2string(time)));
2645 : }
2646 0 : }
2647 0 : }
2648 :
2649 :
2650 : const std::vector<SUMOTime>
2651 0 : GUIApplicationWindow::retrieveBreakpoints() const {
2652 0 : myRunThread->getBreakpointLock().lock();
2653 0 : std::vector<SUMOTime> result = myRunThread->getBreakpoints();
2654 0 : myRunThread->getBreakpointLock().unlock();
2655 0 : return result;
2656 0 : }
2657 :
2658 :
2659 : void
2660 0 : GUIApplicationWindow::eraseBreakpointDialog() {
2661 0 : myBreakpointDialog = nullptr;
2662 0 : }
2663 :
2664 : /****************************************************************************/
|