SUMO - Simulation of Urban MObility
GUIMEInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The gui-version of the MEInductLoop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 
35 #include <guisim/GUILane.h>
36 #include <utils/gui/div/GLHelper.h>
40 #include <mesosim/MEInductLoop.h>
41 #include <mesosim/MESegment.h>
42 #include "GUIMEInductLoop.h"
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 /* -------------------------------------------------------------------------
49  * GUIMEInductLoop-methods
50  * ----------------------------------------------------------------------- */
51 GUIMEInductLoop::GUIMEInductLoop(const std::string& id, MESegment* s,
52  double position, const std::string& vTypes)
53  : MEInductLoop(id, s, position, vTypes) {}
54 
55 
57 
58 
61  return new MyWrapper(*this, myPosition);
62 }
63 
64 
65 /* -------------------------------------------------------------------------
66  * GUIMEInductLoop::MyWrapper-methods
67  * ----------------------------------------------------------------------- */
69  : GUIDetectorWrapper("induct loop", detector.getID()),
70  myDetector(detector), myPosition(pos) {
71  const MSLane* lane = detector.mySegment->getEdge().getLanes()[0];
73  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
74  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
76 }
77 
78 
80 
81 
85  b.grow(20);
86  return b;
87 }
88 
89 
90 
93  GUISUMOAbstractView& /* parent */) {
95  new GUIParameterTableWindow(app, *this, 2);
96  // add items
97  /*
98  ret->mkItem("flow [veh/h]", true,
99  new FuncBinding_IntParam<GUIMEInductLoop, double>(
100  &(getLoop()), &GUIMEInductLoop::getFlow, 1));
101  ret->mkItem("mean speed [m/s]", true,
102  new FuncBinding_IntParam<GUIMEInductLoop, double>(
103  &(getLoop()), &GUIMEInductLoop::getMeanSpeed, 1));
104  ret->mkItem("occupancy [%]", true,
105  new FuncBinding_IntParam<GUIMEInductLoop, double>(
106  &(getLoop()), &GUIMEInductLoop::getOccupancy, 1));
107  ret->mkItem("mean vehicle length [m]", true,
108  new FuncBinding_IntParam<GUIMEInductLoop, double>(
109  &(getLoop()), &GUIMEInductLoop::getMeanVehicleLength, 1));
110  ret->mkItem("empty time [s]", true,
111  new FunctionBinding<GUIMEInductLoop, double>(
112  &(getLoop()), &GUIMEInductLoop::getTimeSinceLastDetection));
113  */
114  //
115  ret->mkItem("position [m]", false, myPosition);
116  ret->mkItem("lane", false, myDetector.mySegment->getID());
117  // close building
118  ret->closeBuilding();
119  return ret;
120 }
121 
122 
123 void
125  glPushName(getGlID());
126  glPolygonOffset(0, -2);
127  double width = (double) 2.0 * s.scale;
128  glLineWidth(1.0);
129  const double exaggeration = s.addSize.getExaggeration(s);
130  // shape
131  glColor3d(1, 1, 0);
132  glPushMatrix();
133  glTranslated(myFGPosition.x(), myFGPosition.y(), getType());
134  glRotated(myFGRotation, 0, 0, 1);
135  glScaled(exaggeration, exaggeration, exaggeration);
136  glBegin(GL_QUADS);
137  glVertex2d(0 - 1.0, 2);
138  glVertex2d(-1.0, -2);
139  glVertex2d(1.0, -2);
140  glVertex2d(1.0, 2);
141  glEnd();
142  glBegin(GL_LINES);
143  // without the substracted offsets, lines are partially longer
144  // than the boxes
145  glVertex2d(0, 2 - .1);
146  glVertex2d(0, -2 + .1);
147  glEnd();
148 
149  // outline
150  if (width * exaggeration > 1) {
151  glColor3d(1, 1, 1);
152  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
153  glBegin(GL_QUADS);
154  glVertex2f(0 - 1.0, 2);
155  glVertex2f(-1.0, -2);
156  glVertex2f(1.0, -2);
157  glVertex2f(1.0, 2);
158  glEnd();
159  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
160  }
161 
162  // position indicator
163  if (width * exaggeration > 1) {
164  glRotated(90, 0, 0, -1);
165  glColor3d(1, 1, 1);
166  glBegin(GL_LINES);
167  glVertex2d(0, 1.7);
168  glVertex2d(0, -1.7);
169  glEnd();
170  }
171  glPopMatrix();
172  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
173  glPopName();
174 }
175 
176 
179  return myDetector;
180 }
181 
182 
183 /****************************************************************************/
184 
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
const double myPosition
position from the start of the edge / lane
Definition: MEInductLoop.h:102
double myFGRotation
The rotation in full-geometry mode.
double scale
information about a lane&#39;s width (temporary, used for a single view)
Position myFGPosition
The position in full-geometry mode.
GUIVisualizationTextSettings addName
~GUIMEInductLoop()
Destructor.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:68
double x() const
Returns the x-position.
Definition: Position.h:63
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
GUIMEInductLoop(const std::string &id, MESegment *s, double position, const std::string &vTypes)
Construtor.
Boundary myBoundary
The detector&#39;s boundary.
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIMEInductLoop & getLoop()
Returns the detector itself.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
MyWrapper(GUIMEInductLoop &detector, double pos)
Constructor.
double myPosition
The position on the lane.
A single mesoscopic segment (cell)
Definition: MESegment.h:57
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector&#39;s visualisation-wrapper.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
void closeBuilding()
Closes the building of the table.
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:271
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
A window containing a gl-object&#39;s parameter.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
An induction loop for mesoscopic simulation.
Definition: MEInductLoop.h:55
MESegment *const mySegment
mesoscopic edge segment the loop lies on
Definition: MEInductLoop.h:99
GUIMEInductLoop & myDetector
The wrapped detector.