Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPathManager.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-2023 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/****************************************************************************/
18// Manager for paths in netedit (routes, trips, flows...)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <netbuild/NBEdge.h>
24#include <netbuild/NBVehicle.h>
28
29
30// ===========================================================================
31// class definitions
32// ===========================================================================
33
34class GNENet;
36class GNEEdge;
37class GNELane;
38class GNEJunction;
39class GNEAdditional;
40
42
43public:
45 class PathElement;
46
48 class Segment {
49
50 public:
52 Segment(GNEPathManager* pathManager, PathElement* element, const GNELane* lane,
53 const bool firstSegment, const bool lastSegment);
54
56 Segment(GNEPathManager* pathManager, PathElement* element, const GNEJunction* junction,
57 const GNELane* previousLane, const GNELane* nextLane);
58
60 ~Segment();
61
63 bool isFirstSegment() const;
64
66 bool isLastSegment() const;
67
70
72 const GNELane* getLane() const;
73
75 const GNELane* getPreviousLane() const;
76
78 const GNELane* getNextLane() const;
79
81 const GNEJunction* getJunction() const;
82
84 Segment* getNextSegment() const;
85
87 void setNextSegment(Segment* nexSegment);
88
91
93 void setPreviousSegment(Segment* nexSegment);
94
96 bool isLabelSegment() const;
97
99 void markSegmentLabel();
100
101 protected:
104
107
109 const bool myFirstSegment;
110
112 const bool myLastSegment;
113
116
119
122
125
128
131
134
135 private:
137 Segment();
138
140 Segment(const Segment&) = delete;
141
143 Segment& operator=(const Segment&) = delete;
144 };
145
147 class PathElement : public GUIGlObject {
148
149 public:
150 enum Options {
151 NETWORK_ELEMENT = 1 << 0, // Network element
152 ADDITIONAL_ELEMENT = 1 << 1, // Additional element
153 DEMAND_ELEMENT = 1 << 2, // Demand element
154 DATA_ELEMENT = 1 << 3, // Data element
155 ROUTE = 1 << 4, // Route (needed for overlapping labels)
156 };
157
159 PathElement(GUIGlObjectType type, const std::string& microsimID, FXIcon* icon, const int options);
160
162 virtual ~PathElement();
163
165 bool isNetworkElement() const;
166
168 bool isAdditionalElement() const;
169
171 bool isDemandElement() const;
172
174 bool isDataElement() const;
175
177 bool isRoute() const;
178
180 virtual void computePathElement() = 0;
181
183 virtual bool isPathElementSelected() const = 0;
184
191 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
192
200 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
201
203 virtual GNELane* getFirstPathLane() const = 0;
204
206 virtual GNELane* getLastPathLane() const = 0;
207
209 virtual double getPathElementDepartValue() const = 0;
210
213
215 virtual double getPathElementArrivalValue() const = 0;
216
219
220 private:
222 const int myOption;
223
225 PathElement() = delete;
226
228 PathElement(const PathElement&) = delete;
229
232 };
233
236
237 public:
239 PathCalculator(const GNENet* net);
240
243
246
248 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector<GNEEdge*>& partialEdges) const;
249
251 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, const GNEJunction* fromJunction, const GNEJunction* toJunction) const;
252
254 void calculateReachability(const SUMOVehicleClass vClass, GNEEdge* originEdge);
255
257 bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge* from, const GNEEdge* to) const;
258
260 bool busStopConnected(const GNEAdditional* busStop, const GNEEdge* edge) const;
261
263 bool isPathCalculatorUpdated() const;
264
267
268 private:
270 const GNENet* myNet;
271
274
277
279 std::vector<GNEEdge*> optimizeJunctionPath(const std::vector<GNEEdge*>& edges) const;
280 };
281
283 class PathDraw {
284
285 public:
287 PathDraw();
288
290 ~PathDraw();
291
293 void clearPathDraw();
294
296 bool drawPathGeometry(const bool dottedElement, const GNELane* lane, SumoXMLTag tag);
297
299 bool drawPathGeometry(const bool dottedElement, const GNELane* fromLane, const GNELane* toLane, SumoXMLTag tag);
300
301 private:
303 std::map<const GNELane*, std::set<SumoXMLTag> > myLaneDrawedElements;
304
306 std::map<const std::pair<const GNELane*, const GNELane*>, std::set<SumoXMLTag> > myLane2laneDrawedElements;
307 };
308
310 GNEPathManager(const GNENet* net);
311
314
317
319 const PathElement* getPathElement(const GUIGlObject* GLObject) const;
320
322 const std::vector<Segment*>& getPathElementSegments(PathElement* pathElement) const;
323
326
328 bool isPathValid(const PathElement* pathElement) const;
329
331 const GNELane* getFirstLane(const PathElement* pathElement) const;
332
334 void calculatePathEdges(PathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEEdge*> edges);
335
337 void calculatePathLanes(PathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNELane*> lanes);
338
340 void calculatePathJunctions(PathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEJunction*> junctions);
341
343 void calculateConsecutivePathEdges(PathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEEdge*> edges);
344
346 void calculateConsecutivePathLanes(PathElement* pathElement, const std::vector<GNELane*> lanes);
347
349 void removePath(PathElement* pathElement);
350
352 void drawLanePathElements(const GUIVisualizationSettings& s, const GNELane* lane);
353
355 void drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction);
356
358 void forceDrawPath(const GUIVisualizationSettings& s, const PathElement* pathElement) const;
359
361 void invalidateLanePath(const GNELane* lane);
362
364 void invalidateJunctionPath(const GNEJunction* junction);
365
367 void clearDemandPaths();
368
369protected:
371 void addSegmentInLaneSegments(Segment* segment, const GNELane* lane);
372
374 void addSegmentInJunctionSegments(Segment* segment, const GNEJunction* junction);
375
378
380 void clearSegments();
381
383 bool connectedLanes(const GNELane* fromLane, const GNELane* toLane) const;
384
387
390
392 std::map<const PathElement*, std::vector<Segment*> > myPaths;
393
395 std::map<const GNELane*, std::set<Segment*> > myLaneSegments;
396
398 std::map<const GNEJunction*, std::set<Segment*> > myJunctionSegments;
399
400private:
402 const std::vector<Segment*> myEmptySegments;
403
406
409};
GUIGlObjectType
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
An Element which don't belong to GNENet but has influence in the simulation.
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
class used to calculate paths in nets
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
void updatePathCalculator()
update path calculator (called when SuperModes Demand or Data is selected)
bool isPathCalculatorUpdated() const
check if pathCalculator is updated
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract myDijkstraRouter.
void invalidatePathCalculator()
invalidate pathCalculator
void calculateReachability(const SUMOVehicleClass vClass, GNEEdge *originEdge)
calculate reachability for given edge
std::vector< GNEEdge * > optimizeJunctionPath(const std::vector< GNEEdge * > &edges) const
optimize junction path
bool myPathCalculatorUpdated
flag for checking if path calculator is updated
bool busStopConnected(const GNEAdditional *busStop, const GNEEdge *edge) const
check if exist a path between the given busStop and edge (Either a valid lane or an acces) for pedest...
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
const GNENet * myNet
pointer to net
class used to mark path draw
bool drawPathGeometry(const bool dottedElement, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
std::map< const std::pair< const GNELane *, const GNELane * >, std::set< SumoXMLTag > > myLane2laneDrawedElements
map for saving tags drawn in junctions
void clearPathDraw()
clear path draw
std::map< const GNELane *, std::set< SumoXMLTag > > myLaneDrawedElements
map for saving tags drawn in lanes
class used for path elements
PathElement(const PathElement &)=delete
Invalidated copy constructor.
bool isDataElement() const
check if pathElement is a data element
const int myOption
pathElement option
virtual GNELane * getLastPathLane() const =0
get last path lane
bool isDemandElement() const
check if pathElement is a demand element
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (lane)
virtual double getPathElementArrivalValue() const =0
get path element arrival lane pos
bool isNetworkElement() const
check if pathElement is a network element
virtual void computePathElement()=0
compute pathElement
virtual ~PathElement()
destructor
virtual double getPathElementDepartValue() const =0
get path element depart lane pos
virtual Position getPathElementDepartPos() const =0
get path element depart position
virtual bool isPathElementSelected() const =0
check if path element is selectd
bool isAdditionalElement() const
check if pathElement is an additional element
virtual Position getPathElementArrivalPos() const =0
get path element arrival position
bool isRoute() const
check if pathElement is a route
PathElement()=delete
invalidate default constructor
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (junction)
PathElement & operator=(const PathElement &)=delete
Invalidated assignment operator.
virtual GNELane * getFirstPathLane() const =0
get first path lane
const GNELane * getPreviousLane() const
get previous lane
const GNELane * myNextLane
next lane
Segment & operator=(const Segment &)=delete
Invalidated assignment operator.
Segment * myNextSegment
pointer to next segment (use for draw red line)
PathElement * getPathElement() const
get path element
Segment * getPreviousSegment() const
get previous segment
void setNextSegment(Segment *nexSegment)
set next segment
void setPreviousSegment(Segment *nexSegment)
set previous segment
const GNELane * myLane
lane associated with this segment
const bool myLastSegment
lastSegment
GNEPathManager * myPathManager
path manager
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
PathElement * myPathElement
path element
Segment * myPreviousSegment
pointer to previous segment (use for draw red line)
bool isLabelSegment() const
check if segment is label segment
Segment(const Segment &)=delete
Invalidated copy constructor.
void markSegmentLabel()
mark segment as middle segment
Segment()
default constructor
bool myLabelSegment
flag for check if this segment is a label segment
Segment * getNextSegment() const
get next segment
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * myJunction
junction associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
const GNELane * myPreviousLane
previous lane
const bool myFirstSegment
first segment
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
const std::vector< Segment * > & getPathElementSegments(PathElement *pathElement) const
get path segments
const std::vector< Segment * > myEmptySegments
empty segments (used in getPathElementSegments)
void addSegmentInJunctionSegments(Segment *segment, const GNEJunction *junction)
add segments int junctionSegments (called by Segment constructor)
std::map< const GNEJunction *, std::set< Segment * > > myJunctionSegments
map with junction segments
void invalidateJunctionPath(const GNEJunction *junction)
invalidate junction path
const PathElement * getPathElement(const GUIGlObject *GLObject) const
get path element
PathDraw * getPathDraw()
obtain instance of PathDraw
GNEPathManager & operator=(const GNEPathManager &)=delete
Invalidated assignment operator.
void clearSegments()
clear segments
PathCalculator * myPathCalculator
PathCalculator instance.
void invalidateLanePath(const GNELane *lane)
invalidate lane path
void clearDemandPaths()
clear demand paths
void calculateConsecutivePathEdges(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > edges)
calculate consecutive path edges
void addSegmentInLaneSegments(Segment *segment, const GNELane *lane)
add segments int laneSegments (called by Segment constructor)
bool connectedLanes(const GNELane *fromLane, const GNELane *toLane) const
check if given lanes are connected
void calculatePathJunctions(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEJunction * > junctions)
calculate path junctions (using dijkstra, require path calculator updated)
std::map< const PathElement *, std::vector< Segment * > > myPaths
map with path element and their associated segments
void drawLanePathElements(const GUIVisualizationSettings &s, const GNELane *lane)
draw lane path elements
void removePath(PathElement *pathElement)
remove path
GNEPathManager(const GNEPathManager &)=delete
Invalidated copy constructor.
std::map< const GNELane *, std::set< Segment * > > myLaneSegments
map with lane segments
void clearSegmentFromJunctionAndLaneSegments(Segment *segment)
clear segments from junction and lane Segments (called by Segment destructor)
PathDraw * myPathDraw
PathDraw instance.
void calculatePathEdges(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > edges)
calculate path edges (using dijkstra, require path calculator updated)
void drawJunctionPathElements(const GUIVisualizationSettings &s, const GNEJunction *junction)
draw junction path elements
void forceDrawPath(const GUIVisualizationSettings &s, const PathElement *pathElement) const
force draw path (used carefully, ONLY when we're inspecting a path element, due slowdowns)
~GNEPathManager()
destructor
const GNELane * getFirstLane(const PathElement *pathElement) const
get first lane associated with path element
void calculatePathLanes(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNELane * > lanes)
calculate path lanes (using dijkstra, require path calculator updated)
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
void calculateConsecutivePathLanes(PathElement *pathElement, const std::vector< GNELane * > lanes)
calculate consecutive path lanes
Stores the information about how to visualize structures.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37