Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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
32#include <microsim/MSLane.h>
33#include "GUIEdge.h"
35
36
37// ===========================================================================
38// method definitions
39// ===========================================================================
40/* -------------------------------------------------------------------------
41 * GUIInstantInductLoop-methods
42 * ----------------------------------------------------------------------- */
44 MSLane* const lane, double positionInMeters,
45 const std::string name, const std::string& vTypes,
46 const std::string& nextEdges,
47 int detectPersons) :
48 MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges, detectPersons) {}
49
50
52
53
58
59// -------------------------------------------------------------------------
60// GUIInstantInductLoop::MyWrapper-methods
61// -------------------------------------------------------------------------
62
65 myDetector(detector), myPosition(pos) {
67 myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
68 myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
70}
71
72
74
75
76double
80
81
84 Boundary b(myBoundary);
85 b.grow(20);
86 return b;
87}
88
89
90
93 GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
95 // add items
96 // parameter
97 ret->mkItem(TL("name"), false, myDetector.myName);
98 ret->mkItem(TL("position [m]"), false, myPosition);
99 ret->mkItem(TL("lane"), false, myDetector.getLane()->getID());
100 if (myDetector.isTyped()) {
101 ret->mkItem(TL("vTypes"), false, toString(myDetector.getVehicleTypes()));
102 }
103 // values
104 // close building
105 ret->closeBuilding(&myDetector);
106 return ret;
107}
108
109
110void
112 GLHelper::pushName(getGlID());
113 double width = (double) 2.0 * s.scale;
114 glLineWidth(1.0);
115 const double exaggeration = getExaggeration(s);
116 // shape
117 glColor3d(1, 0, 1);
119 glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
120 glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
121 glRotated(myFGRotation, 0, 0, 1);
122 glScaled(exaggeration, exaggeration, 1);
123 glBegin(GL_QUADS);
124 glVertex2d(0 - 1.0, 2);
125 glVertex2d(-1.0, -2);
126 glVertex2d(1.0, -2);
127 glVertex2d(1.0, 2);
128 glEnd();
129 glTranslated(0, 0, .01);
130 glBegin(GL_LINES);
131 glVertex2d(0, 2 - .1);
132 glVertex2d(0, -2 + .1);
133 glEnd();
134
135 // outline
136 if (width * exaggeration > 1) {
137 glColor3d(1, 1, 1);
138 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
139 glBegin(GL_QUADS);
140 glVertex2d(0 - 1.0, 2);
141 glVertex2d(-1.0, -2);
142 glVertex2d(1.0, -2);
143 glVertex2d(1.0, 2);
144 glEnd();
145 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146 }
147
148 // position indicator
149 if (width * exaggeration > 1) {
150 glRotated(90, 0, 0, -1);
151 glColor3d(1, 1, 1);
152 glBegin(GL_LINES);
153 glVertex2d(0, 1.7);
154 glVertex2d(0, -1.7);
155 glEnd();
156 }
158 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
160}
161
162
165 return myDetector;
166}
167
168
169/****************************************************************************/
@ GLO_JUNCTION
a junction
@ GLO_E1DETECTOR_INSTANT
a E1 detector
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:304
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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:140
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void popName()
pop Name
Definition GLHelper.cpp:149
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
Position myFGPosition
The position in full-geometry mode.
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Boundary myBoundary
The detector's boundary.
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
double myFGRotation
The rotation in full-geometry mode.
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
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, int detectPersons)
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:294
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
const MSLane * getLane() const
Returns the lane the reminder works on.
Static storage of an output device and its base (abstract) implementation.
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
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