Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/gui/GUIApplicationWindow.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Christian Roessel
18
/// @author Michael Behrisch
19
/// @date Sept 2002
20
///
21
// The main window of the SUMO-gui.
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <utils/foxtools/MFXRecentNetworks.h>
27
#include <utils/foxtools/MFXInterThreadEventClient.h>
28
#include <utils/gui/windows/GUIMainWindow.h>
29
30
#include "GUISUMOViewParent.h"
31
32
33
// ===========================================================================
34
// class declarations
35
// ===========================================================================
36
37
class Command;
38
class GUILoadThread;
39
class GUIRunThread;
40
class GUIMessageWindow;
41
class GUIEvent;
42
class GUIParameterTracker;
43
class GUIParameterTableWindow;
44
class GUIDialog_Breakpoints;
45
class MFXLCDLabel;
46
class MFXLabelTooltip;
47
48
49
// ===========================================================================
50
// class definition
51
// ===========================================================================
52
/**
53
* @class GUIApplicationWindow
54
* @brief The main window of the SUMO-gui.
55
*
56
* Beside views on the simulation, shown within a MDI-window, the main window
57
* may also have some further views (children) assigned which are stored
58
* within a separate list.
59
*/
60
class GUIApplicationWindow : public GUIMainWindow, public MFXInterThreadEventClient {
61
// FOX-declarations
62
FXDECLARE(GUIApplicationWindow)
63
64
public:
65
/// @brief Constructor
66
GUIApplicationWindow(FXApp* a);
67
68
/// @brief Destructor
69
virtual ~GUIApplicationWindow();
70
71
/// @name FOX-interactions
72
/// {
73
74
/// @brief Creates the main window (required by FOX)
75
virtual void create();
76
77
/// @brief Detaches the tool/menu bar
78
virtual void detach();
79
80
/// @}
81
82
/// @brief config or net on startup
83
void loadOnStartup(const bool wait = false);
84
85
/// @brief get run thread
86
GUIRunThread* getRunner();
87
88
/// @brief build dependt
89
void dependentBuild(const bool isLibsumo);
90
91
/// @brief set status bar text
92
void setStatusBarText(const std::string& text);
93
94
/// @brief add recent network to recent file list
95
void addRecentNetwork(const FX::FXString& f);
96
97
/// @brief add recent config to recent file list
98
void addRecentConfig(const FX::FXString& f);
99
100
/// @brief get build GLCanvas
101
FXGLCanvas* getBuildGLCanvas() const;
102
103
/// @brief get current simulation time
104
SUMOTime getCurrentSimTime() const;
105
106
/// @brief get tracker interval
107
double getTrackerInterval() const;
108
109
/// @brief get default cursor
110
FXCursor* getDefaultCursor();
111
112
/// @name Inter-thread event handling
113
/// @{
114
115
/// @brief a certain event ocurred
116
virtual void eventOccurred();
117
118
/// @brief called when event "simulation loaded" ocurred
119
void handleEvent_SimulationLoaded(GUIEvent* e);
120
121
/// @brief called when event "simulation step" ocurred
122
void handleEvent_SimulationStep(GUIEvent* e);
123
124
/// @brief called when event "message" ocurred
125
void handleEvent_Message(GUIEvent* e);
126
127
/// @brief called when event "simulation ended" ocurred
128
void handleEvent_SimulationEnded(GUIEvent* e);
129
130
/// @}
131
132
/// @name FOX-callbacks
133
/// @{
134
135
/// @brief Called on menu File->New Window
136
long onCmdNewWindow(FXObject*, FXSelector, void*);
137
138
/// @brief Called on menu File->Open Configuration
139
long onCmdOpenConfiguration(FXObject*, FXSelector, void*);
140
141
/// @brief Called on menu File->Open Network
142
long onCmdOpenNetwork(FXObject*, FXSelector, void*);
143
144
/// @brief Called on menu File->Load Shapes
145
long onCmdOpenShapes(FXObject*, FXSelector, void*);
146
147
/// @brief Called on menu File->Load EdgeData
148
long onCmdOpenEdgeData(FXObject*, FXSelector, void*);
149
150
/// @brief Called on reload
151
long onCmdReload(FXObject*, FXSelector, void*);
152
153
/// @brief Called on quick-reload
154
long onCmdQuickReload(FXObject*, FXSelector, void*);
155
156
/// @brief Called on opening a recent file
157
long onCmdOpenRecent(FXObject*, FXSelector, void*);
158
159
/// @brief Called on menu File->Close
160
long onCmdSaveConfig(FXObject*, FXSelector, void*);
161
162
/// @brief Called on menu File->Close
163
long onCmdClose(FXObject*, FXSelector, void*);
164
165
/// @brief Called by FOX if the application shall be closed (Called either by FileMenu->Quit, the normal close-menu or SIGINT)
166
long onCmdQuit(FXObject*, FXSelector, void*);
167
168
/// @brief Called on menu Edit->Edit Chosen
169
long onCmdEditChosen(FXObject*, FXSelector, void*);
170
171
/// @brief Called on menu Edit->Edit Breakpoints
172
long onCmdEditBreakpoints(FXObject*, FXSelector, void*);
173
174
/// @brief Called on menu Edit->Visualization
175
long onCmdEditViewScheme(FXObject*, FXSelector, void*);
176
177
/// @brief Called on menu Edit->Viewport
178
long onCmdEditViewport(FXObject*, FXSelector, void*);
179
180
/// @brief called if the user selects help->Documentation
181
long onCmdHelp(FXObject* sender, FXSelector sel, void* ptr);
182
183
/// @brief called if the user selects help->Changelog
184
long onCmdChangelog(FXObject* sender, FXSelector sel, void* ptr);
185
186
/// @brief called if the user selects help->Hotkeys
187
long onCmdHotkeys(FXObject* sender, FXSelector sel, void* ptr);
188
189
/// @brief called if the user selects help->Tutorial
190
long onCmdTutorial(FXObject* sender, FXSelector sel, void* ptr);
191
192
/// @brief Called on menu Edit->open in Netedit
193
long onCmdOpenInNetedit(FXObject*, FXSelector, void*);
194
195
/// @brief Opens the application settings menu (Settings->Application Settings...)
196
long onCmdAppSettings(FXObject*, FXSelector, void*);
197
198
/// @brief Toggle gaming mode
199
long onCmdGaming(FXObject*, FXSelector, void*);
200
201
/// @brief Toggle draw junction shape
202
long onCmdToggleDrawJunctionShape(FXObject*, FXSelector, void*);
203
204
/// @brief Toggle draw junction shape
205
long onCmdToggleSecondaryShape(FXObject*, FXSelector, void*);
206
207
/// @brief Toggle full screen mode
208
long onCmdFullScreen(FXObject*, FXSelector, void*);
209
210
/// @brief Toggle listing of internal structures
211
long onCmdListInternal(FXObject*, FXSelector, void*);
212
213
/// @brief Toggle listing of parking vehicles
214
long onCmdListParking(FXObject*, FXSelector, void*);
215
216
/// @brief Toggle listing of teleporting vehicles
217
long onCmdListTeleporting(FXObject*, FXSelector, void*);
218
219
/// @brief Shows the feedback dialog
220
long onCmdFeedback(FXObject*, FXSelector, void*);
221
222
/// @brief Shows the about dialog
223
long onCmdAbout(FXObject*, FXSelector, void*);
224
225
/// @brief Shows the Hall of Fame dialog
226
long onCmdHallOfFame(FXObject*, FXSelector, void*);
227
228
/// @brief Called on "play"
229
long onCmdStart(FXObject*, FXSelector, void*);
230
231
/// @brief Called on "stop"
232
long onCmdStop(FXObject*, FXSelector, void*);
233
234
/// @brief Called on "step"
235
long onCmdStep(FXObject*, FXSelector, void*);
236
237
/// @brief Called on "save state"
238
long onCmdSaveState(FXObject*, FXSelector, void*);
239
240
/// @brief Called on "save state"
241
long onCmdLoadState(FXObject*, FXSelector, void*);
242
243
/// @brief Called on "time toggle"
244
long onCmdTimeToggle(FXObject*, FXSelector, void*);
245
246
/// @brief Called on "delay inc"
247
long onCmdDelayInc(FXObject*, FXSelector, void*);
248
249
/// @brief Called on "delay dec"
250
long onCmdDelayDec(FXObject*, FXSelector, void*);
251
252
/// @brief Called on "delay toggle"
253
long onCmdDelayToggle(FXObject*, FXSelector, void*);
254
255
/// @brief Called on "demand scale"
256
long onCmdDemandScale(FXObject*, FXSelector, void*);
257
258
/// @brief Called if a new view shall be opened (2D view)
259
long onCmdNewView(FXObject*, FXSelector, void*);
260
261
#ifdef HAVE_OSG
262
/// @brief Called if a new 3D view shall be opened
263
long onCmdNewOSG(FXObject*, FXSelector, void*);
264
#endif
265
266
/// @brief Determines whether opening is enabled
267
long onUpdOpen(FXObject*, FXSelector, void*);
268
269
/// @brief Determines whether reloading is enabled
270
long onUpdReload(FXObject*, FXSelector, void*);
271
272
/// @brief Determines whether opening a recent file is enabled
273
long onUpdOpenRecent(FXObject*, FXSelector, void*);
274
275
/// @brief Determines whether adding a view is enabled
276
long onUpdAddView(FXObject*, FXSelector, void*);
277
278
/// @brief Determines whether "play" is enabled
279
long onUpdStart(FXObject* sender, FXSelector, void* ptr);
280
281
/// @brief Determines whether "stop" is enabled
282
long onUpdStop(FXObject*, FXSelector, void*);
283
284
/// @brief Determines whether "step" is enabled
285
long onUpdStep(FXObject*, FXSelector, void*);
286
287
/// @brief Determines whether some buttons which require an active network may be shown
288
long onUpdNeedsNetwork(FXObject*, FXSelector, void*);
289
290
/// @brief Determines whether some buttons which require an sumoConfig may be shown
291
long onUpdNeedsSumoConfig(FXObject*, FXSelector, void*);
292
293
/// @brief Determines whether traci is active
294
long onUpdTraCIStatus(FXObject*, FXSelector, void*);
295
296
/// @brief Called if the message window shall be cleared
297
long onCmdClearMsgWindow(FXObject*, FXSelector, void*);
298
299
/// @brief Called to set a breakpoint via hotkey
300
long onCmdBreakpoint(FXObject*, FXSelector, void*);
301
302
/// @brief Called to set an early breakpoint via hotkey
303
long onCmdBreakpointEarly(FXObject*, FXSelector, void*);
304
305
/// @brief Called on menu commands from the Locator menu
306
long onCmdLocate(FXObject*, FXSelector, void*);
307
308
/// @brief Called on commands from the statistic buttons
309
long onCmdShowStats(FXObject*, FXSelector, void*);
310
311
/// @brief Called on an event from the loading thread
312
long onLoadThreadEvent(FXObject*, FXSelector, void*);
313
314
/// @brief Called on an event from the simulation thread
315
long onRunThreadEvent(FXObject*, FXSelector, void*);
316
317
/// @brief Somebody wants our clipped text
318
long onClipboardRequest(FXObject* sender, FXSelector sel, void* ptr);
319
320
/// @brief called when a key is pressed
321
long onKeyPress(FXObject* o, FXSelector sel, void* data);
322
323
/// @brief called when a key is released
324
long onKeyRelease(FXObject* o, FXSelector sel, void* data);
325
326
/// @}
327
328
/// @brief Returns the simulation delay in miliseconds
329
virtual double getDelay() const;
330
331
/// @brief Sets the delay of the parent application in milliseconds
332
virtual void setDelay(double delay);
333
334
/// @brief Sets the breakpoints of the parent application
335
virtual void setBreakpoints(const std::vector<SUMOTime>& breakpoints);
336
337
/// @brief Adds the given breakpoint
338
void addBreakpoint(SUMOTime time);
339
340
/// @brief Sends an event from the application thread to the GUI and waits until it is handled
341
virtual void sendBlockingEvent(GUIEvent* event);
342
343
/// @brief retrieve list of breakpoints
344
const std::vector<SUMOTime> retrieveBreakpoints() const;
345
346
/// @brief erase current breakpoint dialog
347
void eraseBreakpointDialog();
348
349
/// @brief register custom hotkey action
350
void addHotkey(int key, Command* press, Command* release);
351
352
protected:
353
/// @brief FOX need this
354
FOX_CONSTRUCTOR(GUIApplicationWindow)
355
356
/// @brief add the given menuPane to windows Menu
357
virtual void addToWindowsMenu(FXMenuPane* menuPane);
358
359
/// Builds the menu bar
360
virtual void fillMenuBar();
361
362
/// Builds the tool bar
363
virtual void buildToolBars();
364
365
/// @brief build recent networks
366
void buildRecentNetworks(FXMenuPane* fileMenu, FXMenuPane* fileMenuRecentNetworks);
367
368
/// @brief build recent configs
369
void buildRecentConfigs(FXMenuPane* fileMenu, FXMenuPane* fileMenuRecentConfigs);
370
371
/// @brief the name of the simulation
372
std::string myName;
373
374
/// @brief the thread that loads simulations
375
GUILoadThread* myLoadThread = nullptr;
376
377
/// @brief the thread that runs simulations
378
GUIRunThread* myRunThread = nullptr;
379
380
/// @brief the information whether the simulation was started before
381
bool myWasStarted = false;
382
383
/// @brief The current view number
384
int myViewNumber;
385
386
/// @brief information whether the gui is currently loading and the load-options shall be greyed out
387
bool myAmLoading = false;
388
389
/// @brief whether we are reloading the simulation
390
bool myIsReload = false;
391
392
/// @brief last modification time of the gui setting file
393
long long myGuiSettingsFileMTime = -2;
394
395
/// @brief the submenus
396
FXMenuPane* myFileMenu = nullptr,
397
*myEditMenu = nullptr,
398
*mySelectByPermissions = nullptr,
399
*mySettingsMenu = nullptr,
400
*myLocatorMenu = nullptr,
401
*myControlMenu = nullptr,
402
*myWindowMenu = nullptr,
403
*myHelpMenu = nullptr;
404
405
/// @brief FXMenu pane for recent networks
406
FXMenuPane* myFileMenuRecentNetworks = nullptr;
407
408
/// @brief FXMenu pane for recent configs
409
FXMenuPane* myFileMenuRecentConfigs = nullptr;
410
411
/// @brief the menu cascades
412
FXMenuCascade* mySelectLanesMenuCascade = nullptr;
413
414
/// @brief menuCheck for enable/disable load additionals in netedit
415
FXMenuCheck* myLoadAdditionalsInNetedit = nullptr;
416
417
/// @brief menuCheck for enable/disable load demand elements in netedit
418
FXMenuCheck* myLoadDemandInNetedit = nullptr;
419
420
/// @brief menuCommand for open simulation/network in netedit
421
FXMenuCommand* myOpenInNetedit = nullptr;
422
423
/// @brief Buttons showing and running values and triggering statistic windows
424
std::vector<FXButton*> myStatButtons;
425
426
/// @brief A window to display messages, warnings and error in
427
GUIMessageWindow* myMessageWindow = nullptr;
428
429
/// @brief The splitter that divides the main window into views and the log window
430
FXSplitter* myMainSplitter = nullptr;
431
432
/// @brief for some menu detaching fun
433
FXToolBarShell* myToolBarDrag1 = nullptr,
434
*myToolBarDrag2 = nullptr,
435
*myToolBarDrag3 = nullptr,
436
*myToolBarDrag4 = nullptr,
437
*myToolBarDrag5 = nullptr,
438
*myMenuBarDrag = nullptr,
439
*myToolBarDrag8 = nullptr;
440
441
/// @brief the simulation delay in milliseconds
442
double mySimDelay = 0.;
443
444
/// @brief Simulation delay target
445
FXDataTarget* mySimDelayTarget = nullptr;
446
447
/// @brief Simulation delay spinner
448
FXRealSpinner* mySimDelaySpinner = nullptr;
449
450
/// @brief Simulation delay slider
451
FXSlider* mySimDelaySlider = nullptr;
452
453
/// @brief the demand scale label
454
MFXLabelTooltip* myScaleTrafficTooltip = nullptr;
455
456
/// @brief the demand scale
457
FXRealSpinner* myDemandScaleSpinner = nullptr;
458
459
/// @brief The alternate simulation delay in milliseconds for toggling
460
double myAlternateSimDelay = 0;
461
462
/// @brief List of got requests
463
MFXSynchQue<GUIEvent*> myEvents;
464
465
/// @brief The menu used for the MDI-windows
466
FXMDIMenu* myMDIMenu = nullptr;
467
468
/// @brief The application menu bar
469
FXMenuBar* myMenuBar = nullptr;
470
471
/// @brief The application tool bar
472
FXToolBar* myToolBar1 = nullptr,
473
*myToolBar2 = nullptr,
474
*myToolBar3 = nullptr,
475
*myToolBar4 = nullptr,
476
*myToolBar5 = nullptr,
477
*myToolBar8 = nullptr;
478
479
/// @brief the simulation step display
480
MFXLCDLabel* myLCDLabel = nullptr;
481
482
/// @brief io-event with the load-thread
483
FXEX::MFXThreadEvent myLoadThreadEvent;
484
485
/// @brief io-event with the run-thread
486
FXEX::MFXThreadEvent myRunThreadEvent;
487
488
/// @brief List of recent networks
489
MFXRecentNetworks myRecentNetworks;
490
491
/// @brief List of recent configs
492
MFXRecentNetworks myRecentConfigs;
493
494
/// @brief flag to mark if GUIApplicationWIndow has depend build
495
bool hadDependentBuild = false;
496
497
/// @brief whether to show time as hour:minute:second
498
bool myShowTimeAsHMS = false;
499
500
/// @brief whether the simulation end was already announced
501
bool myHaveNotifiedAboutSimEnd = false;
502
503
/// @brief the mutex for the waiting semaphore
504
FXMutex myEventMutex;
505
506
/// @brief the semaphore when waiting for event completion
507
FXCondition myEventCondition;
508
509
/// @brief menu checkbox to activate game mode
510
FXMenuCheck* myGamingModeCheckbox;
511
512
/// @name game related things
513
/// {
514
515
/// @brief random list of jam sounds
516
RandomDistributor<std::string> myJamSounds;
517
518
/// @brief random list of collision sounds
519
RandomDistributor<std::string> myCollisionSounds;
520
521
/// @brief waiting time after which vehicles trigger jam sounds
522
double myJamSoundTime = 60;
523
524
/// @brief A random number generator used to choose a gaming sound
525
static std::mt19937 myGamingRNG;
526
527
/// @brief previous collision number
528
int myPreviousCollisionNumber = 0;
529
530
/// @brief flag for enable TLS gameMode
531
bool myTLSGame = false;
532
533
/// @brief waiting time label
534
MFXLCDLabel* myWaitingTimeLabel = nullptr;
535
536
/// @brief waiting time
537
SUMOTime myWaitingTime = 0;
538
539
/// @brief time loss label
540
MFXLCDLabel* myTimeLossLabel = nullptr;
541
542
/// @brief time loss
543
SUMOTime myTimeLoss = 0;
544
545
/// @brief total distance label
546
MFXLCDLabel* myTotalDistanceLabel = nullptr;
547
548
/// @brief total distance
549
double myTotalDistance = 0;
550
551
/// @brief emergency vehicle label
552
MFXLCDLabel* myEmergencyVehicleLabel = nullptr;
553
554
/// @brief emergency vehicle count
555
SUMOTime myEmergencyVehicleCount = 0;
556
557
/// @brief toolbars used in game
558
FXToolBar* myToolBar6 = nullptr,
559
*myToolBar7 = nullptr,
560
*myToolBar9 = nullptr,
561
*myToolBar10 = nullptr;
562
563
/// @brief toolbars shell used in game
564
FXToolBarShell* myToolBarDrag6 = nullptr,
565
*myToolBarDrag7 = nullptr,
566
*myToolBarDrag9 = nullptr,
567
*myToolBarDrag10 = nullptr;
568
////}
569
570
/// @brief last time the simulation view was redrawn due to a simStep
571
long myLastStepEventMillis;
572
573
/// @brief custom hotkeys pressed
574
std::map<int, Command*> myHotkeyPress;
575
576
/// @brief custom hotkeys released
577
std::map<int, Command*> myHotkeyRelease;
578
579
/// @brief breakpoint dialog
580
GUIDialog_Breakpoints* myBreakpointDialog = nullptr;
581
582
std::stringstream* myDynamicSelection = nullptr;
583
584
private:
585
/// @brief starts to load a simulation
586
void loadConfigOrNet(const std::string& file);
587
588
/// @brief this method closes all windows and deletes the current simulation
589
void closeAllWindows();
590
591
/// @brief updates the simulation time display
592
void updateTimeLCD(SUMOTime time);
593
594
/// @brief update LCD timer tooltip
595
void updateTimeLCDTooltip();
596
597
/// @brief opens a new simulation display
598
GUISUMOAbstractView* openNewView(GUISUMOViewParent::ViewType vt = GUISUMOViewParent::VIEW_2D_OPENGL, std::string caption = "");
599
600
/// @brief handles additional game-related events
601
void checkGamingEvents();
602
603
/// @brief handles additional game-related events (DRT)
604
void checkGamingEventsDRT();
605
606
/// @brief invalidate copy constructor
607
GUIApplicationWindow(const GUIApplicationWindow& s) = delete;
608
609
/// @brief invalidate assignment operator
610
GUIApplicationWindow& operator=(const GUIApplicationWindow& s) = delete;
611
};
612
613