Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2012-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 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 Constructor
55 : * @param[in] id The name of the shape
56 : * @param[in] type The (abstract) type of the shape
57 : * @param[in] color The color of the shape
58 : * @param[in] layer The layer of the shape
59 : * @param[in] angle The rotation of the shape in navigational degrees
60 : * @param[in] imgFile The raster image of the shape
61 : * @param[in] name shape name
62 : */
63 : Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
64 : double angle, const std::string& imgFile, const std::string& name);
65 :
66 : /// @brief Destructor
67 : virtual ~Shape();
68 :
69 : /// @name Getter
70 : /// @{
71 :
72 : /** @brief Returns the (abstract) type of the Shape
73 : * @return The Shape's (abstract) type
74 : */
75 : inline const std::string& getShapeType() const {
76 6666 : return myType;
77 : }
78 :
79 : /** @brief Returns the color of the Shape
80 : * @return The Shape's color
81 : */
82 : inline const RGBColor& getShapeColor() const {
83 33588 : return myColor;
84 : }
85 :
86 : /** @brief Returns the layer of the Shape
87 : * @return The Shape's layer
88 : */
89 : inline double getShapeLayer() const {
90 39243 : return myLayer;
91 : }
92 :
93 : /** @brief Returns the angle of the Shape in navigational degrees
94 : * @return The Shape's rotation angle
95 : */
96 : inline double getShapeNaviDegree() const {
97 35654 : return myNaviDegreeAngle;
98 : }
99 :
100 : /** @brief Returns the imgFile of the Shape
101 : * @return The Shape's rotation imgFile
102 : */
103 : inline const std::string& getShapeImgFile() const {
104 35384 : return myImgFile;
105 : }
106 :
107 : /// @brief Returns the name of the Shape
108 : inline const std::string getShapeName() const {
109 : return myName;
110 : }
111 :
112 : /// @}
113 :
114 :
115 : /// @name Setter
116 : /// @{
117 :
118 : /** @brief Sets a new type
119 : * @param[in] type The new type to use
120 : */
121 : inline void setShapeType(const std::string& type) {
122 12 : myType = type;
123 : }
124 :
125 : /** @brief Sets a new color
126 : * @param[in] col The new color to use
127 : */
128 : inline void setShapeColor(const RGBColor& col) {
129 17 : myColor = col;
130 0 : }
131 :
132 : /** @brief Sets a new alpha value
133 : * @param[in] alpha The new value to use
134 : */
135 : inline void setShapeAlpha(unsigned char alpha) {
136 801 : myColor.setAlpha(alpha);
137 : }
138 :
139 : /** @brief Sets a new layer
140 : * @param[in] layer The new layer to use
141 : */
142 : inline void setShapeLayer(const double layer) {
143 : myLayer = layer;
144 : }
145 :
146 : /** @brief Sets a new angle in navigational degrees
147 : * @param[in] layer The new angle to use
148 : */
149 5 : virtual void setShapeNaviDegree(const double angle) {
150 5 : myNaviDegreeAngle = angle;
151 5 : }
152 :
153 : /** @brief Sets a new imgFile
154 : * @param[in] imgFile The new imgFile to use
155 : */
156 : inline void setShapeImgFile(const std::string& imgFile) {
157 5 : myImgFile = imgFile;
158 : }
159 :
160 : /// @brief Sets a new shape name
161 : inline void setShapeName(const std::string& name) {
162 : myName = name;
163 : }
164 :
165 : /// @}
166 :
167 : private:
168 : /// @brief The type of the Shape
169 : std::string myType;
170 :
171 : /// @brief The color of the Shape
172 : RGBColor myColor;
173 :
174 : /// @brief The layer of the Shape
175 : double myLayer;
176 :
177 : /// @brief The angle of the Shape
178 : double myNaviDegreeAngle;
179 :
180 : /// @brief The img file (include path)
181 : std::string myImgFile;
182 :
183 : /// @brief shape name
184 : std::string myName;
185 : };
|