Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUIJunctionWrapper.h
169666 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 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,
83
GUISUMOAbstractView& parent);
84
85
/** @brief Returns an own parameter window
86
*
87
* @param[in] app The application needed to build the parameter window
88
* @param[in] parent The parent window needed to build the parameter window
89
* @return The built parameter window
90
* @see GUIGlObject::getParameterWindow
91
*/
92
GUIParameterTableWindow* getParameterWindow(
93
GUIMainWindow& app, GUISUMOAbstractView& parent);
94
95
/// @brief return exaggeration associated with this GLObject
96
double getExaggeration(const GUIVisualizationSettings& s) const;
97
98
/** @brief Returns the boundary to which the view shall be centered in order to show the object
99
*
100
* @return The boundary the object is within
101
* @see GUIGlObject::getCenteringBoundary
102
*/
103
Boundary getCenteringBoundary() const;
104
105
/// @brief Returns the value for generic parameter 'name' or ''
106
const std::string getOptionalName() const;
107
108
/** @brief Draws the object
109
* @param[in] s The settings for the current view (may influence drawing)
110
* @see GUIGlObject::drawGL
111
*/
112
void drawGL(const GUIVisualizationSettings& s) const;
113
//@}
114
115
/** @brief Returns the boundary of the junction
116
* @return This junction's boundary
117
*/
118
Boundary getBoundary() const {
119
return myBoundary;
120
}
121
122
/// @brief whether this is an inner junction (a waiting spot for crossing a "real" junction)
123
bool isInternal() const {
124
return myIsInternal;
125
}
126
127
/** @brief Returns the represented junction
128
* @return The junction itself
129
*/
130
const MSJunction& getJunction() const {
131
return myJunction;
132
}
133
134
135
#ifdef HAVE_OSG
136
void setGeometry(osg::Geometry* geom) {
137
myGeom = geom;
138
}
139
140
void updateColor(const GUIVisualizationSettings& s);
141
#endif
142
143
private:
144
double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
145
146
private:
147
/// @brief A reference to the represented junction
148
MSJunction& myJunction;
149
150
/// @brief An object that stores the shape and its tesselation
151
mutable TesselatedPolygon myTesselation;
152
mutable double myExaggeration;
153
154
/// @brief The maximum size (in either x-, or y-dimension) for determining whether to draw or not
155
double myMaxSize;
156
157
/// @brief The represented junction's boundary
158
Boundary myBoundary;
159
160
/// @brief whether this wraps an instance of MSInternalJunction
161
bool myIsInternal;
162
163
/// @brief whether this junction has only waterways as incoming and outgoing edges
164
bool myAmWaterway;
165
/// @brief whether this junction has only railways as incoming and outgoing edges
166
bool myAmRailway;
167
/// @brief whether this junction has only airways as incoming and outgoing edges
168
bool myAmAirway;
169
170
/// @brief the associated traffic light or ""
171
const std::string myTLLID;
172
173
#ifdef HAVE_OSG
174
osg::Geometry* myGeom;
175
#endif
176
177
178
private:
179
/// @brief Invalidated copy constructor.
180
GUIJunctionWrapper(const GUIJunctionWrapper&);
181
182
/// @brief Invalidated assignment operator.
183
GUIJunctionWrapper& operator=(const GUIJunctionWrapper&);
184
185
};
186
187