Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUIJunctionWrapper.h
193678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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 GUIJunctionWrapper.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Mon, 1 Jul 2003
19
///
20
// Holds geometrical values for a junction
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <utility>
27
#include <utils/geom/PositionVector.h>
28
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
29
#include <utils/gui/globjects/GUIGlObject.h>
30
#include <utils/gui/globjects/GUIPolygon.h>
31
32
33
// ===========================================================================
34
// class declarations
35
// ===========================================================================
36
class MSNet;
37
class MSJunction;
38
#ifdef HAVE_OSG
39
namespace osg {
40
class Geometry;
41
}
42
#endif
43
44
45
// ===========================================================================
46
// class definitions
47
// ===========================================================================
48
/**
49
* @class GUIJunctionWrapper
50
*
51
* As MSJunctions do not have a graphical representation but a complex
52
* inheritance tree, this class is used to encapsulate the geometry of an
53
* abstract junction and to be used as a gl-object.
54
*
55
* In the case the represented junction's shape is empty, the boundary
56
* is computed using the junction's position to which an offset of 1m to each
57
* side is added.
58
*/
59
class GUIJunctionWrapper : public GUIGlObject {
60
public:
61
/** @brief Constructor
62
* @param[in] junction The represented junction
63
*/
64
GUIJunctionWrapper(MSJunction& junction, const std::string& tllID);
65
66
67
/// @brief Destructor
68
virtual ~GUIJunctionWrapper();
69
70
71
72
/// @name inherited from GUIGlObject
73
//@{
74
75
/** @brief Returns an own popup-menu
76
*
77
* @param[in] app The application needed to build the popup-menu
78
* @param[in] parent The parent window needed to build the popup-menu
79
* @return The built popup-menu
80
* @see GUIGlObject::getPopUpMenu
81
*/
82
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
83
84
/** @brief Returns an own parameter window
85
*
86
* @param[in] app The application needed to build the parameter window
87
* @param[in] parent The parent window needed to build the parameter window
88
* @return The built parameter window
89
* @see GUIGlObject::getParameterWindow
90
*/
91
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
92
93
/// @brief return exaggeration associated with this GLObject
94
double getExaggeration(const GUIVisualizationSettings& s) const override;
95
96
/** @brief Returns the boundary to which the view shall be centered in order to show the object
97
*
98
* @return The boundary the object is within
99
* @see GUIGlObject::getCenteringBoundary
100
*/
101
Boundary getCenteringBoundary() const override;
102
103
/// @brief Returns the value for generic parameter 'name' or ''
104
const std::string getOptionalName() const override;
105
106
/** @brief Draws the object
107
* @param[in] s The settings for the current view (may influence drawing)
108
* @see GUIGlObject::drawGL
109
*/
110
void drawGL(const GUIVisualizationSettings& s) const override;
111
//@}
112
113
/** @brief Returns the boundary of the junction
114
* @return This junction's boundary
115
*/
116
Boundary getBoundary() const {
117
return myBoundary;
118
}
119
120
/// @brief whether this is an inner junction (a waiting spot for crossing a "real" junction)
121
bool isInternal() const {
122
return myIsInternal;
123
}
124
125
/** @brief Returns the represented junction
126
* @return The junction itself
127
*/
128
const MSJunction& getJunction() const {
129
return myJunction;
130
}
131
132
133
#ifdef HAVE_OSG
134
void setGeometry(osg::Geometry* geom) {
135
myGeom = geom;
136
}
137
138
void updateColor(const GUIVisualizationSettings& s);
139
#endif
140
141
private:
142
double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
143
144
private:
145
/// @brief A reference to the represented junction
146
MSJunction& myJunction;
147
148
/// @brief An object that stores the shape and its tesselation
149
mutable TesselatedPolygon myTesselation;
150
mutable double myExaggeration;
151
152
/// @brief The maximum size (in either x-, or y-dimension) for determining whether to draw or not
153
double myMaxSize;
154
155
/// @brief The represented junction's boundary
156
Boundary myBoundary;
157
158
/// @brief whether this wraps an instance of MSInternalJunction
159
bool myIsInternal;
160
161
/// @brief whether this junction has only waterways as incoming and outgoing edges
162
bool myAmWaterway;
163
/// @brief whether this junction has only railways as incoming and outgoing edges
164
bool myAmRailway;
165
/// @brief whether this junction has only airways as incoming and outgoing edges
166
bool myAmAirway;
167
168
/// @brief the associated traffic light or ""
169
const std::string myTLLID;
170
171
#ifdef HAVE_OSG
172
osg::Geometry* myGeom;
173
#endif
174
175
176
private:
177
/// @brief Invalidated copy constructor.
178
GUIJunctionWrapper(const GUIJunctionWrapper&);
179
180
/// @brief Invalidated assignment operator.
181
GUIJunctionWrapper& operator=(const GUIJunctionWrapper&);
182
183
};
184
185