Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/div/GUIDottedGeometry.h
169684 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 GUIDottedGeometry.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2021
17
///
18
// File for dotted geometry classes and functions
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/geom/PositionVector.h>
24
#include <utils/gui/settings/GUIVisualizationSettings.h>
25
26
// ===========================================================================
27
// class definitions
28
// ===========================================================================
29
30
class GUIDottedGeometry {
31
32
public:
33
/// @enum for dotted cotour type
34
enum class DottedContourType {
35
INSPECT, // Inspecting element
36
REMOVE, // Mouse over element to remove
37
SELECT, // Mouse over element to select
38
MOVE, // Mouse over element to move
39
FRONT, // Element marked as "front element"
40
OVER, // Mouse over element (orange)
41
FROM, // Element marked as from (green)
42
TO, // Element marked as to (magenta)
43
RELATED, // Element marked as related (cyan)
44
WALKINGAREA, // Used if we're drawing walking areas in contour mode
45
NOTHING
46
};
47
48
/// @brief class for pack all variables related with GUIDottedGeometry color
49
class DottedGeometryColor {
50
51
public:
52
/// @brief constructor
53
DottedGeometryColor();
54
55
/// @brief get inspected color (and change flag)
56
const RGBColor getColor(const GUIVisualizationSettings& settings, DottedContourType type);
57
58
/// @brief change color
59
void changeColor();
60
61
/// @brief rest Dotted Geometry Color
62
void reset();
63
64
private:
65
/// @brief flag to get color
66
bool myColorFlag;
67
68
/// @brief Invalidated assignment operator
69
DottedGeometryColor& operator=(const DottedGeometryColor& other) = delete;
70
};
71
72
/// @brief dotted geometry segment
73
struct Segment {
74
75
/// @brief default constructor
76
Segment();
77
78
/// @brief constructor for a given shape
79
Segment(PositionVector newShape);
80
81
/// @brief shape
82
PositionVector shape;
83
84
/// @brief rotations
85
std::vector<double> rotations;
86
87
/// @brief lengths
88
std::vector<double> lengths;
89
};
90
91
/// @brief constructor
92
GUIDottedGeometry();
93
94
/// @brief constructor for shapes
95
GUIDottedGeometry(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
96
PositionVector shape, const bool closeShape);
97
98
/// @brief update GUIDottedGeometry (using lane shape)
99
void updateDottedGeometry(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
100
const PositionVector& laneShape);
101
102
/// @brief update GUIDottedGeometry (using shape)
103
void updateDottedGeometry(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
104
PositionVector shape, const bool closeShape);
105
106
/// @brief draw dotted geometry
107
void drawDottedGeometry(const GUIVisualizationSettings& s, GUIDottedGeometry::DottedContourType type,
108
DottedGeometryColor& dottedGeometryColor, const double lineWidth, const bool addOffset) const;
109
110
/// @brief draw innen geometry
111
void drawInnenGeometry(const double lineWidth) const;
112
113
/// @brief move shape to side
114
void moveShapeToSide(const double value);
115
116
/// @brief get front position
117
Position getFrontPosition() const;
118
119
/// @brief get back position
120
Position getBackPosition() const;
121
122
/// @brief get simple shape (the shape without resampling)
123
const PositionVector& getUnresampledShape() const;
124
125
/// @brief clear dotted geometry
126
void clearDottedGeometry();
127
128
private:
129
/// @brief calculate shape rotations and lengths
130
void calculateShapeRotationsAndLengths();
131
132
/// @brief shape without resampling
133
PositionVector myUnresampledShape;
134
135
/// @brief dotted element shape (note: It's centered in 0,0 due scaling)
136
std::vector<GUIDottedGeometry::Segment> myDottedGeometrySegments;
137
};
138
139