Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUIInductLoop.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 GUIInductLoop.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Sascha Krieg
18
/// @author Michael Behrisch
19
/// @date Aug 2003
20
///
21
// The gui-version of the MSInductLoop, together with the according
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <utils/foxtools/fxheader.h>
27
#include <microsim/output/MSInductLoop.h>
28
#include <utils/geom/Position.h>
29
#include "GUIDetectorWrapper.h"
30
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
/**
36
* @class GUIInductLoop
37
* @brief The gui-version of the MSInductLoop.
38
*
39
* Allows the building of a wrapper (also declared herein) which draws the
40
* detector on the gl-canvas. Uses a mutex to avoid parallel read/write operations.
41
* The mutex is only set within methods that change MSInductLoop-internal state
42
* and within "collectVehiclesOnDet". All other reading operations should be performed
43
* via the simulation loop only.
44
*/
45
class GUIInductLoop : public MSInductLoop {
46
public:
47
/**
48
* @brief Constructor.
49
* @param[in] id Unique id
50
* @param[in] lane Lane where detector woks on
51
* @param[in] position Position of the detector within the lane
52
* @param[in] vTypes which vehicle types are considered
53
*/
54
GUIInductLoop(const std::string& id, MSLane* const lane, double position, double length,
55
std::string name, const std::string& vTypes,
56
const std::string& nextEdges,
57
int detectPersons, bool show);
58
59
60
/// @brief Destructor
61
~GUIInductLoop();
62
63
/** @brief Returns this detector's visualisation-wrapper
64
* @return The wrapper representing the detector
65
*/
66
virtual GUIDetectorWrapper* buildDetectorGUIRepresentation();
67
68
/// @brief sets special caller for myWrapper
69
void setSpecialColor(const RGBColor* color);
70
71
/// @brief whether the induction loop shall be visible
72
bool isVisible() const {
73
return myShow;
74
}
75
76
/// @brief toggle visibility
77
void setVisible(bool show) {
78
myShow = show;
79
}
80
81
public:
82
/**
83
* @class GUIInductLoop::MyWrapper
84
* @brief A MSInductLoop-visualiser
85
*/
86
class MyWrapper : public GUIDetectorWrapper {
87
88
public:
89
/// @brief Constructor
90
MyWrapper(GUIInductLoop& detector, double pos);
91
92
/// @brief Destructor
93
~MyWrapper();
94
95
/// @name inherited from GUIGlObject
96
//@{
97
98
/** @brief Returns an own parameter window
99
*
100
* @param[in] app The application needed to build the parameter window
101
* @param[in] parent The parent window needed to build the parameter window
102
* @return The built parameter window
103
* @see GUIGlObject::getParameterWindow
104
*/
105
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
106
107
/** @brief Returns the boundary to which the view shall be centered in order to show the object
108
*
109
* @return The boundary the object is within
110
* @see GUIGlObject::getCenteringBoundary
111
*/
112
Boundary getCenteringBoundary() const override;
113
114
/** @brief Draws the object
115
* @param[in] s The settings for the current view (may influence drawing)
116
* @see GUIGlObject::drawGL
117
*/
118
void drawGL(const GUIVisualizationSettings& s) const override;
119
//@}
120
121
/// @brief set (outline) color for extra visualization
122
void setSpecialColor(const RGBColor* color) {
123
mySpecialColor = color;
124
}
125
126
protected:
127
/// @brief whether this detector has an active virtual detector call
128
bool haveOverride() const override;
129
130
/// @brief toggle virtual detector call
131
void toggleOverride() const override;
132
133
private:
134
/// @brief The wrapped detector
135
GUIInductLoop& myDetector;
136
137
/// @brief The detector's boundary
138
Boundary myBoundary;
139
140
/// @brief The rotations of the shape parts
141
std::vector<double> myFGShapeRotations;
142
143
/// @brief The lengths of the shape parts
144
std::vector<double> myFGShapeLengths;
145
146
/// @brief The shape
147
PositionVector myFGShape;
148
149
/// @brief The position in full-geometry mode
150
Position myFGPosition;
151
152
/// @brief The rotation in full-geometry mode
153
double myFGRotation;
154
155
PositionVector myOutline;
156
PositionVector myIndicators;
157
158
/// @brief The position on the lane
159
double myPosition;
160
161
/// @brief Whether this detector has defined a length
162
bool myHaveLength;
163
164
/// @brief color for extra visualization
165
const RGBColor* mySpecialColor;
166
167
private:
168
void setOutlineColor() const;
169
170
private:
171
/// @brief Invalidated copy constructor.
172
MyWrapper(const MyWrapper&);
173
174
/// @brief Invalidated assignment operator.
175
MyWrapper& operator=(const MyWrapper&);
176
177
};
178
179
private:
180
181
/// @brief the glObject wrapper for this induction loop
182
MyWrapper* myWrapper;
183
184
/// @brief whether this induction loop shall be visible in the gui
185
bool myShow;
186
187
};
188
189