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 // ===========================================================================
37 class MESegment;
38 class MSBaseVehicle;
39 class GUILane;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
50 class GUIEdge : public MSEdge, public GUIGlObject {
51 public:
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();
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  GUISUMOAbstractView& parent);
105 
106 
115  GUISUMOAbstractView& parent);
116 
124 
126  double getExaggeration(const GUIVisualizationSettings& s) const;
127 
134 
136  const std::string getOptionalName() const;
137 
142  void drawGL(const GUIVisualizationSettings& s) const;
144 
145 
146  void addPerson(MSTransportable* p) const {
147  FXMutexLock locker(myLock);
149  }
150 
151  void removePerson(MSTransportable* p) const {
152  FXMutexLock locker(myLock);
154  }
155 
156 
157  void addContainer(MSTransportable* c) const {
158  FXMutexLock locker(myLock);
160  }
161 
163  FXMutexLock locker(myLock);
165  }
166 
167  double getAllowedSpeed() const;
169  double getRelativeSpeed() const;
170 
172  void setColor(const GUIVisualizationSettings& s) const;
173 
175  bool setFunctionalColor(const GUIColorer& c) const;
176 
178  bool setMultiColor(const GUIColorer& c) const;
179 
181  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
182 
184  double getScaleValue(int activeScheme) const;
185 
188 
189  void drawMesoVehicles(const GUIVisualizationSettings& s) const;
190 
192  void lock() const {
193  myLock.lock();
194  }
195 
197  void unlock() const {
198  myLock.unlock();
199  }
200 
202  void closeTraffic(const GUILane* lane);
203 
205  void addRerouter();
206 
208  const std::vector<RGBColor>& getSegmentColors() const {
209  return mySegmentColors;
210  }
211 
213  return myMesoColor;
214  }
215 
216  bool showDeadEnd() const {
217  return myShowDeadEnd;
218  }
219 
221  bool isSelected() const;
222 
224  mutable std::vector<RGBColor> mySegmentColors;
225 
228 
230  double getPendingEmits() const;
231 
232 private:
234  GUIEdge(const GUIEdge& s);
235 
238 
239 
240 private:
242  mutable FXMutex myLock;
243 
245 
246 };
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
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:516
double getAllowedSpeed() const
Definition: GUIEdge.cpp:422
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIEdge.cpp:178
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:242
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:466
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIEdge.cpp:218
bool showDeadEnd() const
Definition: GUIEdge.h:216
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:434
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:368
void addContainer(MSTransportable *c) const
Add a container to myContainers.
Definition: GUIEdge.h:157
void lock() const
grant exclusive access to the mesoscopic state
Definition: GUIEdge.h:192
void removeContainer(MSTransportable *c) const
Remove container from myContainers.
Definition: GUIEdge.h:162
RGBColor getMesoColor() const
Definition: GUIEdge.h:212
virtual void closeBuilding()
Has to be called after all edges were built and all connections were set.
Definition: GUIEdge.cpp:80
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:556
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:96
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:428
static std::pair< double, double > getLaneOffsets(double x1, double y1, double x2, double y2, double prev, double wanted)
RGBColor myMesoColor
Definition: GUIEdge.h:244
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:587
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:578
const std::string getOptionalName() const
Returns the street name.
Definition: GUIEdge.cpp:257
GUIEdge(const GUIEdge &s)
invalidated copy constructor
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:628
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:601
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:118
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:248
void addPerson(MSTransportable *p) const
Definition: GUIEdge.h:146
Boundary getBoundary() const
Returns the street's geometry.
Definition: GUIEdge.cpp:132
void removePerson(MSTransportable *p) const
Definition: GUIEdge.h:151
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:208
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:103
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GUIEdge.cpp:242
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIEdge.cpp:262
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIEdge.cpp:160
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:224
void unlock() const
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:197
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition: GUIEdge.cpp:633
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:444
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:227
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:72
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:59
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:51
A road/street connecting two junctions.
Definition: MSEdge.h:77
virtual void removeContainer(MSTransportable *container) const
Remove container from myContainers.
Definition: MSEdge.h:678
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.cpp:1019
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:673
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.cpp:1024
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37