Eclipse SUMO - Simulation of Urban MObility
GNEJunction.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-2022 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;
38
39// ===========================================================================
40// class definitions
41// ===========================================================================
50
52 friend class GNEChange_TLS;
53 friend class GNEChange_Crossing;
54
55public:
61 GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
62
65
69 const PositionVector& getJunctionShape() const;
70
72 void updateGeometry();
73
75 // @note: using an extra function because updateGeometry overrides an abstract virtual function
76 void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
77
81
86
88 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
90
93
101
103 double getExaggeration(const GUIVisualizationSettings& s) const;
104
106 void updateCenteringBoundary(const bool updateGrid);
107
112 void drawGL(const GUIVisualizationSettings& s) const;
113
115 void deleteGLObject();
116
118 void updateGLObject();
120
122 NBNode* getNBNode() const;
123
125 std::vector<GNEJunction*> getJunctionNeighbours() const;
126
128 void addIncomingGNEEdge(GNEEdge* edge);
129
131 void addOutgoingGNEEdge(GNEEdge* edge);
132
134 void removeIncomingGNEEdge(GNEEdge* edge);
135
137 void removeOutgoingGNEEdge(GNEEdge* edge);
138
140 const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
141
143 const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
144
146 const std::vector<GNECrossing*>& getGNECrossings() const;
147
149 const std::vector<GNEWalkingArea*>& getGNEWalkingAreas() const;
150
152 std::vector<GNEConnection*> getGNEConnections() const;
153
156
159
161 void selectTLS(bool selected);
162
165 /* @brief method for getting the Attribute of an XML key
166 * @param[in] key The attribute key
167 * @return string with the value associated to key
168 */
169 std::string getAttribute(SumoXMLAttr key) const;
170
171 /* @brief method for setting the attribute and letting the object perform additional changes
172 * @param[in] key The attribute key
173 * @param[in] value The new value
174 * @param[in] undoList The undoList on which to register changes
175 */
176 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
177
178 /* @brief method for checking if the key and their correspond attribute are valids
179 * @param[in] key The attribute key
180 * @param[in] value The value associated to key key
181 * @return true if the value is valid, false in other case
182 */
183 bool isValid(SumoXMLAttr key, const std::string& value);
184
185 /* @brief method for check if the value for certain attribute is set
186 * @param[in] key The attribute key
187 */
188 bool isAttributeEnabled(SumoXMLAttr key) const;
189
190 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
191 * @param[in] key The attribute key
192 */
193 bool isAttributeComputed(SumoXMLAttr key) const;
195
198
200 void setResponsible(bool newVal);
201
202 /* @brief notify junction that one of its edges has changed its shape, and
203 * therefore the junction shape is no longer valid */
204 void invalidateShape();
205
206 /* @brief update validity of this junctions logic
207 * if the logic is invalidated, existing connections are removed via undo-list
208 * so that the previous state can be restored
209 * also calls invalidateTLS
210 * @param[in] valid The new validity of the junction
211 * @note: this should always be called with an active command group
212 */
213 void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
214
216 void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
217
219 void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
220
222 void markAsModified(GNEUndoList* undoList);
223
224 /* @brief invalidates loaded or edited TLS
225 * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
226 * but all other information intact will be computed instead of guessing a new tlDef
227 * @note: this should always be called with an active command group
228 */
229 void invalidateTLS(GNEUndoList* undoList,
230 const NBConnection& deletedConnection = NBConnection::InvalidConnection,
231 const NBConnection& addedConnection = NBConnection::InvalidConnection);
232
234 void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
235
237 void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
238
240 bool isLogicValid();
241
243 GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
244
246 GNEWalkingArea* retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist = true);
247
249 void markConnectionsDeprecated(bool includingNeighbours);
250
252 void setJunctionType(const std::string& value, GNEUndoList* undoList);
253
255 double getMaxDrawingSize() const;
256
258 void clearWalkingAreas();
259
262
263protected:
266
268 std::vector<GNEEdge*> myGNEIncomingEdges;
269
271 std::vector<GNEEdge*> myGNEOutgoingEdges;
272
274 std::vector<GNECrossing*> myGNECrossings;
275
277 std::vector<GNEWalkingArea*> myGNEWalkingAreas;
278
281
285
287 std::string myLogicStatus;
288
291
294
297
300
303
305 mutable double myExaggeration;
306
307private:
309 void drawTLSIcon(const GUIVisualizationSettings& s) const;
310
313
315 void drawDottedContours(const GUIVisualizationSettings& s, const bool drawShape, const bool drawBubble, const double junctionExaggeration, const double bubbleRadius) const;
316
318 void setAttribute(SumoXMLAttr key, const std::string& value);
319
321 void setMoveShape(const GNEMoveResult& moveResult);
322
324 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
325
330 void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
331
333 RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
334
336 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
337
340
342 void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
343
346
348 void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
349
351 void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
352
354 void mirrorXLeftHand();
355
357 void buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret, const int numSelectedJunctions);
358
360 GNEJunction(const GNEJunction&) = delete;
361
364};
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
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:42
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
void drawDottedContours(const GUIVisualizationSettings &s, const bool drawShape, const bool drawBubble, const double junctionExaggeration, const double bubbleRadius) const
draw dotted contours
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
Definition: GNEJunction.h:290
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.
Definition: GNEJunction.h:302
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
Definition: GNEJunction.h:299
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:57
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()
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
Definition: GNEJunction.h:271
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionChildren(const GUIVisualizationSettings &s) const
draw junction childs
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
double getMaxDrawingSize() const
get the maximum size (in either x-, or y-dimension) for determining whether to draw or not
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
Definition: GNEJunction.h:274
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
GNEMoveOperation * getMoveOperation()
get move operation
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
Definition: GNEJunction.h:268
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
const PositionVector & getJunctionShape() const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
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.
double myMaxDrawingSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not.
Definition: GNEJunction.h:280
Position getPositionInView() const
Returns position of hierarchical element in view.
bool isAttributeComputed(SumoXMLAttr key) const
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:296
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
Definition: GNEJunction.h:293
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:287
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
NBNode * getNBNode() const
Return net build node.
NBNode * myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:265
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
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)
double myExaggeration
exaggeration used in tesselation
Definition: GNEJunction.h:305
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:75
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
std::vector< GNEWalkingArea * > myGNEWalkingAreas
the built walkingArea objects
Definition: GNEJunction.h:277
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
Definition: GNEJunction.h:284
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
Definition: NBConnection.h:124
A definition of a pedestrian crossing.
Definition: NBNode.h:129
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
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.