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"
44 
45 #ifdef _WIN32
46 #include <windows.h>
47 #endif
48 
49 #include <GL/gl.h>
50 
51 #ifdef CHECK_MEMORY_LEAKS
52 #include <foreign/nvwa/debug_new.h>
53 #endif // CHECK_MEMORY_LEAKS
54 
55 
56 // ===========================================================================
57 // method definitions
58 // ===========================================================================
59 /* -------------------------------------------------------------------------
60  * GUI_E2_ZS_Collector-methods
61  * ----------------------------------------------------------------------- */
63  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
64  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
65  SUMOReal jamDistThreshold)
66  : MSE2Collector(id, usage, lane, startPos, detLength, haltingTimeThreshold,
67  haltingSpeedThreshold, jamDistThreshold) {}
68 
69 
70 
72 
73 
76  return new MyWrapper(*this);
77 }
78 
79 
80 
81 /* -------------------------------------------------------------------------
82  * GUI_E2_ZS_Collector::MyWrapper-methods
83  * ----------------------------------------------------------------------- */
85  : GUIDetectorWrapper("E2 detector", detector.getID()),
86  myDetector(detector) {
87  GUILaneWrapper& lw = static_cast<GUIEdge&>(detector.getLane()->getEdge()).getLaneGeometry(detector.getLane());
88  const PositionVector& v = lw.getShape();
89  Line l(v.getBegin(), v.getEnd());
90  // build geometry
91  myFullGeometry = v.getSubpart(detector.getStartPos(), detector.getEndPos());
92  //
93  myShapeRotations.reserve(myFullGeometry.size() - 1);
94  myShapeLengths.reserve(myFullGeometry.size() - 1);
95  int e = (int) myFullGeometry.size() - 1;
96  for (int i = 0; i < e; ++i) {
97  const Position& f = myFullGeometry[i];
98  const Position& s = myFullGeometry[i + 1];
99  myShapeLengths.push_back(f.distanceTo(s));
100  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
101  }
102  //
103  myBoundary = myFullGeometry.getBoxBoundary();
104 }
105 
106 
108 
109 
110 Boundary
112  Boundary b(myBoundary);
113  b.grow(20);
114  return b;
115 }
116 
117 
122  new GUIParameterTableWindow(app, *this, 13);
123  // add items
124  // parameter
125  ret->mkItem("length [m]", false, myDetector.getEndPos() - myDetector.getStartPos());
126  ret->mkItem("position [m]", false, myDetector.getStartPos());
127  ret->mkItem("lane", false, myDetector.getLane()->getID());
128  // values
129  ret->mkItem("vehicles [#]", true,
131  ret->mkItem("occupancy [%]", true,
133  ret->mkItem("mean speed [m/s]", true,
135  ret->mkItem("mean vehicle length [m]", true,
137  ret->mkItem("jam number [#]", true,
139  ret->mkItem("max jam length [veh]", true,
141  ret->mkItem("max jam length [m]", true,
143  ret->mkItem("jam length sum [veh]", true,
145  ret->mkItem("jam length sum [m]", true,
147  ret->mkItem("started halts [#]", true,
149  // close building
150  ret->closeBuilding();
151  return ret;
152 }
153 
154 
155 void
157  glPushName(getGlID());
158  glPushMatrix();
159  glTranslated(0, 0, getType());
160  SUMOReal dwidth = 1;
161  if (myDetector.getUsageType() == DU_TL_CONTROL) {
162  dwidth = (SUMOReal) 0.3;
163  glColor3d(0, (SUMOReal) .6, (SUMOReal) .8);
164  } else {
165  glColor3d(0, (SUMOReal) .8, (SUMOReal) .8);
166  }
167  SUMOReal width = 2; // !!!
168  if (width * s.addExaggeration > 1.0) {
169  glScaled(s.addExaggeration, s.addExaggeration, 1);
170  GLHelper::drawBoxLines(myFullGeometry, myShapeRotations, myShapeLengths, dwidth);
171  } else {
172  int e = (int) myFullGeometry.size() - 1;
173  for (int i = 0; i < e; ++i) {
174  GLHelper::drawLine(myFullGeometry[i], myShapeRotations[i], myShapeLengths[i]);
175  }
176  }
177  glPopMatrix();
178  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
179  glPopName();
180 }
181 
182 
185  return myDetector;
186 }
187 
188 
189 
190 /****************************************************************************/
191