Eclipse SUMO - Simulation of Urban MObility
GUITLLogicPhasesTrackerWindow.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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/****************************************************************************/
20// A window displaying the phase diagram of a tl-logic
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <vector>
26#include <string>
27#include <bitset>
28#include <utility>
30// fx3d includes windows.h so we need to guard against macro pollution
31#ifdef WIN32
32#define NOMINMAX
33#endif
34#include <fx3d.h>
35#ifdef WIN32
36#undef NOMINMAX
37#endif
44
45
46// ===========================================================================
47// class declarations
48// ===========================================================================
49class GUIMainWindow;
52
53
54// ===========================================================================
55// class definitions
56// ===========================================================================
62 : public FXMainWindow,
63 public ValueRetriever<std::pair<SUMOTime, MSPhaseDefinition> > {
65public:
74 ValueSource<std::pair<SUMOTime, MSPhaseDefinition> >* src);
75
76
84 GUIMainWindow& app,
87
88
91
92
94 void create();
95
96
100 void addValue(std::pair<SUMOTime, MSPhaseDefinition> def);
101
102
106 void setBeginTime(SUMOTime time);
107
108
111
113 long onConfigure(FXObject* sender, FXSelector sel, void* ptr);
114
116 long onPaint(FXObject* sender, FXSelector sel, void* ptr);
117
119 long onSimStep(FXObject* sender, FXSelector sel, void* ptr);
120
122
123
124
125public:
127 typedef std::vector<MSPhaseDefinition> PhasesVector;
128
130 typedef std::vector<SUMOTime> DurationsVector;
131
133 typedef std::vector<int> IndexVector;
134
136 typedef std::vector<std::vector<double > > AdditionalStatesVector;
137
144 class GUITLLogicPhasesTrackerPanel : public FXGLCanvas {
146 public:
152 GUITLLogicPhasesTrackerPanel(FXComposite* c,
154
157
160
161
164
166 long onConfigure(FXObject*, FXSelector, void*);
167
169 long onPaint(FXObject*, FXSelector, void*);
170
172 long onMouseMove(FXObject*, FXSelector, void*);
174
175 const Position& getMousePos() const {
176 return myMousePos;
177 };
178
179 private:
182
184
185 protected:
188
189 };
190
191
195 void drawValues(GUITLLogicPhasesTrackerPanel& caller);
196
197
198private:
201
204
207
210
213
216
220
224
227
229 FXMutex myLock;
230
234 std::vector<std::string> myLinkNames;
235 std::vector<std::string> myDetectorNames;
236 std::vector<std::string> myConditionNames;
237
242
247
250
253
256
259
262
264 FXToolBarShell* myToolBarDrag;
265
267 FXToolBar* myToolBar;
268
270 FXRealSpinner* myBeginOffset;
271
273 FXComboBox* myTimeMode;
274
276 FXComboBox* myGreenMode;
277
279 FXCheckButton* myIndexMode;
280
282 FXCheckButton* myDetectorMode;
283
285 FXCheckButton* myConditionMode;
286
288 static int myLastY;
289
290private:
291
292 void initToolBar();
293
294 void saveSettings();
295 void loadSettings();
296
298 int computeHeight();
299
301 void drawNames(const std::vector<std::string>& names, double fontHeight, double fontWidth, double divHeight, double divWidth, double& h, int extraLines);
302
305 const AdditionalStatesVector& states, const DurationsVector& durations,
306 SUMOTime firstOffset, int first2Show, double hStart,
307 double panelWidth, double leftOffset, double barWidth, double stateHeight, double h20, double& h);
308
311
312protected:
315
316
317};
long long int SUMOTime
Definition: GUI.h:36
Class passing values from a GUIGlObject to another object.
long onConfigure(FXObject *, FXSelector, void *)
called on size change
GUITLLogicPhasesTrackerWindow * myParent
The parent window.
long onPaint(FXObject *, FXSelector, void *)
called if the widget shall be repainted
long onMouseMove(FXObject *, FXSelector, void *)
called on mouse movement (for updating tooltip)
This window displays a phase diagram for a chosen tl-logic.
GUITLLogicPhasesTrackerWindow()
protected constructor for FOX
AdditionalStatesVector myDetectorStates
The state of all used detectors of the current phase.
FXMutex myLock
A lock to avoid addition of new values while drawing.
SUMOTime myBeginTime
The first time a phase was added at.
static int myLastY
y-Position of previously opened window
DurationsVector myTimeInCycle
The time within the cycle for the current phase.
std::vector< std::string > myLinkNames
The names of links.
std::vector< int > IndexVector
Definition of a storage for indices.
DurationsVector myDetectorDurations
The list of detector state durations.
FXCheckButton * myDetectorMode
Whether detector states are drawn.
FXRealSpinner * myBeginOffset
The offset changer (tracking mode)
long onSimStep(FXObject *sender, FXSelector sel, void *ptr)
called on a simulation step
GUITLLogicPhasesTrackerPanel * myPanel
The panel to draw on.
int computeHeight()
compute required windowHeight
void setBeginTime(SUMOTime time)
Sets the time the display shall be shown as beginning at.
FXToolBarShell * myToolBarDrag
The tool bar drag (tracking mode)
FXToolBar * myToolBar
The tool bar (tracking mode)
PhasesVector myPhases
The list of phases.
SUMOTime myFirstPhaseOffset
The offset to draw the first phase (left offset)
std::vector< std::string > myDetectorNames
FXComboBox * myGreenMode
Whether green durations are printed.
IndexVector myPhaseIndex
The index of the current phase.
void addValue(std::pair< SUMOTime, MSPhaseDefinition > def)
Adds a further phase definition.
GLObjectValuePassConnector< std::pair< SUMOTime, MSPhaseDefinition > > * myConnector
The connector for retrieval of further phases.
std::vector< std::string > myConditionNames
int myFirstPhase2Show
The index of the first phase that fits into the window.
long onPaint(FXObject *sender, FXSelector sel, void *ptr)
called if the widget shall be repainted
SUMOTime findTimeInCycle(SUMOTime t)
find time in cycle based on myTimeInCycle
FXCheckButton * myConditionMode
Whether detector states are drawn.
long onConfigure(FXObject *sender, FXSelector sel, void *ptr)
called on size change
SUMOTime myLastTime
The last time a phase was added at.
void create()
Creates the window (FOX-Toolkit)
MSTrafficLightLogic * myTLLogic
The logic to display.
std::vector< std::vector< double > > AdditionalStatesVector
Definition of a storage for detector and condition states.
void drawNames(const std::vector< std::string > &names, double fontHeight, double fontWidth, double divHeight, double divWidth, double &h, int extraLines)
draw row title
FXCheckButton * myIndexMode
Whether phase names shall be printed instead of indices.
std::vector< SUMOTime > DurationsVector
Definition of a storage for durations.
void drawAdditionalStates(GUITLLogicPhasesTrackerPanel &caller, const AdditionalStatesVector &states, const DurationsVector &durations, SUMOTime firstOffset, int first2Show, double hStart, double panelWidth, double leftOffset, double barWidth, double stateHeight, double h20, double &h)
draw detector and condition states
SUMOTime myFirstTime2Show
The time the diagram begins at.
GUIMainWindow * myApplication
The main application.
std::vector< MSPhaseDefinition > PhasesVector
}
bool myAmInTrackingMode
Information whether the tracking mode is on.
void drawValues(GUITLLogicPhasesTrackerPanel &caller)
Draws all values.
DurationsVector myDurations
The list of phase durations.
The parent class for traffic light logics.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37