SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIE3Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The gui-version of a MSE3Collector
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2013 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 
33 #include "GUIE3Collector.h"
34 #include "GUIEdge.h"
35 #include <utils/geom/Line.h>
37 #include <utils/gui/div/GLHelper.h>
39 #include <microsim/MSLane.h>
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 /* -------------------------------------------------------------------------
51  * GUIE3Collector::MyWrapper-methods
52  * ----------------------------------------------------------------------- */
54  : GUIDetectorWrapper("E3 detector", detector.getID()),
55  myDetector(detector) {
56  const CrossSectionVector& entries = detector.getEntries();
57  const CrossSectionVector& exits = detector.getExits();
59  for (i = entries.begin(); i != entries.end(); ++i) {
62  myEntryDefinitions.push_back(def);
63  }
64  for (i = exits.begin(); i != exits.end(); ++i) {
67  myExitDefinitions.push_back(def);
68  }
69 }
70 
71 
73 
74 
77  const MSLane* lane = section.myLane;
78  SUMOReal pos = section.myPosition;
79  const PositionVector& v = lane->getShape();
80  Line l(v.front(), v.back());
82  def.myFGPosition = v.positionAtOffset(pos);
83  def.myFGRotation = -v.rotationDegreeAtOffset(pos);
84  return def;
85 }
86 
87 
92  new GUIParameterTableWindow(app, *this, 3);
93  // add items
94  // values
95  ret->mkItem("vehicles within [#]", true,
97  ret->mkItem("mean speed [m/s]", true,
99  ret->mkItem("haltings [#]", true,
101  // close building
102  ret->closeBuilding();
103  return ret;
104 }
105 
106 
107 void
109  glPushName(getGlID());
110  glPushMatrix();
111  glTranslated(0, 0, getType());
112  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
113  CrossingDefinitions::const_iterator i;
114  glColor3d(0, .8, 0);
115  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
116  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration);
117  }
118  glColor3d(.8, 0, 0);
119  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
120  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration);
121  }
122  glPopMatrix();
123  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
124  glPopName();
125 }
126 
127 
128 void
130  SUMOReal rot, SUMOReal upscale) const {
131  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
132  glPushMatrix();
133  glScaled(upscale, upscale, 1);
134  glTranslated(pos.x(), pos.y(), 0);
135  glRotated(rot, 0, 0, 1);
136  glBegin(GL_LINES);
137  glVertex2d(1.7, 0);
138  glVertex2d(-1.7, 0);
139  glEnd();
140  glBegin(GL_QUADS);
141  glVertex2d(-1.7, .5);
142  glVertex2d(-1.7, -.5);
143  glVertex2d(1.7, -.5);
144  glVertex2d(1.7, .5);
145  glEnd();
146  // arrows
147  glTranslated(1.5, 0, 0);
148  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
150  glTranslated(-3, 0, 0);
151  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
153  glPopMatrix();
154 }
155 
156 
157 Boundary
159  Boundary b(myBoundary);
160  b.grow(20);
161  return b;
162 }
163 
164 
167  return myDetector;
168 }
169 
170 
171 /* -------------------------------------------------------------------------
172  * GUIE3Collector-methods
173  * ----------------------------------------------------------------------- */
174 GUIE3Collector::GUIE3Collector(const std::string& id,
175  const CrossSectionVector& entries, const CrossSectionVector& exits,
176  SUMOReal haltingSpeedThreshold,
177  SUMOTime haltingTimeThreshold)
178  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold) {}
179 
180 
182 
183 
184 const CrossSectionVector&
186  return myEntries;
187 }
188 
189 
190 const CrossSectionVector&
192  return myExits;
193 }
194 
195 
196 
199  return new MyWrapper(*this);
200 }
201 
202 
203 
204 /****************************************************************************/
205