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-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 
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>
40 
41 #ifdef _WIN32
42 #include <windows.h>
43 #endif
44 
45 #include <GL/gl.h>
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 /* -------------------------------------------------------------------------
56  * GUIE3Collector::MyWrapper-methods
57  * ----------------------------------------------------------------------- */
59  : GUIDetectorWrapper("E3 detector", detector.getID()),
60  myDetector(detector) {
61  const CrossSectionVector& entries = detector.getEntries();
62  const CrossSectionVector& exits = detector.getExits();
64  for (i = entries.begin(); i != entries.end(); ++i) {
67  myEntryDefinitions.push_back(def);
68  }
69  for (i = exits.begin(); i != exits.end(); ++i) {
72  myExitDefinitions.push_back(def);
73  }
74 }
75 
76 
78 
79 
82  const MSLane* lane = section.myLane;
83  SUMOReal pos = section.myPosition;
84  const PositionVector& v = lane->getShape();
85  Line l(v.getBegin(), v.getEnd());
88  def.myFGRotation = -v.rotationDegreeAtLengthPosition(pos);
89  return def;
90 }
91 
92 
97  new GUIParameterTableWindow(app, *this, 3);
98  // add items
99  // values
100  ret->mkItem("vehicles within [#]", true,
102  ret->mkItem("mean speed [m/s]", true,
104  ret->mkItem("haltings [#]", true,
106  // close building
107  ret->closeBuilding();
108  return ret;
109 }
110 
111 
112 void
114  glPushName(getGlID());
115  glPushMatrix();
116  glTranslated(0, 0, getType());
117  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
118  CrossingDefinitions::const_iterator i;
119  glColor3d(0, .8, 0);
120  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
121  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration);
122  }
123  glColor3d(.8, 0, 0);
124  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
125  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration);
126  }
127  glPopMatrix();
128  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
129  glPopName();
130 }
131 
132 
133 void
135  SUMOReal rot, SUMOReal upscale) const {
136  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
137  glPushMatrix();
138  glScaled(upscale, upscale, 1);
139  glTranslated(pos.x(), pos.y(), 0);
140  glRotated(rot, 0, 0, 1);
141  glBegin(GL_LINES);
142  glVertex2d(1.7, 0);
143  glVertex2d(-1.7, 0);
144  glEnd();
145  glBegin(GL_QUADS);
146  glVertex2d(-1.7, .5);
147  glVertex2d(-1.7, -.5);
148  glVertex2d(1.7, -.5);
149  glVertex2d(1.7, .5);
150  glEnd();
151  // arrows
152  glTranslated(1.5, 0, 0);
153  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
155  glTranslated(-3, 0, 0);
156  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
158  glPopMatrix();
159 }
160 
161 
162 Boundary
164  Boundary b(myBoundary);
165  b.grow(20);
166  return b;
167 }
168 
169 
172  return myDetector;
173 }
174 
175 
176 /* -------------------------------------------------------------------------
177  * GUIE3Collector-methods
178  * ----------------------------------------------------------------------- */
179 GUIE3Collector::GUIE3Collector(const std::string& id,
180  const CrossSectionVector& entries, const CrossSectionVector& exits,
181  SUMOReal haltingSpeedThreshold,
182  SUMOTime haltingTimeThreshold)
183  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold) {}
184 
185 
187 
188 
189 const CrossSectionVector&
191  return myEntries;
192 }
193 
194 
195 const CrossSectionVector&
197  return myExits;
198 }
199 
200 
201 
204  return new MyWrapper(*this);
205 }
206 
207 
208 
209 /****************************************************************************/
210