SUMO - Simulation of Urban MObility
GNEJunction.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing and editing junctions in netedit (adapted from
8 // GUIJunctionWrapper)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef GNEJunction_h
22 #define GNEJunction_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "GNENetElement.h"
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GNENet;
40 class GNEEdge;
41 class GNECrossing;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
54 class GNEJunction : public GNENetElement {
55 
57  friend class GNEChange_TLS;
58  friend class GNEChange_Crossing;
59 
60 public:
66  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false);
67 
69  virtual ~GNEJunction();
70 
73 
81 
90 
97 
102  void drawGL(const GUIVisualizationSettings& s) const;
104 
106  Boundary getBoundary() const;
107 
109  NBNode* getNBNode() const;
110 
112  Position getPosition() 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  void markAsCreateEdgeSource();
143 
146 
148  void selectTLS(bool selected);
149 
151  void updateGeometry();
152 
155 
161  void move(Position pos);
162 
164  void registerMove(GNEUndoList* undoList);
165 
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);
194 
196  void setResponsible(bool newVal);
197 
198  /* @brief notify junction that one of its edges has changed its shape, and
199  * therefore the junction shape is no longer valid */
200  void invalidateShape();
201 
202  /* @brief update validity of this junctions logic
203  * if the logic is invalidated, existing connections are removed via undo-list
204  * so that the previous state can be restored
205  * also calls invalidateTLS
206  * @param[in] valid The new validity of the junction
207  * @note: this should always be called with an active command group */
208  void setLogicValid(bool valid, GNEUndoList* undoList = 0, const std::string& status = GUESSED);
209 
211  void markAsModified(GNEUndoList* undoList);
212 
213  /* @brief invalidates loaded or edited TLS
214  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
215  * but all other information intact will be computed instead of guessing a new tlDef
216  * @note: this should always be called with an active command group */
217  void invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection = NBConnection::InvalidConnection);
218 
220  void removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
221 
223  bool isLogicValid();
224 
226  void dropGNECrossings();
227 
228 private:
231 
233  std::vector<GNEEdge*> myGNEEdges;
234 
236  std::vector<GNEEdge*> myGNEIncomingEdges;
237 
239  std::vector<GNEEdge*> myGNEOutgoingEdges;
240 
243 
245  double myMaxSize;
246 
249 
253 
255  std::string myLogicStatus;
256 
259 
262 
265 
267  std::vector<GNECrossing*> myGNECrossings;
268 
269 private:
271  GNEJunction(const GNEJunction&);
272 
275 
277  void setAttribute(SumoXMLAttr key, const std::string& value);
278 
280  void setPosition(Position pos);
281 
283  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
284 
286  double getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
287 
289  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
290 
293 
295  void rebuildGNECrossings();
296 };
297 
298 
299 #endif
300 
301 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:258
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:261
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:245
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:255
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
double getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
void invalidateShape()
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:252
static const NBConnection InvalidConnection
Definition: NBConnection.h:127
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:236
bool isValid(SumoXMLAttr key, const std::string &value)
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
Stores the information about how to visualize structures.
NBNode * getNBNode() const
Return net build node.
The base class for traffic light logic definitions.
Position getPosition() const
Return current position.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:88
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:264
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
void updateShapesAndGeometries()
update shapes of all elements associated to the junction
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
Position myOrigPos
restore point for undo
Definition: GNEJunction.h:242
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool isLogicValid()
whether this junction has a valid logic
void removeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
void dropGNECrossings()
drop crossings
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:233
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:230
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection)
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:57
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:78
void updateGeometry()
Update the boundary of the junction.
Definition: GNEJunction.cpp:87
Boundary getBoundary() const
Returns the boundary of the junction.
GNEJunction & operator=(const GNEJunction &)
Invalidated assignment operator.
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:248
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:267
void recomputeNeighborsJunctions()
recompute neighbors junctions
void rebuildGNECrossings()
rebuilds crossing objects for this junction
void move(Position pos)
reposition the node at pos and informs the edges
The popup menu of a globject.
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:239
Represents a single node (junction) during network building.
Definition: NBNode.h:75
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:65
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
std::string getAttribute(SumoXMLAttr key) const
void setPosition(Position pos)
reposition the NBNnode and nothing else
A window containing a gl-object&#39;s parameter.
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction