Eclipse SUMO - Simulation of Urban MObility
GUIInstantInductLoop.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2003-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// The gui-version of the MSInstantInductLoop
21/****************************************************************************/
22#include <config.h>
23
31#include <microsim/MSLane.h>
32#include "GUIEdge.h"
34
35
36// ===========================================================================
37// method definitions
38// ===========================================================================
39/* -------------------------------------------------------------------------
40 * GUIInstantInductLoop-methods
41 * ----------------------------------------------------------------------- */
43 MSLane* const lane, double positionInMeters,
44 const std::string name, const std::string& vTypes,
45 const std::string& nextEdges) :
46 MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges) {}
47
48
50
51
54 return new MyWrapper(*this, myPosition);
55}
56
57// -------------------------------------------------------------------------
58// GUIInstantInductLoop::MyWrapper-methods
59// -------------------------------------------------------------------------
60
63 myDetector(detector), myPosition(pos) {
65 myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
66 myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
68}
69
70
72
73
74double
76 return s.addSize.getExaggeration(s, this);
77}
78
79
82 Boundary b(myBoundary);
83 b.grow(20);
84 return b;
85}
86
87
88
91 GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
93 // add items
94 // parameter
95 ret->mkItem("name", false, myDetector.myName);
96 ret->mkItem("position [m]", false, myPosition);
97 ret->mkItem("lane", false, myDetector.getLane()->getID());
98 if (myDetector.isTyped()) {
99 ret->mkItem("vTypes", false, toString(myDetector.getVehicleTypes()));
100 }
101 // values
102 // close building
103 ret->closeBuilding(&myDetector);
104 return ret;
105}
106
107
108void
110 GLHelper::pushName(getGlID());
111 double width = (double) 2.0 * s.scale;
112 glLineWidth(1.0);
113 const double exaggeration = getExaggeration(s);
114 // shape
115 glColor3d(1, 0, 1);
117 glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
118 glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
119 glRotated(myFGRotation, 0, 0, 1);
120 glScaled(exaggeration, exaggeration, 1);
121 glBegin(GL_QUADS);
122 glVertex2d(0 - 1.0, 2);
123 glVertex2d(-1.0, -2);
124 glVertex2d(1.0, -2);
125 glVertex2d(1.0, 2);
126 glEnd();
127 glTranslated(0, 0, .01);
128 glBegin(GL_LINES);
129 glVertex2d(0, 2 - .1);
130 glVertex2d(0, -2 + .1);
131 glEnd();
132
133 // outline
134 if (width * exaggeration > 1) {
135 glColor3d(1, 1, 1);
136 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
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 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
144 }
145
146 // position indicator
147 if (width * exaggeration > 1) {
148 glRotated(90, 0, 0, -1);
149 glColor3d(1, 1, 1);
150 glBegin(GL_LINES);
151 glVertex2d(0, 1.7);
152 glVertex2d(0, -1.7);
153 glEnd();
154 }
156 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
158}
159
160
163 return myDetector;
164}
165
166
167/****************************************************************************/
@ GLO_JUNCTION
a junction
@ GLO_E1DETECTOR_INSTANT
a E1 detector
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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:300
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
A MSInductLoop-visualiser.
Position myFGPosition
The position in full-geometry mode.
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Boundary myBoundary
The detector's boundary.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
double myFGRotation
The rotation in full-geometry mode.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIInstantInductLoop & getLoop()
Returns the detector itself.
The gui-version of the MSInstantInductLoop.
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, double positionInMeters, const std::string name, const std::string &vTypes, const std::string &nextEdges)
Constructor.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector's visualisation-wrapper.
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 instantaneous induction loop.
const double myPosition
Detector's position on lane [m].
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:293
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:551
const MSLane * getLane() const
Returns the lane the reminder works on.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
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