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-2016 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 
59 public:
65  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false);
66 
68  virtual ~GNEJunction();
69 
72 
80 
89 
96 
101  void drawGL(const GUIVisualizationSettings& s) const;
103 
105  Boundary getBoundary() const;
106 
108  NBNode* getNBNode() const;
109 
111  void markAsCreateEdgeSource();
112 
115 
117  void selectTLS(bool selected);
118 
120  void updateGeometry();
121 
127  void move(Position pos);
128 
130  void registerMove(GNEUndoList* undoList);
131 
134  /* @brief method for getting the Attribute of an XML key
135  * @param[in] key The attribute key
136  * @return string with the value associated to key
137  */
138  std::string getAttribute(SumoXMLAttr key) const;
139 
140  /* @brief method for setting the attribute and letting the object perform additional changes
141  * @param[in] key The attribute key
142  * @param[in] value The new value
143  * @param[in] undoList The undoList on which to register changes
144  */
145  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
146 
147  /* @brief method for checking if the key and their correspond attribute are valids
148  * @param[in] key The attribute key
149  * @param[in] value The value asociated to key key
150  * @return true if the value is valid, false in other case
151  */
152  bool isValid(SumoXMLAttr key, const std::string& value);
154 
156  void setResponsible(bool newVal);
157 
158  /* @brief notify junction that one of its edges has changed its shape, and
159  * therefore the junction shape is no longer valid */
160  void invalidateShape();
161 
162  /* @brief update validity of this junctions logic
163  * if the logic is invalidated, existing connections are removed via undo-list
164  * so that the previous state can be restored
165  * also calls invalidateTLS
166  * @param[in] valid The new validity of the junction
167  * @note: this should always be called with an active command group */
168  void setLogicValid(bool valid, GNEUndoList* undoList = 0, const std::string& status = GUESSED);
169 
170  /* @brief invalidates loaded or edited TLS
171  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
172  * but all other information intact will be computed instead of guessing a new tlDef
173  * @note: this should always be called with an active command group */
174  void invalidateTLS(GNEUndoList* undoList,
175  const NBConnection& deletedConnection = NBConnection::InvalidConnection);
176 
178  void removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
179 
181  bool isLogicValid();
182 
185 
186 private:
189 
192 
195 
198 
202 
204  std::string myLogicStatus;
205 
208 
211 
214 
216  std::vector<GNECrossing*> myCrossings;
217 
218 private:
220  GNEJunction(const GNEJunction&);
221 
224 
226  void setAttribute(SumoXMLAttr key, const std::string& value);
227 
229  void setPosition(Position pos);
230 
232  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
233 
235  SUMOReal getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
236 
238  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
239 
242 
244  void rebuildCrossings(bool deleteOnly);
245 };
246 
247 
248 #endif
249 
250 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:207
void rebuildCrossings(bool deleteOnly)
rebuilds crossing objects for this junction
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:210
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:204
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 invalidateShape()
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:201
static const NBConnection InvalidConnection
Definition: NBConnection.h:128
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:86
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:213
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
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:191
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
void updateCrossingAttributes(NBNode::Crossing crossing)
modify the specified crossing (using friend privileges)
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:194
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:188
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:197
void move(Position pos)
reposition the node at pos and informs the edges
The popup menu of a globject.
Represents a single node (junction) during network building.
Definition: NBNode.h:74
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
A definition of a pedestrian crossing.
Definition: NBNode.h:132
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:68
#define SUMOReal
Definition: config.h:213
std::vector< GNECrossing * > myCrossings
the built crossing objects
Definition: GNEJunction.h:216
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
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