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-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/****************************************************************************/
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 MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges) {}
48
49
51
52
57
58// -------------------------------------------------------------------------
59// GUIInstantInductLoop::MyWrapper-methods
60// -------------------------------------------------------------------------
61
64 myDetector(detector), myPosition(pos) {
66 myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
67 myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
69}
70
71
73
74
75double
79
80
83 Boundary b(myBoundary);
84 b.grow(20);
85 return b;
86}
87
88
89
92 GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
94 // add items
95 // parameter
96 ret->mkItem(TL("name"), false, myDetector.myName);
97 ret->mkItem(TL("position [m]"), false, myPosition);
98 ret->mkItem(TL("lane"), false, myDetector.getLane()->getID());
99 if (myDetector.isTyped()) {
100 ret->mkItem(TL("vTypes"), false, toString(myDetector.getVehicleTypes()));
101 }
102 // values
103 // close building
104 ret->closeBuilding(&myDetector);
105 return ret;
106}
107
108
109void
111 GLHelper::pushName(getGlID());
112 double width = (double) 2.0 * s.scale;
113 glLineWidth(1.0);
114 const double exaggeration = getExaggeration(s);
115 // shape
116 glColor3d(1, 0, 1);
118 glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
119 glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
120 glRotated(myFGRotation, 0, 0, 1);
121 glScaled(exaggeration, exaggeration, 1);
122 glBegin(GL_QUADS);
123 glVertex2d(0 - 1.0, 2);
124 glVertex2d(-1.0, -2);
125 glVertex2d(1.0, -2);
126 glVertex2d(1.0, 2);
127 glEnd();
128 glTranslated(0, 0, .01);
129 glBegin(GL_LINES);
130 glVertex2d(0, 2 - .1);
131 glVertex2d(0, -2 + .1);
132 glEnd();
133
134 // outline
135 if (width * exaggeration > 1) {
136 glColor3d(1, 1, 1);
137 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
138 glBegin(GL_QUADS);
139 glVertex2d(0 - 1.0, 2);
140 glVertex2d(-1.0, -2);
141 glVertex2d(1.0, -2);
142 glVertex2d(1.0, 2);
143 glEnd();
144 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
145 }
146
147 // position indicator
148 if (width * exaggeration > 1) {
149 glRotated(90, 0, 0, -1);
150 glColor3d(1, 1, 1);
151 glBegin(GL_LINES);
152 glVertex2d(0, 1.7);
153 glVertex2d(0, -1.7);
154 glEnd();
155 }
157 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
159}
160
161
164 return myDetector;
165}
166
167
168/****************************************************************************/
@ 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:315
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: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
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: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: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