SUMO - Simulation of Urban MObility
GUI_E2_ZS_CollectorOverLanes.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The gui-version of a MS_E2_ZS_CollectorOverLanes.
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
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 
36 #include <utils/gui/div/GLHelper.h>
37 #include <utils/geom/GeomHelper.h>
39 #include <microsim/MSLane.h>
40 #include <guisim/GUIEdge.h>
41 #include "GUI_E2_ZS_Collector.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_CollectorOverLanes-methods
54  * ----------------------------------------------------------------------- */
56  DetectorUsage usage, MSLane* lane, SUMOReal startPos,
57  SUMOTime haltingTimeThreshold,
58  SUMOReal haltingSpeedThreshold,
59  SUMOReal jamDistThreshold, const std::string& vTypes)
60  : MS_E2_ZS_CollectorOverLanes(id, usage, lane, startPos,
61  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes) {}
62 
63 
64 
66 
67 
70  return new MyWrapper(*this, myAlreadyBuild);
71 }
72 
73 
76  SUMOReal start, SUMOReal end,
77  const std::set<std::string>& vTypes) {
78  std::string id = makeID(myID, c, r);
79  if (start + end < l->getLength()) {
80  start = l->getLength() - end - (SUMOReal) 0.1;
81  }
82  return new GUI_E2_ZS_Collector(id, myUsage,
83  l, start, end, haltingTimeThresholdM,
85 }
86 
87 
88 /* -------------------------------------------------------------------------
89  * GUI_E2_ZS_CollectorOverLanes::MyWrapper-methods
90  * ----------------------------------------------------------------------- */
93  const LaneDetMap& detectors)
94  : GUIDetectorWrapper("E2OverLanes detector", detector.getID()),
95  myDetector(detector) {
96  for (LaneDetMap::const_iterator i = detectors.begin(); i != detectors.end(); ++i) {
97  GUI_E2_ZS_Collector* c = static_cast<GUI_E2_ZS_Collector*>((*i).second);
99  mySubWrappers.push_back(dw);
101  }
102 }
103 
104 
106  for (std::vector<GUIDetectorWrapper*>::iterator i = mySubWrappers.begin(); i != mySubWrappers.end(); ++i) {
107  delete(*i);
108  }
109 }
110 
111 
112 Boundary
114  Boundary b(myBoundary);
115  return b;
116 }
117 
118 
122  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 12);
123  // add items
124  /*
125  myMkExistingItem(*ret, "density [?]", E2::DENSITY);
126  myMkExistingItem(*ret, "jam lengths [veh]", E2::MAX_JAM_LENGTH_IN_VEHICLES);
127  myMkExistingItem(*ret, "jam length [m]", E2::MAX_JAM_LENGTH_IN_METERS);
128  myMkExistingItem(*ret, "jam len sum [veh]", E2::JAM_LENGTH_SUM_IN_VEHICLES);
129  myMkExistingItem(*ret, "jam len sum [m]", E2::JAM_LENGTH_SUM_IN_METERS);
130  myMkExistingItem(*ret, "queue length [veh]", E2::QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_VEHICLES);
131  myMkExistingItem(*ret, "queue length [m]", E2::QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_METERS);
132  myMkExistingItem(*ret, "vehicles [veh]", E2::N_VEHICLES);
133  myMkExistingItem(*ret, "occupancy degree [?]", E2::OCCUPANCY_DEGREE);
134  myMkExistingItem(*ret, "space mean speed [?]", E2::SPACE_MEAN_SPEED);
135  myMkExistingItem(*ret, "halting duration [?]", E2::CURRENT_HALTING_DURATION_SUM_PER_VEHICLE);
136  */
137  //
138  ret->mkItem("length [m]", false, myDetector.getLength());
139  /*
140  ret->mkItem("position [m]", false,
141  myDetector.getStartPos());*/
142 // ret->mkItem("", false, myDetector.getStartLaneID());
143  // close building
144  ret->closeBuilding();
145  return ret;
146 }
147 
148 
149 /*
150 void
151 GUI_E2_ZS_CollectorOverLanes::MyWrapper::myMkExistingItem(GUIParameterTableWindow &ret,
152  const std::string &name,
153  E2::DetType type)
154 {
155 if (!myDetector.hasDetector(type)) {
156  return;
157 }
158 MyValueRetriever *binding =
159  new MyValueRetriever(myDetector, type, 1);
160 ret.mkItem(name.c_str(), true, binding);
161 }
162 */
163 
164 
165 void
167  for (std::vector<GUIDetectorWrapper*>::const_iterator i = mySubWrappers.begin(); i != mySubWrappers.end(); ++i) {
168  (*i)->drawGL(s);
169  }
170 }
171 
172 
175  return myDetector;
176 }
177 
178 
179 
180 /****************************************************************************/
181 
SUMOReal haltingSpeedThresholdM
Describes how slow a vehicle must be before being assigned to a jam.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
GUI_E2_ZS_CollectorOverLanes & myDetector
Builds a view within the parameter table if the according type is available.
long long int SUMOTime
Definition: SUMOTime.h:43
The gui-version of a MS_E2_ZS_CollectorOverLanes.
An areal (along a single lane) detector.
Definition: MSE2Collector.h:83
A detector which joins E2Collectors over consecutive lanes (backward)
SUMOTime haltingTimeThresholdM
Describes how long a vehicle shall stay before being assigned to a jam.
Stores the information about how to visualize structures.
GUI_E2_ZS_CollectorOverLanes & getLoop()
Returns the detector itself.
virtual Boundary getCenteringBoundary() const =0
const std::string & getID() const
Returns the id.
Definition: Named.h:66
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
DetectorUsage myUsage
Information about how this detector is used.
SUMOReal jamDistThresholdM
Describes how long a jam must be before being recognized.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Boundary myBoundary
The detector&#39;s boundary.
std::vector< GUIDetectorWrapper * > mySubWrappers
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Builds the graphical representation.
std::map< MSLane *, MSE2Collector * > LaneDetMap
Definition of a map from a lane to the detector lying on it.
std::string myID
The name of the object.
Definition: Named.h:136
MyWrapper(GUI_E2_ZS_CollectorOverLanes &detector, const LaneDetMap &detectors)
Constructor.
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
SUMOReal getLength() const
Returns this detector&#39;s length [m].
std::string makeID(const std::string &baseID, int c, int r) const
Builds an id for one of the E2 collectors this detector uses.
MSE2Collector * buildCollector(int c, int r, MSLane *l, SUMOReal start, SUMOReal end, const std::set< std::string > &vTypes)
Builds a single collector.
The gui-version of the MS_E2_ZS_Collector.
LaneDetMap myAlreadyBuild
Storage for detectors which already have been build for a single lane.
GUI_E2_ZS_CollectorOverLanes(std::string id, DetectorUsage usage, MSLane *lane, SUMOReal startPos, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, const std::string &vTypes)
Constructor.
#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.
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.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.