SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
13 // Copyright (C) 2001-2012 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 "GUILaneWrapper.h"
37 #include "GUI_E2_ZS_Collector.h"
38 #include <utils/gui/div/GLHelper.h>
39 #include <utils/geom/Line.h>
40 #include <utils/geom/GeomHelper.h>
43 #include "GUIEdge.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 /* -------------------------------------------------------------------------
55  * GUI_E2_ZS_Collector-methods
56  * ----------------------------------------------------------------------- */
58  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
59  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
60  SUMOReal jamDistThreshold)
61  : MSE2Collector(id, usage, lane, startPos, detLength, haltingTimeThreshold,
62  haltingSpeedThreshold, jamDistThreshold) {}
63 
64 
65 
67 
68 
71  return new MyWrapper(*this);
72 }
73 
74 
75 
76 /* -------------------------------------------------------------------------
77  * GUI_E2_ZS_Collector::MyWrapper-methods
78  * ----------------------------------------------------------------------- */
80  : GUIDetectorWrapper("E2 detector", detector.getID()),
81  myDetector(detector) {
82  GUILaneWrapper& lw = static_cast<GUIEdge&>(detector.getLane()->getEdge()).getLaneGeometry(detector.getLane());
83  const PositionVector& v = lw.getShape();
84  Line l(v.getBegin(), v.getEnd());
85  // build geometry
86  myFullGeometry = v.getSubpart(detector.getStartPos(), detector.getEndPos());
87  //
88  myShapeRotations.reserve(myFullGeometry.size() - 1);
89  myShapeLengths.reserve(myFullGeometry.size() - 1);
90  int e = (int) myFullGeometry.size() - 1;
91  for (int i = 0; i < e; ++i) {
92  const Position& f = myFullGeometry[i];
93  const Position& s = myFullGeometry[i + 1];
94  myShapeLengths.push_back(f.distanceTo(s));
95  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
96  }
97  //
98  myBoundary = myFullGeometry.getBoxBoundary();
99 }
100 
101 
103 
104 
105 Boundary
107  Boundary b(myBoundary);
108  b.grow(20);
109  return b;
110 }
111 
112 
117  new GUIParameterTableWindow(app, *this, 13);
118  // add items
119  // parameter
120  ret->mkItem("length [m]", false, myDetector.getEndPos() - myDetector.getStartPos());
121  ret->mkItem("position [m]", false, myDetector.getStartPos());
122  ret->mkItem("lane", false, myDetector.getLane()->getID());
123  // values
124  ret->mkItem("vehicles [#]", true,
126  ret->mkItem("occupancy [%]", true,
128  ret->mkItem("mean speed [m/s]", true,
130  ret->mkItem("mean vehicle length [m]", true,
132  ret->mkItem("jam number [#]", true,
134  ret->mkItem("max jam length [veh]", true,
136  ret->mkItem("max jam length [m]", true,
138  ret->mkItem("jam length sum [veh]", true,
140  ret->mkItem("jam length sum [m]", true,
142  ret->mkItem("started halts [#]", true,
144  // close building
145  ret->closeBuilding();
146  return ret;
147 }
148 
149 
150 void
152  glPushName(getGlID());
153  glPushMatrix();
154  glTranslated(0, 0, getType());
155  SUMOReal dwidth = 1;
156  if (myDetector.getUsageType() == DU_TL_CONTROL) {
157  dwidth = (SUMOReal) 0.3;
158  glColor3d(0, (SUMOReal) .6, (SUMOReal) .8);
159  } else {
160  glColor3d(0, (SUMOReal) .8, (SUMOReal) .8);
161  }
162  SUMOReal width = 2; // !!!
163  if (width * s.addExaggeration > 1.0) {
164  glScaled(s.addExaggeration, s.addExaggeration, 1);
165  GLHelper::drawBoxLines(myFullGeometry, myShapeRotations, myShapeLengths, dwidth);
166  } else {
167  int e = (int) myFullGeometry.size() - 1;
168  for (int i = 0; i < e; ++i) {
169  GLHelper::drawLine(myFullGeometry[i], myShapeRotations[i], myShapeLengths[i]);
170  }
171  }
172  glPopMatrix();
173  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
174  glPopName();
175 }
176 
177 
180  return myDetector;
181 }
182 
183 
184 
185 /****************************************************************************/
186