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.org/sumo
3 // Copyright (C) 2003-2020 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 
26 #include "GUIInstantInductLoop.h"
27 #include <utils/gui/div/GLHelper.h>
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& vTypes)
45  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
46 
47 
49 
50 
53  return new MyWrapper(*this, myPosition);
54 }
55 
56 // -------------------------------------------------------------------------
57 // GUIInstantInductLoop::MyWrapper-methods
58 // -------------------------------------------------------------------------
59 
61  GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID()),
62  myDetector(detector), myPosition(pos) {
64  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
65  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
67 }
68 
69 
71 
72 
75  Boundary b(myBoundary);
76  b.grow(20);
77  return b;
78 }
79 
80 
81 
84  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
85  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
86  // add items
87  // parameter
88  ret->mkItem("position [m]", false, myPosition);
89  ret->mkItem("lane", false, myDetector.getLane()->getID());
90  // values
91  // close building
92  ret->closeBuilding();
93  return ret;
94 }
95 
96 
97 void
99  glPushName(getGlID());
100  double width = (double) 2.0 * s.scale;
101  glLineWidth(1.0);
102  const double exaggeration = s.addSize.getExaggeration(s, this);
103  // shape
104  glColor3d(1, 0, 1);
105  glPushMatrix();
106  glTranslated(0, 0, getType());
107  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
108  glRotated(myFGRotation, 0, 0, 1);
109  glScaled(exaggeration, exaggeration, 1);
110  glBegin(GL_QUADS);
111  glVertex2d(0 - 1.0, 2);
112  glVertex2d(-1.0, -2);
113  glVertex2d(1.0, -2);
114  glVertex2d(1.0, 2);
115  glEnd();
116  glTranslated(0, 0, .01);
117  glBegin(GL_LINES);
118  glVertex2d(0, 2 - .1);
119  glVertex2d(0, -2 + .1);
120  glEnd();
121 
122  // outline
123  if (width * exaggeration > 1) {
124  glColor3d(1, 1, 1);
125  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
126  glBegin(GL_QUADS);
127  glVertex2f(0 - 1.0, 2);
128  glVertex2f(-1.0, -2);
129  glVertex2f(1.0, -2);
130  glVertex2f(1.0, 2);
131  glEnd();
132  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
133  }
134 
135  // position indicator
136  if (width * exaggeration > 1) {
137  glRotated(90, 0, 0, -1);
138  glColor3d(1, 1, 1);
139  glBegin(GL_LINES);
140  glVertex2d(0, 1.7);
141  glVertex2d(0, -1.7);
142  glEnd();
143  }
144  glPopMatrix();
145  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
146  glPopName();
147 }
148 
149 
152  return myDetector;
153 }
154 
155 
156 /****************************************************************************/
@ GLO_E1DETECTOR_INSTANT
a E1 detector
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:77
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
A MSInductLoop-visualiser.
Position myFGPosition
The position in full-geometry mode.
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 &vTypes)
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:82
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:476
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:503
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:60
double x() const
Returns the x-position.
Definition: Position.h:54
double y() const
Returns the y-position.
Definition: Position.h:59
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