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:
61 
62  static const double BUBBLE_RADIUS;
63 
69  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false);
70 
72  ~GNEJunction();
73 
76 
84 
93 
100 
105  void drawGL(const GUIVisualizationSettings& s) const;
107 
109  Boundary getBoundary() const;
110 
112  NBNode* getNBNode() const;
113 
115  Position getPositionInView() 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*>& getGNEEdges() const;
134 
136  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
137 
139  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
140 
142  const std::vector<GNECrossing*>& getGNECrossings() const;
143 
145  void markAsCreateEdgeSource();
146 
149 
151  void selectTLS(bool selected);
152 
154  void updateGeometry();
155 
158 
164  void moveJunctionGeometry(Position pos);
165 
171  void moveJunctionGeometry2D(Position pos2D);
172 
174  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
175 
181 
184  /* @brief method for getting the Attribute of an XML key
185  * @param[in] key The attribute key
186  * @return string with the value associated to key
187  */
188  std::string getAttribute(SumoXMLAttr key) const;
189 
190  /* @brief method for setting the attribute and letting the object perform additional changes
191  * @param[in] key The attribute key
192  * @param[in] value The new value
193  * @param[in] undoList The undoList on which to register changes
194  */
195  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
196 
197  /* @brief method for checking if the key and their correspond attribute are valids
198  * @param[in] key The attribute key
199  * @param[in] value The value asociated to key key
200  * @return true if the value is valid, false in other case
201  */
202  bool isValid(SumoXMLAttr key, const std::string& value);
204 
206  void setResponsible(bool newVal);
207 
208  /* @brief notify junction that one of its edges has changed its shape, and
209  * therefore the junction shape is no longer valid */
210  void invalidateShape();
211 
212  /* @brief update validity of this junctions logic
213  * if the logic is invalidated, existing connections are removed via undo-list
214  * so that the previous state can be restored
215  * also calls invalidateTLS
216  * @param[in] valid The new validity of the junction
217  * @note: this should always be called with an active command group */
218  void setLogicValid(bool valid, GNEUndoList* undoList = 0, const std::string& status = GUESSED);
219 
221  void markAsModified(GNEUndoList* undoList);
222 
223  /* @brief invalidates loaded or edited TLS
224  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
225  * but all other information intact will be computed instead of guessing a new tlDef
226  * @note: this should always be called with an active command group */
227  void invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection = NBConnection::InvalidConnection);
228 
230  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
231 
233  bool isLogicValid();
234 
236  GNECrossing* retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist = true);
237 
238 private:
241 
243  std::vector<GNEEdge*> myGNEEdges;
244 
246  std::vector<GNEEdge*> myGNEIncomingEdges;
247 
249  std::vector<GNEEdge*> myGNEOutgoingEdges;
250 
252  double myMaxSize;
253 
256 
260 
262  std::string myLogicStatus;
263 
266 
269 
272 
274  std::vector<GNECrossing*> myGNECrossings;
275 
276 private:
278  GNEJunction(const GNEJunction&);
279 
282 
284  void setAttribute(SumoXMLAttr key, const std::string& value);
285 
287  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
288 
290  double getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
291 
293  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
294 
297 
299  void rebuildGNECrossings();
300 };
301 
302 
303 #endif
304 
305 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:265
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:268
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
void moveJunctionGeometry2D(Position pos2D)
reposition the node as above but keep the old z value
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:252
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:262
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
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:259
static const NBConnection InvalidConnection
Definition: NBConnection.h:127
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:246
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 getPositionInView() const
Return current position.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
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:271
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
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
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:52
void moveJunctionGeometry(Position pos)
reposition the node at pos and informs the edges
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 commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:243
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:240
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:58
static const double BUBBLE_RADIUS
Definition: GNEJunction.h:62
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:81
void updateGeometry()
Update the boundary of the junction.
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:255
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:274
void recomputeNeighborsJunctions()
recompute neighbors junctions
void rebuildGNECrossings()
rebuilds crossing objects for this junction
The popup menu of a globject.
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:249
Represents a single node (junction) during network building.
Definition: NBNode.h:75
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
A definition of a pedestrian crossing.
Definition: NBNode.h:135
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:69
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
This functions has to be implemented in allGNEAttributeCarrier.
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
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