Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIE3Collector.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// The gui-version of a MSE3Collector
21/****************************************************************************/
22#include <config.h>
23
24#include "GUIE3Collector.h"
25#include "GUIEdge.h"
29#include <microsim/MSLane.h>
31
32
33// ===========================================================================
34// method definitions
35// ===========================================================================
36
37// -------------------------------------------------------------------------
38// GUIE3Collector::MyWrapper-methods
39// -------------------------------------------------------------------------
40
42 GUIDetectorWrapper(GLO_E3DETECTOR, detector.getID(), GUIIconSubSys::getIcon(GUIIcon::E3)),
43 myDetector(detector) {
44 const CrossSectionVector& entries = detector.getEntries();
45 const CrossSectionVector& exits = detector.getExits();
47 for (i = entries.begin(); i != entries.end(); ++i) {
50 myEntryDefinitions.push_back(def);
51 }
52 for (i = exits.begin(); i != exits.end(); ++i) {
55 myExitDefinitions.push_back(def);
56 }
57}
58
59
61
62
70
71
76 new GUIParameterTableWindow(app, *this);
77 // add items
78 // values
79 ret->mkItem("name", false, myDetector.myName);
80 if (myDetector.isTyped()) {
81 ret->mkItem("vTypes", false, toString(myDetector.getVehicleTypes()));
82 }
83 ret->mkItem("vehicles within [#]", true,
85 ret->mkItem("mean speed [m/s]", true,
87 ret->mkItem("haltings [#]", true,
89 ret->mkItem("last interval mean travel time [s]", true,
91 ret->mkItem("last interval mean haltings [#]", true,
93 ret->mkItem("last interval mean time loss time [s]", true,
95 ret->mkItem("last interval mean vehicle count [#]", true,
97
98 // close building
99 ret->closeBuilding(&myDetector);
100 return ret;
101}
102
103
104void
106 GLHelper::pushName(getGlID());
108 glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
109 typedef std::vector<SingleCrossingDefinition> CrossingDefinitions;
110 CrossingDefinitions::const_iterator i;
112 const double exaggeration = getExaggeration(s);
113 for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) {
114 drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
115 }
117 for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) {
118 drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, exaggeration);
119 }
121 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
123}
124
125
126void
128 double rot, double upscale) const {
129 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
131 glTranslated(pos.x(), pos.y(), 0);
132 glRotated(rot, 0, 0, 1);
133 glScaled(upscale, upscale, 1);
134 glBegin(GL_LINES);
135 glVertex2d(1.7, 0);
136 glVertex2d(-1.7, 0);
137 glEnd();
138 glBegin(GL_QUADS);
139 glVertex2d(-1.7, .5);
140 glVertex2d(-1.7, -.5);
141 glVertex2d(1.7, -.5);
142 glVertex2d(1.7, .5);
143 glEnd();
144 // arrows
145 glTranslated(1.5, 0, 0);
146 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
147 GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
148 glTranslated(-3, 0, 0);
149 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
150 GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
152}
153
154
155double
159
160
163 Boundary b(myBoundary);
164 b.grow(20);
165 return b;
166}
167
168
171 return myDetector;
172}
173
174
175/* -------------------------------------------------------------------------
176 * GUIE3Collector-methods
177 * ----------------------------------------------------------------------- */
178GUIE3Collector::GUIE3Collector(const std::string& id,
179 const CrossSectionVector& entries, const CrossSectionVector& exits,
180 double haltingSpeedThreshold,
181 SUMOTime haltingTimeThreshold,
182 const std::string name, const std::string& vTypes,
183 const std::string& nextEdges,
184 int detectPersons,
185 bool openEntry, bool expectArrival):
186 MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, name, vTypes, nextEdges, detectPersons, openEntry, expectArrival)
187{}
188
189
191
192
195 return myEntries;
196}
197
198
201 return myExits;
202}
203
204
205
210
211
212/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ GLO_JUNCTION
a junction
@ GLO_E3DETECTOR
a E3 detector
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
CrossSectionVector::const_iterator CrossSectionVectorConstIt
std::vector< MSCrossSection > CrossSectionVector
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:300
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:583
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition GLHelper.cpp:558
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:277
static void popName()
pop Name
Definition GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
std::vector< SingleCrossingDefinition > CrossingDefinitions
Definition of a list of cross (entry/exit-point) positions.
SingleCrossingDefinition buildDefinition(const MSCrossSection &section)
Builds the description about the position of the entry/exit point.
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void drawSingleCrossing(const Position &pos, double rot, double upscale) const
Draws a single entry/exit point.
GUIE3Collector & getDetector()
Returns the detector itself.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
CrossingDefinitions myExitDefinitions
The list of exit positions.
CrossingDefinitions myEntryDefinitions
The list of entry positions.
MyWrapper(GUIE3Collector &detector)
Constructor.
Boundary myBoundary
The detector's boundary.
The gui-version of the MSE3Collector.
~GUIE3Collector()
Destructor.
const CrossSectionVector & getExits() const
Returns the list of exit points.
GUIDetectorWrapper * buildDetectorGUIRepresentation()
Returns the wrapper for this detector.
GUIE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons, bool openEntry, bool expectArrival)
Constructor.
const CrossSectionVector & getEntries() const
Returns the list of entry points.
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationSizeSettings addSize
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
A simple description of a position on a lane (crossing of a lane)
MSLane * myLane
The lane to cross.
double myPosition
The position at the lane.
A detector of vehicles passing an area between entry/exit points.
CrossSectionVector myExits
The detector's exits.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
double getLastIntervalMeanTravelTime() const
int getLastIntervalVehicleSum() const
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
double getLastIntervalMeanHaltsPerVehicle() const
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
double getLastIntervalMeanTimeLoss() const
CrossSectionVector myEntries
The detector's entrys.
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:293
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:551
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Representation of a single crossing point.
static const RGBColor E3ExitColor
color for Exits
static const RGBColor E3EntryColor
color for Entrys
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values