Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIMEInductLoop.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// The gui-version of the MEInductLoop
19/****************************************************************************/
20#include <config.h>
21
22
26#include <guisim/GUILane.h>
32#include <mesosim/MESegment.h>
33#include "GUIMEInductLoop.h"
34
35
36// ===========================================================================
37// method definitions
38// ===========================================================================
39/* -------------------------------------------------------------------------
40 * GUIMEInductLoop-methods
41 * ----------------------------------------------------------------------- */
43 double position,
44 const std::string name, const std::string& vTypes,
45 const std::string& nextEdges,
46 int detectPersons,
47 bool /*show*/):
48 MEInductLoop(id, s, position, name, vTypes, nextEdges, detectPersons)
49{}
50
51
53
54
59
60// -----------------------------------------------------------------------
61// GUIMEInductLoop::MyWrapper-methods
62// -----------------------------------------------------------------------
63
65 : GUIDetectorWrapper(GLO_E1DETECTOR_ME, detector.getID(), GUIIconSubSys::getIcon(GUIIcon::E1)),
66 myDetector(detector), myPosition(pos) {
67 const MSLane* lane = detector.mySegment->getEdge().getLanes()[0];
69 myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
70 myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
72}
73
74
76
77
78double
82
83
86 Boundary b(myBoundary);
87 b.grow(20);
88 return b;
89}
90
91
92
95 GUISUMOAbstractView& /* parent */) {
97 // add items
98 /*
99 ret->mkItem("flow [veh/h]", true,
100 new FuncBinding_IntParam<GUIMEInductLoop, double>(
101 &(getLoop()), &GUIMEInductLoop::getFlow, 1));
102 ret->mkItem("mean speed [m/s]", true,
103 new FuncBinding_IntParam<GUIMEInductLoop, double>(
104 &(getLoop()), &GUIMEInductLoop::getMeanSpeed, 1));
105 ret->mkItem("occupancy [%]", true,
106 new FuncBinding_IntParam<GUIMEInductLoop, double>(
107 &(getLoop()), &GUIMEInductLoop::getOccupancy, 1));
108 ret->mkItem("mean vehicle length [m]", true,
109 new FuncBinding_IntParam<GUIMEInductLoop, double>(
110 &(getLoop()), &GUIMEInductLoop::getMeanVehicleLength, 1));
111 ret->mkItem("empty time [s]", true,
112 new FunctionBinding<GUIMEInductLoop, double>(
113 &(getLoop()), &GUIMEInductLoop::getTimeSinceLastDetection));
114 */
115 //
116 ret->mkItem("position [m]", false, myPosition);
117 ret->mkItem("lane", false, myDetector.mySegment->getID());
118 // close building
119 ret->closeBuilding();
120 return ret;
121}
122
123
124void
126 GLHelper::pushName(getGlID());
127 glPolygonOffset(0, -2);
128 double width = (double) 2.0 * s.scale;
129 glLineWidth(1.0);
130 const double exaggeration = getExaggeration(s);
131 // shape
132 glColor3d(1, 1, 0);
134 glTranslated(myFGPosition.x(), myFGPosition.y(), getType());
135 glRotated(myFGRotation, 0, 0, 1);
136 glScaled(exaggeration, exaggeration, exaggeration);
137 glBegin(GL_QUADS);
138 glVertex2d(0 - 1.0, 2);
139 glVertex2d(-1.0, -2);
140 glVertex2d(1.0, -2);
141 glVertex2d(1.0, 2);
142 glEnd();
143 glBegin(GL_LINES);
144 // without the subtracted offsets, lines are partially longer
145 // than the boxes
146 glVertex2d(0, 2 - .1);
147 glVertex2d(0, -2 + .1);
148 glEnd();
149
150 // outline
151 if (width * exaggeration > 1) {
152 glColor3d(1, 1, 1);
153 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
154 glBegin(GL_QUADS);
155 glVertex2d(0 - 1.0, 2);
156 glVertex2d(-1.0, -2);
157 glVertex2d(1.0, -2);
158 glVertex2d(1.0, 2);
159 glEnd();
160 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
161 }
162
163 // position indicator
164 if (width * exaggeration > 1) {
165 glRotated(90, 0, 0, -1);
166 glColor3d(1, 1, 1);
167 glBegin(GL_LINES);
168 glVertex2d(0, 1.7);
169 glVertex2d(0, -1.7);
170 glEnd();
171 }
173 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
175}
176
177
180 return myDetector;
181}
182
183
184/****************************************************************************/
@ GLO_E1DETECTOR_ME
a E1 detector
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:343
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void popName()
pop Name
Definition GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Boundary myBoundary
The detector's boundary.
Position myFGPosition
The position in full-geometry mode.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIMEInductLoop & getLoop()
Returns the detector itself.
double myFGRotation
The rotation in full-geometry mode.
MyWrapper(GUIMEInductLoop &detector, double pos)
Constructor.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIMEInductLoop(const std::string &id, MESegment *s, double position, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool show)
Construtor.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector's visualisation-wrapper.
~GUIMEInductLoop()
Destructor.
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationSizeSettings addSize
double scale
information about a lane's width (temporary, used for a single view)
An induction loop for mesoscopic simulation.
MESegment *const mySegment
mesoscopic edge segment the loop lies on
const double myPosition
position from the start of the edge / lane
A single mesoscopic segment (cell)
Definition MESegment.h:49
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition MESegment.h:359
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
Representation of a lane in the micro simulation.
Definition MSLane.h:84
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values