SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The gui-version of the MSInductLoop, together with the according
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 
35 #include "GUILaneWrapper.h"
36 #include "GUIInductLoop.h"
37 #include <utils/gui/div/GLHelper.h>
38 #include <utils/geom/Line.h>
42 #include <microsim/MSLane.h>
44 #include "GUIEdge.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  * GUIInductLoop-methods
57  * ----------------------------------------------------------------------- */
58 GUIInductLoop::GUIInductLoop(const std::string& id, MSLane* const lane,
59  SUMOReal position, bool splitByType)
60  : MSInductLoop(id, lane, position, splitByType) {}
61 
62 
64 
65 
68  return new MyWrapper(*this, static_cast<GUIEdge&>(getLane()->getEdge()).getLaneGeometry(getLane()), myPosition);
69 }
70 
71 
72 void
76 }
77 
78 
79 void
82  MSInductLoop::enterDetectorByMove(veh, entryTimestep);
83 }
84 
85 void
88  MSInductLoop::leaveDetectorByMove(veh, leaveTimestep);
89 }
90 
91 void
95 }
96 
97 
98 std::vector<MSInductLoop::VehicleData>
102 }
103 
104 
105 /* -------------------------------------------------------------------------
106  * GUIInductLoop::MyWrapper-methods
107  * ----------------------------------------------------------------------- */
109  GUILaneWrapper& wrapper, SUMOReal pos)
110  : GUIDetectorWrapper("induct loop", detector.getID()),
111  myDetector(detector), myPosition(pos) {
112  const PositionVector& v = wrapper.getShape();
114  Line l(v.getBegin(), v.getEnd());
115  myBoundary.add(myFGPosition.x() + (SUMOReal) 5.5, myFGPosition.y() + (SUMOReal) 5.5);
116  myBoundary.add(myFGPosition.x() - (SUMOReal) 5.5, myFGPosition.y() - (SUMOReal) 5.5);
118 }
119 
120 
122 
123 
124 Boundary
126  Boundary b(myBoundary);
127  b.grow(20);
128  return b;
129 }
130 
131 
132 
135  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
136  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
137  // add items
138  // parameter
139  ret->mkItem("position [m]", false, myPosition);
140  ret->mkItem("lane", false, myDetector.getLane()->getID());
141  // values
142  ret->mkItem("passed vehicles [#]", true,
144  ret->mkItem("speed [m/s]", true,
146  ret->mkItem("occupancy [%]", true,
148  ret->mkItem("vehicle length [m]", true,
150  ret->mkItem("empty time [s]", true,
152  // close building
153  ret->closeBuilding();
154  return ret;
155 }
156 
157 
158 void
160  glPushName(getGlID());
161  SUMOReal width = (SUMOReal) 2.0 * s.scale;
162  glLineWidth(1.0);
163  // shape
164  glColor3d(1, 1, 0);
165  glPushMatrix();
166  glTranslated(0, 0, getType());
167  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
168  glRotated(myFGRotation, 0, 0, 1);
169  glScaled(s.addExaggeration, s.addExaggeration, 1);
170  glBegin(GL_QUADS);
171  glVertex2d(0 - 1.0, 2);
172  glVertex2d(-1.0, -2);
173  glVertex2d(1.0, -2);
174  glVertex2d(1.0, 2);
175  glEnd();
176  glTranslated(0, 0, .01);
177  glBegin(GL_LINES);
178  glVertex2d(0, 2 - .1);
179  glVertex2d(0, -2 + .1);
180  glEnd();
181 
182  // outline
183  if (width * s.addExaggeration > 1) {
184  glColor3d(1, 1, 1);
185  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
186  glBegin(GL_QUADS);
187  glVertex2f(0 - 1.0, 2);
188  glVertex2f(-1.0, -2);
189  glVertex2f(1.0, -2);
190  glVertex2f(1.0, 2);
191  glEnd();
192  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
193  }
194 
195  // position indicator
196  if (width * s.addExaggeration > 1) {
197  glRotated(90, 0, 0, -1);
198  glColor3d(1, 1, 1);
199  glBegin(GL_LINES);
200  glVertex2d(0, 1.7);
201  glVertex2d(0, -1.7);
202  glEnd();
203  }
204  glPopMatrix();
205  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
206  glPopName();
207 }
208 
209 
212  return myDetector;
213 }
214 
215 
216 
217 /****************************************************************************/
218