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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A class for visualizing and editing junctions in netedit (adapted from
16 // GUIJunctionWrapper)
17 /****************************************************************************/
18 #ifndef GNEJunction_h
19 #define GNEJunction_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #include "GNENetElement.h"
27 #include <netbuild/NBNode.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 // ===========================================================================
48 class GNEJunction : public GNENetElement {
49 
51  friend class GNEChange_TLS;
52  friend class GNEChange_Crossing;
53 
54 public:
56  static const double BUBBLE_RADIUS;
57 
63  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false);
64 
66  ~GNEJunction();
67 
69  std::string generateChildID(SumoXMLTag childTag);
70 
74  void updateGeometry();
75 
77  // @note: using an extra function because updateGeometry overrides an abstract virtual function
78  void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
79 
83 
86 
94 
101 
106  void drawGL(const GUIVisualizationSettings& s) const;
108 
110  NBNode* getNBNode() const;
111 
113  std::vector<GNEJunction*> getJunctionNeighbours() const;
114 
116  void addIncomingGNEEdge(GNEEdge* edge);
117 
119  void addOutgoingGNEEdge(GNEEdge* edge);
120 
122  void removeIncomingGNEEdge(GNEEdge* edge);
123 
125  void removeOutgoingGNEEdge(GNEEdge* edge);
126 
128  const std::vector<GNEEdge*>& getGNEEdges() const;
129 
131  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
132 
134  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
135 
137  const std::vector<GNECrossing*>& getGNECrossings() const;
138 
140  std::vector<GNEConnection*> getGNEConnections() const;
141 
143  void markAsCreateEdgeSource();
144 
147 
149  void selectTLS(bool selected);
150 
153 
155  void startGeometryMoving(bool extendToNeighbors = true);
156 
158  void endGeometryMoving(bool extendToNeighbors = true);
159 
163  void moveGeometry(const Position& oldPos, const Position& offset);
164 
166  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
167 
169 
172  /* @brief method for getting the Attribute of an XML key
173  * @param[in] key The attribute key
174  * @return string with the value associated to key
175  */
176  std::string getAttribute(SumoXMLAttr key) const;
177 
178  /* @brief method for setting the attribute and letting the object perform additional changes
179  * @param[in] key The attribute key
180  * @param[in] value The new value
181  * @param[in] undoList The undoList on which to register changes
182  */
183  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
184 
185  /* @brief method for checking if the key and their correspond attribute are valids
186  * @param[in] key The attribute key
187  * @param[in] value The value asociated to key key
188  * @return true if the value is valid, false in other case
189  */
190  bool isValid(SumoXMLAttr key, const std::string& value);
192 
195 
197  std::string getGenericParametersStr() const;
198 
200  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
201 
203  void setGenericParametersStr(const std::string& value);
204 
206 
208  void setResponsible(bool newVal);
209 
210  /* @brief notify junction that one of its edges has changed its shape, and
211  * therefore the junction shape is no longer valid */
212  void invalidateShape();
213 
214  /* @brief update validity of this junctions logic
215  * if the logic is invalidated, existing connections are removed via undo-list
216  * so that the previous state can be restored
217  * also calls invalidateTLS
218  * @param[in] valid The new validity of the junction
219  * @note: this should always be called with an active command group
220  */
221  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
222 
224  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
225 
227  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
228 
230  void markAsModified(GNEUndoList* undoList);
231 
232  /* @brief invalidates loaded or edited TLS
233  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
234  * but all other information intact will be computed instead of guessing a new tlDef
235  * @note: this should always be called with an active command group
236  */
237  void invalidateTLS(GNEUndoList* undoList,
238  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
239  const NBConnection& addedConnection = NBConnection::InvalidConnection);
240 
242  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
243 
245  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
246 
248  bool isLogicValid();
249 
251  GNECrossing* retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist = true);
252 
254  void markConnectionsDeprecated(bool includingNeighbours);
255 
256 private:
259 
261  std::vector<GNEEdge*> myGNEEdges;
262 
264  std::vector<GNEEdge*> myGNEIncomingEdges;
265 
267  std::vector<GNEEdge*> myGNEOutgoingEdges;
268 
270  std::vector<GNECrossing*> myGNECrossings;
271 
273  double myMaxSize;
274 
278 
280  std::string myLogicStatus;
281 
284 
287 
290 
292  void setAttribute(SumoXMLAttr key, const std::string& value);
293 
298  void moveJunctionGeometry(const Position& pos);
299 
301  RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
302 
304  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
305 
307  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
308 
311 
313  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
314 
316  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
317 
319  void mirrorXLeftHand();
320 
322  GNEJunction(const GNEJunction&) = delete;
323 
325  GNEJunction& operator=(const GNEJunction&) = delete;
326 };
327 
328 
329 #endif
330 
331 /****************************************************************************/
GNEJunction::BUBBLE_RADIUS
static const double BUBBLE_RADIUS
constant values for drawing buubles
Definition: GNEJunction.h:56
NBConnection::InvalidConnection
const static NBConnection InvalidConnection
Definition: NBConnection.h:121
GNEJunction::getPositionInView
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEJunction.cpp:113
GNEJunction::markConnectionsDeprecated
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
Definition: GNEJunction.cpp:984
GNEJunction::unMarkAsCreateEdgeSource
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
Definition: GNEJunction.cpp:571
GNEJunction::isLogicValid
bool isLogicValid()
whether this junction has a valid logic
Definition: GNEJunction.cpp:955
GNEJunction::mirrorXLeftHand
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
Definition: GNEJunction.cpp:165
GNEJunction::getColorValue
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
Definition: GNEJunction.cpp:1380
GNEJunction::myNBNode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:258
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNEJunction::invalidateShape
void invalidateShape()
Definition: GNEJunction.cpp:705
GNEJunction::myAmTLSSelected
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:289
GNEJunction::commitGeometryMoving
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
Definition: GNEJunction.cpp:690
GNEJunction::removeEdgeFromCrossings
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
Definition: GNEJunction.cpp:929
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNEJunction::getJunctionNeighbours
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
Definition: GNEJunction.cpp:458
GNEJunction::myLogicStatus
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:280
GNEJunction::updateGeometryAfterNetbuild
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
Definition: GNEJunction.cpp:106
GNEJunction::getGNEOutgoingEdges
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:541
GNEJunction::getGNEConnections
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
Definition: GNEJunction.cpp:553
GNEJunction::retrieveGNECrossing
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
Definition: GNEJunction.cpp:961
GNEJunction::removeIncomingGNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
Definition: GNEJunction.cpp:501
GNEJunction::moveGeometry
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEJunction.cpp:668
GNEJunction::getGNECrossings
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
Definition: GNEJunction.cpp:547
GNEJunction::markAsModified
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
Definition: GNEJunction.cpp:869
GNEJunction::myHasValidLogic
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:286
GNEJunction::myGNEEdges
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:261
GNEJunction::setResponsible
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEJunction.cpp:1285
GNEJunction::myMaxSize
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not.
Definition: GNEJunction.h:273
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNEJunction::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEJunction.cpp:1260
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNEJunction::myGNEIncomingEdges
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:264
GNEJunction::startGeometryMoving
void startGeometryMoving(bool extendToNeighbors=true)
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEJunction.cpp:583
GNEJunction::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEJunction.cpp:101
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNEJunction::getNBNode
NBNode * getNBNode() const
Return net build node.
Definition: GNEJunction.cpp:452
GNEAttributeCarrier::FEATURE_GUESSED
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
Definition: GNEAttributeCarrier.h:587
RGBColor
Definition: RGBColor.h:40
GNECrossing
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:45
GNEJunction::invalidateTLS
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
Definition: GNEJunction.cpp:880
GNEJunction::markAsCreateEdgeSource
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
Definition: GNEJunction.cpp:565
GNEJunction::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEJunction.cpp:241
GNEJunction::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEJunction.cpp:998
GNEJunction::removeTrafficLight
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
Definition: GNEJunction.cpp:1498
GNEJunction::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEJunction.cpp:1048
GNEJunction::addIncomingGNEEdge
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
Definition: GNEJunction.cpp:472
GNENetElement.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEJunction::endGeometryMoving
void endGeometryMoving(bool extendToNeighbors=true)
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEJunction.cpp:622
GNEChange_TLS
Definition: GNEChange_TLS.h:43
GNENetElement
Definition: GNENetElement.h:42
GNEJunction::addOutgoingGNEEdge
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
Definition: GNEJunction.cpp:487
NBConnection
Definition: NBConnection.h:44
GNEJunction::myAmCreateEdgeSource
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:277
GNEJunction::rebuildGNECrossings
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
Definition: GNEJunction.cpp:119
GNEJunction::~GNEJunction
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:71
GNEJunction::removeConnectionsFrom
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
Definition: GNEJunction.cpp:746
GNEJunction::setLogicValid
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
Definition: GNEJunction.cpp:723
GNEJunction::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEJunction.cpp:177
GNEJunction::getGNEIncomingEdges
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:535
GNEJunction::addTrafficLight
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
Definition: GNEJunction.cpp:1490
GNEJunction::GNEJunction
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:60
GNEJunction::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEJunction.cpp:91
GUIMainWindow
Definition: GUIMainWindow.h:47
GNEChange_Crossing
Definition: GNEChange_Crossing.h:49
GNEJunction::moveJunctionGeometry
void moveJunctionGeometry(const Position &pos)
reposition the node at pos without updating GRID and informs the edges
Definition: GNEJunction.cpp:1436
GNEJunction::getGNEEdges
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
Definition: GNEJunction.cpp:529
GNEJunction::setColor
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
Definition: GNEJunction.cpp:1471
GNEJunction::myGNECrossings
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:270
GNEJunction::operator=
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
GNEConnection
Definition: GNEConnection.h:38
GNEJunction::selectTLS
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
Definition: GNEJunction.cpp:577
GNEJunction::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEJunction.cpp:1200
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:68
GNEUndoList
Definition: GNEUndoList.h:49
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNEJunction
Definition: GNEJunction.h:48
GNEJunction::removeConnectionsTo
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
Definition: GNEJunction.cpp:775
NBNode::Crossing
A definition of a pedestrian crossing.
Definition: NBNode.h:132
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNEJunction::removeTLSConnections
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
Definition: GNEJunction.cpp:804
NBNode.h
GNEJunction::replaceIncomingConnections
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
Definition: GNEJunction.cpp:834
GNEJunction::getGenericParameters
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEJunction.cpp:1249
GNEJunction::myGNEOutgoingEdges
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:267
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:68
GNEJunction::removeOutgoingGNEEdge
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
Definition: GNEJunction.cpp:515
GNEJunction::myAmResponsible
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:283
GNEJunction::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEJunction.cpp:1234
GNEJunction::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEJunction.cpp:261