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-sim.org/
13 // Copyright (C) 2001-2014 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/Line.h>
39 #include <utils/geom/GeomHelper.h>
42 #include "GUIEdge.h"
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 /* -------------------------------------------------------------------------
54  * GUI_E2_ZS_Collector-methods
55  * ----------------------------------------------------------------------- */
57  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
58  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
59  SUMOReal jamDistThreshold)
60  : MSE2Collector(id, usage, lane, startPos, detLength, haltingTimeThreshold,
61  haltingSpeedThreshold, jamDistThreshold) {}
62 
63 
64 
66 
67 
70  return new MyWrapper(*this);
71 }
72 
73 
74 
75 /* -------------------------------------------------------------------------
76  * GUI_E2_ZS_Collector::MyWrapper-methods
77  * ----------------------------------------------------------------------- */
79  : GUIDetectorWrapper("E2 detector", detector.getID()),
80  myDetector(detector) {
81  const PositionVector& v = detector.getLane()->getShape();
82  Line l(v.front(), v.back());
83  // build geometry
84  myFullGeometry = v.getSubpart(detector.getStartPos(), detector.getEndPos());
85  //
86  myShapeRotations.reserve(myFullGeometry.size() - 1);
87  myShapeLengths.reserve(myFullGeometry.size() - 1);
88  int e = (int) myFullGeometry.size() - 1;
89  for (int i = 0; i < e; ++i) {
90  const Position& f = myFullGeometry[i];
91  const Position& s = myFullGeometry[i + 1];
92  myShapeLengths.push_back(f.distanceTo(s));
93  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
94  }
95  //
96  myBoundary = myFullGeometry.getBoxBoundary();
97 }
98 
99 
101 
102 
103 Boundary
105  Boundary b(myBoundary);
106  b.grow(20);
107  return b;
108 }
109 
110 
115  new GUIParameterTableWindow(app, *this, 13);
116  // add items
117  // parameter
118  ret->mkItem("length [m]", false, myDetector.getEndPos() - myDetector.getStartPos());
119  ret->mkItem("position [m]", false, myDetector.getStartPos());
120  ret->mkItem("lane", false, myDetector.getLane()->getID());
121  // values
122  ret->mkItem("vehicles [#]", true,
124  ret->mkItem("occupancy [%]", true,
126  ret->mkItem("mean speed [m/s]", true,
128  ret->mkItem("mean vehicle length [m]", true,
130  ret->mkItem("jam number [#]", true,
132  ret->mkItem("max jam length [veh]", true,
134  ret->mkItem("max jam length [m]", true,
136  ret->mkItem("jam length sum [veh]", true,
138  ret->mkItem("jam length sum [m]", true,
140  ret->mkItem("started halts [#]", true,
142  // close building
143  ret->closeBuilding();
144  return ret;
145 }
146 
147 
148 void
150  glPushName(getGlID());
151  glPushMatrix();
152  glTranslated(0, 0, getType());
153  SUMOReal dwidth = 1;
154  if (myDetector.getUsageType() == DU_TL_CONTROL) {
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 = 2; // !!!
161  if (width * s.addExaggeration > 1.0) {
162  glScaled(s.addExaggeration, s.addExaggeration, 1);
163  GLHelper::drawBoxLines(myFullGeometry, myShapeRotations, myShapeLengths, dwidth);
164  } else {
165  int e = (int) myFullGeometry.size() - 1;
166  for (int i = 0; i < e; ++i) {
167  GLHelper::drawLine(myFullGeometry[i], myShapeRotations[i], myShapeLengths[i]);
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