Eclipse SUMO - Simulation of Urban MObility
GNECrossing.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 Inner Lanes (used when editing traffic lights)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 #include "GNENetworkElement.h"
23 #include <netbuild/NBNode.h>
24 
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
30 class PositionVector;
31 class GNEJunction;
32 class GNEEdge;
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
45 
46 public:
48  GNECrossing(GNENet* net);
49 
54  GNECrossing(GNEJunction* parentJunction, std::vector<NBEdge*> edges);
55 
57  ~GNECrossing();
58 
60  bool isNetworkElementValid() const;
61 
63  std::string getNetworkElementProblem() const;
64 
67 
69  const PositionVector& getCrossingShape() const;
70 
72  void updateGeometry();
73 
76 
78 
81 
83  bool checkDrawFromContour() const;
84 
86  bool checkDrawToContour() const;
87 
89  bool checkDrawRelatedContour() const;
90 
92  bool checkDrawOverContour() const;
93 
95  bool checkDrawDeleteContour() const;
96 
98  bool checkDrawSelectContour() const;
99 
101  bool checkDrawMoveContour() const;
102 
104 
109 
111  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
113 
116 
118  const std::vector<NBEdge*>& getCrossingEdges() const;
119 
122 
125 
133 
136 
138  void updateCenteringBoundary(const bool updateGrid);
139 
144  void drawGL(const GUIVisualizationSettings& s) const;
145 
147  void deleteGLObject();
148 
150  void updateGLObject();
151 
153 
156  /* @brief method for getting the Attribute of an XML key
157  * @param[in] key The attribute key
158  * @return string with the value associated to key
159  */
160  std::string getAttribute(SumoXMLAttr key) const;
161 
162  /* @brief method for getting the Attribute of an XML key in Position format
163  * @param[in] key The attribute key
164  * @return position with the value associated to key
165  */
167 
168  /* @brief method for setting the attribute and letting the object perform additional changes
169  * @param[in] key The attribute key
170  * @param[in] value The new value
171  * @param[in] undoList The undoList on which to register changes
172  */
173  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
174 
175  /* @brief method for checking if the key and their correspond attribute are valids
176  * @param[in] key The attribute key
177  * @param[in] value The value associated to key key
178  * @return true if the value is valid, false in other case
179  */
180  bool isValid(SumoXMLAttr key, const std::string& value);
181 
182  /* @brief method for check if the value for certain attribute is set
183  * @param[in] key The attribute key
184  */
185  bool isAttributeEnabled(SumoXMLAttr key) const;
186 
188 
190  const Parameterised::Map& getACParametersMap() const;
191 
193  bool checkEdgeBelong(GNEEdge* edges) const;
194 
196  bool checkEdgeBelong(const std::vector<GNEEdge*>& edges) const;
197 
198 protected:
201 
203  std::vector<NBEdge*> myCrossingEdges;
204 
207 
210 
211 private:
213  bool checkDrawCrossing(const GUIVisualizationSettings& s) const;
214 
217  const NBNode::Crossing* crossing, const double width, const double exaggeration) const;
218 
220  RGBColor getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;
221 
223  void drawCrossingDetailed(const double width, const double exaggeration) const;
224 
227  const double width, const double exaggeration) const;
228 
230  void setAttribute(SumoXMLAttr key, const std::string& value);
231 
233  void setMoveShape(const GNEMoveResult& moveResult);
234 
236  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
237 
239  void drawTLSLinkNo(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;
240 
242  GNECrossing(const GNECrossing&) = delete;
243 
245  GNECrossing& operator=(const GNECrossing&) = delete;
246 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:44
std::string getAttribute(SumoXMLAttr key) const
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
bool checkDrawCrossing(const GUIVisualizationSettings &s) const
check if draw crossing
std::vector< NBEdge * > myCrossingEdges
Crossing Edges (It works as ID because a junction can only ONE Crossing with the same edges)
Definition: GNECrossing.h:203
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const Parameterised::Map & getACParametersMap() const
get parameters map
bool isNetworkElementValid() const
check if current network element is valid to be written into XML
Definition: GNECrossing.cpp:67
void deleteGLObject()
delete element
GNECrossing(GNENet *net)
default constructor
Definition: GNECrossing.cpp:40
void updateGeometry()
update pre-computed geometry information
Definition: GNECrossing.cpp:86
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGLObject()
update GLObject (geometry, ID, etc.)
void drawCrossing(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const NBNode::Crossing *crossing, const double width, const double exaggeration) const
draw crossing
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNECrossing.cpp:94
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const NBNode::Crossing *crossing) const
draw TLS Link Number
bool checkDrawToContour() const
check if draw from contour (magenta)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
bool checkEdgeBelong(GNEEdge *edges) const
return true if a edge belongs to crossing's edges
GNEJunction * myParentJunction
the parent junction of this crossing
Definition: GNECrossing.h:200
const std::vector< NBEdge * > & getCrossingEdges() const
get crossingEdges
PositionVector getAttributePositionVector(SumoXMLAttr key) const
GUIGeometry myCrossingGeometry
crossing geometry
Definition: GNECrossing.h:206
bool isAttributeEnabled(SumoXMLAttr key) const
bool checkDrawSelectContour() const
check if draw select contour (blue)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool checkDrawFromContour() const
check if draw from contour (green)
GNECrossing(const GNECrossing &)=delete
Invalidated copy constructor.
GNEJunction * getParentJunction() const
get parent Junction
GNECrossing & operator=(const GNECrossing &)=delete
Invalidated assignment operator.
NBNode::Crossing * getNBCrossing() const
get referente to NBode::Crossing
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
std::string getNetworkElementProblem() const
return a string with the current network element problem
Definition: GNECrossing.cpp:73
const PositionVector & getCrossingShape() const
get Crossing shape
Definition: GNECrossing.cpp:79
bool checkDrawOverContour() const
check if draw over contour (orange)
~GNECrossing()
Destructor.
Definition: GNECrossing.cpp:59
void calculateCrossingContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double width, const double exaggeration) const
calculate contour
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
NBNode::Crossing * myTemplateNBCrossing
template NBCrossing
Definition: GNECrossing.h:209
RGBColor getCrossingColor(const GUIVisualizationSettings &s, const NBNode::Crossing *crossing) const
get crossing color
void drawCrossingDetailed(const double width, const double exaggeration) const
draw crossing with hight detail
bool isValid(SumoXMLAttr key, const std::string &value)
GNEMoveOperation * getMoveOperation()
get move operation
bool checkDrawMoveContour() const
check if draw move contour (red)
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
The popup menu of a globject.
Stores the information about how to visualize structures.
A definition of a pedestrian crossing.
Definition: NBNode.h:135
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.