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-2022 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// class definitions
43// ===========================================================================
50class GUIEdge : public MSEdge, public GUIGlObject {
51public:
57 GUIEdge(const std::string& id, int numericalID,
58 const SumoXMLEdgeFunc function,
59 const std::string& streetName, const std::string& edgeType, int priority,
60 double distance);
61
62
64 ~GUIEdge();
65
67 virtual void closeBuilding() override;
68
69 /* @brief Returns the gl-ids of all known edges
70 * @param[in] includeInternal Whether to include ids of internal edges
71 */
72 static std::vector<GUIGlID> getIDs(bool includeInternal);
73
74 /* @brief Returns the combined length of all edges
75 * @param[in] includeInternal Whether to include lengths of internal edges
76 * @param[in] eachLane Whether to count each lane separately
77 */
78 static double getTotalLength(bool includeInternal, bool eachLane);
79
81 Boundary getBoundary() const;
82
84 MSLane& getLane(int laneNo);
85
89 static std::pair<double, double> getLaneOffsets(double x1, double y1,
90 double x2, double y2, double prev, double wanted);
91
92
94
95
104
105
114
122
124 double getExaggeration(const GUIVisualizationSettings& s) const override;
125
131 Boundary getCenteringBoundary() const override;
132
134 const std::string getOptionalName() const override;
135
140 void drawGL(const GUIVisualizationSettings& s) const override;
142
143 void addTransportable(MSTransportable* t) const override {
144 FXMutexLock locker(myLock);
146 }
147
148 void removeTransportable(MSTransportable* t) const override {
149 FXMutexLock locker(myLock);
151 }
152
155
164 const std::set<MSTransportable*, ComparatorNumericalIdLess>& getPersonsSecure() const {
165 myLock.lock();
166 return myPersons;
167 }
168
173 void releasePersons() const {
174 myLock.unlock();
175 }
177
178 double getAllowedSpeed() const;
180 double getRelativeSpeed() const;
181
183 void setColor(const GUIVisualizationSettings& s) const;
184
186 bool setFunctionalColor(const GUIColorer& c) const;
187
189 bool setMultiColor(const GUIColorer& c) const;
190
192 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
193
195 double getScaleValue(int activeScheme) const;
196
199
200 void drawMesoVehicles(const GUIVisualizationSettings& s) const;
201
203 void lock() const override {
204 myLock.lock();
205 }
206
208 void unlock() const override {
209 myLock.unlock();
210 }
211
213 void closeTraffic(const GUILane* lane);
214
216 void addRerouter();
217
219 const std::vector<RGBColor>& getSegmentColors() const {
220 return mySegmentColors;
221 }
222
224 return myMesoColor;
225 }
226
227 bool showDeadEnd() const {
228 return myShowDeadEnd;
229 }
230
232 bool isSelected() const override;
233
235 mutable std::vector<RGBColor> mySegmentColors;
236
239
241 double getPendingEmits() const;
242
243private:
245 GUIEdge(const GUIEdge& s);
246
249
250
251private:
253 mutable FXMutex myLock;
254
256
257};
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:50
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:250
double getAllowedSpeed() const
Definition: GUIEdge.cpp:426
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:253
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GUIEdge.cpp:244
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:470
bool showDeadEnd() const
Definition: GUIEdge.h:227
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:219
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:438
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:372
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUIEdge.cpp:160
RGBColor getMesoColor() const
Definition: GUIEdge.h:223
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:520
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:560
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:264
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:432
void unlock() const override
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:208
void lock() const override
grant exclusive access to the mesoscopic state
Definition: GUIEdge.h:203
RGBColor myMesoColor
Definition: GUIEdge.h:255
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:591
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:582
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:143
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:605
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:173
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:259
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:235
void removeTransportable(MSTransportable *t) const override
Definition: GUIEdge.h:148
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:632
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition: GUIEdge.cpp:637
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:448
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:238
~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:164
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:1094
virtual void addTransportable(MSTransportable *t) const
Definition: MSEdge.cpp:1085
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