Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
26#include <netbuild/NBNode.h>
27
28#include "GNENetworkElement.h"
29
30// ===========================================================================
31// class declarations
32// ===========================================================================
33class GNEConnection;
34class GNECrossing;
35class GNEEdge;
36class GNEInternalLane;
37class GNENet;
38class GNEWalkingArea;
40
41// ===========================================================================
42// class definitions
43// ===========================================================================
52
54 friend class GNEChange_TLS;
55 friend class GNEChange_Crossing;
56
57public:
63 GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
64
67
71 const PositionVector& getJunctionShape() const;
72
74 void updateGeometry();
75
77 // @note: using an extra function because updateGeometry overrides an abstract virtual function
78 void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
79
82
84
87
89 bool checkDrawFromContour() const;
90
92 bool checkDrawToContour() const;
93
95 bool checkDrawRelatedContour() const;
96
98 bool checkDrawOverContour() const;
99
101 bool checkDrawDeleteContour() const;
102
104 bool checkDrawDeleteContourSmall() const;
105
107 bool checkDrawSelectContour() const;
108
110 bool checkDrawMoveContour() const;
111
113
118
120 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
121
123
126
134
136 double getExaggeration(const GUIVisualizationSettings& s) const;
137
140
142 void updateCenteringBoundary(const bool updateGrid);
143
148 void drawGL(const GUIVisualizationSettings& s) const;
149
151 void deleteGLObject();
152
154 void updateGLObject();
156
158 NBNode* getNBNode() const;
159
161 std::vector<GNEJunction*> getJunctionNeighbours() const;
162
164 void addIncomingGNEEdge(GNEEdge* edge);
165
167 void addOutgoingGNEEdge(GNEEdge* edge);
168
170 void removeIncomingGNEEdge(GNEEdge* edge);
171
173 void removeOutgoingGNEEdge(GNEEdge* edge);
174
176 const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
177
179 const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
180
182 const std::vector<GNECrossing*>& getGNECrossings() const;
183
185 const std::vector<GNEWalkingArea*>& getGNEWalkingAreas() const;
186
188 std::vector<GNEConnection*> getGNEConnections() const;
189
192
195
197 void selectTLS(bool selected);
198
201 /* @brief method for getting the Attribute of an XML key
202 * @param[in] key The attribute key
203 * @return string with the value associated to key
204 */
205 std::string getAttribute(SumoXMLAttr key) const;
206
207 /* @brief method for getting the Attribute of an XML key in Position format
208 * @param[in] key The attribute key
209 * @return position with the value associated to key
210 */
212
213 /* @brief method for setting the attribute and letting the object perform additional changes
214 * @param[in] key The attribute key
215 * @param[in] value The new value
216 * @param[in] undoList The undoList on which to register changes
217 */
218 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
219
220 /* @brief method for checking if the key and their correspond attribute are valids
221 * @param[in] key The attribute key
222 * @param[in] value The value associated to key key
223 * @return true if the value is valid, false in other case
224 */
225 bool isValid(SumoXMLAttr key, const std::string& value);
226
227 /* @brief method for check if the value for certain attribute is set
228 * @param[in] key The attribute key
229 */
230 bool isAttributeEnabled(SumoXMLAttr key) const;
231
232 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
233 * @param[in] key The attribute key
234 */
235 bool isAttributeComputed(SumoXMLAttr key) const;
237
240
242 void setResponsible(bool newVal);
243
244 /* @brief notify junction that one of its edges has changed its shape, and
245 * therefore the junction shape is no longer valid */
246 void invalidateShape();
247
248 /* @brief update validity of this junctions logic
249 * if the logic is invalidated, existing connections are removed via undo-list
250 * so that the previous state can be restored
251 * also calls invalidateTLS
252 * @param[in] valid The new validity of the junction
253 * @note: this should always be called with an active command group
254 */
255 void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
256
258 void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
259
261 void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
262
264 void markAsModified(GNEUndoList* undoList);
265
266 /* @brief invalidates loaded or edited TLS
267 * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
268 * but all other information intact will be computed instead of guessing a new tlDef
269 * @note: this should always be called with an active command group
270 */
271 void invalidateTLS(GNEUndoList* undoList,
272 const NBConnection& deletedConnection = NBConnection::InvalidConnection,
273 const NBConnection& addedConnection = NBConnection::InvalidConnection);
274
276 void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
277
279 void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
280
282 bool isLogicValid();
283
285 GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
286
288 GNEWalkingArea* retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist = true);
289
291 void markConnectionsDeprecated(bool includingNeighbours);
292
294 void setJunctionType(const std::string& value, GNEUndoList* undoList);
295
297 void clearWalkingAreas();
298
301
303 void addInternalLane(const GNEInternalLane* internalLane);
304
306 void removeInternalLane(const GNEInternalLane* internalLane);
307
308protected:
311
314
317
320
322 std::vector<GNEEdge*> myGNEIncomingEdges;
323
325 std::vector<GNEEdge*> myGNEOutgoingEdges;
326
328 std::vector<GNECrossing*> myGNECrossings;
329
331 std::vector<GNEWalkingArea*> myGNEWalkingAreas;
332
334 std::vector<const GNEInternalLane*> myInternalLanes;
335
339
341 std::string myLogicStatus;
342
344 bool myAmResponsible = false;
345
348
350 bool myAmTLSSelected = false;
351
354
357
359 mutable double myExaggeration = 1;
360
361private:
363 bool drawAsBubble(const GUIVisualizationSettings& s, const double junctionShapeArea) const;
364
367 const double exaggeration) const;
368
371 const double exaggeration) const;
372
375
377 void drawTLSIcon(const GUIVisualizationSettings& s) const;
378
380 void drawElevation(const GUIVisualizationSettings& s) const;
381
383 void drawJunctionName(const GUIVisualizationSettings& s) const;
384
387
390 const double exaggeration, const bool drawBubble) const;
391
393 void setAttribute(SumoXMLAttr key, const std::string& value);
394
396 void setMoveShape(const GNEMoveResult& moveResult);
397
399 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
400
405 void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
406
408 RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
409
411 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
412
415
417 void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
418
421
423 void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
424
426 void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
427
429 void mirrorXLeftHand();
430
432 void buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret, const int numSelectedJunctions);
433
435 GNEJunction(const GNEJunction&) = delete;
436
439};
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)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition GNECrossing.h:44
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
void updateGLObject()
update GLObject (geometry, ID, etc.)
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
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
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
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.
std::string getAttribute(SumoXMLAttr key) const
void setResponsible(bool newVal)
set responsibility for deleting internal structures
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
void deleteGLObject()
delete element
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
void moveJunctionGeometry(const Position &pos, const bool updateEdgeBoundaries)
reposition the node at pos without updating GRID and informs the edges
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void invalidateShape()
GNEContour myCircleContour
variable used for draw circle contours
void updateGeometry()
update pre-computed geometry information (including crossings)
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
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
bool checkDrawMoveContour() const
check if draw move contour (red)
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
PositionVector getAttributePositionVector(SumoXMLAttr key) const
void clearWalkingAreas()
clear walking areas
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
bool checkDrawSelectContour() const
check if draw select contour (blue)
GNEWalkingArea * retrieveGNEWalkingArea(const std::string &NBNodeWalkingAreaID, bool createIfNoExist=true)
get GNEWalkingArea if exist, and if not create it if create is enabled
GNEMoveOperation * getMoveOperation()
get move operation
bool checkDrawFromContour() const
check if draw from contour (green)
bool checkDrawOverContour() const
check if draw over contour (orange)
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 addInternalLane(const GNEInternalLane *internalLane)
add internal lane
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
const PositionVector & getJunctionShape() const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void drawJunctionName(const GUIVisualizationSettings &s) const
draw junction name
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
bool checkDrawToContour() const
check if draw from contour (magenta)
const Parameterised::Map & getACParametersMap() const
get parameters map
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show 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
bool isAttributeComputed(SumoXMLAttr key) const
void removeInternalLane(const GNEInternalLane *internalLane)
remove internal lane
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
bool isValid(SumoXMLAttr key, const std::string &value)
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)
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.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
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
void setJunctionType(const std::string &value, GNEUndoList *undoList)
set junction Type (using undo/redo)
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
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
bool isAttributeEnabled(SumoXMLAttr key) const
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
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.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.