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 
25 #include <netbuild/NBNode.h>
26 
27 #include "GNENetworkElement.h"
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class GNENet;
33 class GNEEdge;
34 class GNECrossing;
36 class GNEConnection;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
49 
51  friend class GNEChange_TLS;
52  friend class GNEChange_Crossing;
53 
54 public:
60  GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
61 
63  ~GNEJunction();
64 
68  const PositionVector& getJunctionShape() const;
69 
71  void updateGeometry();
72 
74  // @note: using an extra function because updateGeometry overrides an abstract virtual function
75  void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
76 
80 
85 
87  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
89 
92 
100 
102  double getExaggeration(const GUIVisualizationSettings& s) const;
103 
105  void updateCenteringBoundary(const bool updateGrid);
106 
111  void drawGL(const GUIVisualizationSettings& s) const;
113 
115  NBNode* getNBNode() const;
116 
118  std::vector<GNEJunction*> getJunctionNeighbours() const;
119 
121  void addIncomingGNEEdge(GNEEdge* edge);
122 
124  void addOutgoingGNEEdge(GNEEdge* edge);
125 
127  void removeIncomingGNEEdge(GNEEdge* edge);
128 
130  void removeOutgoingGNEEdge(GNEEdge* edge);
131 
133  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
134 
136  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
137 
139  const std::vector<GNECrossing*>& getGNECrossings() const;
140 
142  std::vector<GNEConnection*> getGNEConnections() const;
143 
145  void markAsCreateEdgeSource();
146 
149 
151  void selectTLS(bool selected);
152 
155  /* @brief method for getting the Attribute of an XML key
156  * @param[in] key The attribute key
157  * @return string with the value associated to key
158  */
159  std::string getAttribute(SumoXMLAttr key) const;
160 
161  /* @brief method for setting the attribute and letting the object perform additional changes
162  * @param[in] key The attribute key
163  * @param[in] value The new value
164  * @param[in] undoList The undoList on which to register changes
165  */
166  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
167 
168  /* @brief method for checking if the key and their correspond attribute are valids
169  * @param[in] key The attribute key
170  * @param[in] value The value asociated to key key
171  * @return true if the value is valid, false in other case
172  */
173  bool isValid(SumoXMLAttr key, const std::string& value);
174 
175  /* @brief method for check if the value for certain attribute is set
176  * @param[in] key The attribute key
177  */
178  bool isAttributeEnabled(SumoXMLAttr key) const;
179 
180  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
181  * @param[in] key The attribute key
182  */
183  bool isAttributeComputed(SumoXMLAttr key) const;
185 
187  const std::map<std::string, std::string>& getACParametersMap() const;
188 
190  void setResponsible(bool newVal);
191 
192  /* @brief notify junction that one of its edges has changed its shape, and
193  * therefore the junction shape is no longer valid */
194  void invalidateShape();
195 
196  /* @brief update validity of this junctions logic
197  * if the logic is invalidated, existing connections are removed via undo-list
198  * so that the previous state can be restored
199  * also calls invalidateTLS
200  * @param[in] valid The new validity of the junction
201  * @note: this should always be called with an active command group
202  */
203  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
204 
206  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
207 
209  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
210 
212  void markAsModified(GNEUndoList* undoList);
213 
214  /* @brief invalidates loaded or edited TLS
215  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
216  * but all other information intact will be computed instead of guessing a new tlDef
217  * @note: this should always be called with an active command group
218  */
219  void invalidateTLS(GNEUndoList* undoList,
220  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
221  const NBConnection& addedConnection = NBConnection::InvalidConnection);
222 
224  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
225 
227  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
228 
230  bool isLogicValid();
231 
233  GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
234 
236  void markConnectionsDeprecated(bool includingNeighbours);
237 
238 protected:
241 
243  std::vector<GNEEdge*> myGNEIncomingEdges;
244 
246  std::vector<GNEEdge*> myGNEOutgoingEdges;
247 
249  std::vector<GNECrossing*> myGNECrossings;
250 
253 
257 
259  std::string myLogicStatus;
260 
263 
266 
269 
272 
273 private:
275  void drawTLSIcon(const GUIVisualizationSettings& s) const;
276 
278  void drawJunctionChildren(const GUIVisualizationSettings& s) const;
279 
281  void setAttribute(SumoXMLAttr key, const std::string& value);
282 
284  void setMoveShape(const GNEMoveResult& moveResult);
285 
287  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
288 
293  void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
294 
296  RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
297 
299  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
300 
303 
305  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
306 
309 
311  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
312 
314  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
315 
317  void mirrorXLeftHand();
318 
320  GNEJunction(const GNEJunction&) = delete;
321 
323  GNEJunction& operator=(const GNEJunction&) = delete;
324 };
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 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 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:262
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
std::string getAttribute(SumoXMLAttr key) const
void setResponsible(bool newVal)
set responsibility for deleting internal structures
bool myColorForMissingConnections
whether this junction probably should have some connections but doesn't
Definition: GNEJunction.h:271
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:50
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
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 asociated with this GLObject
void invalidateShape()
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:95
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:246
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
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:249
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
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:243
const PositionVector & getJunctionShape() const
Definition: GNEJunction.cpp:89
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
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:252
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
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:268
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:265
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:259
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:240
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
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:66
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
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:256
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
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.