SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIInstantInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The gui-version of the MSInstantInductLoop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
33 #include "GUILaneWrapper.h"
34 #include "GUIInstantInductLoop.h"
35 #include <utils/gui/div/GLHelper.h>
36 #include <utils/geom/Line.h>
41 #include <microsim/MSLane.h>
42 #include "GUIEdge.h"
43 
44 #ifdef _WIN32
45 #include <windows.h>
46 #endif
47 
48 #include <GL/gl.h>
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 // ===========================================================================
56 // method definitions
57 // ===========================================================================
58 /* -------------------------------------------------------------------------
59  * GUIInstantInductLoop-methods
60  * ----------------------------------------------------------------------- */
62  MSLane* const lane, SUMOReal positionInMeters)
63  : MSInstantInductLoop(id, od, lane, positionInMeters) {}
64 
65 
67 
68 
71  return new MyWrapper(*this, static_cast<GUIEdge&>(getLane()->getEdge()).getLaneGeometry(getLane()), myPosition);
72 }
73 
74 
75 /* -------------------------------------------------------------------------
76  * GUIInstantInductLoop::MyWrapper-methods
77  * ----------------------------------------------------------------------- */
79  GUILaneWrapper& wrapper, SUMOReal pos)
80  : GUIDetectorWrapper("instant induct loop", detector.getID()),
81  myDetector(detector), myPosition(pos) {
82  const PositionVector& v = wrapper.getShape();
87 }
88 
89 
91 
92 
95  Boundary b(myBoundary);
96  b.grow(20);
97  return b;
98 }
99 
100 
101 
104  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
105  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
106  // add items
107  // parameter
108  ret->mkItem("position [m]", false, myPosition);
109  ret->mkItem("lane", false, myDetector.getLane()->getID());
110  // values
111  // close building
112  ret->closeBuilding();
113  return ret;
114 }
115 
116 
117 void
119  glPushName(getGlID());
120  SUMOReal width = (SUMOReal) 2.0 * s.scale;
121  glLineWidth(1.0);
122  // shape
123  glColor3d(1, 0, 1);
124  glPushMatrix();
125  glTranslated(0, 0, getType());
126  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
127  glRotated(myFGRotation, 0, 0, 1);
128  glScaled(s.addExaggeration, s.addExaggeration, 1);
129  glBegin(GL_QUADS);
130  glVertex2d(0 - 1.0, 2);
131  glVertex2d(-1.0, -2);
132  glVertex2d(1.0, -2);
133  glVertex2d(1.0, 2);
134  glEnd();
135  glTranslated(0, 0, .01);
136  glBegin(GL_LINES);
137  glVertex2d(0, 2 - .1);
138  glVertex2d(0, -2 + .1);
139  glEnd();
140 
141  // outline
142  if (width * s.addExaggeration > 1) {
143  glColor3d(1, 1, 1);
144  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
145  glBegin(GL_QUADS);
146  glVertex2f(0 - 1.0, 2);
147  glVertex2f(-1.0, -2);
148  glVertex2f(1.0, -2);
149  glVertex2f(1.0, 2);
150  glEnd();
151  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
152  }
153 
154  // position indicator
155  if (width * s.addExaggeration > 1) {
156  glRotated(90, 0, 0, -1);
157  glColor3d(1, 1, 1);
158  glBegin(GL_LINES);
159  glVertex2d(0, 1.7);
160  glVertex2d(0, -1.7);
161  glEnd();
162  }
163  glPopMatrix();
164  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
165  glPopName();
166 }
167 
168 
171  return myDetector;
172 }
173 
174 
175 
176 /****************************************************************************/
177