SUMO - Simulation of Urban MObility
GUI_E2_ZS_Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The gui-version of the MS_E2_ZS_Collector
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
36 #include "GUI_E2_ZS_Collector.h"
37 #include <utils/gui/div/GLHelper.h>
38 #include <utils/geom/GeomHelper.h>
41 #include "GUIEdge.h"
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 /* -------------------------------------------------------------------------
53  * GUI_E2_ZS_Collector-methods
54  * ----------------------------------------------------------------------- */
56  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
57  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
58  SUMOReal jamDistThreshold)
59  : MSE2Collector(id, usage, lane, startPos, detLength, haltingTimeThreshold,
60  haltingSpeedThreshold, jamDistThreshold) {}
61 
62 
63 
65 
66 
69  return new MyWrapper(*this);
70 }
71 
72 
73 
74 /* -------------------------------------------------------------------------
75  * GUI_E2_ZS_Collector::MyWrapper-methods
76  * ----------------------------------------------------------------------- */
78  : GUIDetectorWrapper("E2 detector", detector.getID()),
79  myDetector(detector) {
80  const PositionVector& v = detector.getLane()->getShape();
81  // build geometry
82  myFullGeometry = v.getSubpart(detector.getStartPos(), detector.getEndPos());
83  //
84  myShapeRotations.reserve(myFullGeometry.size() - 1);
85  myShapeLengths.reserve(myFullGeometry.size() - 1);
86  int e = (int) myFullGeometry.size() - 1;
87  for (int i = 0; i < e; ++i) {
88  const Position& f = myFullGeometry[i];
89  const Position& s = myFullGeometry[i + 1];
90  myShapeLengths.push_back(f.distanceTo(s));
91  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
92  }
93  //
95 }
96 
97 
99 
100 
101 Boundary
103  Boundary b(myBoundary);
104  b.grow(20);
105  return b;
106 }
107 
108 
113  new GUIParameterTableWindow(app, *this, 13);
114  // add items
115  // parameter
116  ret->mkItem("length [m]", false, myDetector.getEndPos() - myDetector.getStartPos());
117  ret->mkItem("position [m]", false, myDetector.getStartPos());
118  ret->mkItem("lane", false, myDetector.getLane()->getID());
119  // values
120  ret->mkItem("vehicles [#]", true,
122  ret->mkItem("occupancy [%]", true,
124  ret->mkItem("mean speed [m/s]", true,
126  ret->mkItem("mean vehicle length [m]", true,
128  ret->mkItem("jam number [#]", true,
130  ret->mkItem("max jam length [veh]", true,
132  ret->mkItem("max jam length [m]", true,
134  ret->mkItem("jam length sum [veh]", true,
136  ret->mkItem("jam length sum [m]", true,
138  ret->mkItem("started halts [#]", true,
140  // close building
141  ret->closeBuilding();
142  return ret;
143 }
144 
145 
146 void
148  glPushName(getGlID());
149  glPushMatrix();
150  glTranslated(0, 0, getType());
151  SUMOReal dwidth = 1;
152  const SUMOReal exaggeration = s.addSize.getExaggeration(s);
153  if (exaggeration > 0) {
155  dwidth = (SUMOReal) 0.3;
156  glColor3d(0, (SUMOReal) .6, (SUMOReal) .8);
157  } else {
158  glColor3d(0, (SUMOReal) .8, (SUMOReal) .8);
159  }
160  SUMOReal width = (SUMOReal) 2.0 * s.scale;
161  if (width * exaggeration > 1.0) {
163  } else {
164  int e = (int) myFullGeometry.size() - 1;
165  for (int i = 0; i < e; ++i) {
167  }
168  }
169  }
170  glPopMatrix();
171  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
172  glPopName();
173 }
174 
175 
178  return myDetector;
179 }
180 
181 
182 
183 /****************************************************************************/
184 
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
Boundary myBoundary
The detector&#39;s boundary.
long long int SUMOTime
Definition: SUMOTime.h:43
GUIVisualizationTextSettings addName
An areal (along a single lane) detector.
Definition: MSE2Collector.h:83
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
Stores the information about how to visualize structures.
~GUI_E2_ZS_Collector()
Destructor.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
std::vector< SUMOReal > myShapeRotations
A sequence of rotations in full-geometry mode.
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
PositionVector myFullGeometry
A sequence of positions in full-geometry mode.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUI_E2_ZS_Collector & getDetector()
Returns the detector itself.
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
GUI_E2_ZS_Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Constructor.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:221
virtual DetectorUsage getUsageType() const
Returns the detector&#39;s usage type.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIGlID getGlID() const
Returns the numerical id of the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
const MSLane * getLane() const
Returns the lane the reminder works on.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
GUI_E2_ZS_Collector & myDetector
The wrapped detector.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
MyWrapper(GUI_E2_ZS_Collector &detector)
Constructor.
#define PI
Definition: polyfonts.c:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
SUMOReal getStartPos() const
Returns the begin position of the detector.
std::vector< SUMOReal > myShapeLengths
A sequence of lengths in full-geometry mode.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
int getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
The gui-version of the MS_E2_ZS_Collector.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:422
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:269
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
#define SUMOReal
Definition: config.h:213
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
A window containing a gl-object&#39;s parameter.
PositionVector getSubpart(SUMOReal beginOffset, SUMOReal endOffset) const
get subpart of a position vector
SUMOReal getEndPos() const
Returns the end position of the detector.