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  void addIncomingGNEEdge(GNEEdge* edge);
113 
115  void addOutgoingGNEEdge(GNEEdge* edge);
116 
118  void removeIncomingGNEEdge(GNEEdge* edge);
119 
121  void removeOutgoingGNEEdge(GNEEdge* edge);
122 
124  const std::vector<GNEEdge*>& getGNEEdges() const;
125 
127  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
128 
130  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
131 
133  const std::vector<GNECrossing*>& getGNECrossings() const;
134 
136  void markAsCreateEdgeSource();
137 
140 
142  void selectTLS(bool selected);
143 
145  void updateGeometry();
146 
152  void move(Position pos);
153 
155  void registerMove(GNEUndoList* undoList);
156 
162 
165  /* @brief method for getting the Attribute of an XML key
166  * @param[in] key The attribute key
167  * @return string with the value associated to key
168  */
169  std::string getAttribute(SumoXMLAttr key) const;
170 
171  /* @brief method for setting the attribute and letting the object perform additional changes
172  * @param[in] key The attribute key
173  * @param[in] value The new value
174  * @param[in] undoList The undoList on which to register changes
175  */
176  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
177 
178  /* @brief method for checking if the key and their correspond attribute are valids
179  * @param[in] key The attribute key
180  * @param[in] value The value asociated to key key
181  * @return true if the value is valid, false in other case
182  */
183  bool isValid(SumoXMLAttr key, const std::string& value);
185 
187  void setResponsible(bool newVal);
188 
189  /* @brief notify junction that one of its edges has changed its shape, and
190  * therefore the junction shape is no longer valid */
191  void invalidateShape();
192 
193  /* @brief update validity of this junctions logic
194  * if the logic is invalidated, existing connections are removed via undo-list
195  * so that the previous state can be restored
196  * also calls invalidateTLS
197  * @param[in] valid The new validity of the junction
198  * @note: this should always be called with an active command group */
199  void setLogicValid(bool valid, GNEUndoList* undoList = 0, const std::string& status = GUESSED);
200 
202  void markAsModified(GNEUndoList* undoList);
203 
204  /* @brief invalidates loaded or edited TLS
205  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
206  * but all other information intact will be computed instead of guessing a new tlDef
207  * @note: this should always be called with an active command group */
208  void invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection = NBConnection::InvalidConnection);
209 
211  void removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
212 
214  bool isLogicValid();
215 
217  void dropGNECrossings();
218 
219 private:
222 
224  std::vector<GNEEdge*> myGNEEdges;
225 
227  std::vector<GNEEdge*> myGNEIncomingEdges;
228 
230  std::vector<GNEEdge*> myGNEOutgoingEdges;
231 
234 
237 
240 
244 
246  std::string myLogicStatus;
247 
250 
253 
256 
258  std::vector<GNECrossing*> myGNECrossings;
259 
260 private:
262  GNEJunction(const GNEJunction&);
263 
266 
268  void setAttribute(SumoXMLAttr key, const std::string& value);
269 
271  void setPosition(Position pos);
272 
274  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
275 
277  SUMOReal getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
278 
280  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
281 
284 
286  void rebuildGNECrossings();
287 };
288 
289 
290 #endif
291 
292 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:249
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:252
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:246
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
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:243
static const NBConnection InvalidConnection
Definition: NBConnection.h:127
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:227
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.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
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:255
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:233
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
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
SUMOReal getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
void removeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
SUMOReal myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:236
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:224
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:221
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:54
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:82
void updateGeometry()
Update the boundary of the junction.
Definition: GNEJunction.cpp:91
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:239
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:258
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:230
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:69
#define SUMOReal
Definition: config.h:208
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