Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/globjects/GUIShapeContainer.h
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2009-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 GUIShapeContainer.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @author Jakob Erdmann
18
/// @date 08.10.2009
19
///
20
// Storage for geometrical objects extended by mutexes
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <utils/foxtools/fxheader.h>
26
#include <utils/shapes/ShapeContainer.h>
27
#include <utils/gui/globjects/GUIGlObject.h>
28
#include <utils/gui/globjects/GUIPolygon.h>
29
30
// ===========================================================================
31
// class declarations
32
// ===========================================================================
33
class SUMORTree;
34
class Position;
35
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
/**
41
* @class GUIShapeContainer
42
* @brief Storage for geometrical objects extended by mutexes
43
* @see ShapeContainer
44
*/
45
class GUIShapeContainer : public ShapeContainer {
46
public:
47
/// @brief Constructor
48
GUIShapeContainer(SUMORTree& vis);
49
50
/// @brief Destructor
51
virtual ~GUIShapeContainer();
52
53
/** @brief Builds a polygon using the given values and adds it to the container
54
* @param[in] id The name of the polygon
55
* @param[in] type The (abstract) type of the polygon
56
* @param[in] color The color of the polygon
57
* @param[in] layer The layer of the polygon
58
* @param[in] angle The rotation of the polygon
59
* @param[in] imgFile The raster image of the polygon
60
* @param[in] shape The shape of the polygon
61
* @param[in] geo specify if shape was loaded as GEO coordinate
62
* @param[in] fill Whether the polygon shall be filled
63
* @param[in] lineWidth Line width when drawing unfilled polygon
64
* @return whether the polygon could be added
65
*/
66
virtual bool addPolygon(const std::string& id, const std::string& type, const RGBColor& color, double layer,
67
double angle, const std::string& imgFile, const PositionVector& shape, bool geo,
68
bool fill, double lineWidth, bool ignorePruning = false,
69
const std::string& name = Shape::DEFAULT_NAME) override;
70
71
/// @brief Adds dynamics to the given Polygon, @see ShapeContainer addPolygonDynamics
72
/// @note Supplies the visualisation RTree to the dynamics for updating the object when moving
73
PolygonDynamics* addPolygonDynamics(double simtime,
74
std::string polyID,
75
SUMOTrafficObject* trackedObject,
76
const std::vector<double>& timeSpan,
77
const std::vector<double>& alphaSpan,
78
bool looped,
79
bool rotate) override;
80
81
/// @brief Update PolygonDynamics, @see ShapeContainer
82
/// @note Locks the visualisation RTree
83
SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics* pd) override;
84
85
/** @brief Builds a POI using the given values and adds it to the container
86
* @param[in] id The name of the POI
87
* @param[in] type The (abstract) type of the POI
88
* @param[in] color The color of the POI
89
* @param[in] pos The position of the POI
90
* @param[in[ geo use GEO coordinates (lon/lat)
91
* @param[in] lane The Lane in which this POI is placed
92
* @param[in] posOverLane The position over Lane
93
* @param[in] friendlyPos enable or disable friendly position over lane
94
* @param[in] posLat The position lateral over Lane
95
* @param[in] icon The icon of the POI
96
* @param[in] layer The layer of the POI
97
* @param[in] angle The rotation of the POI
98
* @param[in] imgFile The raster image of the POI
99
* @param[in] width The width of the POI image
100
* @param[in] height The height of the POI image
101
* @return whether the poi could be added
102
*/
103
virtual bool addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
104
const std::string& lane, double posOverLane, bool friendlyPos, double posLat, const std::string& icon,
105
double layer, double angle, const std::string& imgFile, double width, double height,
106
bool ignorePruning = false) override;
107
108
/** @brief Removes a polygon from the container
109
* @param[in] id The id of the polygon
110
* @return Whether the polygon could be removed
111
*/
112
virtual bool removePolygon(const std::string& id, bool useLock = true) override;
113
114
/** @brief Removes a PoI from the container
115
* @param[in] id The id of the PoI
116
* @return Whether the poi could be removed
117
*/
118
virtual bool removePOI(const std::string& id) override;
119
120
/** @brief Assigns a new position to the named PoI
121
* @param[in] id The id of the PoI to move
122
* @param[in] pos The PoI's new position
123
*/
124
virtual void movePOI(const std::string& id, const Position& pos) override;
125
126
/** @brief Assigns a shape to the named polygon
127
* @param[in] id The id of the polygon to reshape
128
* @param[in] shape The polygon's new shape
129
*/
130
virtual void reshapePolygon(const std::string& id, const PositionVector& shape) override;
131
132
/// @brief Returns the gl-ids of all pois
133
std::vector<GUIGlID> getPOIIds() const;
134
135
/// @brief Returns the gl-ids of all polygons
136
std::vector<GUIGlID> getPolygonIDs() const;
137
138
/// @brief allow replacement
139
void allowReplacement();
140
141
inline const std::set<std::string>& getInactiveTypes(void) const {
142
return myInactivePolygonTypes;
143
};
144
145
/// @brief Sets polygon types that define which one is active or not.
146
/// @param inactivePolygonTypes The whole set of inactive polygon types.
147
void setInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);
148
149
/// @brief Adds new polygon types to the set of inactive ones.
150
/// @param inactivePolygonTypes Some set of inactive polygon types.
151
void addInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);
152
153
/// @brief Remove some polygon types that were deemed as inactive.
154
/// @param inactivePolygonTypes Some set of inactive polygon types.
155
void removeInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);
156
157
private:
158
/// @brief The mutex for adding/removing operations
159
mutable FXMutex myLock;
160
161
/// @brief The RTree structure to add and remove visualization elements
162
SUMORTree& myVis;
163
164
/// @brief whether existing ids shall be replaced
165
bool myAllowReplacement;
166
167
/// @brief The polygon types that define the inactive polygons.
168
std::set<std::string> myInactivePolygonTypes;
169
170
/// @brief Determine which polygons are active based on their type.
171
void computeActivePolygons(void);
172
};
173
174