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 /****************************************************************************/
14 // A class for visualizing and editing junctions in netedit (adapted from
15 // GUIJunctionWrapper)
16 /****************************************************************************/
17 #ifndef GNEJunction_h
18 #define GNEJunction_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 #include "GNENetElement.h"
26 #include <netbuild/NBNode.h>
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class GNENet;
32 class GNEEdge;
33 class GNECrossing;
35 class GNEConnection;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
47 class GNEJunction : public GNENetElement {
48 
50  friend class GNEChange_TLS;
51  friend class GNEChange_Crossing;
52 
53 public:
55  static const double BUBBLE_RADIUS;
56 
62  GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
63 
65  ~GNEJunction();
66 
68  std::string generateChildID(SumoXMLTag childTag);
69 
73  const PositionVector& getJunctionShape() const;
74 
76  void updateGeometry();
77 
79  // @note: using an extra function because updateGeometry overrides an abstract virtual function
80  void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
81 
85 
88 
96 
103 
108  void drawGL(const GUIVisualizationSettings& s) const;
110 
112  NBNode* getNBNode() const;
113 
115  std::vector<GNEJunction*> getJunctionNeighbours() const;
116 
118  void addIncomingGNEEdge(GNEEdge* edge);
119 
121  void addOutgoingGNEEdge(GNEEdge* edge);
122 
124  void removeIncomingGNEEdge(GNEEdge* edge);
125 
127  void removeOutgoingGNEEdge(GNEEdge* edge);
128 
130  const std::vector<GNEEdge*>& getGNEEdges() const;
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 
157  void startGeometryMoving(bool extendToNeighbors = true);
158 
160  void endGeometryMoving(bool extendToNeighbors = true);
161 
165  void moveGeometry(const Position& oldPos, const Position& offset);
166 
168  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
169 
171 
174  /* @brief method for getting the Attribute of an XML key
175  * @param[in] key The attribute key
176  * @return string with the value associated to key
177  */
178  std::string getAttribute(SumoXMLAttr key) const;
179 
180  /* @brief method for setting the attribute and letting the object perform additional changes
181  * @param[in] key The attribute key
182  * @param[in] value The new value
183  * @param[in] undoList The undoList on which to register changes
184  */
185  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
186 
187  /* @brief method for checking if the key and their correspond attribute are valids
188  * @param[in] key The attribute key
189  * @param[in] value The value asociated to key key
190  * @return true if the value is valid, false in other case
191  */
192  bool isValid(SumoXMLAttr key, const std::string& value);
193 
194  /* @brief method for check if the value for certain attribute is set
195  * @param[in] key The attribute key
196  */
197  bool isAttributeEnabled(SumoXMLAttr key) const;
199 
201  void setResponsible(bool newVal);
202 
203  /* @brief notify junction that one of its edges has changed its shape, and
204  * therefore the junction shape is no longer valid */
205  void invalidateShape();
206 
207  /* @brief update validity of this junctions logic
208  * if the logic is invalidated, existing connections are removed via undo-list
209  * so that the previous state can be restored
210  * also calls invalidateTLS
211  * @param[in] valid The new validity of the junction
212  * @note: this should always be called with an active command group
213  */
214  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
215 
217  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
218 
220  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
221 
223  void markAsModified(GNEUndoList* undoList);
224 
225  /* @brief invalidates loaded or edited TLS
226  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
227  * but all other information intact will be computed instead of guessing a new tlDef
228  * @note: this should always be called with an active command group
229  */
230  void invalidateTLS(GNEUndoList* undoList,
231  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
232  const NBConnection& addedConnection = NBConnection::InvalidConnection);
233 
235  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
236 
238  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
239 
241  bool isLogicValid();
242 
244  GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
245 
247  void markConnectionsDeprecated(bool includingNeighbours);
248 
249 private:
252 
254  std::vector<GNEEdge*> myGNEEdges;
255 
257  std::vector<GNEEdge*> myGNEIncomingEdges;
258 
260  std::vector<GNEEdge*> myGNEOutgoingEdges;
261 
263  std::vector<GNECrossing*> myGNECrossings;
264 
266  double myMaxSize;
267 
271 
273  std::string myLogicStatus;
274 
277 
280 
283 
285  void drawTLSIcon(const GUIVisualizationSettings& s) const;
286 
288  void drawJunctionChilds(const GUIVisualizationSettings& s) const;
289 
291  void setAttribute(SumoXMLAttr key, const std::string& value);
292 
297  void moveJunctionGeometry(const Position& pos);
298 
300  RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
301 
303  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
304 
306  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
307 
310 
312  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
313 
315  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
316 
318  void mirrorXLeftHand();
319 
321  GNEJunction(const GNEJunction&) = delete;
322 
324  GNEJunction& operator=(const GNEJunction&) = delete;
325 };
326 
327 
328 #endif
329 
330 /****************************************************************************/
GNEJunction::BUBBLE_RADIUS
static const double BUBBLE_RADIUS
constant values for drawing buubles
Definition: GNEJunction.h:55
NBConnection::InvalidConnection
const static NBConnection InvalidConnection
Definition: NBConnection.h:126
GNEJunction::getPositionInView
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEJunction.cpp:122
GNEJunction::markConnectionsDeprecated
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
Definition: GNEJunction.cpp:919
GNEJunction::unMarkAsCreateEdgeSource
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
Definition: GNEJunction.cpp:517
GNEJunction::isLogicValid
bool isLogicValid()
whether this junction has a valid logic
Definition: GNEJunction.cpp:890
GNEJunction::mirrorXLeftHand
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
Definition: GNEJunction.cpp:174
GNEJunction::getColorValue
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
Definition: GNEJunction.cpp:1396
GNEJunction::drawJunctionChilds
void drawJunctionChilds(const GUIVisualizationSettings &s) const
draw junction childs
Definition: GNEJunction.cpp:1219
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNEJunction::invalidateShape
void invalidateShape()
Definition: GNEJunction.cpp:641
GNEJunction::myAmTLSSelected
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:282
GNEJunction::commitGeometryMoving
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
Definition: GNEJunction.cpp:626
GNEJunction::removeEdgeFromCrossings
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
Definition: GNEJunction.cpp:864
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNEJunction::getJunctionNeighbours
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
Definition: GNEJunction.cpp:404
GNEJunction::myLogicStatus
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:273
GNEJunction::updateGeometryAfterNetbuild
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
Definition: GNEJunction.cpp:115
GNEJunction::getGNEOutgoingEdges
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:487
GNEJunction::getGNEConnections
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
Definition: GNEJunction.cpp:499
GNEJunction::removeIncomingGNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
Definition: GNEJunction.cpp:447
GNEJunction::moveGeometry
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEJunction.cpp:614
GNEJunction::getGNECrossings
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
Definition: GNEJunction.cpp:493
GNEJunction::markAsModified
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
Definition: GNEJunction.cpp:804
GNEJunction::myHasValidLogic
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:279
GNEJunction::myGNEEdges
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:254
GNEJunction::setResponsible
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEJunction.cpp:1193
PositionVector
A list of positions.
Definition: PositionVector.h:45
GNEJunction::myMaxSize
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not.
Definition: GNEJunction.h:266
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNEJunction::myGNEIncomingEdges
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:257
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:529
GNEJunction::updateGeometry
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:109
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNEJunction::getNBNode
NBNode * getNBNode() const
Return net build node.
Definition: GNEJunction.cpp:398
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:595
RGBColor
Definition: RGBColor.h:39
GNEJunction::myNBNode
NBNode * myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:251
GNECrossing
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:44
GNEJunction::invalidateTLS
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
Definition: GNEJunction.cpp:815
GNEJunction::markAsCreateEdgeSource
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
Definition: GNEJunction.cpp:511
GNEJunction::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEJunction.cpp:253
GNEJunction::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEJunction.cpp:933
GNEJunction::drawTLSIcon
void drawTLSIcon(const GUIVisualizationSettings &s) const
draw TLS icon
Definition: GNEJunction.cpp:1202
GNEJunction::removeTrafficLight
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
Definition: GNEJunction.cpp:1514
GNEJunction::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEJunction.cpp:987
GNEJunction::addIncomingGNEEdge
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
Definition: GNEJunction.cpp:418
GNEJunction::GNEJunction
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:61
GNENetElement.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
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:568
GNEChange_TLS
Definition: GNEChange_TLS.h:42
GNENetElement
Definition: GNENetElement.h:43
GNEJunction::addOutgoingGNEEdge
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
Definition: GNEJunction.cpp:433
NBConnection
Definition: NBConnection.h:43
GNEJunction::myAmCreateEdgeSource
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:270
GNEJunction::rebuildGNECrossings
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
Definition: GNEJunction.cpp:128
GNEJunction::~GNEJunction
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:73
GNEJunction::removeConnectionsFrom
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
Definition: GNEJunction.cpp:682
GNEJunction::setLogicValid
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
Definition: GNEJunction.cpp:659
GNEJunction::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEJunction.cpp:186
GNEJunction::getGNEIncomingEdges
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:481
GNEJunction::addTrafficLight
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
Definition: GNEJunction.cpp:1506
GNEJunction::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEJunction.cpp:93
GUIMainWindow
Definition: GUIMainWindow.h:46
GNEChange_Crossing
Definition: GNEChange_Crossing.h:48
GNEJunction::moveJunctionGeometry
void moveJunctionGeometry(const Position &pos)
reposition the node at pos without updating GRID and informs the edges
Definition: GNEJunction.cpp:1452
GNEJunction::getGNEEdges
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
Definition: GNEJunction.cpp:475
GNEJunction::setColor
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
Definition: GNEJunction.cpp:1487
GNEJunction::myGNECrossings
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:263
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:523
GNEJunction::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEJunction.cpp:1138
GNEJunction::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEJunction.cpp:1172
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEJunction
Definition: GNEJunction.h:47
GNEJunction::removeConnectionsTo
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
Definition: GNEJunction.cpp:711
NBNode::Crossing
A definition of a pedestrian crossing.
Definition: NBNode.h:131
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
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:740
NBNode.h
GNEJunction::replaceIncomingConnections
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
Definition: GNEJunction.cpp:769
GNEJunction::getJunctionShape
const PositionVector & getJunctionShape() const
Definition: GNEJunction.cpp:103
GNEJunction::myGNEOutgoingEdges
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:260
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:67
GNEJunction::removeOutgoingGNEEdge
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
Definition: GNEJunction.cpp:461
GNEJunction::retrieveGNECrossing
GNECrossing * retrieveGNECrossing(NBNode::Crossing *NBNodeCrossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
Definition: GNEJunction.cpp:896
GNEJunction::myAmResponsible
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:276
GNEJunction::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEJunction.cpp:273