SUMO - Simulation of Urban MObility
GUIInstantInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2003-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The gui-version of the MSInstantInductLoop
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
34 #include "GUIInstantInductLoop.h"
35 #include <utils/gui/div/GLHelper.h>
39 #include <microsim/MSLane.h>
40 #include "GUIEdge.h"
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
47 /* -------------------------------------------------------------------------
48  * GUIInstantInductLoop-methods
49  * ----------------------------------------------------------------------- */
51  MSLane* const lane, double positionInMeters,
52  const std::string& vTypes)
53  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
54 
55 
57 
58 
61  return new MyWrapper(*this, myPosition);
62 }
63 
64 
65 /* -------------------------------------------------------------------------
66  * GUIInstantInductLoop::MyWrapper-methods
67  * ----------------------------------------------------------------------- */
69  : GUIDetectorWrapper("instant induct loop", detector.getID()),
70  myDetector(detector), myPosition(pos) {
72  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
73  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
75 }
76 
77 
79 
80 
84  b.grow(20);
85  return b;
86 }
87 
88 
89 
92  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
93  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
94  // add items
95  // parameter
96  ret->mkItem("position [m]", false, myPosition);
97  ret->mkItem("lane", false, myDetector.getLane()->getID());
98  // values
99  // close building
100  ret->closeBuilding();
101  return ret;
102 }
103 
104 
105 void
107  glPushName(getGlID());
108  double width = (double) 2.0 * s.scale;
109  glLineWidth(1.0);
110  const double exaggeration = s.addSize.getExaggeration(s);
111  // shape
112  glColor3d(1, 0, 1);
113  glPushMatrix();
114  glTranslated(0, 0, getType());
115  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
116  glRotated(myFGRotation, 0, 0, 1);
117  glScaled(exaggeration, exaggeration, 1);
118  glBegin(GL_QUADS);
119  glVertex2d(0 - 1.0, 2);
120  glVertex2d(-1.0, -2);
121  glVertex2d(1.0, -2);
122  glVertex2d(1.0, 2);
123  glEnd();
124  glTranslated(0, 0, .01);
125  glBegin(GL_LINES);
126  glVertex2d(0, 2 - .1);
127  glVertex2d(0, -2 + .1);
128  glEnd();
129 
130  // outline
131  if (width * exaggeration > 1) {
132  glColor3d(1, 1, 1);
133  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
134  glBegin(GL_QUADS);
135  glVertex2f(0 - 1.0, 2);
136  glVertex2f(-1.0, -2);
137  glVertex2f(1.0, -2);
138  glVertex2f(1.0, 2);
139  glEnd();
140  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
141  }
142 
143  // position indicator
144  if (width * exaggeration > 1) {
145  glRotated(90, 0, 0, -1);
146  glColor3d(1, 1, 1);
147  glBegin(GL_LINES);
148  glVertex2d(0, 1.7);
149  glVertex2d(0, -1.7);
150  glEnd();
151  }
152  glPopMatrix();
153  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
154  glPopName();
155 }
156 
157 
160  return myDetector;
161 }
162 
163 
164 
165 /****************************************************************************/
166 
const MSLane * getLane() const
Returns the lane the reminder works on.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
double scale
information about a lane&#39;s width (temporary, used for a single view)
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
double myFGRotation
The rotation in full-geometry mode.
GUIVisualizationTextSettings addName
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:67
double x() const
Returns the x-position.
Definition: Position.h:62
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
An instantaneous induction loop.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:439
Boundary myBoundary
The detector&#39;s boundary.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIInstantInductLoop & myDetector
The wrapped detector.
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
GUIInstantInductLoop & getLoop()
Returns the detector itself.
~GUIInstantInductLoop()
Destructor.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
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 Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:461
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
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:85
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A window containing a gl-object&#39;s parameter.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector&#39;s visualisation-wrapper.