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 
The gui-version of the MSE3Collector.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
long long int SUMOTime
Definition: SUMOTime.h:35
double scale
information about a lane&#39;s width (temporary, used for a single view)
const CrossSectionVector & getEntries() const
Returns the list of entry points.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
std::vector< SingleCrossingDefinition > CrossingDefinitions
Definition of a list of cross (entry/exit-point) positions.
GUIVisualizationTextSettings addName
const CrossSectionVector & getExits() const
Returns the list of exit points.
A simple description of a position on a lane (crossing of a lane)
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:62
SingleCrossingDefinition buildDefinition(const MSCrossSection &section)
Builds the description about the position of the entry/exit point.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
std::vector< MSCrossSection > CrossSectionVector
double x() const
Returns the x-position.
Definition: Position.h:57
GUIE3Collector & myDetector
The wrapped detector.
CrossSectionVector::const_iterator CrossSectionVectorConstIt
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:478
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Constructor.
a E3 detector
~GUIE3Collector()
Destructor.
GUIVisualizationSizeSettings addSize
CrossingDefinitions myEntryDefinitions
The list of entry positions.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
static const RGBColor E3Exit
color for Exits
double myPosition
The position at the lane.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
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
MyWrapper(GUIE3Collector &detector)
Constructor.
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
CrossSectionVector myEntries
The detector&#39;s entries.
static const RGBColor E3Entry
color for Entrys
CrossingDefinitions myExitDefinitions
The list of exit positions.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:58
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIE3Collector & getDetector()
Returns the detector itself.
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
GUIVisualizationColorSettings colorSettings
color settings
MSLane * myLane
The lane to cross.
Representation of a single crossing point.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:136
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
void drawSingleCrossing(const Position &pos, double rot, double upscale) const
Draws a single entry/exit point.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Boundary myBoundary
The detector&#39;s boundary.
A window containing a gl-object&#39;s parameter.
CrossSectionVector myExits
The detector&#39;s exits.
a junction