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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The gui-version of a MSE3Collector
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "GUIE3Collector.h"
33 #include "GUIEdge.h"
35 #include <utils/gui/div/GLHelper.h>
37 #include <microsim/MSLane.h>
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
44 /* -------------------------------------------------------------------------
45  * GUIE3Collector::MyWrapper-methods
46  * ----------------------------------------------------------------------- */
48  : GUIDetectorWrapper("E3 detector", detector.getID()),
49  myDetector(detector) {
50  const CrossSectionVector& entries = detector.getEntries();
51  const CrossSectionVector& exits = detector.getExits();
53  for (i = entries.begin(); i != entries.end(); ++i) {
56  myEntryDefinitions.push_back(def);
57  }
58  for (i = exits.begin(); i != exits.end(); ++i) {
61  myExitDefinitions.push_back(def);
62  }
63 }
64 
65 
67 
68 
74  return def;
75 }
76 
77 
82  new GUIParameterTableWindow(app, *this, 3);
83  // add items
84  // values
85  ret->mkItem("vehicles within [#]", true,
87  ret->mkItem("mean speed [m/s]", true,
89  ret->mkItem("haltings [#]", true,
91  // close building
92  ret->closeBuilding();
93  return ret;
94 }
95 
96 
97 void
99  glPushName(getGlID());
100  glPushMatrix();
101  glTranslated(0, 0, getType());
102  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
103  CrossingDefinitions::const_iterator i;
105  const double exaggeration = s.addSize.getExaggeration(s);
106  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
107  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
108  }
110  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
111  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
112  }
113  glPopMatrix();
114  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
115  glPopName();
116 }
117 
118 
119 void
121  double rot, double upscale) const {
122  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
123  glPushMatrix();
124  glScaled(upscale, upscale, 1);
125  glTranslated(pos.x(), pos.y(), 0);
126  glRotated(rot, 0, 0, 1);
127  glBegin(GL_LINES);
128  glVertex2d(1.7, 0);
129  glVertex2d(-1.7, 0);
130  glEnd();
131  glBegin(GL_QUADS);
132  glVertex2d(-1.7, .5);
133  glVertex2d(-1.7, -.5);
134  glVertex2d(1.7, -.5);
135  glVertex2d(1.7, .5);
136  glEnd();
137  // arrows
138  glTranslated(1.5, 0, 0);
139  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
140  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
141  glTranslated(-3, 0, 0);
142  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
143  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
144  glPopMatrix();
145 }
146 
147 
148 Boundary
150  Boundary b(myBoundary);
151  b.grow(20);
152  return b;
153 }
154 
155 
158  return myDetector;
159 }
160 
161 
162 /* -------------------------------------------------------------------------
163  * GUIE3Collector-methods
164  * ----------------------------------------------------------------------- */
165 GUIE3Collector::GUIE3Collector(const std::string& id,
166  const CrossSectionVector& entries, const CrossSectionVector& exits,
167  double haltingSpeedThreshold,
168  SUMOTime haltingTimeThreshold, const std::string& vTypes)
169  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes) {}
170 
171 
173 
174 
175 const CrossSectionVector&
177  return myEntries;
178 }
179 
180 
181 const CrossSectionVector&
183  return myExits;
184 }
185 
186 
187 
190  return new MyWrapper(*this);
191 }
192 
193 
194 
195 /****************************************************************************/
196 
The gui-version of the MSE3Collector.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
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:67
SingleCrossingDefinition buildDefinition(const MSCrossSection &section)
Builds the description about the position of the entry/exit point.
std::vector< MSCrossSection > CrossSectionVector
double x() const
Returns the x-position.
Definition: Position.h:62
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:439
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:47
~GUIE3Collector()
Destructor.
GUIVisualizationSizeSettings addSize
CrossingDefinitions myEntryDefinitions
The list of entry positions.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
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:45
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.
static const RGBColor SUMO_color_E3Entry
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
CrossSectionVector myEntries
The detector&#39;s entries.
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Constructor.
CrossingDefinitions myExitDefinitions
The list of exit positions.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:461
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:64
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIE3Collector & getDetector()
Returns the detector itself.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
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:428
static const RGBColor SUMO_color_E3Exit
long long int SUMOTime
Definition: TraCIDefs.h:51
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:137
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:85
void drawSingleCrossing(const Position &pos, double rot, double upscale) const
Draws a single entry/exit point.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
Boundary myBoundary
The detector&#39;s boundary.
A window containing a gl-object&#39;s parameter.
CrossSectionVector myExits
The detector&#39;s exits.