SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  std::vector<GNEEdge*> getGNEEdges() const;
112 
114  std::vector<GNEEdge*> getGNEIncomingEdges() const;
115 
117  std::vector<GNEEdge*> getGNEOutgoingEdges() const;
118 
120  void markAsCreateEdgeSource();
121 
124 
126  void selectTLS(bool selected);
127 
129  void updateGeometry();
130 
136  void move(Position pos);
137 
139  void registerMove(GNEUndoList* undoList);
140 
146 
149  /* @brief method for getting the Attribute of an XML key
150  * @param[in] key The attribute key
151  * @return string with the value associated to key
152  */
153  std::string getAttribute(SumoXMLAttr key) const;
154 
155  /* @brief method for setting the attribute and letting the object perform additional changes
156  * @param[in] key The attribute key
157  * @param[in] value The new value
158  * @param[in] undoList The undoList on which to register changes
159  */
160  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
161 
162  /* @brief method for checking if the key and their correspond attribute are valids
163  * @param[in] key The attribute key
164  * @param[in] value The value asociated to key key
165  * @return true if the value is valid, false in other case
166  */
167  bool isValid(SumoXMLAttr key, const std::string& value);
169 
171  void setResponsible(bool newVal);
172 
173  /* @brief notify junction that one of its edges has changed its shape, and
174  * therefore the junction shape is no longer valid */
175  void invalidateShape();
176 
177  /* @brief update validity of this junctions logic
178  * if the logic is invalidated, existing connections are removed via undo-list
179  * so that the previous state can be restored
180  * also calls invalidateTLS
181  * @param[in] valid The new validity of the junction
182  * @note: this should always be called with an active command group */
183  void setLogicValid(bool valid, GNEUndoList* undoList = 0, const std::string& status = GUESSED);
184 
186  void markAsModified(GNEUndoList* undoList);
187 
188  /* @brief invalidates loaded or edited TLS
189  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
190  * but all other information intact will be computed instead of guessing a new tlDef
191  * @note: this should always be called with an active command group */
192  void invalidateTLS(GNEUndoList* undoList,
193  const NBConnection& deletedConnection = NBConnection::InvalidConnection);
194 
196  void removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
197 
199  bool isLogicValid();
200 
203 
204 private:
207 
210 
213 
216 
220 
222  std::string myLogicStatus;
223 
226 
229 
232 
234  std::vector<GNECrossing*> myCrossings;
235 
236 private:
238  GNEJunction(const GNEJunction&);
239 
242 
244  void setAttribute(SumoXMLAttr key, const std::string& value);
245 
247  void setPosition(Position pos);
248 
250  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
251 
253  SUMOReal getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
254 
256  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
257 
260 
262  void rebuildCrossings(bool deleteOnly);
263 };
264 
265 
266 #endif
267 
268 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:225
void rebuildCrossings(bool deleteOnly)
rebuilds crossing objects for this junction
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:228
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:222
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:219
static const NBConnection InvalidConnection
Definition: NBConnection.h:127
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:231
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:209
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
std::vector< GNEEdge * > getGNEEdges() const
Return all GNEEdges vinculated with this Junction.
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:212
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:206
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:55
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:83
void updateGeometry()
Update the boundary of the junction.
Definition: GNEJunction.cpp:92
Boundary getBoundary() const
Returns the boundary of the junction.
GNEJunction & operator=(const GNEJunction &)
Invalidated assignment operator.
Boundary myBoundary
The represented junction's boundary.
Definition: GNEJunction.h:215
void move(Position pos)
reposition the node at pos and informs the edges
The popup menu of a globject.
std::vector< GNEEdge * > getGNEOutgoingEdges() const
Return incoming GNEEdges.
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:69
#define SUMOReal
Definition: config.h:214
std::vector< GNECrossing * > myCrossings
the built crossing objects
Definition: GNEJunction.h:234
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
std::vector< GNEEdge * > getGNEIncomingEdges() const
Return incoming GNEEdges.
std::string getAttribute(SumoXMLAttr key) const
void setPosition(Position pos)
reposition the NBNnode and nothing else
A window containing a gl-object's parameter.
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction