SUMO - Simulation of Urban MObility
GUIE2Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // The gui-version of the MSE2Collector
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
35 #include "GUIE2Collector.h"
36 #include <utils/gui/div/GLHelper.h>
37 #include <utils/geom/GeomHelper.h>
40 #include "GUIEdge.h"
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
47 /* -------------------------------------------------------------------------
48  * GUIE2Collector-methods
49  * ----------------------------------------------------------------------- */
50 GUIE2Collector::GUIE2Collector(const std::string& id, DetectorUsage usage,
51  MSLane* lane, double startPos, double endPos, double detLength,
52  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold,
53  double jamDistThreshold, const std::string& vTypes, bool showDetector)
54  : MSE2Collector(id, usage, lane, startPos, endPos, detLength, haltingTimeThreshold,
55  haltingSpeedThreshold, jamDistThreshold, vTypes),
56  myShowDetectorInGUI(showDetector) {}
57 
58 GUIE2Collector::GUIE2Collector(const std::string& id, DetectorUsage usage,
59  std::vector<MSLane*> lanes, double startPos, double endPos,
60  SUMOTime haltingTimeThreshold, double haltingSpeedThreshold,
61  double jamDistThreshold, const std::string& vTypes, bool showDetector)
62  : MSE2Collector(id, usage, lanes, startPos, endPos, haltingTimeThreshold,
63  haltingSpeedThreshold, jamDistThreshold, vTypes),
64  myShowDetectorInGUI(showDetector) {}
65 
67 
68 
71  return new MyWrapper(*this);
72 }
73 
74 
75 
76 /* -------------------------------------------------------------------------
77  * GUIE2Collector::MyWrapper-methods
78  * ----------------------------------------------------------------------- */
80  : GUIDetectorWrapper("E2 detector", detector.getID()),
81  myDetector(detector) {
82 
83  // collect detector shape into one vector (v)
85  const std::vector<MSLane*> lanes = detector.getLanes();
86  for (std::vector<MSLane*>::const_iterator li = lanes.begin(); li != lanes.end(); ++li) {
87  const PositionVector& shape = (*li)->getShape();
88  v.insert(v.end(), shape.begin(), shape.end());
89  }
90 
91  // build geometry
92  myFullGeometry = v.getSubpart(detector.getStartPos(), detector.getStartPos() + detector.getLength());
93  //
94  myShapeRotations.reserve(myFullGeometry.size() - 1);
95  myShapeLengths.reserve(myFullGeometry.size() - 1);
96  int e = (int) myFullGeometry.size() - 1;
97  for (int i = 0; i < e; ++i) {
98  const Position& f = myFullGeometry[i];
99  const Position& s = myFullGeometry[i + 1];
100  myShapeLengths.push_back(f.distanceTo(s));
101  myShapeRotations.push_back((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double) M_PI);
102  }
103  //
105 }
106 
107 
109 
110 
111 Boundary
113  Boundary b(myBoundary);
114  b.grow(20);
115  return b;
116 }
117 
118 
123  new GUIParameterTableWindow(app, *this, 13);
124  // add items
125  // parameter
126  ret->mkItem("length [m]", false, myDetector.getLength());
127  ret->mkItem("position [m]", false, myDetector.getStartPos());
128  ret->mkItem("lane", false, myDetector.getLane()->getID());
129  // values
130  ret->mkItem("vehicles [#]", true,
132  ret->mkItem("occupancy [%]", true,
134  ret->mkItem("mean speed [m/s]", true,
136  ret->mkItem("mean vehicle length [m]", true,
138  ret->mkItem("jam number [#]", true,
140  ret->mkItem("max jam length [veh]", true,
142  ret->mkItem("max jam length [m]", true,
144  ret->mkItem("jam length sum [veh]", true,
146  ret->mkItem("jam length sum [m]", true,
148  ret->mkItem("started halts [#]", true,
150  // close building
151  ret->closeBuilding();
152  return ret;
153 }
154 
155 
156 void
159  return;
160  }
161  glPushName(getGlID());
162  glPushMatrix();
163  glTranslated(0, 0, getType());
164  double dwidth = 1;
165  const double exaggeration = s.addSize.getExaggeration(s);
166  if (exaggeration > 0) {
168  dwidth = (double) 0.3;
169  glColor3d(0, (double) .6, (double) .8);
170  } else {
171  glColor3d(0, (double) .8, (double) .8);
172  }
173  double width = (double) 2.0 * s.scale;
174  if (width * exaggeration > 1.0) {
176  } else {
177  int e = (int) myFullGeometry.size() - 1;
178  for (int i = 0; i < e; ++i) {
180  }
181  }
182  }
183  glPopMatrix();
184  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
185  glPopName();
186 }
187 
188 
191  return myDetector;
192 }
193 
194 
195 
196 /****************************************************************************/
197 
const MSLane * getLane() const
Returns the lane the reminder works on.
std::vector< double > myShapeLengths
A sequence of lengths in full-geometry mode.
double scale
information about a lane&#39;s width (temporary, used for a single view)
std::vector< double > myShapeRotations
A sequence of rotations in full-geometry mode.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:183
GUIVisualizationTextSettings addName
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
An areal detector corresponding to a sequence of consecutive lanes.
Definition: MSE2Collector.h:86
MyWrapper(GUIE2Collector &detector)
Constructor.
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:67
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
double x() const
Returns the x-position.
Definition: Position.h:62
double getLength() const
Returns the length of the detector.
GUIE2Collector & myDetector
The wrapped detector.
double getStartPos() const
Returns the begin position of the detector.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
The gui-version of the MSE2Collector.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
PositionVector myFullGeometry
A sequence of positions in full-geometry mode.
GUIVisualizationSizeSettings addSize
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
double getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
int getCurrentJamNumber() const
Returns the current number of jams.
std::vector< MSLane * > getLanes()
Returns a vector containing pointers to the lanes covered by the detector ordered from its first to i...
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
GUIE2Collector(const std::string &id, DetectorUsage usage, MSLane *lane, double startPos, double endPos, double detLength, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, bool showDetector)
Constructor with given end position and detector length.
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:301
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:276
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
#define M_PI
Definition: odrSpiral.cpp:40
double getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
virtual DetectorUsage getUsageType() const
Returns the detector&#39;s usage type.
bool myShowDetectorInGUI
Whether the detector shall be drawn in the gui.
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
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:239
long long int SUMOTime
Definition: TraCIDefs.h:51
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
~GUIE2Collector()
Destructor.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
double getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
double getCurrentOccupancy() const
Returns the current detector occupancy.
A window containing a gl-object&#39;s parameter.
GUIE2Collector & getDetector()
Returns the detector itself.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
Boundary myBoundary
The detector&#39;s boundary.