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