SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
12 // Copyright (C) 2001-2012 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/Line.h>
38 #include <utils/geom/GeomHelper.h>
40 #include <guisim/GUIEdge.h>
41 #include "GUILaneWrapper.h"
43 
44 #ifdef _WIN32
45 #include <windows.h>
46 #include <GL/gl.h> /* OpenGL header file */
47 #endif // _WIN32
48 
49 #ifdef CHECK_MEMORY_LEAKS
50 #include <foreign/nvwa/debug_new.h>
51 #endif // CHECK_MEMORY_LEAKS
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
57 /* -------------------------------------------------------------------------
58  * GUI_E2_ZS_CollectorOverLanes-methods
59  * ----------------------------------------------------------------------- */
61  DetectorUsage usage, MSLane* lane, SUMOReal startPos,
62  SUMOTime haltingTimeThreshold,
63  SUMOReal haltingSpeedThreshold,
64  SUMOReal jamDistThreshold)
65  : MS_E2_ZS_CollectorOverLanes(id, usage, lane, startPos,
66  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold) {}
67 
68 
69 
71 
72 
75  return new MyWrapper(*this, myAlreadyBuild);
76 }
77 
78 
81  SUMOReal start, SUMOReal end) {
82  std::string id = makeID(myID, c, r);
83  if (start + end < l->getLength()) {
84  start = l->getLength() - end - (SUMOReal) 0.1;
85  }
86  return new GUI_E2_ZS_Collector(id, myUsage,
87  l, start, end, haltingTimeThresholdM,
89 }
90 
91 
92 /* -------------------------------------------------------------------------
93  * GUI_E2_ZS_CollectorOverLanes::MyWrapper-methods
94  * ----------------------------------------------------------------------- */
97  const LaneDetMap& detectors)
98  : GUIDetectorWrapper("E2OverLanes detector", detector.getID()),
99  myDetector(detector) {
100  for (LaneDetMap::const_iterator i = detectors.begin(); i != detectors.end(); ++i) {
101  MSLane* l = (*i).first;
102  GUIEdge& edge = static_cast<GUIEdge&>(l->getEdge());
103  GUILaneWrapper& w = edge.getLaneGeometry(l);
104  GUI_E2_ZS_Collector* c = static_cast<GUI_E2_ZS_Collector*>((*i).second);
106  mySubWrappers.push_back(dw);
108  }
109 }
110 
111 
113  for (std::vector<GUIDetectorWrapper*>::iterator i = mySubWrappers.begin(); i != mySubWrappers.end(); ++i) {
114  delete(*i);
115  }
116 }
117 
118 
119 Boundary
121  Boundary b(myBoundary);
122  return b;
123 }
124 
125 
129  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 12);
130  // add items
131  /*
132  myMkExistingItem(*ret, "density [?]", E2::DENSITY);
133  myMkExistingItem(*ret, "jam lengths [veh]", E2::MAX_JAM_LENGTH_IN_VEHICLES);
134  myMkExistingItem(*ret, "jam length [m]", E2::MAX_JAM_LENGTH_IN_METERS);
135  myMkExistingItem(*ret, "jam len sum [veh]", E2::JAM_LENGTH_SUM_IN_VEHICLES);
136  myMkExistingItem(*ret, "jam len sum [m]", E2::JAM_LENGTH_SUM_IN_METERS);
137  myMkExistingItem(*ret, "queue length [veh]", E2::QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_VEHICLES);
138  myMkExistingItem(*ret, "queue length [m]", E2::QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_METERS);
139  myMkExistingItem(*ret, "vehicles [veh]", E2::N_VEHICLES);
140  myMkExistingItem(*ret, "occupancy degree [?]", E2::OCCUPANCY_DEGREE);
141  myMkExistingItem(*ret, "space mean speed [?]", E2::SPACE_MEAN_SPEED);
142  myMkExistingItem(*ret, "halting duration [?]", E2::CURRENT_HALTING_DURATION_SUM_PER_VEHICLE);
143  */
144  //
145  ret->mkItem("length [m]", false, myDetector.getLength());
146  /*
147  ret->mkItem("position [m]", false,
148  myDetector.getStartPos());*/
149 // ret->mkItem("", false, myDetector.getStartLaneID());
150  // close building
151  ret->closeBuilding();
152  return ret;
153 }
154 
155 
156 /*
157 void
158 GUI_E2_ZS_CollectorOverLanes::MyWrapper::myMkExistingItem(GUIParameterTableWindow &ret,
159  const std::string &name,
160  E2::DetType type)
161 {
162 if (!myDetector.hasDetector(type)) {
163  return;
164 }
165 MyValueRetriever *binding =
166  new MyValueRetriever(myDetector, type, 1);
167 ret.mkItem(name.c_str(), true, binding);
168 }
169 */
170 
171 
172 void
174  for (std::vector<GUIDetectorWrapper*>::const_iterator i = mySubWrappers.begin(); i != mySubWrappers.end(); ++i) {
175  (*i)->drawGL(s);
176  }
177 }
178 
179 
182  return myDetector;
183 }
184 
185 
186 
187 /****************************************************************************/
188