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-2013 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"
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 /* -------------------------------------------------------------------------
54  * GUIInstantInductLoop-methods
55  * ----------------------------------------------------------------------- */
57  MSLane* const lane, SUMOReal positionInMeters)
58  : MSInstantInductLoop(id, od, lane, positionInMeters) {}
59 
60 
62 
63 
66  return new MyWrapper(*this, static_cast<GUIEdge&>(getLane()->getEdge()).getLaneGeometry(getLane()), myPosition);
67 }
68 
69 
70 /* -------------------------------------------------------------------------
71  * GUIInstantInductLoop::MyWrapper-methods
72  * ----------------------------------------------------------------------- */
74  GUILaneWrapper& wrapper, SUMOReal pos)
75  : GUIDetectorWrapper("instant induct loop", detector.getID()),
76  myDetector(detector), myPosition(pos) {
77  const PositionVector& v = wrapper.getShape();
82 }
83 
84 
86 
87 
90  Boundary b(myBoundary);
91  b.grow(20);
92  return b;
93 }
94 
95 
96 
99  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
100  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
101  // add items
102  // parameter
103  ret->mkItem("position [m]", false, myPosition);
104  ret->mkItem("lane", false, myDetector.getLane()->getID());
105  // values
106  // close building
107  ret->closeBuilding();
108  return ret;
109 }
110 
111 
112 void
114  glPushName(getGlID());
115  SUMOReal width = (SUMOReal) 2.0 * s.scale;
116  glLineWidth(1.0);
117  // shape
118  glColor3d(1, 0, 1);
119  glPushMatrix();
120  glTranslated(0, 0, getType());
121  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
122  glRotated(myFGRotation, 0, 0, 1);
123  glScaled(s.addExaggeration, s.addExaggeration, 1);
124  glBegin(GL_QUADS);
125  glVertex2d(0 - 1.0, 2);
126  glVertex2d(-1.0, -2);
127  glVertex2d(1.0, -2);
128  glVertex2d(1.0, 2);
129  glEnd();
130  glTranslated(0, 0, .01);
131  glBegin(GL_LINES);
132  glVertex2d(0, 2 - .1);
133  glVertex2d(0, -2 + .1);
134  glEnd();
135 
136  // outline
137  if (width * s.addExaggeration > 1) {
138  glColor3d(1, 1, 1);
139  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
140  glBegin(GL_QUADS);
141  glVertex2f(0 - 1.0, 2);
142  glVertex2f(-1.0, -2);
143  glVertex2f(1.0, -2);
144  glVertex2f(1.0, 2);
145  glEnd();
146  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
147  }
148 
149  // position indicator
150  if (width * s.addExaggeration > 1) {
151  glRotated(90, 0, 0, -1);
152  glColor3d(1, 1, 1);
153  glBegin(GL_LINES);
154  glVertex2d(0, 1.7);
155  glVertex2d(0, -1.7);
156  glEnd();
157  }
158  glPopMatrix();
159  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
160  glPopName();
161 }
162 
163 
166  return myDetector;
167 }
168 
169 
170 
171 /****************************************************************************/
172