Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/network/GNECrossing.h
185790 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNECrossing.h
15
/// @author Jakob Erdmann
16
/// @date June 2011
17
///
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
// class declarations
27
// ===========================================================================
28
29
class GNEEdge;
30
class GNEJunction;
31
class GNEMoveElementCrossing;
32
class GUIGLObjectPopupMenu;
33
class PositionVector;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
40
class GNECrossing : public GNENetworkElement {
41
42
public:
43
/// @brief default constructor
44
GNECrossing(GNENet* net);
45
46
/**@brief Constructor
47
* @param[in] junction GNEJunction in which this crossing is placed
48
* @param[in] crossing Node::Crossing
49
*/
50
GNECrossing(GNEJunction* junction, std::vector<NBEdge*> edges);
51
52
/// @brief Destructor
53
~GNECrossing();
54
55
/// @brief methods to retrieve the elements linked to this crossing
56
/// @{
57
58
/// @brief get GNEMoveElement associated with this crossing
59
GNEMoveElement* getMoveElement() const override;
60
61
/// @brief get parameters associated with this crossing
62
Parameterised* getParameters() override;
63
64
/// @brief get parameters associated with this crossing (constant)
65
const Parameterised* getParameters() const override;
66
67
/// @}
68
69
/// @brief check if current network element is valid to be written into XML
70
bool isNetworkElementValid() const override;
71
72
/// @brief return a string with the current network element problem
73
std::string getNetworkElementProblem() const override;
74
75
/// @name Functions related with geometry of element
76
/// @{
77
78
/// @brief get Crossing shape
79
const PositionVector& getCrossingShape() const;
80
81
/// @brief update pre-computed geometry information
82
void updateGeometry() override;
83
84
/// @brief Returns position of hierarchical element in view
85
Position getPositionInView() const;
86
87
/// @}
88
89
/// @name Function related with contour drawing
90
/// @{
91
92
/// @brief check if draw from contour (green)
93
bool checkDrawFromContour() const override;
94
95
/// @brief check if draw from contour (magenta)
96
bool checkDrawToContour() const override;
97
98
/// @brief check if draw related contour (cyan)
99
bool checkDrawRelatedContour() const override;
100
101
/// @brief check if draw over contour (orange)
102
bool checkDrawOverContour() const override;
103
104
/// @brief check if draw delete contour (pink/white)
105
bool checkDrawDeleteContour() const override;
106
107
/// @brief check if draw delete contour small (pink/white)
108
bool checkDrawDeleteContourSmall() const override;
109
110
/// @brief check if draw select contour (blue)
111
bool checkDrawSelectContour() const override;
112
113
/// @brief check if draw move contour (red)
114
bool checkDrawMoveContour() const override;
115
116
/// @}
117
118
/// @brief get crossingEdges
119
const std::vector<NBEdge*>& getCrossingEdges() const;
120
121
///@brief get referente to NBode::Crossing
122
NBNode::Crossing* getNBCrossing() const;
123
124
/// @name inherited from GUIGlObject
125
/// @{
126
/**@brief Returns an own popup-menu
127
*
128
* @param[in] app The application needed to build the popup-menu
129
* @param[in] parent The parent window needed to build the popup-menu
130
* @return The built popup-menu
131
* @see GUIGlObject::getPopUpMenu
132
*/
133
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
134
135
/// @brief Returns the boundary to which the view shall be centered in order to show the object
136
Boundary getCenteringBoundary() const override;
137
138
/// @brief update centering boundary (implies change in RTREE)
139
void updateCenteringBoundary(const bool updateGrid);
140
141
/**@brief Draws the object
142
* @param[in] s The settings for the current view (may influence drawing)
143
* @see GUIGlObject::drawGL
144
*/
145
void drawGL(const GUIVisualizationSettings& s) const override;
146
147
/// @brief delete element
148
void deleteGLObject() override;
149
150
/// @brief update GLObject (geometry, ID, etc.)
151
void updateGLObject() override;
152
153
/// @}
154
155
/// @name inherited from GNEAttributeCarrier
156
/// @{
157
/* @brief method for getting the Attribute of an XML key
158
* @param[in] key The attribute key
159
* @return string with the value associated to key
160
*/
161
std::string getAttribute(SumoXMLAttr key) const override;
162
163
/* @brief method for getting the Attribute of an XML key in double format
164
* @param[in] key The attribute key
165
* @return double with the value associated to key
166
*/
167
double getAttributeDouble(SumoXMLAttr key) const override;
168
169
/* @brief method for getting the Attribute of an XML key in position format
170
* @param[in] key The attribute key
171
* @return position with the value associated to key
172
*/
173
Position getAttributePosition(SumoXMLAttr key) const override;
174
175
/* @brief method for getting the Attribute of an XML key in Position format
176
* @param[in] key The attribute key
177
* @return position with the value associated to key
178
*/
179
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
180
181
/* @brief method for setting the attribute and letting the object perform additional changes
182
* @param[in] key The attribute key
183
* @param[in] value The new value
184
* @param[in] undoList The undoList on which to register changes
185
*/
186
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
187
188
/* @brief method for checking if the key and their correspond attribute are valids
189
* @param[in] key The attribute key
190
* @param[in] value The value associated to key key
191
* @return true if the value is valid, false in other case
192
*/
193
bool isValid(SumoXMLAttr key, const std::string& value) override;
194
195
/* @brief method for check if the value for certain attribute is set
196
* @param[in] key The attribute key
197
*/
198
bool isAttributeEnabled(SumoXMLAttr key) const override;
199
200
/// @}
201
202
/// @brief return true if a edge belongs to crossing's edges
203
bool checkEdgeBelong(GNEEdge* edges) const;
204
205
/// @brief return true if a edge of a vector of edges belongs to crossing's edges
206
bool checkEdgeBelong(const std::vector<GNEEdge*>& edges) const;
207
208
protected:
209
/// @brief move element crossing
210
GNEMoveElementCrossing* myMoveElementCrossing = nullptr;
211
212
/// @brief Crossing Edges (It works as ID because a junction can only ONE Crossing with the same edges)
213
std::vector<NBEdge*> myCrossingEdges;
214
215
/// @brief crossing geometry
216
GUIGeometry myCrossingGeometry;
217
218
/// @brief template NBCrossing
219
NBNode::Crossing* myTemplateNBCrossing;
220
221
private:
222
/// @brief check if draw crossing
223
bool checkDrawCrossing(const GUIVisualizationSettings& s) const;
224
225
/// @brief draw crossing
226
void drawCrossing(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
227
const NBNode::Crossing* crossing, const double width, const double exaggeration) const;
228
229
/// @brief get crossing color
230
RGBColor getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;
231
232
/// @brief draw crossing with hight detail
233
void drawCrossingDetailed(const double width, const double exaggeration) const;
234
235
/// @brief calculate contour
236
void calculateCrossingContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
237
const double width, const double exaggeration) const;
238
239
/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
240
void setAttribute(SumoXMLAttr key, const std::string& value) override;
241
242
/// @brief draw TLS Link Number
243
void drawTLSLinkNo(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;
244
245
/// @brief Invalidated copy constructor.
246
GNECrossing(const GNECrossing&) = delete;
247
248
/// @brief Invalidated assignment operator.
249
GNECrossing& operator=(const GNECrossing&) = delete;
250
};
251
252