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-2024 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 GNENet;
34class GNEEdge;
35class GNECrossing;
37class GNEConnection;
38class GNEInternalLane;
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
51
53 friend class GNEChange_TLS;
54 friend class GNEChange_Crossing;
55
56public:
62 GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
63
66
70 const PositionVector& getJunctionShape() const;
71
73 void updateGeometry();
74
76 // @note: using an extra function because updateGeometry overrides an abstract virtual function
77 void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
78
81
83
86
88 bool checkDrawFromContour() const;
89
91 bool checkDrawToContour() const;
92
94 bool checkDrawRelatedContour() const;
95
97 bool checkDrawOverContour() const;
98
100 bool checkDrawDeleteContour() const;
101
103 bool checkDrawSelectContour() const;
104
106 bool checkDrawMoveContour() const;
107
109
114
116 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
117
119
122
130
132 double getExaggeration(const GUIVisualizationSettings& s) const;
133
136
138 void updateCenteringBoundary(const bool updateGrid);
139
144 void drawGL(const GUIVisualizationSettings& s) const;
145
147 void deleteGLObject();
148
150 void updateGLObject();
152
154 NBNode* getNBNode() const;
155
157 std::vector<GNEJunction*> getJunctionNeighbours() const;
158
160 void addIncomingGNEEdge(GNEEdge* edge);
161
163 void addOutgoingGNEEdge(GNEEdge* edge);
164
166 void removeIncomingGNEEdge(GNEEdge* edge);
167
169 void removeOutgoingGNEEdge(GNEEdge* edge);
170
172 const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
173
175 const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
176
178 const std::vector<GNECrossing*>& getGNECrossings() const;
179
181 const std::vector<GNEWalkingArea*>& getGNEWalkingAreas() const;
182
184 std::vector<GNEConnection*> getGNEConnections() const;
185
188
191
193 void selectTLS(bool selected);
194
197 /* @brief method for getting the Attribute of an XML key
198 * @param[in] key The attribute key
199 * @return string with the value associated to key
200 */
201 std::string getAttribute(SumoXMLAttr key) const;
202
203 /* @brief method for getting the Attribute of an XML key in Position format
204 * @param[in] key The attribute key
205 * @return position with the value associated to key
206 */
208
209 /* @brief method for setting the attribute and letting the object perform additional changes
210 * @param[in] key The attribute key
211 * @param[in] value The new value
212 * @param[in] undoList The undoList on which to register changes
213 */
214 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
215
216 /* @brief method for checking if the key and their correspond attribute are valids
217 * @param[in] key The attribute key
218 * @param[in] value The value associated to key key
219 * @return true if the value is valid, false in other case
220 */
221 bool isValid(SumoXMLAttr key, const std::string& value);
222
223 /* @brief method for check if the value for certain attribute is set
224 * @param[in] key The attribute key
225 */
226 bool isAttributeEnabled(SumoXMLAttr key) const;
227
228 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
229 * @param[in] key The attribute key
230 */
231 bool isAttributeComputed(SumoXMLAttr key) const;
233
236
238 void setResponsible(bool newVal);
239
240 /* @brief notify junction that one of its edges has changed its shape, and
241 * therefore the junction shape is no longer valid */
242 void invalidateShape();
243
244 /* @brief update validity of this junctions logic
245 * if the logic is invalidated, existing connections are removed via undo-list
246 * so that the previous state can be restored
247 * also calls invalidateTLS
248 * @param[in] valid The new validity of the junction
249 * @note: this should always be called with an active command group
250 */
251 void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
252
254 void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
255
257 void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
258
260 void markAsModified(GNEUndoList* undoList);
261
262 /* @brief invalidates loaded or edited TLS
263 * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
264 * but all other information intact will be computed instead of guessing a new tlDef
265 * @note: this should always be called with an active command group
266 */
267 void invalidateTLS(GNEUndoList* undoList,
268 const NBConnection& deletedConnection = NBConnection::InvalidConnection,
269 const NBConnection& addedConnection = NBConnection::InvalidConnection);
270
272 void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
273
275 void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
276
278 bool isLogicValid();
279
281 GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
282
284 GNEWalkingArea* retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist = true);
285
287 void markConnectionsDeprecated(bool includingNeighbours);
288
290 void setJunctionType(const std::string& value, GNEUndoList* undoList);
291
293 void clearWalkingAreas();
294
297
299 void addInternalLane(const GNEInternalLane* internalLane);
300
302 void removeInternalLane(const GNEInternalLane* internalLane);
303
304protected:
307
310
313
316
318 std::vector<GNEEdge*> myGNEIncomingEdges;
319
321 std::vector<GNEEdge*> myGNEOutgoingEdges;
322
324 std::vector<GNECrossing*> myGNECrossings;
325
327 std::vector<GNEWalkingArea*> myGNEWalkingAreas;
328
330 std::vector<const GNEInternalLane*> myInternalLanes;
331
335
337 std::string myLogicStatus;
338
340 bool myAmResponsible = false;
341
344
346 bool myAmTLSSelected = false;
347
350
353
355 mutable double myExaggeration = 1;
356
357private:
359 bool drawAsBubble(const GUIVisualizationSettings& s, const double junctionShapeArea) const;
360
363 const double exaggeration) const;
364
367 const double exaggeration) const;
368
371
374
376 void drawJunctionName(const GUIVisualizationSettings& s) const;
377
380
383 const double exaggeration, const bool drawBubble) const;
384
386 void setAttribute(SumoXMLAttr key, const std::string& value);
387
389 void setMoveShape(const GNEMoveResult& moveResult);
390
392 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
393
398 void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
399
401 RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
402
404 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
405
408
410 void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
411
414
416 void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
417
419 void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
420
422 void mirrorXLeftHand();
423
425 void buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret, const int numSelectedJunctions);
426
428 GNEJunction(const GNEJunction&) = delete;
429
432};
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
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)
void drawTLSIcon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d) const
draw TLS icon
GNEJunction(const GNEJunction &)=delete
Invalidated copy constructor.
bool isLogicValid()
whether this junction has a valid logic
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.
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
void drawElevation(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d) const
draw elevation
~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.