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 /****************************************************************************/
16 // The gui-version of the MSInstantInductLoop
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
27 #include "GUIInstantInductLoop.h"
28 #include <utils/gui/div/GLHelper.h>
32 #include <microsim/MSLane.h>
33 #include "GUIEdge.h"
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
40 /* -------------------------------------------------------------------------
41  * GUIInstantInductLoop-methods
42  * ----------------------------------------------------------------------- */
44  MSLane* const lane, double positionInMeters,
45  const std::string& vTypes)
46  : MSInstantInductLoop(id, od, lane, positionInMeters, vTypes) {}
47 
48 
50 
51 
54  return new MyWrapper(*this, myPosition);
55 }
56 
57 // -------------------------------------------------------------------------
58 // GUIInstantInductLoop::MyWrapper-methods
59 // -------------------------------------------------------------------------
60 
62  GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID()),
63  myDetector(detector), myPosition(pos) {
65  myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
66  myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
68 }
69 
70 
72 
73 
76  Boundary b(myBoundary);
77  b.grow(20);
78  return b;
79 }
80 
81 
82 
85  GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
86  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7);
87  // add items
88  // parameter
89  ret->mkItem("position [m]", false, myPosition);
90  ret->mkItem("lane", false, myDetector.getLane()->getID());
91  // values
92  // close building
93  ret->closeBuilding();
94  return ret;
95 }
96 
97 
98 void
100  glPushName(getGlID());
101  double width = (double) 2.0 * s.scale;
102  glLineWidth(1.0);
103  const double exaggeration = s.addSize.getExaggeration(s, this);
104  // shape
105  glColor3d(1, 0, 1);
106  glPushMatrix();
107  glTranslated(0, 0, getType());
108  glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
109  glRotated(myFGRotation, 0, 0, 1);
110  glScaled(exaggeration, exaggeration, 1);
111  glBegin(GL_QUADS);
112  glVertex2d(0 - 1.0, 2);
113  glVertex2d(-1.0, -2);
114  glVertex2d(1.0, -2);
115  glVertex2d(1.0, 2);
116  glEnd();
117  glTranslated(0, 0, .01);
118  glBegin(GL_LINES);
119  glVertex2d(0, 2 - .1);
120  glVertex2d(0, -2 + .1);
121  glEnd();
122 
123  // outline
124  if (width * exaggeration > 1) {
125  glColor3d(1, 1, 1);
126  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
127  glBegin(GL_QUADS);
128  glVertex2f(0 - 1.0, 2);
129  glVertex2f(-1.0, -2);
130  glVertex2f(1.0, -2);
131  glVertex2f(1.0, 2);
132  glEnd();
133  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
134  }
135 
136  // position indicator
137  if (width * exaggeration > 1) {
138  glRotated(90, 0, 0, -1);
139  glColor3d(1, 1, 1);
140  glBegin(GL_LINES);
141  glVertex2d(0, 1.7);
142  glVertex2d(0, -1.7);
143  glEnd();
144  }
145  glPopMatrix();
146  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
147  glPopName();
148 }
149 
150 
153  return myDetector;
154 }
155 
156 
157 
158 /****************************************************************************/
159 
GUIGlObject.h
GUIInstantInductLoop::MyWrapper::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIInstantInductLoop.cpp:84
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
GUIParameterTableWindow.h
GUIDetectorWrapper
Definition: GUIDetectorWrapper.h:42
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSInstantInductLoop.h
GUIInstantInductLoop::MyWrapper::~MyWrapper
~MyWrapper()
Destructor.
Definition: GUIInstantInductLoop.cpp:71
MSInstantInductLoop::myPosition
const double myPosition
Detector's position on lane [m].
Definition: MSInstantInductLoop.h:160
GUIInstantInductLoop.h
GLHelper.h
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:219
GUIInstantInductLoop
The gui-version of the MSInstantInductLoop.
Definition: GUIInstantInductLoop.h:38
GUIInstantInductLoop::MyWrapper::myFGPosition
Position myFGPosition
The position in full-geometry mode.
Definition: GUIInstantInductLoop.h:118
GUIVisualizationSettings::addName
GUIVisualizationTextSettings addName
Definition: GUIVisualizationSettings.h:591
GUIInstantInductLoop::MyWrapper::getLoop
GUIInstantInductLoop & getLoop()
Returns the detector itself.
Definition: GUIInstantInductLoop.cpp:152
GUIInstantInductLoop::buildDetectorGUIRepresentation
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns this detector's visualisation-wrapper.
Definition: GUIInstantInductLoop.cpp:53
GUIInstantInductLoop::GUIInstantInductLoop
GUIInstantInductLoop(const std::string &id, OutputDevice &od, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
Definition: GUIInstantInductLoop.cpp:43
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:108
GLO_E1DETECTOR_INSTANT
@ GLO_E1DETECTOR_INSTANT
a E1 detector
Definition: GUIGlObjectTypes.h:75
PositionVector::rotationDegreeAtOffset
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:319
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:632
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
GUIInstantInductLoop::MyWrapper::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIInstantInductLoop.cpp:99
GUIInstantInductLoop::MyWrapper
A MSInductLoop-visualiser.
Definition: GUIInstantInductLoop.h:67
MSInstantInductLoop
An instantaneous induction loop.
Definition: MSInstantInductLoop.h:53
GLIncludes.h
MSMoveReminder::getLane
const MSLane * getLane() const
Returns the lane the reminder works on.
Definition: MSMoveReminder.h:85
MSLane::getShape
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:477
FunctionBinding.h
GUIMainWindow
Definition: GUIMainWindow.h:46
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
GUIInstantInductLoop::~GUIInstantInductLoop
~GUIInstantInductLoop()
Destructor.
Definition: GUIInstantInductLoop.cpp:49
GUIEdge.h
config.h
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:589
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
MSLane::geometryPositionAtOffset
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:504
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:75
MSLane.h
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUIInstantInductLoop::MyWrapper::myFGRotation
double myFGRotation
The rotation in full-geometry mode.
Definition: GUIInstantInductLoop.h:121
GUIInstantInductLoop::MyWrapper::myBoundary
Boundary myBoundary
The detector's boundary.
Definition: GUIInstantInductLoop.h:115
PositionVector.h
GUIInstantInductLoop::MyWrapper::MyWrapper
MyWrapper(GUIInstantInductLoop &detector, double pos)
Constructor.
Definition: GUIInstantInductLoop.cpp:61
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