Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A class for visualizing and editing junctions in netedit (adapted from
16 // GUIJunctionWrapper)
17 /****************************************************************************/
18 #ifndef GNEJunction_h
19 #define GNEJunction_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #include "GNENetElement.h"
27 #include <netbuild/NBNode.h>
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class GNENet;
33 class GNEEdge;
34 class GNECrossing;
36 class GNEConnection;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
48 class GNEJunction : public GNENetElement {
49 
51  friend class GNEChange_TLS;
52  friend class GNEChange_Crossing;
53 
54 public:
56  static const double BUBBLE_RADIUS;
57 
63  GNEJunction(NBNode& nbn, GNENet* net, bool loaded = false);
64 
66  ~GNEJunction();
67 
69  std::string generateChildID(SumoXMLTag childTag);
70 
74  void updateGeometry();
75 
77  // @note: using an extra function because updateGeometry overrides an abstract virtual function
78  void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
79 
83 
86 
94 
101 
106  void drawGL(const GUIVisualizationSettings& s) const;
108 
110  NBNode* getNBNode() const;
111 
113  std::vector<GNEJunction*> getJunctionNeighbours() const;
114 
116  void addIncomingGNEEdge(GNEEdge* edge);
117 
119  void addOutgoingGNEEdge(GNEEdge* edge);
120 
122  void removeIncomingGNEEdge(GNEEdge* edge);
123 
125  void removeOutgoingGNEEdge(GNEEdge* edge);
126 
128  const std::vector<GNEEdge*>& getGNEEdges() const;
129 
131  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
132 
134  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
135 
137  const std::vector<GNECrossing*>& getGNECrossings() const;
138 
140  std::vector<GNEConnection*> getGNEConnections() const;
141 
143  void markAsCreateEdgeSource();
144 
147 
149  void selectTLS(bool selected);
150 
153 
155  void startGeometryMoving(bool extendToNeighbors = true);
156 
158  void endGeometryMoving(bool extendToNeighbors = true);
159 
163  void moveGeometry(const Position& oldPos, const Position& offset);
164 
166  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
167 
169 
172  /* @brief method for getting the Attribute of an XML key
173  * @param[in] key The attribute key
174  * @return string with the value associated to key
175  */
176  std::string getAttribute(SumoXMLAttr key) const;
177 
178  /* @brief method for setting the attribute and letting the object perform additional changes
179  * @param[in] key The attribute key
180  * @param[in] value The new value
181  * @param[in] undoList The undoList on which to register changes
182  */
183  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
184 
185  /* @brief method for checking if the key and their correspond attribute are valids
186  * @param[in] key The attribute key
187  * @param[in] value The value asociated to key key
188  * @return true if the value is valid, false in other case
189  */
190  bool isValid(SumoXMLAttr key, const std::string& value);
192 
195 
197  std::string getGenericParametersStr() const;
198 
200  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
201 
203  void setGenericParametersStr(const std::string& value);
204 
206 
208  void setResponsible(bool newVal);
209 
210  /* @brief notify junction that one of its edges has changed its shape, and
211  * therefore the junction shape is no longer valid */
212  void invalidateShape();
213 
214  /* @brief update validity of this junctions logic
215  * if the logic is invalidated, existing connections are removed via undo-list
216  * so that the previous state can be restored
217  * also calls invalidateTLS
218  * @param[in] valid The new validity of the junction
219  * @note: this should always be called with an active command group
220  */
221  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
222 
224  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
225 
227  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
228 
230  void markAsModified(GNEUndoList* undoList);
231 
232  /* @brief invalidates loaded or edited TLS
233  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
234  * but all other information intact will be computed instead of guessing a new tlDef
235  * @note: this should always be called with an active command group
236  */
237  void invalidateTLS(GNEUndoList* undoList,
238  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
239  const NBConnection& addedConnection = NBConnection::InvalidConnection);
240 
242  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
243 
245  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
246 
248  bool isLogicValid();
249 
251  GNECrossing* retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist = true);
252 
254  void markConnectionsDeprecated(bool includingNeighbours);
255 
256 private:
259 
261  std::vector<GNEEdge*> myGNEEdges;
262 
264  std::vector<GNEEdge*> myGNEIncomingEdges;
265 
267  std::vector<GNEEdge*> myGNEOutgoingEdges;
268 
270  std::vector<GNECrossing*> myGNECrossings;
271 
273  double myMaxSize;
274 
278 
280  std::string myLogicStatus;
281 
284 
287 
290 
292  void setAttribute(SumoXMLAttr key, const std::string& value);
293 
298  void moveJunctionGeometry(const Position& pos);
299 
301  RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
302 
304  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
305 
307  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
308 
311 
313  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
314 
316  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
317 
319  void mirrorXLeftHand();
320 
322  GNEJunction(const GNEJunction&) = delete;
323 
325  GNEJunction& operator=(const GNEJunction&) = delete;
326 };
327 
328 
329 #endif
330 
331 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:283
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:286
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:273
Position getPositionInView() const
Returns position of hierarchical element in view.
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:280
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void invalidateShape()
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEJunction.cpp:91
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:277
static const NBConnection InvalidConnection
Definition: NBConnection.h:121
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:264
bool isValid(SumoXMLAttr key, const std::string &value)
Stores the information about how to visualize structures.
The base class for traffic light logic definitions.
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
std::string getGenericParametersStr() const
return generic parameters in string format
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
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:289
void startGeometryMoving(bool extendToNeighbors=true)
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
std::string getAttribute(SumoXMLAttr key) const
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
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:45
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
bool isLogicValid()
whether this junction has a valid logic
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:261
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:258
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
static const double BUBBLE_RADIUS
constant values for drawing buubles
Definition: GNEJunction.h:56
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:71
void updateGeometry()
update pre-computed geometry information
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:270
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
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:267
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
Represents a single node (junction) during network building.
Definition: NBNode.h:68
A definition of a pedestrian crossing.
Definition: NBNode.h:132
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:60
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries ...
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 setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
void moveJunctionGeometry(const Position &pos)
reposition the node at pos without updating GRID and informs the edges
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
void endGeometryMoving(bool extendToNeighbors=true)
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...