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