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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A road/street connecting two junctions (gui-version)
19 /****************************************************************************/
20 #ifndef GUIEdge_h
21 #define GUIEdge_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <vector>
30 #include <string>
31 #include <fx.h>
32 #include <microsim/MSEdge.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MESegment;
41 class MSBaseVehicle;
42 class GUILane;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
53 class GUIEdge : public MSEdge, public GUIGlObject {
54 public:
60  GUIEdge(const std::string& id, int numericalID,
61  const SumoXMLEdgeFunc function,
62  const std::string& streetName, const std::string& edgeType, int priority,
63  double distance);
64 
65 
67  ~GUIEdge();
68 
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 
87 
88 
92  static std::pair<double, double> getLaneOffsets(double x1, double y1,
93  double x2, double y2, double prev, double wanted);
94 
95 
97 
98 
107  GUISUMOAbstractView& parent);
108 
109 
118  GUISUMOAbstractView& parent);
119 
120 
127 
129  const std::string getOptionalName() const;
130 
135  void drawGL(const GUIVisualizationSettings& s) const;
137 
138 
139  void addPerson(MSTransportable* p) const {
140  FXMutexLock locker(myLock);
142  }
143 
144  void removePerson(MSTransportable* p) const {
145  FXMutexLock locker(myLock);
147  }
148 
149 
150  void addContainer(MSTransportable* c) const {
151  FXMutexLock locker(myLock);
153  }
154 
156  FXMutexLock locker(myLock);
158  }
159 
160  int getVehicleNo() const;
161  std::string getVehicleIDs() const;
162  double getBruttoOccupancy() const;
163  double getAllowedSpeed() const;
165  double getFlow() const;
167  double getRelativeSpeed() const;
168 
170  void setColor(const GUIVisualizationSettings& s) const;
171 
173  bool setFunctionalColor(const GUIColorer& c) const;
174 
176  bool setMultiColor(const GUIColorer& c) const;
177 
179  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
180 
182  double getScaleValue(int activeScheme) const;
183 
186 
187  void drawMesoVehicles(const GUIVisualizationSettings& s) const;
188 
190  void lock() const {
191  myLock.lock();
192  }
193 
195  void unlock() const {
196  myLock.unlock();
197  }
198 
200  void closeTraffic(const GUILane* lane);
201 
203  void addRerouter();
204 
206  const std::vector<RGBColor>& getSegmentColors() const {
207  return mySegmentColors;
208  }
209 
211  return myMesoColor;
212  }
213 
215  bool isSelected() const;
216 
218  mutable std::vector<RGBColor> mySegmentColors;
219 
220 
221 
222 private:
224  GUIEdge(const GUIEdge& s);
225 
227  GUIEdge& operator=(const GUIEdge& s);
228 
229 
230 private:
232  mutable FXMutex myLock;
233 
235 
236 };
237 
238 
239 #endif
240 
241 /****************************************************************************/
242 
int getVehicleNo() const
Definition: GUIEdge.cpp:347
static std::pair< double, double > getLaneOffsets(double x1, double y1, double x2, double y2, double prev, double wanted)
void lock() const
grant exclusive access to the mesoscopic state
Definition: GUIEdge.h:190
RGBColor myMesoColor
Definition: GUIEdge.h:234
RGBColor getMesoColor() const
Definition: GUIEdge.h:210
double getBruttoOccupancy() const
Definition: GUIEdge.cpp:382
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:510
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIEdge.cpp:147
void addPerson(MSTransportable *p) const
Definition: GUIEdge.h:139
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:218
Stores the information about how to visualize structures.
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GUIEdge.cpp:119
void removePerson(MSTransportable *p) const
Definition: GUIEdge.h:144
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:298
std::string getVehicleIDs() const
Definition: GUIEdge.cpp:357
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:199
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
const std::string getOptionalName() const
Returns the street name.
Definition: GUIEdge.cpp:208
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:206
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:62
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:83
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:414
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
A road/street connecting two junctions.
Definition: MSEdge.h:76
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:404
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:484
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:74
double getAllowedSpeed() const
Definition: GUIEdge.cpp:392
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
void unlock() const
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:195
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:541
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIEdge.cpp:213
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.h:609
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIEdge.cpp:164
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.h:613
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:66
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:558
virtual void removeContainer(MSTransportable *container) const
Remove container from myContainers.
Definition: MSEdge.h:626
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:398
void removeContainer(MSTransportable *c) const
Remove container from myContainers.
Definition: GUIEdge.h:155
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:90
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:532
void addContainer(MSTransportable *c) const
Add a container to myContainers.
Definition: GUIEdge.h:150
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:436
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:621
A single mesoscopic segment (cell)
Definition: MESegment.h:50
The popup menu of a globject.
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:585
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:232
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:105
double getFlow() const
return flow based on meanSpead
Definition: GUIEdge.cpp:372
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
A window containing a gl-object&#39;s parameter.