Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/shapes/Shape.h
193759 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2012-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 Shape.h
15
/// @author Jakob Erdmann
16
/// @author Michael Behrisch
17
/// @date Oct 2012
18
///
19
// A 2D- or 3D-Shape
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <string>
25
#include <map>
26
#include <utils/common/Named.h>
27
#include <utils/common/RGBColor.h>
28
#include <utils/common/Parameterised.h>
29
30
31
// ===========================================================================
32
// class definitions
33
// ===========================================================================
34
/**
35
* @class Shape
36
* @brief A 2D- or 3D-Shape
37
*/
38
class Shape : public Named {
39
public:
40
/// @name default shape's values
41
/// @{
42
static const std::string DEFAULT_TYPE;
43
static const double DEFAULT_LAYER;
44
static const double DEFAULT_LINEWIDTH;
45
static const double DEFAULT_LAYER_POI;
46
static const double DEFAULT_ANGLE;
47
static const std::string DEFAULT_IMG_FILE;
48
static const double DEFAULT_IMG_WIDTH;
49
static const double DEFAULT_IMG_HEIGHT;
50
static const std::string DEFAULT_NAME;
51
static const Parameterised::Map DEFAULT_PARAMETERS;
52
/// @}
53
54
/** @brief default consructor
55
* @param[in] id The name of the shape
56
*/
57
Shape(const std::string& id);
58
59
/** @brief Constructor
60
* @param[in] id The name of the shape
61
* @param[in] type The (abstract) type of the shape
62
* @param[in] color The color of the shape
63
* @param[in] layer The layer of the shape
64
* @param[in] angle The rotation of the shape in navigational degrees
65
* @param[in] imgFile The raster image of the shape
66
* @param[in] name shape name
67
*/
68
Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
69
double angle, const std::string& imgFile, const std::string& name);
70
71
/// @brief Destructor
72
virtual ~Shape();
73
74
/**@brief write shape attributes in a xml file
75
* @param[in] device device in which write parameters of shape
76
*/
77
void writeShapeAttributes(OutputDevice& device, const RGBColor& defaultColor, const double defaultLayer) const;
78
79
/// @name Getter
80
/// @{
81
82
/** @brief Returns the (abstract) type of the Shape
83
* @return The Shape's (abstract) type
84
*/
85
const std::string& getShapeType() const;
86
87
/** @brief Returns the color of the Shape
88
* @return The Shape's color
89
*/
90
const RGBColor& getShapeColor() const;
91
92
/** @brief Returns the layer of the Shape
93
* @return The Shape's layer
94
*/
95
double getShapeLayer() const;
96
97
/** @brief Returns the angle of the Shape in navigational degrees
98
* @return The Shape's rotation angle
99
*/
100
double getShapeNaviDegree() const;
101
102
/** @brief Returns the imgFile of the Shape
103
* @return The Shape's rotation imgFile
104
*/
105
const std::string& getShapeImgFile() const;
106
107
/// @brief Returns the name of the Shape
108
const std::string& getShapeName() const;
109
110
/// @}
111
112
/// @name Setter
113
/// @{
114
115
/** @brief Sets a new type
116
* @param[in] type The new type to use
117
*/
118
void setShapeType(const std::string& type);
119
120
/** @brief Sets a new color
121
* @param[in] col The new color to use
122
*/
123
void setShapeColor(const RGBColor& col);
124
125
/** @brief Sets a new alpha value
126
* @param[in] alpha The new value to use
127
*/
128
void setShapeAlpha(unsigned char alpha);
129
130
/** @brief Sets a new layer
131
* @param[in] layer The new layer to use
132
*/
133
void setShapeLayer(const double layer);
134
135
/** @brief Sets a new angle in navigational degrees
136
* @param[in] layer The new angle to use
137
*/
138
virtual void setShapeNaviDegree(const double angle);
139
140
/** @brief Sets a new imgFile
141
* @param[in] imgFile The new imgFile to use
142
*/
143
void setShapeImgFile(const std::string& imgFile);
144
145
/// @brief Sets a new shape name
146
void setShapeName(const std::string& name);
147
148
/// @}
149
150
private:
151
/// @brief The type of the Shape
152
std::string myType;
153
154
/// @brief The color of the Shape
155
RGBColor myColor;
156
157
/// @brief The layer of the Shape
158
double myLayer;
159
160
/// @brief The angle of the Shape
161
double myNaviDegreeAngle;
162
163
/// @brief The img file (include path)
164
std::string myImgFile;
165
166
/// @brief shape name
167
std::string myName;
168
};
169
170