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 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 /* -------------------------------------------------------------------------
49  * GUIInstantInductLoop-methods
50  * ----------------------------------------------------------------------- */
52  MSLane* const lane, double positionInMeters,
53  const std::string& vTypes)
54  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
55 
56 
58 
59 
62  return new MyWrapper(*this, myPosition);
63 }
64 
65 
66 /* -------------------------------------------------------------------------
67  * GUIInstantInductLoop::MyWrapper-methods
68  * ----------------------------------------------------------------------- */
70  : GUIDetectorWrapper("instant induct loop", detector.getID()),
71  myDetector(detector), myPosition(pos) {
73  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
74  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
76 }
77 
78 
80 
81 
85  b.grow(20);
86  return b;
87 }
88 
89 
90 
93  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
94  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
95  // add items
96  // parameter
97  ret->mkItem("position [m]", false, myPosition);
98  ret->mkItem("lane", false, myDetector.getLane()->getID());
99  // values
100  // close building
101  ret->closeBuilding();
102  return ret;
103 }
104 
105 
106 void
108  glPushName(getGlID());
109  double width = (double) 2.0 * s.scale;
110  glLineWidth(1.0);
111  const double exaggeration = s.addSize.getExaggeration(s);
112  // shape
113  glColor3d(1, 0, 1);
114  glPushMatrix();
115  glTranslated(0, 0, getType());
116  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
117  glRotated(myFGRotation, 0, 0, 1);
118  glScaled(exaggeration, exaggeration, 1);
119  glBegin(GL_QUADS);
120  glVertex2d(0 - 1.0, 2);
121  glVertex2d(-1.0, -2);
122  glVertex2d(1.0, -2);
123  glVertex2d(1.0, 2);
124  glEnd();
125  glTranslated(0, 0, .01);
126  glBegin(GL_LINES);
127  glVertex2d(0, 2 - .1);
128  glVertex2d(0, -2 + .1);
129  glEnd();
130 
131  // outline
132  if (width * exaggeration > 1) {
133  glColor3d(1, 1, 1);
134  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
135  glBegin(GL_QUADS);
136  glVertex2f(0 - 1.0, 2);
137  glVertex2f(-1.0, -2);
138  glVertex2f(1.0, -2);
139  glVertex2f(1.0, 2);
140  glEnd();
141  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
142  }
143 
144  // position indicator
145  if (width * exaggeration > 1) {
146  glRotated(90, 0, 0, -1);
147  glColor3d(1, 1, 1);
148  glBegin(GL_LINES);
149  glVertex2d(0, 1.7);
150  glVertex2d(0, -1.7);
151  glEnd();
152  }
153  glPopMatrix();
154  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
155  glPopName();
156 }
157 
158 
161  return myDetector;
162 }
163 
164 
165 
166 /****************************************************************************/
167 
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
double scale
information about a lane&#39;s width (temporary, used for a single view)
double myFGRotation
The rotation in full-geometry mode.
GUIVisualizationTextSettings addName
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double x() const
Returns the x-position.
Definition: Position.h:63
Stores the information about how to visualize structures.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
An instantaneous induction loop.
Boundary myBoundary
The detector&#39;s boundary.
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.
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.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
GUIInstantInductLoop & getLoop()
Returns the detector itself.
double y() const
Returns the y-position.
Definition: Position.h:68
~GUIInstantInductLoop()
Destructor.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
const double myPosition
Detector&#39;s position on lane [m].
The gui-version of the MSInstantInductLoop.
double myPosition
The position on the lane.
A MSInductLoop-visualiser.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
Position myFGPosition
The position in full-geometry mode.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
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.