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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing and editing junctions in netedit (adapted from
19 // GUIJunctionWrapper)
20 /****************************************************************************/
21 #pragma once
22 #include "GNENetworkElement.h"
23 
24 #include <netbuild/NBNode.h>
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
29 class GNENet;
30 class GNEEdge;
31 class GNECrossing;
33 class GNEConnection;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
46 
48  friend class GNEChange_TLS;
49  friend class GNEChange_Crossing;
50 
51 public:
57  GNEJunction(GNENet* net, NBNode* nbn, bool loaded = false);
58 
60  ~GNEJunction();
61 
65  const PositionVector& getJunctionShape() const;
66 
68  void updateGeometry();
69 
71  // @note: using an extra function because updateGeometry overrides an abstract virtual function
72  void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings = false);
73 
77 
81  GNEMoveOperation* getMoveOperation(const double shapeOffset);
82 
84  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
86 
89 
97 
99  void updateCenteringBoundary(const bool updateGrid);
100 
105  void drawGL(const GUIVisualizationSettings& s) const;
107 
109  NBNode* getNBNode() const;
110 
112  std::vector<GNEJunction*> getJunctionNeighbours() const;
113 
115  void addIncomingGNEEdge(GNEEdge* edge);
116 
118  void addOutgoingGNEEdge(GNEEdge* edge);
119 
121  void removeIncomingGNEEdge(GNEEdge* edge);
122 
124  void removeOutgoingGNEEdge(GNEEdge* edge);
125 
127  const std::vector<GNEEdge*>& getGNEIncomingEdges() const;
128 
130  const std::vector<GNEEdge*>& getGNEOutgoingEdges() const;
131 
133  const std::vector<GNECrossing*>& getGNECrossings() const;
134 
136  std::vector<GNEConnection*> getGNEConnections() const;
137 
139  void markAsCreateEdgeSource();
140 
143 
145  void selectTLS(bool selected);
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);
168 
169  /* @brief method for check if the value for certain attribute is set
170  * @param[in] key The attribute key
171  */
172  bool isAttributeEnabled(SumoXMLAttr key) const;
174 
176  const std::map<std::string, std::string>& getACParametersMap() const;
177 
179  void setResponsible(bool newVal);
180 
181  /* @brief notify junction that one of its edges has changed its shape, and
182  * therefore the junction shape is no longer valid */
183  void invalidateShape();
184 
185  /* @brief update validity of this junctions logic
186  * if the logic is invalidated, existing connections are removed via undo-list
187  * so that the previous state can be restored
188  * also calls invalidateTLS
189  * @param[in] valid The new validity of the junction
190  * @note: this should always be called with an active command group
191  */
192  void setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status = FEATURE_GUESSED);
193 
195  void removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
196 
198  void removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane = -1);
199 
201  void markAsModified(GNEUndoList* undoList);
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  */
208  void invalidateTLS(GNEUndoList* undoList,
209  const NBConnection& deletedConnection = NBConnection::InvalidConnection,
210  const NBConnection& addedConnection = NBConnection::InvalidConnection);
211 
213  void replaceIncomingConnections(GNEEdge* which, GNEEdge* by, GNEUndoList* undoList);
214 
216  void removeEdgeFromCrossings(GNEEdge* edge, GNEUndoList* undoList);
217 
219  bool isLogicValid();
220 
222  GNECrossing* retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist = true);
223 
225  void markConnectionsDeprecated(bool includingNeighbours);
226 
228  void addPathAdditionalElement(GNEAdditional* additionalElement);
229 
231  void removePathAdditionalElement(GNEAdditional* additionalElement);
232 
234  void addPathDemandElement(GNEDemandElement* demandElement);
235 
237  void removePathDemandElement(GNEDemandElement* demandElement);
238 
240  void addPathGenericData(GNEGenericData* genericData);
241 
243  void removePathGenericData(GNEGenericData* genericData);
244 
246  void invalidatePathElements();
247 
248 protected:
251 
253  std::vector<GNEEdge*> myGNEIncomingEdges;
254 
256  std::vector<GNEEdge*> myGNEOutgoingEdges;
257 
259  std::vector<GNECrossing*> myGNECrossings;
260 
262  std::map<SumoXMLTag, std::vector<GNEAdditional*> > myPathAdditionalElements;
263 
265  std::map<SumoXMLTag, std::vector<GNEDemandElement*> > myPathDemandElements;
266 
268  std::map<SumoXMLTag, std::vector<GNEGenericData*> > myPathGenericDatas;
269 
272 
276 
278  std::string myLogicStatus;
279 
282 
285 
288 
291 
292 private:
294  void drawTLSIcon(const GUIVisualizationSettings& s) const;
295 
297  void drawJunctionChildren(const GUIVisualizationSettings& s) const;
298 
300  void setAttribute(SumoXMLAttr key, const std::string& value);
301 
303  void setMoveShape(const GNEMoveResult& moveResult);
304 
306  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
307 
312  void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
313 
315  RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
316 
318  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
319 
322 
324  void addTrafficLight(NBTrafficLightDefinition* tlDef, bool forceInsert);
325 
328 
330  void rebuildGNECrossings(bool rebuildNBNodeCrossings = true);
331 
333  void removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList);
334 
336  void mirrorXLeftHand();
337 
339  GNEJunction(const GNEJunction&) = delete;
340 
342  GNEJunction& operator=(const GNEJunction&) = delete;
343 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:41
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
An Element which don't belongs to GNENet but has influency in the simulation.
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
std::map< SumoXMLTag, std::vector< GNEAdditional * > > myPathAdditionalElements
map with references to path additional elements
Definition: GNEJunction.h:262
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
Definition: GNEJunction.cpp:98
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:281
void addPathGenericData(GNEGenericData *genericData)
add path demand element (used by GNEPathElement)
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
std::string getAttribute(SumoXMLAttr key) const
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
bool myColorForMissingConnections
whether this junction probably should have some connections but doesn't
Definition: GNEJunction.h:290
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:50
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
std::map< SumoXMLTag, std::vector< GNEDemandElement * > > myPathDemandElements
map with references to path demand elements
Definition: GNEJunction.h:265
void moveJunctionGeometry(const Position &pos, const bool updateEdgeBoundaries)
reposition the node at pos without updating GRID and informs the edges
void invalidateShape()
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:92
void removePathDemandElement(GNEDemandElement *demandElement)
remove path demand element (used by GNEPathElement)
GNEJunction(const GNEJunction &)=delete
Invalidated copy constructor.
bool isLogicValid()
whether this junction has a valid logic
void drawTLSIcon(const GUIVisualizationSettings &s) const
draw TLS icon
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the (child) outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:256
std::map< SumoXMLTag, std::vector< GNEGenericData * > > myPathGenericDatas
map with references to path generic data elements
Definition: GNEJunction.h:268
void removePathAdditionalElement(GNEAdditional *additionalElement)
remove path additional element (used by GNEPathElement)
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionChildren(const GUIVisualizationSettings &s) const
draw junction childs
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
void addPathAdditionalElement(GNEAdditional *additionalElement)
add path additional element (used by GNEPathElement)
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:259
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
void invalidatePathElements()
invalidate path element childs
GNECrossing * retrieveGNECrossing(NBNode::Crossing *NBNodeCrossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the (child) incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:253
const PositionVector & getJunctionShape() const
Definition: GNEJunction.cpp:86
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double myMaxDrawingSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not.
Definition: GNEJunction.h:271
GNEJunction & operator=(const GNEJunction &)=delete
Invalidated assignment operator.
Position getPositionInView() const
Returns position of hierarchical element in view.
void removePathGenericData(GNEGenericData *genericData)
remove path demand element (used by GNEPathElement)
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:287
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
bool isValid(SumoXMLAttr key, const std::string &value)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:284
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:278
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
NBNode * getNBNode() const
Return net build node.
void addPathDemandElement(GNEDemandElement *demandElement)
add path demand element (used by GNEPathElement)
NBNode * myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:250
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void checkMissingConnections()
compute whether this junction probably should have some connections but doesn't
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:66
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:275
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
bool isAttributeEnabled(SumoXMLAttr key) const
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
The popup menu of a globject.
Stores the information about how to visualize structures.
static const NBConnection InvalidConnection
Definition: NBConnection.h:124
A definition of a pedestrian crossing.
Definition: NBNode.h:129
Represents a single node (junction) during network building.
Definition: NBNode.h:66
The base class for traffic light logic definitions.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.