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-2022 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 
73 double
75  return s.addSize.getExaggeration(s, this);
76 }
77 
78 
81  Boundary b(myBoundary);
82  b.grow(20);
83  return b;
84 }
85 
86 
87 
90  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
91  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
92  // add items
93  // parameter
94  ret->mkItem("position [m]", false, myPosition);
95  ret->mkItem("lane", false, myDetector.getLane()->getID());
96  // values
97  // close building
98  ret->closeBuilding(&myDetector);
99  return ret;
100 }
101 
102 
103 void
105  GLHelper::pushName(getGlID());
106  double width = (double) 2.0 * s.scale;
107  glLineWidth(1.0);
108  const double exaggeration = getExaggeration(s);
109  // shape
110  glColor3d(1, 0, 1);
112  glTranslated(0, 0, getType());
113  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
114  glRotated(myFGRotation, 0, 0, 1);
115  glScaled(exaggeration, exaggeration, 1);
116  glBegin(GL_QUADS);
117  glVertex2d(0 - 1.0, 2);
118  glVertex2d(-1.0, -2);
119  glVertex2d(1.0, -2);
120  glVertex2d(1.0, 2);
121  glEnd();
122  glTranslated(0, 0, .01);
123  glBegin(GL_LINES);
124  glVertex2d(0, 2 - .1);
125  glVertex2d(0, -2 + .1);
126  glEnd();
127 
128  // outline
129  if (width * exaggeration > 1) {
130  glColor3d(1, 1, 1);
131  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
132  glBegin(GL_QUADS);
133  glVertex2d(0 - 1.0, 2);
134  glVertex2d(-1.0, -2);
135  glVertex2d(1.0, -2);
136  glVertex2d(1.0, 2);
137  glEnd();
138  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
139  }
140 
141  // position indicator
142  if (width * exaggeration > 1) {
143  glRotated(90, 0, 0, -1);
144  glColor3d(1, 1, 1);
145  glBegin(GL_LINES);
146  glVertex2d(0, 1.7);
147  glVertex2d(0, -1.7);
148  glEnd();
149  }
151  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
153 }
154 
155 
158  return myDetector;
159 }
160 
161 
162 /****************************************************************************/
@ 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
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
A MSInductLoop-visualiser.
Position myFGPosition
The position in full-geometry mode.
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated 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 &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:478
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
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