Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 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,
66 : GUISUMOAbstractView& parent);
67 :
68 : /** @brief Returns an own parameter window
69 : *
70 : * @param[in] app The application needed to build the parameter window
71 : * @param[in] parent The parent window needed to build the parameter window
72 : * @return The built parameter window
73 : * @see GUIGlObject::getParameterWindow
74 : */
75 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
76 : GUISUMOAbstractView& parent);
77 :
78 : /** @brief Returns the boundary to which the view shall be centered in order to show the object
79 : *
80 : * @return The boundary the object is within
81 : * @see GUIGlObject::getCenteringBoundary
82 : */
83 : Boundary getCenteringBoundary() const;
84 :
85 : /// @brief Returns the value for generic parameter 'name' or ''
86 : const std::string getOptionalName() const;
87 :
88 : /** @brief Draws the object
89 : * @param[in] s The settings for the current view (may influence drawing)
90 : * @see GUIGlObject::drawGL
91 : */
92 : void drawGL(const GUIVisualizationSettings& s) const;
93 : //@}
94 :
95 :
96 : /// Builds a GUITLLogicPhasesTrackerWindow which will receive new phases
97 : void begin2TrackPhases();
98 :
99 : /// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
100 : void showPhases();
101 :
102 : /// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
103 : void switchTLSLogic(int to);
104 :
105 : /// Returns the index of the given link within the according tls
106 : int getLinkIndex(const MSLink* const link) const;
107 :
108 : MSTrafficLightLogic& getTLLogic() const {
109 0 : return myTLLogic;
110 : }
111 :
112 : MSTrafficLightLogic* getActiveTLLogic() const;
113 :
114 : int getCurrentPhase() const;
115 : std::string getCurrentPhaseName() const;
116 : int getCurrentDurationSeconds() const;
117 : int getCurrentMinDurSeconds() const;
118 : int getCurrentMaxDurSeconds() const;
119 : int getCurrentEarliestEndSeconds() const;
120 : int getCurrentLatestEndSeconds() const;
121 : int getDefaultCycleTimeSeconds() const;
122 : int getCurrentTimeInCycleSeconds() const;
123 : int getRunningDurationSeconds() const;
124 :
125 : public:
126 : /**
127 : * @class GUITrafficLightLogicWrapperPopupMenu
128 : * The popup-menu for a TLS-logic. Adds the functionality to open a
129 : * view on the tls-logic and to start tracking of the tls-logic.
130 : */
131 : class GUITrafficLightLogicWrapperPopupMenu : public GUIGLObjectPopupMenu {
132 0 : FXDECLARE(GUITrafficLightLogicWrapperPopupMenu)
133 : public:
134 : /// Constructor
135 : GUITrafficLightLogicWrapperPopupMenu(GUIMainWindow& app,
136 : GUISUMOAbstractView& parent, GUIGlObject& o);
137 :
138 : /// Destructor
139 : ~GUITrafficLightLogicWrapperPopupMenu();
140 :
141 : /// Called if the phases shall be shown
142 : long onCmdShowPhases(FXObject*, FXSelector, void*);
143 :
144 : /// Called if the phases shall be begun to track
145 : long onCmdBegin2TrackPhases(FXObject*, FXSelector, void*);
146 : long onCmdShowDetectors(FXObject*, FXSelector, void*);
147 :
148 : long onCmdSwitchTLS2Off(FXObject*, FXSelector, void*);
149 : long onCmdSwitchTLSLogic(FXObject*, FXSelector, void*);
150 :
151 : protected:
152 : /// protected constructor for FOX
153 0 : GUITrafficLightLogicWrapperPopupMenu() { }
154 :
155 : };
156 :
157 : private:
158 : /// Reference to the according tls
159 : MSTLLogicControl& myTLLogicControl;
160 :
161 : /// The wrapped tl-logic
162 : MSTrafficLightLogic& myTLLogic;
163 :
164 : /// The main application
165 : GUIMainWindow* myApp;
166 :
167 : };
|