SUMO - Simulation of Urban MObility
GUIE3Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The gui-version of a MSE3Collector
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GUIE3Collector.h"
34 #include "GUIEdge.h"
36 #include <utils/gui/div/GLHelper.h>
38 #include <microsim/MSLane.h>
40 
41 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 /* -------------------------------------------------------------------------
50  * GUIE3Collector::MyWrapper-methods
51  * ----------------------------------------------------------------------- */
53  : GUIDetectorWrapper("E3 detector", detector.getID()),
54  myDetector(detector) {
55  const CrossSectionVector& entries = detector.getEntries();
56  const CrossSectionVector& exits = detector.getExits();
58  for (i = entries.begin(); i != entries.end(); ++i) {
61  myEntryDefinitions.push_back(def);
62  }
63  for (i = exits.begin(); i != exits.end(); ++i) {
66  myExitDefinitions.push_back(def);
67  }
68 }
69 
70 
72 
73 
79  return def;
80 }
81 
82 
87  new GUIParameterTableWindow(app, *this, 3);
88  // add items
89  // values
90  ret->mkItem("vehicles within [#]", true,
92  ret->mkItem("mean speed [m/s]", true,
94  ret->mkItem("haltings [#]", true,
96  // close building
97  ret->closeBuilding();
98  return ret;
99 }
100 
101 
102 void
104  glPushName(getGlID());
105  glPushMatrix();
106  glTranslated(0, 0, getType());
107  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
108  CrossingDefinitions::const_iterator i;
109  glColor3d(0, .8, 0);
110  const SUMOReal exaggeration = s.addSize.getExaggeration(s);
111  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
112  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
113  }
114  glColor3d(.8, 0, 0);
115  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
116  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
117  }
118  glPopMatrix();
119  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
120  glPopName();
121 }
122 
123 
124 void
126  SUMOReal rot, SUMOReal upscale) const {
127  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
128  glPushMatrix();
129  glScaled(upscale, upscale, 1);
130  glTranslated(pos.x(), pos.y(), 0);
131  glRotated(rot, 0, 0, 1);
132  glBegin(GL_LINES);
133  glVertex2d(1.7, 0);
134  glVertex2d(-1.7, 0);
135  glEnd();
136  glBegin(GL_QUADS);
137  glVertex2d(-1.7, .5);
138  glVertex2d(-1.7, -.5);
139  glVertex2d(1.7, -.5);
140  glVertex2d(1.7, .5);
141  glEnd();
142  // arrows
143  glTranslated(1.5, 0, 0);
144  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
146  glTranslated(-3, 0, 0);
147  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
149  glPopMatrix();
150 }
151 
152 
153 Boundary
155  Boundary b(myBoundary);
156  b.grow(20);
157  return b;
158 }
159 
160 
163  return myDetector;
164 }
165 
166 
167 /* -------------------------------------------------------------------------
168  * GUIE3Collector-methods
169  * ----------------------------------------------------------------------- */
170 GUIE3Collector::GUIE3Collector(const std::string& id,
171  const CrossSectionVector& entries, const CrossSectionVector& exits,
172  SUMOReal haltingSpeedThreshold,
173  SUMOTime haltingTimeThreshold, const std::string& vTypes)
174  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes) {}
175 
176 
178 
179 
180 const CrossSectionVector&
182  return myEntries;
183 }
184 
185 
186 const CrossSectionVector&
188  return myExits;
189 }
190 
191 
192 
195  return new MyWrapper(*this);
196 }
197 
198 
199 
200 /****************************************************************************/
201 
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
The gui-version of the MSE3Collector.
long long int SUMOTime
Definition: SUMOTime.h:43
const CrossSectionVector & getEntries() const
Returns the list of entry points.
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)
void drawSingleCrossing(const Position &pos, SUMOReal rot, SUMOReal upscale) const
Draws a single entry/exit point.
Stores the information about how to visualize structures.
SingleCrossingDefinition buildDefinition(const MSCrossSection &section)
Builds the description about the position of the entry/exit point.
std::vector< MSCrossSection > CrossSectionVector
GUIE3Collector & myDetector
The wrapped detector.
CrossSectionVector::const_iterator CrossSectionVectorConstIt
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
Definition: GLHelper.cpp:130
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
static void drawTriangleAtEnd(const Position &p1, const Position &p2, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:422
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Constructor.
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
~GUIE3Collector()
Destructor.
GUIVisualizationSizeSettings addSize
CrossingDefinitions myEntryDefinitions
The list of entry positions.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
MyWrapper(GUIE3Collector &detector)
Constructor.
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
SUMOReal myPosition
The position at the lane.
CrossSectionVector myEntries
The detector&#39;s entries.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:232
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
CrossingDefinitions myExitDefinitions
The list of exit positions.
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:65
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIE3Collector & getDetector()
Returns the detector itself.
#define SUMOReal
Definition: config.h:213
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
MSLane * myLane
The lane to cross.
Representation of a single crossing point.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
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.
void closeBuilding()
Closes the building of the table.
A window containing a gl-object&#39;s parameter.
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
CrossSectionVector myExits
The detector&#39;s exits.