1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    GUITrafficLightLogicWrapper.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Jakob Erdmann
13 /// @author  Michael Behrisch
14 /// @date    Oct/Nov 2003
15 /// @version $Id$
16 ///
17 // A wrapper for tl-logics to allow their visualisation and interaction
18 /****************************************************************************/
19 #ifndef GUITrafficLightLogicWrapper_h
20 #define GUITrafficLightLogicWrapper_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <gui/GUITLLogicPhasesTrackerWindow.h>
29 #include <utils/gui/globjects/GUIGlObject.h>
30 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSTrafficLightLogic;
37 class GUIMainWindow;
38 
39 
40 // ===========================================================================
41 // class definition
42 // ===========================================================================
43 /**
44  * @class GUITrafficLightLogicWrapper
45  * This class is responsible for the visualisation of tl-logics and the
46  *  interaction with them.
47  */
48 class GUITrafficLightLogicWrapper : public GUIGlObject {
49 public:
50     /// Constructor
51     GUITrafficLightLogicWrapper(MSTLLogicControl& control, MSTrafficLightLogic& tll);
52 
53     /// Destructor
54     ~GUITrafficLightLogicWrapper();
55 
56 
57 
58     /// @name inherited from GUIGlObject
59     //@{
60 
61     /** @brief Returns an own popup-menu
62      *
63      * @param[in] app The application needed to build the popup-menu
64      * @param[in] parent The parent window needed to build the popup-menu
65      * @return The built popup-menu
66      * @see GUIGlObject::getPopUpMenu
67      */
68     GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
69                                        GUISUMOAbstractView& parent);
70 
71 
72     /** @brief Returns an own parameter window
73      *
74      * @param[in] app The application needed to build the parameter window
75      * @param[in] parent The parent window needed to build the parameter window
76      * @return The built parameter window
77      * @see GUIGlObject::getParameterWindow
78      */
79     GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
80             GUISUMOAbstractView& parent);
81 
82 
83     /** @brief Returns the boundary to which the view shall be centered in order to show the object
84      *
85      * @return The boundary the object is within
86      * @see GUIGlObject::getCenteringBoundary
87      */
88     Boundary getCenteringBoundary() const;
89 
90 
91     /** @brief Draws the object
92      * @param[in] s The settings for the current view (may influence drawing)
93      * @see GUIGlObject::drawGL
94      */
95     void drawGL(const GUIVisualizationSettings& s) const;
96     //@}
97 
98 
99     /// Builds a GUITLLogicPhasesTrackerWindow which will receive new phases
100     void begin2TrackPhases();
101 
102     /// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
103     void showPhases();
104 
105     /// Builds a GUITLLogicPhasesTrackerWindow which displays the phase diagram
106     void switchTLSLogic(int to);
107 
108     /// Returns the index of the given link within the according tls
109     int getLinkIndex(const MSLink* const link) const;
110 
111 
112 public:
113     /**
114      * @class GUITrafficLightLogicWrapperPopupMenu
115      * The popup-menu for a TLS-logic. Adds the functionality to open a
116      *  view on the tls-logic and to start tracking of the tls-logic.
117      */
118     class GUITrafficLightLogicWrapperPopupMenu : public GUIGLObjectPopupMenu {
119         FXDECLARE(GUITrafficLightLogicWrapperPopupMenu)
120     public:
121         /// Constructor
122         GUITrafficLightLogicWrapperPopupMenu(GUIMainWindow& app,
123                                              GUISUMOAbstractView& parent, GUIGlObject& o);
124 
125         /// Destructor
126         ~GUITrafficLightLogicWrapperPopupMenu();
127 
128         /// Called if the phases shall be shown
129         long onCmdShowPhases(FXObject*, FXSelector, void*);
130 
131         /// Called if the phases shall be begun to track
132         long onCmdBegin2TrackPhases(FXObject*, FXSelector, void*);
133 
134         long onCmdSwitchTLS2Off(FXObject*, FXSelector, void*);
135         long onCmdSwitchTLSLogic(FXObject*, FXSelector, void*);
136 
137     protected:
138         /// protected constructor for FOX
GUITrafficLightLogicWrapperPopupMenu()139         GUITrafficLightLogicWrapperPopupMenu() { }
140 
141     };
142 
143 private:
144     /// Reference to the according tls
145     MSTLLogicControl& myTLLogicControl;
146 
147     /// The wrapped tl-logic
148     MSTrafficLightLogic& myTLLogic;
149 
150     /// The main application
151     GUIMainWindow* myApp;
152 
153 };
154 
155 
156 #endif
157 
158 /****************************************************************************/
159 
160