Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The gui-version of the MSInstantInductLoop
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
28 #include "GUIInstantInductLoop.h"
29 #include <utils/gui/div/GLHelper.h>
33 #include <microsim/MSLane.h>
34 #include "GUIEdge.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 /* -------------------------------------------------------------------------
42  * GUIInstantInductLoop-methods
43  * ----------------------------------------------------------------------- */
45  MSLane* const lane, double positionInMeters,
46  const std::string& vTypes)
47  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
48 
49 
51 
52 
55  return new MyWrapper(*this, myPosition);
56 }
57 
58 // -------------------------------------------------------------------------
59 // GUIInstantInductLoop::MyWrapper-methods
60 // -------------------------------------------------------------------------
61 
64  myDetector(detector), myPosition(pos) {
66  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
67  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
69 }
70 
71 
73 
74 
78  b.grow(20);
79  return b;
80 }
81 
82 
83 
86  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
87  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
88  // add items
89  // parameter
90  ret->mkItem("position [m]", false, myPosition);
91  ret->mkItem("lane", false, myDetector.getLane()->getID());
92  // values
93  // close building
94  ret->closeBuilding();
95  return ret;
96 }
97 
98 
99 void
101  glPushName(getGlID());
102  double width = (double) 2.0 * s.scale;
103  glLineWidth(1.0);
104  const double exaggeration = s.addSize.getExaggeration(s, this);
105  // shape
106  glColor3d(1, 0, 1);
107  glPushMatrix();
108  glTranslated(0, 0, getType());
109  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
110  glRotated(myFGRotation, 0, 0, 1);
111  glScaled(exaggeration, exaggeration, 1);
112  glBegin(GL_QUADS);
113  glVertex2d(0 - 1.0, 2);
114  glVertex2d(-1.0, -2);
115  glVertex2d(1.0, -2);
116  glVertex2d(1.0, 2);
117  glEnd();
118  glTranslated(0, 0, .01);
119  glBegin(GL_LINES);
120  glVertex2d(0, 2 - .1);
121  glVertex2d(0, -2 + .1);
122  glEnd();
123 
124  // outline
125  if (width * exaggeration > 1) {
126  glColor3d(1, 1, 1);
127  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
128  glBegin(GL_QUADS);
129  glVertex2f(0 - 1.0, 2);
130  glVertex2f(-1.0, -2);
131  glVertex2f(1.0, -2);
132  glVertex2f(1.0, 2);
133  glEnd();
134  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
135  }
136 
137  // position indicator
138  if (width * exaggeration > 1) {
139  glRotated(90, 0, 0, -1);
140  glColor3d(1, 1, 1);
141  glBegin(GL_LINES);
142  glVertex2d(0, 1.7);
143  glVertex2d(0, -1.7);
144  glEnd();
145  }
146  glPopMatrix();
147  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
148  glPopName();
149 }
150 
151 
154  return myDetector;
155 }
156 
157 
158 
159 /****************************************************************************/
160 
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:62
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
double x() const
Returns the x-position.
Definition: Position.h:57
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:478
Boundary myBoundary
The detector&#39;s boundary.
const std::string & getID() const
Returns the id.
Definition: Named.h:77
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
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:505
GUIGlID getGlID() const
Returns the numerical id of the object.
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
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:79
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
A window containing a gl-object&#39;s parameter.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector&#39;s visualisation-wrapper.