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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A class for visualizing and editing junctions in netedit (adapted from
18 // GUIJunctionWrapper)
19 /****************************************************************************/
20 #ifndef GNEJunction_h
21 #define GNEJunction_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNENetElement.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GNENet;
39 class GNEEdge;
40 class GNECrossing;
42 class GNEConnection;
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 
91 
96  void drawGL(const GUIVisualizationSettings& s) const;
98 
100  Boundary getBoundary() const;
101 
103  NBNode* getNBNode() const;
104 
106  Position getPositionInView() const;
107 
109  std::vector<GNEJunction*> getJunctionNeighbours() 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  std::vector<GNEConnection*> getGNEConnections() const;
137 
139  void markAsCreateEdgeSource();
140 
143 
145  void selectTLS(bool selected);
146 
148  void updateGeometry();
149 
153  void moveGeometry(const Position& oldPos, const Position& offset);
154 
156  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
157 
163 
166  /* @brief method for getting the Attribute of an XML key
167  * @param[in] key The attribute key
168  * @return string with the value associated to key
169  */
170  std::string getAttribute(SumoXMLAttr key) const;
171 
172  /* @brief method for setting the attribute and letting the object perform additional changes
173  * @param[in] key The attribute key
174  * @param[in] value The new value
175  * @param[in] undoList The undoList on which to register changes
176  */
177  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
178 
179  /* @brief method for checking if the key and their correspond attribute are valids
180  * @param[in] key The attribute key
181  * @param[in] value The value asociated to key key
182  * @return true if the value is valid, false in other case
183  */
184  bool isValid(SumoXMLAttr key, const std::string& value);
186 
188  void setResponsible(bool newVal);
189 
190  /* @brief notify junction that one of its edges has changed its shape, and
191  * therefore the junction shape is no longer valid */
192  void invalidateShape();
193 
194  /* @brief update validity of this junctions logic
195  * if the logic is invalidated, existing connections are removed via undo-list
196  * so that the previous state can be restored
197  * also calls invalidateTLS
198  * @param[in] valid The new validity of the junction
199  * @note: this should always be called with an active command group */
200  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = GUESSED);
201 
203  void markAsModified(GNEUndoList* undoList);
204 
205  /* @brief invalidates loaded or edited TLS
206  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
207  * but all other information intact will be computed instead of guessing a new tlDef
208  * @note: this should always be called with an active command group */
209  void invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection = NBConnection::InvalidConnection);
210 
212  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
213 
215  bool isLogicValid();
216 
218  GNECrossing* retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist = true);
219 
220 private:
223 
225  std::vector<GNEEdge*> myGNEEdges;
226 
228  std::vector<GNEEdge*> myGNEIncomingEdges;
229 
231  std::vector<GNEEdge*> myGNEOutgoingEdges;
232 
234  double myMaxSize;
235 
238 
242 
244  std::string myLogicStatus;
245 
248 
251 
254 
256  std::vector<GNECrossing*> myGNECrossings;
257 
258 private:
260  void setAttribute(SumoXMLAttr key, const std::string& value);
261 
266  void moveJunctionGeometry(const Position& pos);
267 
269  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
270 
272  double getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
273 
275  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
276 
279 
281  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
282 
284  GNEJunction(const GNEJunction&) = delete;
285 
287  GNEJunction& operator=(const GNEJunction&) = delete;
288 };
289 
290 
291 #endif
292 
293 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:247
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:250
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:234
Position getPositionInView() const
Return current position.
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:244
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=GUESSED)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
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:241
static const NBConnection InvalidConnection
Definition: NBConnection.h:126
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:228
bool isValid(SumoXMLAttr key, const std::string &value)
Stores the information about how to visualize structures.
The base class for traffic light logic definitions.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
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:253
void updateShapesAndGeometries()
update shapes of all elements associated to the junction
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
Boundary getBoundary() const
Returns the boundary of the junction.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
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:225
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
double getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:222
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:56
static const double BUBBLE_RADIUS
Definition: GNEJunction.h:62
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:78
void updateGeometry()
Update the boundary of the junction.
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:237
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:256
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
The popup menu of a globject.
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:231
Represents a single node (junction) during network building.
Definition: NBNode.h:74
A definition of a pedestrian crossing.
Definition: NBNode.h:131
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:66
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
NBNode * getNBNode() const
Return net build node.
void moveJunctionGeometry(const Position &pos)
reposition the node at pos and informs the edges
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction