Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEJunction.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-2025 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// A class for visualizing and editing junctions in netedit (adapted from
19// GUIJunctionWrapper)
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <netbuild/NBNode.h>
28
29#include "GNENetworkElement.h"
30
31// ===========================================================================
32// class declarations
33// ===========================================================================
34
35class GNEConnection;
36class GNECrossing;
37class GNEEdge;
38class GNEInternalLane;
41class GNENet;
42class GNEWalkingArea;
44
45// ===========================================================================
46// class definitions
47// ===========================================================================
48
50
52 friend class GNEChange_TLS;
53 friend class GNEChange_Crossing;
55
56public:
62 GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
63
66
69
71 GNEMoveElement* getMoveElement() const override;
72
74 Parameterised* getParameters() override;
75
77 const Parameterised* getParameters() const override;
78
80
84 const PositionVector& getJunctionShape() const;
85
87 void updateGeometry() override;
88
90 // @note: using an extra function because updateGeometry overrides an abstract virtual function
91 void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
92
95
97
100
102 bool checkDrawFromContour() const override;
103
105 bool checkDrawToContour() const override;
106
108 bool checkDrawRelatedContour() const override;
109
111 bool checkDrawOverContour() const override;
112
114 bool checkDrawDeleteContour() const override;
115
117 bool checkDrawDeleteContourSmall() const override;
118
120 bool checkDrawSelectContour() const override;
121
123 bool checkDrawMoveContour() const override;
124
126
129
137
139 double getExaggeration(const GUIVisualizationSettings& s) const override;
140
142 Boundary getCenteringBoundary() const override;
143
145 void updateCenteringBoundary(const bool updateGrid);
146
151 void drawGL(const GUIVisualizationSettings& s) const override;
152
154 void deleteGLObject() override;
155
157 void updateGLObject() override;
159
161 NBNode* getNBNode() const;
162
164 std::vector<GNEJunction*> getJunctionNeighbours() const;
165
167 void addIncomingGNEEdge(GNEEdge* edge);
168
170 void addOutgoingGNEEdge(GNEEdge* edge);
171
173 void removeIncomingGNEEdge(GNEEdge* edge);
174
176 void removeOutgoingGNEEdge(GNEEdge* edge);
177
179 const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
180
182 const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
183
185 const std::vector<GNECrossing*>& getGNECrossings() const;
186
188 const std::vector<GNEWalkingArea*>& getGNEWalkingAreas() const;
189
191 std::vector<GNEConnection*> getGNEConnections() const;
192
195
198
200 void selectTLS(bool selected);
201
204 /* @brief method for getting the Attribute of an XML key
205 * @param[in] key The attribute key
206 * @return string with the value associated to key
207 */
208 std::string getAttribute(SumoXMLAttr key) const override;
209
210 /* @brief method for getting the Attribute of an XML key in double format
211 * @param[in] key The attribute key
212 * @return double with the value associated to key
213 */
214 double getAttributeDouble(SumoXMLAttr key) const override;
215
216 /* @brief method for getting the Attribute of an XML key in position format
217 * @param[in] key The attribute key
218 * @return position with the value associated to key
219 */
220 Position getAttributePosition(SumoXMLAttr key) const override;
221
222 /* @brief method for getting the Attribute of an XML key in Position format
223 * @param[in] key The attribute key
224 * @return position with the value associated to key
225 */
227
228 /* @brief method for setting the attribute and letting the object perform additional changes
229 * @param[in] key The attribute key
230 * @param[in] value The new value
231 * @param[in] undoList The undoList on which to register changes
232 */
233 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
234
235 /* @brief method for checking if the key and their correspond attribute are valids
236 * @param[in] key The attribute key
237 * @param[in] value The value associated to key key
238 * @return true if the value is valid, false in other case
239 */
240 bool isValid(SumoXMLAttr key, const std::string& value) override;
241
242 /* @brief method for check if the value for certain attribute is set
243 * @param[in] key The attribute key
244 */
245 bool isAttributeEnabled(SumoXMLAttr key) const override;
246
247 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
248 * @param[in] key The attribute key
249 */
250 bool isAttributeComputed(SumoXMLAttr key) const override;
251
253
255 void setResponsible(bool newVal);
256
257 /* @brief notify junction that one of its edges has changed its shape, and
258 * therefore the junction shape is no longer valid */
259 void invalidateShape();
260
261 /* @brief update validity of this junctions logic
262 * if the logic is invalidated, existing connections are removed via undo-list
263 * so that the previous state can be restored
264 * also calls invalidateTLS
265 * @param[in] valid The new validity of the junction
266 * @note: this should always be called with an active command group
267 */
268 void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
269
271 void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
272
274 void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
275
277 void markAsModified(GNEUndoList* undoList);
278
279 /* @brief invalidates loaded or edited TLS
280 * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
281 * but all other information intact will be computed instead of guessing a new tlDef
282 * @note: this should always be called with an active command group
283 */
284 void invalidateTLS(GNEUndoList* undoList,
285 const NBConnection& deletedConnection = NBConnection::InvalidConnection,
286 const NBConnection& addedConnection = NBConnection::InvalidConnection);
287
289 void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
290
292 void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
293
295 bool isLogicValid();
296
298 GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
299
301 GNEWalkingArea* retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist = true);
302
304 void markConnectionsDeprecated(bool includingNeighbours);
305
307 void setJunctionType(const std::string& value, GNEUndoList* undoList);
308
310 void clearWalkingAreas();
311
314
316 void addInternalLane(const GNEInternalLane* internalLane);
317
319 void removeInternalLane(const GNEInternalLane* internalLane);
320
321protected:
324
327
330
333
336
338 std::vector<GNEEdge*> myGNEIncomingEdges;
339
341 std::vector<GNEEdge*> myGNEOutgoingEdges;
342
344 std::vector<GNECrossing*> myGNECrossings;
345
347 std::vector<GNEWalkingArea*> myGNEWalkingAreas;
348
350 std::vector<const GNEInternalLane*> myInternalLanes;
351
355
357 std::string myLogicStatus;
358
360 bool myAmResponsible = false;
361
364
366 bool myAmTLSSelected = false;
367
370
373
375 mutable double myExaggeration = 1;
376
377private:
379 bool drawAsBubble(const GUIVisualizationSettings& s, const double junctionShapeArea) const;
380
383 const double exaggeration) const;
384
387 const double exaggeration) const;
388
391
393 void drawTLSIcon(const GUIVisualizationSettings& s) const;
394
396 void drawElevation(const GUIVisualizationSettings& s) const;
397
399 void drawJunctionName(const GUIVisualizationSettings& s) const;
400
403
406 const double exaggeration, const bool drawBubble) const;
407
409 void setAttribute(SumoXMLAttr key, const std::string& value) override;
410
415 void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
416
418 RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
419
421 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
422
425
427 void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
428
431
433 void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
434
436 void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
437
439 void mirrorXLeftHand();
440
442 void buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret, const int numSelectedJunctions);
443
445 GNEJunction(const GNEJunction&) = delete;
446
449};
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
bool checkDrawFromContour() const override
check if draw from contour (green)
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
bool isAttributeEnabled(SumoXMLAttr key) const override
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
void rebuildGNEWalkingAreas()
rebuilds WalkingAreas objects for this junction
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
bool myAmResponsible
whether we are responsible for deleting myNBNode
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
TesselatedPolygon myTesselation
An object that stores the shape and its tesselation.
const std::vector< GNEWalkingArea * > & getGNEWalkingAreas() const
Returns GNEWalkingAreas.
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Position getAttributePosition(SumoXMLAttr key) const override
bool myColorForMissingConnections
whether this junction probably should have some connections but doesn't
std::vector< const GNEInternalLane * > myInternalLanes
internal lanes related placed in this junction
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
std::string getAttribute(SumoXMLAttr key) const override
void moveJunctionGeometry(const Position &pos, const bool updateEdgeBoundaries)
reposition the node at pos without updating GRID and informs the edges
bool checkDrawSelectContour() const override
check if draw select contour (blue)
void invalidateShape()
GNEContour myCircleContour
variable used for draw circle contours
bool isAttributeComputed(SumoXMLAttr key) const override
GNEJunction(const GNEJunction &)=delete
Invalidated copy constructor.
bool isLogicValid()
whether this junction has a valid logic
void drawTLSIcon(const GUIVisualizationSettings &s) const
draw TLS icon
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the (child) outgoings GNEEdges vinculated with this junction
void updateGeometry() override
update pre-computed geometry information (including crossings)
bool checkDrawOverContour() const override
check if draw over contour (orange)
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
determines color value
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
bool checkDrawMoveContour() const override
check if draw move contour (red)
GNEMoveElementJunction * myMoveElementJunction
move element junction
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void clearWalkingAreas()
clear walking areas
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
GNEWalkingArea * retrieveGNEWalkingArea(const std::string &NBNodeWalkingAreaID, bool createIfNoExist=true)
get GNEWalkingArea if exist, and if not create it if create is enabled
void updateGLObject() override
update GLObject (geometry, ID, etc.)
GNECrossing * retrieveGNECrossing(NBNode::Crossing *NBNodeCrossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the (child) incomings GNEEdges vinculated with this junction
Boundary myJunctionBoundary
edge boundary
void calculateJunctioncontour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const bool drawBubble) const
calculate contour
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void addInternalLane(const GNEInternalLane *internalLane)
add internal lane
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
const PositionVector & getJunctionShape() const
void drawJunctionName(const GUIVisualizationSettings &s) const
draw junction name
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Position getPositionInView() const
Returns position of hierarchical element in view.
void drawJunctionAsBubble(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw junction as bubble
void removeInternalLane(const GNEInternalLane *internalLane)
remove internal lane
bool checkDrawToContour() const override
check if draw from contour (magenta)
bool isValid(SumoXMLAttr key, const std::string &value) override
bool myAmTLSSelected
whether this junction is selected in tls-mode
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
bool myHasValidLogic
whether this junctions logic is valid
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
void drawJunctionChildren(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d) const
draw junction childs
bool drawAsBubble(const GUIVisualizationSettings &s, const double junctionShapeArea) const
check if draw junction as bubble
NBNode * getNBNode() const
Return net build node.
void drawJunctionCenter(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d) const
draw junction center (only in move mode)
void drawElevation(const GUIVisualizationSettings &s) const
draw elevation
NBNode * myNBNode
A reference to the represented junction.
Parameterised * getParameters() override
get parameters associated with this junction
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this junction
int * myDrawingToggle
drawing toggle (used to avoid double draws)
void checkMissingConnections()
compute whether this junction probably should have some connections but doesn't
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
double getAttributeDouble(SumoXMLAttr key) const override
void setJunctionType(const std::string &value, GNEUndoList *undoList)
set junction Type (using undo/redo)
void drawJunctionAsShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw junction as bubble
double myExaggeration
exaggeration used in tesselation
~GNEJunction()
Destructor.
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
std::vector< GNEWalkingArea * > myGNEWalkingAreas
the built walkingArea objects
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
void buildTLSOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret, const int numSelectedJunctions)
build TLS operations contextual menu
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
void deleteGLObject() override
delete element
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
The popup menu of a globject.
Stores the information about how to visualize structures.
static const NBConnection InvalidConnection
A definition of a pedestrian crossing.
Definition NBNode.h:135
Represents a single node (junction) during network building.
Definition NBNode.h:66
The base class for traffic light logic definitions.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.