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-2017 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 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 /* -------------------------------------------------------------------------
46  * GUIE3Collector::MyWrapper-methods
47  * ----------------------------------------------------------------------- */
49  : GUIDetectorWrapper("E3 detector", detector.getID()),
50  myDetector(detector) {
51  const CrossSectionVector& entries = detector.getEntries();
52  const CrossSectionVector& exits = detector.getExits();
54  for (i = entries.begin(); i != entries.end(); ++i) {
57  myEntryDefinitions.push_back(def);
58  }
59  for (i = exits.begin(); i != exits.end(); ++i) {
62  myExitDefinitions.push_back(def);
63  }
64 }
65 
66 
68 
69 
75  return def;
76 }
77 
78 
83  new GUIParameterTableWindow(app, *this, 3);
84  // add items
85  // values
86  ret->mkItem("vehicles within [#]", true,
88  ret->mkItem("mean speed [m/s]", true,
90  ret->mkItem("haltings [#]", true,
92  // close building
93  ret->closeBuilding();
94  return ret;
95 }
96 
97 
98 void
100  glPushName(getGlID());
101  glPushMatrix();
102  glTranslated(0, 0, getType());
103  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
104  CrossingDefinitions::const_iterator i;
105  glColor3d(0, .8, 0);
106  const double exaggeration = s.addSize.getExaggeration(s);
107  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
108  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
109  }
110  glColor3d(.8, 0, 0);
111  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
112  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
113  }
114  glPopMatrix();
115  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
116  glPopName();
117 }
118 
119 
120 void
122  double rot, double upscale) const {
123  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
124  glPushMatrix();
125  glScaled(upscale, upscale, 1);
126  glTranslated(pos.x(), pos.y(), 0);
127  glRotated(rot, 0, 0, 1);
128  glBegin(GL_LINES);
129  glVertex2d(1.7, 0);
130  glVertex2d(-1.7, 0);
131  glEnd();
132  glBegin(GL_QUADS);
133  glVertex2d(-1.7, .5);
134  glVertex2d(-1.7, -.5);
135  glVertex2d(1.7, -.5);
136  glVertex2d(1.7, .5);
137  glEnd();
138  // arrows
139  glTranslated(1.5, 0, 0);
140  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
141  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
142  glTranslated(-3, 0, 0);
143  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
144  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
145  glPopMatrix();
146 }
147 
148 
149 Boundary
151  Boundary b(myBoundary);
152  b.grow(20);
153  return b;
154 }
155 
156 
159  return myDetector;
160 }
161 
162 
163 /* -------------------------------------------------------------------------
164  * GUIE3Collector-methods
165  * ----------------------------------------------------------------------- */
166 GUIE3Collector::GUIE3Collector(const std::string& id,
167  const CrossSectionVector& entries, const CrossSectionVector& exits,
168  double haltingSpeedThreshold,
169  SUMOTime haltingTimeThreshold, const std::string& vTypes)
170  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes) {}
171 
172 
174 
175 
176 const CrossSectionVector&
178  return myEntries;
179 }
180 
181 
182 const CrossSectionVector&
184  return myExits;
185 }
186 
187 
188 
191  return new MyWrapper(*this);
192 }
193 
194 
195 
196 /****************************************************************************/
197 
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.
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:68
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:63
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:426
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:48
~GUIE3Collector()
Destructor.
GUIVisualizationSizeSettings addSize
CrossingDefinitions myEntryDefinitions
The list of entry positions.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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:46
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:234
MyWrapper(GUIE3Collector &detector)
Constructor.
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:448
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.
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:418
long long int SUMOTime
Definition: TraCIDefs.h:52
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:126
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
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.
void closeBuilding()
Closes the building of the table.
A window containing a gl-object&#39;s parameter.
CrossSectionVector myExits
The detector&#39;s exits.