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-sim.org/
12 // Copyright (C) 2001-2014 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 "GUIInductLoop.h"
36 #include <utils/gui/div/GLHelper.h>
37 #include <utils/geom/Line.h>
41 #include <microsim/MSLane.h>
43 #include "GUIEdge.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 /* -------------------------------------------------------------------------
55  * GUIInductLoop-methods
56  * ----------------------------------------------------------------------- */
57 GUIInductLoop::GUIInductLoop(const std::string& id, MSLane* const lane,
58  SUMOReal position, bool splitByType)
59  : MSInductLoop(id, lane, position, splitByType) {}
60 
61 
63 
64 
67  return new MyWrapper(*this, myPosition);
68 }
69 
70 
71 void
75 }
76 
77 
78 void
81  MSInductLoop::enterDetectorByMove(veh, entryTimestep);
82 }
83 
84 void
87  MSInductLoop::leaveDetectorByMove(veh, leaveTimestep);
88 }
89 
90 void
94 }
95 
96 
97 std::vector<MSInductLoop::VehicleData>
101 }
102 
103 
104 /* -------------------------------------------------------------------------
105  * GUIInductLoop::MyWrapper-methods
106  * ----------------------------------------------------------------------- */
108  : GUIDetectorWrapper("induct loop", detector.getID()),
109  myDetector(detector), myPosition(pos) {
110  myFGPosition = detector.getLane()->geometryPositionAtOffset(pos);
111  myBoundary.add(myFGPosition.x() + (SUMOReal) 5.5, myFGPosition.y() + (SUMOReal) 5.5);
112  myBoundary.add(myFGPosition.x() - (SUMOReal) 5.5, myFGPosition.y() - (SUMOReal) 5.5);
113  myFGRotation = -detector.getLane()->getShape().rotationDegreeAtOffset(pos);
114 }
115 
116 
118 
119 
120 Boundary
122  Boundary b(myBoundary);
123  b.grow(20);
124  return b;
125 }
126 
127 
128 
131  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
132  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
133  // add items
134  // parameter
135  ret->mkItem("position [m]", false, myPosition);
136  ret->mkItem("lane", false, myDetector.getLane()->getID());
137  // values
138  ret->mkItem("passed vehicles [#]", true,
140  ret->mkItem("speed [m/s]", true,
142  ret->mkItem("occupancy [%]", true,
144  ret->mkItem("vehicle length [m]", true,
146  ret->mkItem("empty time [s]", true,
148  // close building
149  ret->closeBuilding();
150  return ret;
151 }
152 
153 
154 void
156  glPushName(getGlID());
157  SUMOReal width = (SUMOReal) 2.0 * s.scale;
158  glLineWidth(1.0);
159  // shape
160  glColor3d(1, 1, 0);
161  glPushMatrix();
162  glTranslated(0, 0, getType());
163  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
164  glRotated(myFGRotation, 0, 0, 1);
165  glScaled(s.addExaggeration, s.addExaggeration, 1);
166  glBegin(GL_QUADS);
167  glVertex2d(0 - 1.0, 2);
168  glVertex2d(-1.0, -2);
169  glVertex2d(1.0, -2);
170  glVertex2d(1.0, 2);
171  glEnd();
172  glTranslated(0, 0, .01);
173  glBegin(GL_LINES);
174  glVertex2d(0, 2 - .1);
175  glVertex2d(0, -2 + .1);
176  glEnd();
177 
178  // outline
179  if (width * s.addExaggeration > 1) {
180  glColor3d(1, 1, 1);
181  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
182  glBegin(GL_QUADS);
183  glVertex2f(0 - 1.0, 2);
184  glVertex2f(-1.0, -2);
185  glVertex2f(1.0, -2);
186  glVertex2f(1.0, 2);
187  glEnd();
188  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
189  }
190 
191  // position indicator
192  if (width * s.addExaggeration > 1) {
193  glRotated(90, 0, 0, -1);
194  glColor3d(1, 1, 1);
195  glBegin(GL_LINES);
196  glVertex2d(0, 1.7);
197  glVertex2d(0, -1.7);
198  glEnd();
199  }
200  glPopMatrix();
201  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
202  glPopName();
203 }
204 
205 
208  return myDetector;
209 }
210 
211 
212 
213 /****************************************************************************/
214