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