Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUITrafficLightLogicWrapper.h
193672 views
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 GUITrafficLightLogicWrapper.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Oct/Nov 2003
19
///
20
// A wrapper for tl-logics to allow their visualisation and interaction
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <gui/GUITLLogicPhasesTrackerWindow.h>
26
#include <utils/gui/globjects/GUIGlObject.h>
27
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
28
29
30
// ===========================================================================
31
// class declarations
32
// ===========================================================================
33
class MSTrafficLightLogic;
34
class GUIMainWindow;
35
36
37
// ===========================================================================
38
// class definition
39
// ===========================================================================
40
/**
41
* @class GUITrafficLightLogicWrapper
42
* This class is responsible for the visualisation of tl-logics and the
43
* interaction with them.
44
*/
45
class GUITrafficLightLogicWrapper : public GUIGlObject {
46
public:
47
/// Constructor
48
GUITrafficLightLogicWrapper(MSTLLogicControl& control, MSTrafficLightLogic& tll);
49
50
/// Destructor
51
~GUITrafficLightLogicWrapper();
52
53
54
55
/// @name inherited from GUIGlObject
56
//@{
57
58
/** @brief Returns an own popup-menu
59
*
60
* @param[in] app The application needed to build the popup-menu
61
* @param[in] parent The parent window needed to build the popup-menu
62
* @return The built popup-menu
63
* @see GUIGlObject::getPopUpMenu
64
*/
65
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
66
67
/** @brief Returns an own parameter window
68
*
69
* @param[in] app The application needed to build the parameter window
70
* @param[in] parent The parent window needed to build the parameter window
71
* @return The built parameter window
72
* @see GUIGlObject::getParameterWindow
73
*/
74
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
75
76
/** @brief Returns the boundary to which the view shall be centered in order to show the object
77
*
78
* @return The boundary the object is within
79
* @see GUIGlObject::getCenteringBoundary
80
*/
81
Boundary getCenteringBoundary() const override;
82
83
/// @brief Returns the value for generic parameter 'name' or ''
84
const std::string getOptionalName() const override;
85
86
/** @brief Draws the object
87
* @param[in] s The settings for the current view (may influence drawing)
88
* @see GUIGlObject::drawGL
89
*/
90
void drawGL(const GUIVisualizationSettings& s) const override;
91
//@}
92
93
94
/// Builds a GUITLLogicPhasesTrackerWindow which will receive new phases
95
void begin2TrackPhases(GUIMainWindow* app = nullptr);
96
97
/// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
98
void showPhases();
99
100
/// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
101
void switchTLSLogic(int to);
102
103
/// Returns the index of the given link within the according tls
104
int getLinkIndex(const MSLink* const link) const;
105
106
MSTrafficLightLogic& getTLLogic() const {
107
return myTLLogic;
108
}
109
110
MSTrafficLightLogic* getActiveTLLogic() const;
111
112
int getCurrentPhase() const;
113
std::string getCurrentPhaseName() const;
114
int getCurrentDurationSeconds() const;
115
int getCurrentMinDurSeconds() const;
116
int getCurrentMaxDurSeconds() const;
117
int getCurrentEarliestEndSeconds() const;
118
int getCurrentLatestEndSeconds() const;
119
int getDefaultCycleTimeSeconds() const;
120
int getCurrentTimeInCycleSeconds() const;
121
int getRunningDurationSeconds() const;
122
123
public:
124
/**
125
* @class GUITrafficLightLogicWrapperPopupMenu
126
* The popup-menu for a TLS-logic. Adds the functionality to open a
127
* view on the tls-logic and to start tracking of the tls-logic.
128
*/
129
class GUITrafficLightLogicWrapperPopupMenu : public GUIGLObjectPopupMenu {
130
FXDECLARE(GUITrafficLightLogicWrapperPopupMenu)
131
132
public:
133
/// Constructor
134
GUITrafficLightLogicWrapperPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
135
136
/// Destructor
137
~GUITrafficLightLogicWrapperPopupMenu();
138
139
/// Called if the phases shall be shown
140
long onCmdShowPhases(FXObject*, FXSelector, void*);
141
142
/// Called if the phases shall be begun to track
143
long onCmdBegin2TrackPhases(FXObject*, FXSelector, void*);
144
long onCmdShowDetectors(FXObject*, FXSelector, void*);
145
146
long onCmdSwitchTLS2Off(FXObject*, FXSelector, void*);
147
long onCmdSwitchTLSLogic(FXObject*, FXSelector, void*);
148
149
protected:
150
/// protected constructor for FOX
151
GUITrafficLightLogicWrapperPopupMenu() { }
152
153
};
154
155
private:
156
/// Reference to the according tls
157
MSTLLogicControl& myTLLogicControl;
158
159
/// The wrapped tl-logic
160
MSTrafficLightLogic& myTLLogic;
161
162
/// The main application
163
GUIMainWindow* myApp;
164
};
165
166