Eclipse SUMO - Simulation of Urban MObility
GUIE3Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 a MSE3Collector
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "GUIE3Collector.h"
27 #include "GUIEdge.h"
29 #include <utils/gui/div/GLHelper.h>
31 #include <microsim/MSLane.h>
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 
39 // -------------------------------------------------------------------------
40 // GUIE3Collector::MyWrapper-methods
41 // -------------------------------------------------------------------------
42 
44  GUIDetectorWrapper(GLO_E3DETECTOR, detector.getID()),
45  myDetector(detector) {
46  const CrossSectionVector& entries = detector.getEntries();
47  const CrossSectionVector& exits = detector.getExits();
49  for (i = entries.begin(); i != entries.end(); ++i) {
52  myEntryDefinitions.push_back(def);
53  }
54  for (i = exits.begin(); i != exits.end(); ++i) {
57  myExitDefinitions.push_back(def);
58  }
59 }
60 
61 
63 
64 
70  return def;
71 }
72 
73 
78  new GUIParameterTableWindow(app, *this, 3);
79  // add items
80  // values
81  ret->mkItem("vehicles within [#]", true,
83  ret->mkItem("mean speed [m/s]", true,
85  ret->mkItem("haltings [#]", true,
87  // close building
88  ret->closeBuilding();
89  return ret;
90 }
91 
92 
93 void
95  glPushName(getGlID());
96  glPushMatrix();
97  glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
98  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
99  CrossingDefinitions::const_iterator i;
101  const double exaggeration = s.addSize.getExaggeration(s, this);
102  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
103  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
104  }
106  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
107  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
108  }
109  glPopMatrix();
110  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
111  glPopName();
112 }
113 
114 
115 void
117  double rot, double upscale) const {
118  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
119  glPushMatrix();
120  glScaled(upscale, upscale, 1);
121  glTranslated(pos.x(), pos.y(), 0);
122  glRotated(rot, 0, 0, 1);
123  glBegin(GL_LINES);
124  glVertex2d(1.7, 0);
125  glVertex2d(-1.7, 0);
126  glEnd();
127  glBegin(GL_QUADS);
128  glVertex2d(-1.7, .5);
129  glVertex2d(-1.7, -.5);
130  glVertex2d(1.7, -.5);
131  glVertex2d(1.7, .5);
132  glEnd();
133  // arrows
134  glTranslated(1.5, 0, 0);
135  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
136  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
137  glTranslated(-3, 0, 0);
138  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
139  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
140  glPopMatrix();
141 }
142 
143 
144 Boundary
146  Boundary b(myBoundary);
147  b.grow(20);
148  return b;
149 }
150 
151 
154  return myDetector;
155 }
156 
157 
158 /* -------------------------------------------------------------------------
159  * GUIE3Collector-methods
160  * ----------------------------------------------------------------------- */
161 GUIE3Collector::GUIE3Collector(const std::string& id,
162  const CrossSectionVector& entries, const CrossSectionVector& exits,
163  double haltingSpeedThreshold,
164  SUMOTime haltingTimeThreshold, const std::string& vTypes, bool openEntry)
165  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes, openEntry) {}
166 
167 
169 
170 
171 const CrossSectionVector&
173  return myEntries;
174 }
175 
176 
177 const CrossSectionVector&
179  return myExits;
180 }
181 
182 
183 
186  return new MyWrapper(*this);
187 }
188 
189 
190 
191 /****************************************************************************/
192 
MSE3Collector::getCurrentHaltingNumber
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Definition: MSE3Collector.cpp:536
MSE3Collector::getVehiclesWithin
int getVehiclesWithin() const
Returns the number of vehicles within the area.
Definition: MSE3Collector.cpp:542
MSE3Collector::myExits
CrossSectionVector myExits
The detector's exits.
Definition: MSE3Collector.h:347
GUIE3Collector::MyWrapper::MyWrapper
MyWrapper(GUIE3Collector &detector)
Constructor.
Definition: GUIE3Collector.cpp:43
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GUIE3Collector::MyWrapper::~MyWrapper
~MyWrapper()
Destrutor.
Definition: GUIE3Collector.cpp:62
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GUIParameterTableWindow.h
GUIE3Collector::~GUIE3Collector
~GUIE3Collector()
Destructor.
Definition: GUIE3Collector.cpp:168
MSE3Collector
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:58
GUIE3Collector::buildDetectorGUIRepresentation
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
Definition: GUIE3Collector.cpp:185
GUIDetectorWrapper
Definition: GUIDetectorWrapper.h:43
GUIE3Collector::MyWrapper::myExitDefinitions
CrossingDefinitions myExitDefinitions
The list of exit positions.
Definition: GUIE3Collector.h:158
GUIE3Collector::MyWrapper::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIE3Collector.cpp:145
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
CrossSectionVectorConstIt
CrossSectionVector::const_iterator CrossSectionVectorConstIt
Definition: MSCrossSection.h:66
MSCrossSection
A simple description of a position on a lane (crossing of a lane)
Definition: MSCrossSection.h:44
GLHelper.h
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
GUIE3Collector::MyWrapper
Definition: GUIE3Collector.h:82
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:220
GUIE3Collector::MyWrapper::SingleCrossingDefinition::myFGRotation
double myFGRotation
The rotation.
Definition: GUIE3Collector.h:133
GUIVisualizationSettings::addName
GUIVisualizationTextSettings addName
Definition: GUIVisualizationSettings.h:582
MSCrossSection::myPosition
double myPosition
The position at the lane.
Definition: MSCrossSection.h:59
GUIE3Collector::MyWrapper::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIE3Collector.cpp:75
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
GUIVisualizationColorSettings::E3Entry
static const RGBColor E3Entry
color for Entrys
Definition: GUIVisualizationSettings.h:217
PositionVector::rotationDegreeAtOffset
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:311
MSCrossSection::myLane
MSLane * myLane
The lane to cross.
Definition: MSCrossSection.h:56
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
GUIE3Collector
The gui-version of the MSE3Collector.
Definition: GUIE3Collector.h:46
GUIE3Collector.h
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
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
GUIE3Collector::MyWrapper::buildDefinition
SingleCrossingDefinition buildDefinition(const MSCrossSection &section)
Builds the description about the position of the entry/exit point.
Definition: GUIE3Collector.cpp:66
GUIE3Collector::MyWrapper::getDetector
GUIE3Collector & getDetector()
Returns the detector itself.
Definition: GUIE3Collector.cpp:153
MSE3Collector::getCurrentMeanSpeed
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
Definition: MSE3Collector.cpp:530
GUIE3Collector::MyWrapper::myBoundary
Boundary myBoundary
The detector's boundary.
Definition: GUIE3Collector.h:149
GUIE3Collector::getExits
const CrossSectionVector & getExits() const
Returns the list of exit points.
Definition: GUIE3Collector.cpp:178
GUIE3Collector::MyWrapper::myEntryDefinitions
CrossingDefinitions myEntryDefinitions
The list of entry positions.
Definition: GUIE3Collector.h:155
GUIVisualizationSettings::colorSettings
GUIVisualizationColorSettings colorSettings
color settings
Definition: GUIVisualizationSettings.h:649
GUIE3Collector::MyWrapper::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIE3Collector.cpp:94
GLO_E3DETECTOR
a E3 detector
Definition: GUIGlObjectTypes.h:80
GUIE3Collector::GUIE3Collector
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Constructor.
Definition: GUIE3Collector.cpp:161
GLIncludes.h
GUIVisualizationColorSettings::E3Exit
static const RGBColor E3Exit
color for Exits
Definition: GUIVisualizationSettings.h:220
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
MSE3Collector::myEntries
CrossSectionVector myEntries
The detector's entries.
Definition: MSE3Collector.h:344
GLHelper::drawBoxLine
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:136
GUIE3Collector::MyWrapper::CrossingDefinitions
std::vector< SingleCrossingDefinition > CrossingDefinitions
Definition of a list of cross (entry/exit-point) positions.
Definition: GUIE3Collector.h:152
GUIE3Collector::getEntries
const CrossSectionVector & getEntries() const
Returns the list of entry points.
Definition: GUIE3Collector.cpp:172
GUIE3Collector::MyWrapper::drawSingleCrossing
void drawSingleCrossing(const Position &pos, double rot, double upscale) const
Draws a single entry/exit point.
Definition: GUIE3Collector.cpp:116
GUIEdge.h
config.h
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:580
GLO_JUNCTION
a junction
Definition: GUIGlObjectTypes.h:51
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
MSLane.h
GUIE3Collector::MyWrapper::SingleCrossingDefinition::myFGPosition
Position myFGPosition
The position.
Definition: GUIE3Collector.h:131
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
FunctionBinding
Definition: FunctionBinding.h:41
GUIE3Collector::MyWrapper::SingleCrossingDefinition
Representation of a single crossing point.
Definition: GUIE3Collector.h:129
CrossSectionVector
std::vector< MSCrossSection > CrossSectionVector
Definition: MSCrossSection.h:64
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
GLHelper::drawTriangleAtEnd
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:440