SUMO - Simulation of Urban MObility
GUIInstantInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The gui-version of the MSInstantInductLoop
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2003-2017 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 "GUIInstantInductLoop.h"
36 #include <utils/gui/div/GLHelper.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  const std::string& vTypes)
58  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
59 
60 
62 
63 
66  return new MyWrapper(*this, myPosition);
67 }
68 
69 
70 /* -------------------------------------------------------------------------
71  * GUIInstantInductLoop::MyWrapper-methods
72  * ----------------------------------------------------------------------- */
74  : GUIDetectorWrapper("instant induct loop", detector.getID()),
75  myDetector(detector), myPosition(pos) {
80 }
81 
82 
84 
85 
89  b.grow(20);
90  return b;
91 }
92 
93 
94 
97  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
98  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
99  // add items
100  // parameter
101  ret->mkItem("position [m]", false, myPosition);
102  ret->mkItem("lane", false, myDetector.getLane()->getID());
103  // values
104  // close building
105  ret->closeBuilding();
106  return ret;
107 }
108 
109 
110 void
112  glPushName(getGlID());
113  SUMOReal width = (SUMOReal) 2.0 * s.scale;
114  glLineWidth(1.0);
115  const SUMOReal exaggeration = s.addSize.getExaggeration(s);
116  // shape
117  glColor3d(1, 0, 1);
118  glPushMatrix();
119  glTranslated(0, 0, getType());
120  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
121  glRotated(myFGRotation, 0, 0, 1);
122  glScaled(exaggeration, exaggeration, 1);
123  glBegin(GL_QUADS);
124  glVertex2d(0 - 1.0, 2);
125  glVertex2d(-1.0, -2);
126  glVertex2d(1.0, -2);
127  glVertex2d(1.0, 2);
128  glEnd();
129  glTranslated(0, 0, .01);
130  glBegin(GL_LINES);
131  glVertex2d(0, 2 - .1);
132  glVertex2d(0, -2 + .1);
133  glEnd();
134 
135  // outline
136  if (width * exaggeration > 1) {
137  glColor3d(1, 1, 1);
138  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
139  glBegin(GL_QUADS);
140  glVertex2f(0 - 1.0, 2);
141  glVertex2f(-1.0, -2);
142  glVertex2f(1.0, -2);
143  glVertex2f(1.0, 2);
144  glEnd();
145  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146  }
147 
148  // position indicator
149  if (width * exaggeration > 1) {
150  glRotated(90, 0, 0, -1);
151  glColor3d(1, 1, 1);
152  glBegin(GL_LINES);
153  glVertex2d(0, 1.7);
154  glVertex2d(0, -1.7);
155  glEnd();
156  }
157  glPopMatrix();
158  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
159  glPopName();
160 }
161 
162 
165  return myDetector;
166 }
167 
168 
169 
170 /****************************************************************************/
171 
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
MyWrapper(GUIInstantInductLoop &detector, SUMOReal pos)
Constructor.
GUIVisualizationTextSettings addName
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Stores the information about how to visualize structures.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
An instantaneous induction loop.
Boundary myBoundary
The detector&#39;s boundary.
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIGlID getGlID() const
Returns the numerical id of the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
const MSLane * getLane() const
Returns the lane the reminder works on.
const SUMOReal myPosition
Detector&#39;s position on lane [m].
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
SUMOReal myFGRotation
The rotation in full-geometry mode.
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, SUMOReal positionInMeters, const std::string &vTypes)
Constructor.
GUIInstantInductLoop & myDetector
The wrapped detector.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
SUMOReal myPosition
The position on the lane.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIInstantInductLoop & getLoop()
Returns the detector itself.
~GUIInstantInductLoop()
Destructor.
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:238
The gui-version of the MSInstantInductLoop.
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
A MSInductLoop-visualiser.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:208
Position myFGPosition
The position in full-geometry mode.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
A window containing a gl-object&#39;s parameter.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector&#39;s visualisation-wrapper.