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-2018 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 <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 
64 
66  ~GUIEdge();
67 
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 
119 
126 
127 
132  void drawGL(const GUIVisualizationSettings& s) const;
134 
135 
136  void addPerson(MSTransportable* p) const {
139  }
140 
141  void removePerson(MSTransportable* p) const {
144  }
145 
146 
147  void addContainer(MSTransportable* c) const {
150  }
151 
155  }
156 
157  int getVehicleNo() const;
158  std::string getVehicleIDs() const;
159  double getBruttoOccupancy() const;
160  double getAllowedSpeed() const;
162  double getFlow() const;
164  double getRelativeSpeed() const;
165 
167  void setColor(const GUIVisualizationSettings& s) const;
168 
170  bool setFunctionalColor(const GUIColorer& c) const;
171 
173  bool setMultiColor(const GUIColorer& c) const;
174 
176  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
177 
179  double getScaleValue(int activeScheme) const;
180 
183 
184  void drawMesoVehicles(const GUIVisualizationSettings& s) const;
185 
187  void lock() const {
188  myLock.lock();
189  }
190 
192  void unlock() const {
193  myLock.unlock();
194  }
195 
197  void closeTraffic(const GUILane* lane);
198 
200  void addRerouter();
201 
203  const std::vector<RGBColor>& getSegmentColors() const {
204  return mySegmentColors;
205  }
206 
208  return myMesoColor;
209  }
210 
212  bool isSelected() const;
213 
215  mutable std::vector<RGBColor> mySegmentColors;
216 
217 
218 
219 private:
221  GUIEdge(const GUIEdge& s);
222 
224  GUIEdge& operator=(const GUIEdge& s);
225 
226 
227 private:
229  mutable MFXMutex myLock;
230 
232 
233 };
234 
235 
236 #endif
237 
238 /****************************************************************************/
239 
int getVehicleNo() const
Definition: GUIEdge.cpp:334
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:187
RGBColor myMesoColor
Definition: GUIEdge.h:231
RGBColor getMesoColor() const
Definition: GUIEdge.h:207
double getBruttoOccupancy() const
Definition: GUIEdge.cpp:369
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:497
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIEdge.cpp:146
void addPerson(MSTransportable *p) const
Definition: GUIEdge.h:136
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:215
Stores the information about how to visualize structures.
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GUIEdge.cpp:118
void removePerson(MSTransportable *p) const
Definition: GUIEdge.h:141
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:285
std::string getVehicleIDs() const
Definition: GUIEdge.cpp:344
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:198
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
const std::vector< RGBColor > & getSegmentColors() const
return segment colors (meso)
Definition: GUIEdge.h:203
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:63
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:82
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:401
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
A road/street connecting two junctions.
Definition: MSEdge.h:75
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:391
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:471
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:73
double getAllowedSpeed() const
Definition: GUIEdge.cpp:379
GUIEdge & operator=(const GUIEdge &s)
invalidated assignment operator
void unlock() const
release exclusive access to the mesoscopic state
Definition: GUIEdge.h:192
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:528
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:208
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.h:595
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIEdge.cpp:163
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.h:599
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:545
virtual void removeContainer(MSTransportable *container) const
Remove container from myContainers.
Definition: MSEdge.h:612
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:385
void removeContainer(MSTransportable *c) const
Remove container from myContainers.
Definition: GUIEdge.h:152
void unlock()
release mutex lock
Definition: MFXMutex.cpp:87
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:89
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:519
void addContainer(MSTransportable *c) const
Add a container to myContainers.
Definition: GUIEdge.h:147
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:423
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:607
MFXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:229
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
Definition: AbstractMutex.h:59
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:572
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
void lock()
lock mutex
Definition: MFXMutex.cpp:77
GUIEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
Definition: GUIEdge.cpp:66
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:104
double getFlow() const
return flow based on meanSpead
Definition: GUIEdge.cpp:359
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
A window containing a gl-object&#39;s parameter.