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-2020 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>
28 #include <fx.h>
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 
86 
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  GUISUMOAbstractView& parent);
107 
108 
117  GUISUMOAbstractView& parent);
118 
126 
133 
135  const std::string getOptionalName() const;
136 
141  void drawGL(const GUIVisualizationSettings& s) const;
143 
144 
145  void addPerson(MSTransportable* p) const {
146  FXMutexLock locker(myLock);
148  }
149 
150  void removePerson(MSTransportable* p) const {
151  FXMutexLock locker(myLock);
153  }
154 
155 
156  void addContainer(MSTransportable* c) const {
157  FXMutexLock locker(myLock);
159  }
160 
162  FXMutexLock locker(myLock);
164  }
165 
166  double getAllowedSpeed() const;
168  double getRelativeSpeed() const;
169 
171  void setColor(const GUIVisualizationSettings& s) const;
172 
174  bool setFunctionalColor(const GUIColorer& c) const;
175 
177  bool setMultiColor(const GUIColorer& c) const;
178 
180  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
181 
183  double getScaleValue(int activeScheme) const;
184 
187 
188  void drawMesoVehicles(const GUIVisualizationSettings& s) const;
189 
191  void lock() const {
192  myLock.lock();
193  }
194 
196  void unlock() const {
197  myLock.unlock();
198  }
199 
201  void closeTraffic(const GUILane* lane);
202 
204  void addRerouter();
205 
207  const std::vector<RGBColor>& getSegmentColors() const {
208  return mySegmentColors;
209  }
210 
212  return myMesoColor;
213  }
214 
215  bool showDeadEnd() const {
216  return myShowDeadEnd;
217  }
218 
220  bool isSelected() const;
221 
223  mutable std::vector<RGBColor> mySegmentColors;
224 
227 
228 
229 private:
231  GUIEdge(const GUIEdge& s);
232 
235 
236 
237 private:
239  mutable FXMutex myLock;
240 
242 
243 };
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:486
double getAllowedSpeed() const
Definition: GUIEdge.cpp:394
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIEdge.cpp:176
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:239
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:438
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIEdge.cpp:209
bool showDeadEnd() const
Definition: GUIEdge.h:215
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:406
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:346
void addContainer(MSTransportable *c) const
Add a container to myContainers.
Definition: GUIEdge.h:156
void lock() const
grant exclusive access to the mesoscopic state
Definition: GUIEdge.h:191
void removeContainer(MSTransportable *c) const
Remove container from myContainers.
Definition: GUIEdge.h:161
RGBColor getMesoColor() const
Definition: GUIEdge.h:211
virtual void closeBuilding()
Has to be called after all edges were built and all connections were set.
Definition: GUIEdge.cpp:78
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:512
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:94
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:400
static std::pair< double, double > getLaneOffsets(double x1, double y1, double x2, double y2, double prev, double wanted)
RGBColor myMesoColor
Definition: GUIEdge.h:241
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:543
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:534
const std::string getOptionalName() const
Returns the street name.
Definition: GUIEdge.cpp:242
GUIEdge(const GUIEdge &s)
invalidated copy constructor
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:587
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:560
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:116
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:233
void addPerson(MSTransportable *p) const
Definition: GUIEdge.h:145
Boundary getBoundary() const
Returns the street's geometry.
Definition: GUIEdge.cpp:130
void removePerson(MSTransportable *p) const
Definition: GUIEdge.h:150
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:207
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:101
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIEdge.cpp:247
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIEdge.cpp:158
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:223
void unlock() const
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:196
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:416
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:226
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:70
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:47
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:667
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.cpp:948
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:662
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.cpp:953
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:36