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 
63  GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID()),
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 
77  Boundary b(myBoundary);
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 
GUIGlObject.h
GUIInstantInductLoop::MyWrapper::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIInstantInductLoop.cpp:85
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
GUIParameterTableWindow.h
GUIDetectorWrapper
Definition: GUIDetectorWrapper.h:43
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSInstantInductLoop.h
GUIInstantInductLoop::MyWrapper::~MyWrapper
~MyWrapper()
Destructor.
Definition: GUIInstantInductLoop.cpp:72
MSInstantInductLoop::myPosition
const double myPosition
Detector's position on lane [m].
Definition: MSInstantInductLoop.h:161
GUIInstantInductLoop.h
GLHelper.h
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:220
GUIInstantInductLoop
The gui-version of the MSInstantInductLoop.
Definition: GUIInstantInductLoop.h:39
GUIInstantInductLoop::MyWrapper::myFGPosition
Position myFGPosition
The position in full-geometry mode.
Definition: GUIInstantInductLoop.h:119
GUIVisualizationSettings::addName
GUIVisualizationTextSettings addName
Definition: GUIVisualizationSettings.h:582
GUIInstantInductLoop::MyWrapper::getLoop
GUIInstantInductLoop & getLoop()
Returns the detector itself.
Definition: GUIInstantInductLoop.cpp:153
GUIInstantInductLoop::buildDetectorGUIRepresentation
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector's visualisation-wrapper.
Definition: GUIInstantInductLoop.cpp:54
GUIInstantInductLoop::GUIInstantInductLoop
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
Definition: GUIInstantInductLoop.cpp:44
GUIParameterTableWindow::mkItem
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Definition: GUIParameterTableWindow.h:109
GLO_E1DETECTOR_INSTANT
a E1 detector
Definition: GUIGlObjectTypes.h:76
PositionVector::rotationDegreeAtOffset
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:311
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:623
Position::x
double x() const
Returns the x-position.
Definition: Position.h:57
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
GUIInstantInductLoop::MyWrapper::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIInstantInductLoop.cpp:100
GUIInstantInductLoop::MyWrapper
A MSInductLoop-visualiser.
Definition: GUIInstantInductLoop.h:68
MSInstantInductLoop
An instantaneous induction loop.
Definition: MSInstantInductLoop.h:54
GLIncludes.h
MSMoveReminder::getLane
const MSLane * getLane() const
Returns the lane the reminder works on.
Definition: MSMoveReminder.h:83
MSLane::getShape
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
FunctionBinding.h
GUIMainWindow
Definition: GUIMainWindow.h:47
Position::y
double y() const
Returns the y-position.
Definition: Position.h:62
GUIInstantInductLoop::~GUIInstantInductLoop
~GUIInstantInductLoop()
Destructor.
Definition: GUIInstantInductLoop.cpp:50
GUIEdge.h
config.h
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:580
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
MSLane::geometryPositionAtOffset
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
GUIInstantInductLoop::MyWrapper::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIInstantInductLoop.cpp:76
MSLane.h
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GUIInstantInductLoop::MyWrapper::myFGRotation
double myFGRotation
The rotation in full-geometry mode.
Definition: GUIInstantInductLoop.h:122
GUIInstantInductLoop::MyWrapper::myBoundary
Boundary myBoundary
The detector's boundary.
Definition: GUIInstantInductLoop.h:116
PositionVector.h
GUIInstantInductLoop::MyWrapper::MyWrapper
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Definition: GUIInstantInductLoop.cpp:62
GUIVisualizationSizeSettings::getExaggeration
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Definition: GUIVisualizationSettings.cpp:212