Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIEdge.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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,
61 const std::string& routingType, int priority,
62 double distance);
63
64
66 ~GUIEdge();
67
69 virtual void closeBuilding() override;
70
71 /* @brief Returns the gl-ids of all known edges
72 * @param[in] includeInternal Whether to include ids of internal edges
73 */
74 static std::vector<GUIGlID> getIDs(bool includeInternal);
75
76 /* @brief Returns the combined length of all edges
77 * @param[in] includeInternal Whether to include lengths of internal edges
78 * @param[in] eachLane Whether to count each lane separately
79 */
80 static double getTotalLength(bool includeInternal, bool eachLane);
81
83 Boundary getBoundary() const;
84
86 MSLane& getLane(int laneNo);
87
91 static std::pair<double, double> getLaneOffsets(double x1, double y1,
92 double x2, double y2, double prev, double wanted);
93
94
96
97
106
107
116
124
130 Boundary getCenteringBoundary() const override;
131
133 const std::string getOptionalName() const override;
134
139 void drawGL(const GUIVisualizationSettings& s) const override;
141
142 double getClickPriority() const override;
143
144 void addTransportable(MSTransportable* t) const override {
145 FXMutexLock locker(myLock);
147 }
148
149 void removeTransportable(MSTransportable* t) const override {
150 FXMutexLock locker(myLock);
152 }
153
156
165 const std::set<MSTransportable*, ComparatorNumericalIdLess>& getPersonsSecure() const {
166 myLock.lock();
167 return myPersons;
168 }
169
174 void releasePersons() const {
175 myLock.unlock();
176 }
178
179 double getAllowedSpeed() const;
181 double getRelativeSpeed() const;
182
184 void setColor(const GUIVisualizationSettings& s) const;
185
187 bool setFunctionalColor(const GUIColorer& c) const;
188
190 bool setMultiColor(const GUIColorer& c) const;
191
193 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
194
196 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const;
197
200
201 void drawMesoVehicles(const GUIVisualizationSettings& s) const;
202
204 void lock() const override {
205 myLock.lock();
206 }
207
209 void unlock() const override {
210 myLock.unlock();
211 }
212
214 void closeTraffic(const GUILane* lane);
215
217 void addRerouter();
218
220 const std::vector<RGBColor>& getSegmentColors() const {
221 return mySegmentColors;
222 }
223
225 return myMesoColor;
226 }
227
228 bool showDeadEnd() const {
229 return myShowDeadEnd;
230 }
231
233 bool isSelected() const override;
234
236 mutable std::vector<RGBColor> mySegmentColors;
237
240
242 double getPendingEmits() const;
243
244private:
246 GUIEdge(const GUIEdge& s);
247
250
251
252private:
254 mutable FXMutex myLock;
255
257
258};
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
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUIEdge.cpp:669
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUIEdge.cpp:249
double getAllowedSpeed() const
Definition GUIEdge.cpp:450
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition GUIEdge.h:254
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition GUIEdge.cpp:494
bool showDeadEnd() const
Definition GUIEdge.h:228
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition GUIEdge.h:220
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUIEdge.cpp:462
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition GUIEdge.cpp:395
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUIEdge.cpp:164
RGBColor getMesoColor() const
Definition GUIEdge.h:224
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUIEdge.cpp:544
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition GUIEdge.cpp:99
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUIEdge.cpp:263
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition GUIEdge.cpp:456
void unlock() const override
release exclusive access to the mesoscopic state
Definition GUIEdge.h:209
void lock() const override
grant exclusive access to the mesoscopic state
Definition GUIEdge.h:204
RGBColor myMesoColor
Definition GUIEdge.h:256
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition GUIEdge.cpp:618
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition GUIEdge.cpp:609
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition GUIEdge.cpp:83
GUIEdge(const GUIEdge &s)
invalidated copy constructor
void addTransportable(MSTransportable *t) const override
Definition GUIEdge.h:144
void addRerouter()
add a rerouter
Definition GUIEdge.cpp:632
static double getTotalLength(bool includeInternal, bool eachLane)
Definition GUIEdge.cpp:121
void releasePersons() const
Allows to use the container for microsimulation again.
Definition GUIEdge.h:174
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:135
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition GUIEdge.cpp:106
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUIEdge.cpp:182
const std::string getOptionalName() const override
Returns the street name.
Definition GUIEdge.cpp:258
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition GUIEdge.h:236
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition GUIEdge.cpp:584
void removeTransportable(MSTransportable *t) const override
Definition GUIEdge.h:149
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUIEdge.cpp:659
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition GUIEdge.cpp:664
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition GUIEdge.cpp:472
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition GUIEdge.h:239
~GUIEdge()
Destructor.
Definition GUIEdge.cpp:75
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition GUIEdge.cpp:224
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersonsSecure() const
Returns this edge's persons set; locks it for microsimulation.
Definition GUIEdge.h:165
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:50
The base class for microscopic and mesoscopic vehicles.
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:957
virtual void removeTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1207
virtual void addTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1198
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