Eclipse SUMO - Simulation of Urban MObility
GUIEdge.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/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/****************************************************************************/
21// A road/street connecting two junctions (gui-version)
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <vector>
27#include <string>
29#include <microsim/MSEdge.h>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MESegment;
38class MSBaseVehicle;
39class GUILane;
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
51class GUIEdge : public MSEdge, public GUIGlObject {
52public:
58 GUIEdge(const std::string& id, int numericalID,
59 const SumoXMLEdgeFunc function,
60 const std::string& streetName, const std::string& edgeType, int priority,
61 double distance);
62
63
65 ~GUIEdge();
66
68 virtual void closeBuilding() override;
69
70 /* @brief Returns the gl-ids of all known edges
71 * @param[in] includeInternal Whether to include ids of internal edges
72 */
73 static std::vector<GUIGlID> getIDs(bool includeInternal);
74
75 /* @brief Returns the combined length of all edges
76 * @param[in] includeInternal Whether to include lengths of internal edges
77 * @param[in] eachLane Whether to count each lane separately
78 */
79 static double getTotalLength(bool includeInternal, bool eachLane);
80
82 Boundary getBoundary() const;
83
85 MSLane& getLane(int laneNo);
86
90 static std::pair<double, double> getLaneOffsets(double x1, double y1,
91 double x2, double y2, double prev, double wanted);
92
93
95
96
105
106
115
123
129 Boundary getCenteringBoundary() const override;
130
132 const std::string getOptionalName() const override;
133
138 void drawGL(const GUIVisualizationSettings& s) const override;
140
141 void addTransportable(MSTransportable* t) const override {
142 FXMutexLock locker(myLock);
144 }
145
146 void removeTransportable(MSTransportable* t) const override {
147 FXMutexLock locker(myLock);
149 }
150
153
162 const std::set<MSTransportable*, ComparatorNumericalIdLess>& getPersonsSecure() const {
163 myLock.lock();
164 return myPersons;
165 }
166
171 void releasePersons() const {
172 myLock.unlock();
173 }
175
176 double getAllowedSpeed() const;
178 double getRelativeSpeed() const;
179
181 void setColor(const GUIVisualizationSettings& s) const;
182
184 bool setFunctionalColor(const GUIColorer& c) const;
185
187 bool setMultiColor(const GUIColorer& c) const;
188
190 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
191
193 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const;
194
197
198 void drawMesoVehicles(const GUIVisualizationSettings& s) const;
199
201 void lock() const override {
202 myLock.lock();
203 }
204
206 void unlock() const override {
207 myLock.unlock();
208 }
209
211 void closeTraffic(const GUILane* lane);
212
214 void addRerouter();
215
217 const std::vector<RGBColor>& getSegmentColors() const {
218 return mySegmentColors;
219 }
220
222 return myMesoColor;
223 }
224
225 bool showDeadEnd() const {
226 return myShowDeadEnd;
227 }
228
230 bool isSelected() const override;
231
233 mutable std::vector<RGBColor> mySegmentColors;
234
237
239 double getPendingEmits() const;
240
241private:
243 GUIEdge(const GUIEdge& s);
244
247
248
249private:
251 mutable FXMutex myLock;
252
254
255};
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:51
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:244
double getAllowedSpeed() const
Definition: GUIEdge.cpp:445
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:251
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:489
bool showDeadEnd() const
Definition: GUIEdge.h:225
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:217
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:457
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:390
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUIEdge.cpp:160
RGBColor getMesoColor() const
Definition: GUIEdge.h:221
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:539
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:96
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIEdge.cpp:258
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:451
void unlock() const override
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:206
void lock() const override
grant exclusive access to the mesoscopic state
Definition: GUIEdge.h:201
RGBColor myMesoColor
Definition: GUIEdge.h:253
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:613
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:604
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition: GUIEdge.cpp:80
GUIEdge(const GUIEdge &s)
invalidated copy constructor
void addTransportable(MSTransportable *t) const override
Definition: GUIEdge.h:141
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:627
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:118
void releasePersons() const
Allows to use the container for microsimulation again.
Definition: GUIEdge.h:171
static std::pair< double, double > getLaneOffsets(double x1, double y1, double x2, double y2, double prev, double wanted)
Boundary getBoundary() const
Returns the street's geometry.
Definition: GUIEdge.cpp:132
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:103
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUIEdge.cpp:178
const std::string getOptionalName() const override
Returns the street name.
Definition: GUIEdge.cpp:253
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:233
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:579
void removeTransportable(MSTransportable *t) const override
Definition: GUIEdge.h:146
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:654
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition: GUIEdge.cpp:659
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:467
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:236
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:72
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition: GUIEdge.cpp:220
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersonsSecure() const
Returns this edge's persons set; locks it for microsimulation.
Definition: GUIEdge.h:162
GUIEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority, double distance)
Constructor.
Definition: GUIEdge.cpp:62
The popup menu of a globject.
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:60
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
A single mesoscopic segment (cell)
Definition: MESegment.h:49
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:77
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
Definition: MSEdge.h:908
virtual void removeTransportable(MSTransportable *t) const
Definition: MSEdge.cpp:1095
virtual void addTransportable(MSTransportable *t) const
Definition: MSEdge.cpp:1086
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37