Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/GNEContour.h
169678 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 GNEContour.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Aug 2023
17
///
18
// class used for show contour elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/gui/div/GUIDottedGeometry.h>
24
25
// ===========================================================================
26
// class declaration
27
// ===========================================================================
28
29
class GNENet;
30
class GNEEdge;
31
class GNESegment;
32
class GNEAttributeCarrier;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNEContour {
39
40
public:
41
/// @brief Constructor
42
GNEContour();
43
44
/// @brief destructor
45
~GNEContour();
46
47
/// @brief get contour boundary
48
Boundary getContourBoundary() const;
49
50
/// @brief void clear contour
51
void clearContour() const;
52
53
/// @brief calculate contours
54
/// @{
55
56
/// @brief calculate contour (for closed shapes)
57
void calculateContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
58
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
59
const double scale, const GUIGlObject* boundaryParent,
60
const bool addToSelectedObjects = true) const;
61
62
/// @brief calculate contour extruded (used in elements formed by a central shape)
63
void calculateContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
64
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
65
const double extrusionWidth, const double scale, const bool closeFirstExtrem,
66
const bool closeLastExtrem, const double offset, const GNESegment* segment,
67
const GUIGlObject* boundaryParent, const bool addToSelectedObjects = true) const;
68
69
/// @brief calculate contour (for rectangled elements)
70
void calculateContourRectangleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
71
const GUIGlObject* glObject, const Position& pos, const double width, const double height,
72
const double layer, const double offsetX, const double offsetY, const double rot,
73
const double scale, const GUIGlObject* boundaryParent) const;
74
75
/// @brief calculate contour (circle elements)
76
void calculateContourCircleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
77
const GUIGlObject* glObject, const Position& pos, double radius, const double layer,
78
const double scale, const GUIGlObject* boundaryParent) const;
79
80
/// @brief calculate contour edge
81
void calculateContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
82
const GNEEdge* edge, const GUIGlObject* elementToRegister, const double layer,
83
const bool closeFirstExtrem, const bool closeLastExtrem) const;
84
85
/// @brief calculate contour between two consecutive edges
86
void calculateContourEdges(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
87
const GNEEdge* fromEdge, const GNEEdge* toEdge) const;
88
89
/// @brief calculate contour for first geometry point
90
void calculateContourFirstGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
91
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
92
const double radius, const double scale) const;
93
94
/// @brief calculate contour for last geometry point
95
void calculateContourLastGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
96
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
97
const double radius, const double scale) const;
98
99
/// @brief calculate contour for middle geometry point
100
void calculateContourMiddleGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
101
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
102
const double radius, const double scale) const;
103
104
/// @brief calculate contour for all geometry points
105
void calculateContourAllGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
106
const GUIGlObject* glObject, const PositionVector& shape, const double layer,
107
const double radius, const double scale, const bool calculatePosOverShape) const;
108
109
/// @brief calculate contour for edge geometry points
110
void calculateContourEdgeGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
111
const GNEEdge* edge, const double radius, const bool calculatePosOverShape,
112
const bool firstExtrem, const bool lastExtrem) const;
113
/// @}
114
115
/// @brief drawing contour functions
116
/// @{
117
118
/// @brief check if draw path contours (if we're inspecting/selecting/deleting a path, we need to draw all path elements)
119
bool checkDrawPathContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
120
const GNEAttributeCarrier* AC) const;
121
122
/// @brief draw dotted contours (basics, select, delete, inspect...)
123
bool drawDottedContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
124
const GNEAttributeCarrier* AC, const double lineWidth, const bool addOffset) const;
125
126
/// @brief draw dotted contour for geometry points
127
void drawDottedContourGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
128
const GNEAttributeCarrier* AC, const PositionVector& shape, const double radius,
129
const double scale, const double lineWidth) const;
130
131
/// @brief draw innen contour (currently used only in walkingAreas)
132
void drawInnenContourClosed(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
133
const PositionVector& shape, const double scale, const double lineWidth) const;
134
135
/// @brief draw dotted contour (call out of this class only in special cases, for example in WalkingAreas)
136
bool drawDottedContour(const GUIVisualizationSettings& s, GUIDottedGeometry::DottedContourType type,
137
const double lineWidth, const bool addOffset) const;
138
/// @}
139
140
private:
141
/// @brief dotted geometries
142
std::vector<GUIDottedGeometry>* myDottedGeometries;
143
144
/// @brief contourboundary
145
Boundary* myContourBoundary;
146
147
/// @brief calculated shape
148
PositionVector* myCalculatedShape;
149
150
/// @brief dotted geometry color
151
static GUIDottedGeometry::DottedGeometryColor myDottedGeometryColor;
152
153
/// @name build contour functions
154
/// @{
155
156
/// @brief build contour around closed shape (ej. polygon)
157
void buildContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
158
const PositionVector& shape, const double scale) const;
159
160
/// @brief build contour around extruded shape (ej. lane)
161
void buildContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
162
const PositionVector& shape, const double extrusionWidth, const double scale,
163
const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const;
164
165
/// @brief build contour around rectangle
166
void buildContourRectangle(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
167
const Position& pos, const double width, const double height, const double offsetX,
168
const double offsetY, const double rot, const double scale) const;
169
170
/// @brief build contour aorund circle
171
void buildContourCircle(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
172
const Position& pos, double radius, const double scale) const;
173
174
/// @brief build contour around edge
175
void buildContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
176
const GNEEdge* edge, const bool closeFirstExtrem, const bool closeLastExtrem) const;
177
178
/// @brief build contour between two from-to edgeds
179
void buildContourEdges(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
180
const GNEEdge* fromEdge, const GNEEdge* toEdge) const;
181
/// @}
182
183
/// @brief Invalidated copy constructor.
184
GNEContour(const GNEContour&) = delete;
185
186
/// @brief Invalidated assignment operator
187
GNEContour& operator=(const GNEContour& src) = delete;
188
};
189
190