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-2018 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 
70 
78 
85 
90  void drawGL(const GUIVisualizationSettings& s) const;
92 
94  Boundary getBoundary() const;
95 
97  NBNode* getNBNode() const;
98 
100  Position getPositionInView() const;
101 
103  std::vector<GNEJunction*> getJunctionNeighbours() const;
104 
106  void addIncomingGNEEdge(GNEEdge* edge);
107 
109  void addOutgoingGNEEdge(GNEEdge* edge);
110 
112  void removeIncomingGNEEdge(GNEEdge* edge);
113 
115  void removeOutgoingGNEEdge(GNEEdge* edge);
116 
118  const std::vector<GNEEdge*>& getGNEEdges() const;
119 
121  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
122 
124  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
125 
127  const std::vector<GNECrossing*>& getGNECrossings() const;
128 
130  std::vector<GNEConnection*> getGNEConnections() const;
131 
133  void markAsCreateEdgeSource();
134 
137 
139  void selectTLS(bool selected);
140 
142  void updateGeometry(bool updateGrid);
143 
146 
148  void startGeometryMoving(bool extendToNeighbors = true);
149 
151  void endGeometryMoving(bool extendToNeighbors = true);
152 
156  void moveGeometry(const Position& oldPos, const Position& offset);
157 
159  void commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList);
160 
165  void updateShapesAndGeometries(bool updateGrid);
167 
170  /* @brief method for getting the Attribute of an XML key
171  * @param[in] key The attribute key
172  * @return string with the value associated to key
173  */
174  std::string getAttribute(SumoXMLAttr key) const;
175 
176  /* @brief method for setting the attribute and letting the object perform additional changes
177  * @param[in] key The attribute key
178  * @param[in] value The new value
179  * @param[in] undoList The undoList on which to register changes
180  */
181  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
182 
183  /* @brief method for checking if the key and their correspond attribute are valids
184  * @param[in] key The attribute key
185  * @param[in] value The value asociated to key key
186  * @return true if the value is valid, false in other case
187  */
188  bool isValid(SumoXMLAttr key, const std::string& value);
190 
193 
195  std::string getGenericParametersStr() const;
196 
198  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
199 
201  void setGenericParametersStr(const std::string& value);
202 
204 
206  void setResponsible(bool newVal);
207 
208  /* @brief notify junction that one of its edges has changed its shape, and
209  * therefore the junction shape is no longer valid */
210  void invalidateShape();
211 
212  /* @brief update validity of this junctions logic
213  * if the logic is invalidated, existing connections are removed via undo-list
214  * so that the previous state can be restored
215  * also calls invalidateTLS
216  * @param[in] valid The new validity of the junction
217  * @note: this should always be called with an active command group
218  */
219  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
220 
222  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
223 
225  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
226 
228  void markAsModified(GNEUndoList* undoList);
229 
230  /* @brief invalidates loaded or edited TLS
231  * @param[in] deletedConnection If a valid connection is given a replacement def with this connection removed
232  * but all other information intact will be computed instead of guessing a new tlDef
233  * @note: this should always be called with an active command group
234  */
235  void invalidateTLS(GNEUndoList* undoList,
236  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
237  const NBConnection& addedConnection = NBConnection::InvalidConnection);
238 
240  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
241 
243  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
244 
246  bool isLogicValid();
247 
249  GNECrossing* retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist = true);
250 
252  void markConnectionsDeprecated(bool includingNeighbours);
253 
254 private:
257 
260 
262  std::vector<GNEEdge*> myGNEEdges;
263 
265  std::vector<GNEEdge*> myGNEIncomingEdges;
266 
268  std::vector<GNEEdge*> myGNEOutgoingEdges;
269 
271  double myMaxSize;
272 
276 
278  std::string myLogicStatus;
279 
282 
285 
288 
290  std::vector<GNECrossing*> myGNECrossings;
291 
293  void setAttribute(SumoXMLAttr key, const std::string& value);
294 
296  void mouseOverObject(const GUIVisualizationSettings& s) const;
297 
302  void moveJunctionGeometry(const Position& pos, bool updateGrid);
303 
305  void setColor(const GUIVisualizationSettings& s, bool bubble) const;
306 
308  double getColorValue(const GUIVisualizationSettings& s, bool bubble) const;
309 
311  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
312 
315 
317  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
318 
320  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
321 
323  GNEJunction(const GNEJunction&) = delete;
324 
326  GNEJunction& operator=(const GNEJunction&) = delete;
327 };
328 
329 
330 #endif
331 
332 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:281
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:284
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:271
Position getPositionInView() const
Return current position.
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:278
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 moveJunctionGeometry(const Position &pos, bool updateGrid)
reposition the node at pos and informs the edges
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:275
static const NBConnection InvalidConnection
Definition: NBConnection.h:121
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:265
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:77
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:287
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
Boundary getBoundary() const
Returns the boundary of the junction.
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 mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
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 updateGeometry(bool updateGrid)
Update the boundary of the junction.
Definition: GNEJunction.cpp:91
Boundary myJunctionBoundary
junction boundary
Definition: GNEJunction.h:259
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:262
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
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:256
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
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 setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:290
void updateShapesAndGeometries(bool updateGrid)
update shapes of all elements associated to the junction
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:268
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:125
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:58
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.
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 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...