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 <string>
35 #include <utility>
37 #include <netbuild/NBConnection.h>
38 #include <netbuild/NBNode.h>
39 
40 #include "GNEAttributeCarrier.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class GNENet;
47 class GNEEdge;
48 class GNECrossing;
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
62 
63  friend class GNEChange_TLS;
64 
65 public:
71  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false) ;
72 
73 
75  virtual ~GNEJunction() ;
76 
77 
79 
80 
89  GUISUMOAbstractView& parent) ;
90 
91 
100  GUIMainWindow& app, GUISUMOAbstractView& parent) ;
101 
102 
109 
110 
115  void drawGL(const GUIVisualizationSettings& s) const ;
117 
118 
119 
124  return myBoundary;
125  }
126 
127 
129  void updateBoundary();
130 
131 
135  myAmCreateEdgeSource = true;
136  }
137 
141  myAmCreateEdgeSource = false;
142  }
143 
144 
146  void selectTLS(bool selected) {
147  myAmTLSSelected = selected;
148  }
149 
150 
154  return &myNBNode;
155  }
156 
157 
163  void move(Position pos);
164 
165 
167  void registerMove(GNEUndoList* undoList);
168 
169 
170  //@name inherited from GNEAttributeCarrier
172  std::string getAttribute(SumoXMLAttr key) const;
173 
174  /* @brief method for setting the attribute and letting the object perform additional changes
175  * @param[in] key The attribute key
176  * @param[in] value The new value
177  * @param[in] undoList The undoList on which to register changes
178  */
179  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
180 
181  bool isValid(SumoXMLAttr key, const std::string& value);
183 
185  void setResponsible(bool newVal) {
186  myAmResponsible = newVal;
187  }
188 
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 = 0, const std::string& status = GUESSED);
201 
202 
203  /* @brief invalidates loaded or edited TLS
204  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
205  * but all other information intact will be computed instead of guessing a new tlDef
206  * @note: this should always be called with an active command group */
207  void invalidateTLS(GNEUndoList* undoList,
208  const NBConnection& deletedConnection = NBConnection::InvalidConnection);
209 
211  void removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
212 
213  /* @brief whether this junction has a valid logic */
214  bool isLogicValid() {
215  return myHasValidLogic;
216  }
217 
218  static void resetDecal() {
219  TLSDecalInitialized = false;
220  }
221 
224 
225 private:
228 
231 
234 
237 
238  /* @brief whether this junction is the first junction for a newly created
239  * edge. (see GNEApplicationWindow::createEdgeSource)
240  */
242 
243  // the net to inform about updates
245 
247  std::string myLogicStatus;
248 
251 
254 
257 
259  std::vector<GNECrossing*> myCrossings;
260 
262  static int TLSDecalGlID;
263 
265  static bool TLSDecalInitialized;
266 
267 private:
269  GNEJunction(const GNEJunction&);
270 
273 
274  /* @brief method for setting the attribute and nothing else
275  * (used in GNEChange_Attribute)
276  * */
277  void setAttribute(SumoXMLAttr key, const std::string& value);
278 
280  void setPosition(Position pos);
281 
283  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
284 
286  SUMOReal getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
287 
289  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
290 
293 
295  void rebuildCrossings(bool deleteOnly);
296 };
297 
298 
299 #endif
300 
301 /****************************************************************************/
302 
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:250
void rebuildCrossings(bool deleteOnly)
rebuilds crossing objects for this junction
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:253
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEJunction.h:185
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:247
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
Definition: GNEJunction.h:134
bool myAmCreateEdgeSource
Definition: GNEJunction.h:241
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.
static void resetDecal()
Definition: GNEJunction.h:218
static int TLSDecalGlID
gl-id of the tls-decal (drawn in tls-mode)
Definition: GNEJunction.h:262
The base class for traffic light logic definitions.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static bool TLSDecalInitialized
whether the tls-decal has been initialized
Definition: GNEJunction.h:265
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
Definition: GNEJunction.h:146
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:256
GNENet * myNet
Definition: GNEJunction.h:244
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:230
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:55
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()
Definition: GNEJunction.h:214
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:233
NBNode * getNBNode()
returns the internal NBNode
Definition: GNEJunction.h:153
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
Definition: GNEJunction.h:140
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:227
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:61
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:92
Boundary getBoundary() const
Returns the boundary of the junction.
Definition: GNEJunction.h:123
GNEJunction & operator=(const GNEJunction &)
Invalidated assignment operator.
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:236
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:76
#define SUMOReal
Definition: config.h:213
std::vector< GNECrossing * > myCrossings
the built crossing objects
Definition: GNEJunction.h:259
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 updateBoundary()
Update the boundary of the junction.
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light