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-2024 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 double getClickPriority() 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(const GUIVisualizationSettings& s, 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:51
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUIEdge.cpp:665
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUIEdge.cpp:245
double getAllowedSpeed() const
Definition GUIEdge.cpp:446
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition GUIEdge.h:253
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition GUIEdge.cpp:490
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:458
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition GUIEdge.cpp:391
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUIEdge.cpp:161
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:540
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition GUIEdge.cpp:97
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUIEdge.cpp:259
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition GUIEdge.cpp:452
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:614
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition GUIEdge.cpp:605
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition GUIEdge.cpp:81
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:628
static double getTotalLength(bool includeInternal, bool eachLane)
Definition GUIEdge.cpp:119
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:133
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition GUIEdge.cpp:104
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUIEdge.cpp:179
const std::string getOptionalName() const override
Returns the street name.
Definition GUIEdge.cpp:254
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition GUIEdge.h:235
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition GUIEdge.cpp:580
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:655
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition GUIEdge.cpp:660
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition GUIEdge.cpp:468
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition GUIEdge.h:238
~GUIEdge()
Destructor.
Definition GUIEdge.cpp:73
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition GUIEdge.cpp:221
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersonsSecure() const
Returns this edge's persons set; locks it for microsimulation.
Definition GUIEdge.h:164
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.
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:938
virtual void removeTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1197
virtual void addTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1188
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