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-2015 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"
35 #include <utils/geom/Line.h>
37 #include <utils/gui/div/GLHelper.h>
39 #include <microsim/MSLane.h>
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 /* -------------------------------------------------------------------------
51  * GUIE3Collector::MyWrapper-methods
52  * ----------------------------------------------------------------------- */
54  : GUIDetectorWrapper("E3 detector", detector.getID()),
55  myDetector(detector) {
56  const CrossSectionVector& entries = detector.getEntries();
57  const CrossSectionVector& exits = detector.getExits();
59  for (i = entries.begin(); i != entries.end(); ++i) {
62  myEntryDefinitions.push_back(def);
63  }
64  for (i = exits.begin(); i != exits.end(); ++i) {
67  myExitDefinitions.push_back(def);
68  }
69 }
70 
71 
73 
74 
80  return def;
81 }
82 
83 
88  new GUIParameterTableWindow(app, *this, 3);
89  // add items
90  // values
91  ret->mkItem("vehicles within [#]", true,
93  ret->mkItem("mean speed [m/s]", true,
95  ret->mkItem("haltings [#]", true,
97  // close building
98  ret->closeBuilding();
99  return ret;
100 }
101 
102 
103 void
105  glPushName(getGlID());
106  glPushMatrix();
107  glTranslated(0, 0, getType());
108  typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
109  CrossingDefinitions::const_iterator i;
110  glColor3d(0, .8, 0);
111  const SUMOReal exaggeration = s.addSize.getExaggeration(s);
112  for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
113  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
114  }
115  glColor3d(.8, 0, 0);
116  for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
117  drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
118  }
119  glPopMatrix();
120  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
121  glPopName();
122 }
123 
124 
125 void
127  SUMOReal rot, SUMOReal upscale) const {
128  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
129  glPushMatrix();
130  glScaled(upscale, upscale, 1);
131  glTranslated(pos.x(), pos.y(), 0);
132  glRotated(rot, 0, 0, 1);
133  glBegin(GL_LINES);
134  glVertex2d(1.7, 0);
135  glVertex2d(-1.7, 0);
136  glEnd();
137  glBegin(GL_QUADS);
138  glVertex2d(-1.7, .5);
139  glVertex2d(-1.7, -.5);
140  glVertex2d(1.7, -.5);
141  glVertex2d(1.7, .5);
142  glEnd();
143  // arrows
144  glTranslated(1.5, 0, 0);
145  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
147  glTranslated(-3, 0, 0);
148  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
150  glPopMatrix();
151 }
152 
153 
154 Boundary
156  Boundary b(myBoundary);
157  b.grow(20);
158  return b;
159 }
160 
161 
164  return myDetector;
165 }
166 
167 
168 /* -------------------------------------------------------------------------
169  * GUIE3Collector-methods
170  * ----------------------------------------------------------------------- */
171 GUIE3Collector::GUIE3Collector(const std::string& id,
172  const CrossSectionVector& entries, const CrossSectionVector& exits,
173  SUMOReal haltingSpeedThreshold,
174  SUMOTime haltingTimeThreshold)
175  : MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold) {}
176 
177 
179 
180 
181 const CrossSectionVector&
183  return myEntries;
184 }
185 
186 
187 const CrossSectionVector&
189  return myExits;
190 }
191 
192 
193 
196  return new MyWrapper(*this);
197 }
198 
199 
200 
201 /****************************************************************************/
202 
The gui-version of the MSE3Collector.
std::vector< SingleCrossingDefinition > CrossingDefinitions
Definition of a list of cross (entry/exit-point) positions.
GUIVisualizationTextSettings addName
A simple description of a position on a lane (crossing of a lane)
const CrossSectionVector & getExits() const
Returns the list of exit points.
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:340
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
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.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
Constructor.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal scale
information about a lane's width (temporary, used for a single view)
~GUIE3Collector()
Destructor.
GUIVisualizationSizeSettings addSize
CrossingDefinitions myEntryDefinitions
The list of entry positions.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
Definition: Line.h:51
MyWrapper(GUIE3Collector &detector)
Constructor.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
SUMOReal myPosition
The position at the lane.
CrossSectionVector myEntries
The detector's entries.
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
void drawSingleCrossing(const Position &pos, SUMOReal rot, SUMOReal upscale) const
Draws a single entry/exit point.
CrossingDefinitions myExitDefinitions
The list of exit positions.
static void drawTriangleAtEnd(const Line &l, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:422
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
int SUMOTime
Definition: SUMOTime.h:43
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:65
const CrossSectionVector & getEntries() const
Returns the list of entry points.
GUIE3Collector & getDetector()
Returns the detector itself.
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:323
#define SUMOReal
Definition: config.h:218
MSLane * myLane
The lane to cross.
Representation of a single crossing point.
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
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's boundary.
void closeBuilding()
Closes the building of the table.
A window containing a gl-object's parameter.
SUMOReal getExaggeration(const GUIVisualizationSettings &s) const
return the drawing size including exaggeration and constantSize values
CrossSectionVector myExits
The detector's exits.