Eclipse SUMO - Simulation of Urban MObility
Shape.h
Go to the documentation of this file.
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 /****************************************************************************/
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>
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
38 class Shape : public Named {
39 public:
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;
54 
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 
69  virtual ~Shape();
70 
73 
77  inline const std::string& getShapeType() const {
78  return myType;
79  }
80 
84  inline const RGBColor& getShapeColor() const {
85  return myColor;
86  }
87 
91  inline double getShapeLayer() const {
92  return myLayer;
93  }
94 
98  inline double getShapeNaviDegree() const {
99  return myNaviDegreeAngle;
100  }
101 
105  inline const std::string& getShapeImgFile() const {
106  return myImgFile;
107  }
108 
110  inline const std::string getShapeName() const {
111  return myName;
112  }
113 
117  inline bool getShapeRelativePath() const {
118  return myRelativePath;
119  }
121 
122 
125 
129  inline void setShapeType(const std::string& type) {
130  myType = type;
131  }
132 
136  inline void setShapeColor(const RGBColor& col) {
137  myColor = col;
138  }
139 
143  inline void setShapeAlpha(unsigned char alpha) {
144  myColor.setAlpha(alpha);
145  }
146 
150  inline void setShapeLayer(const double layer) {
151  myLayer = layer;
152  }
153 
157  virtual void setShapeNaviDegree(const double angle) {
158  myNaviDegreeAngle = angle;
159  }
160 
164  inline void setShapeImgFile(const std::string& imgFile) {
165  myImgFile = imgFile;
166  }
167 
169  inline void setShapeName(const std::string& name) {
170  myName = name;
171  }
172 
176  inline void setShapeRelativePath(bool relativePath) {
177  myRelativePath = relativePath;
178  }
180 
181 private:
183  std::string myType;
184 
187 
189  double myLayer;
190 
193 
195  std::string myImgFile;
196 
198  std::string myName;
199 
202 };
Base class for objects which have an id.
Definition: Named.h:54
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
void setAlpha(unsigned char alpha)
Sets a new alpha value.
Definition: RGBColor.cpp:108
A 2D- or 3D-Shape.
Definition: Shape.h:38
const std::string getShapeName() const
Returns the name of the Shape.
Definition: Shape.h:110
std::string myImgFile
The img file (include path)
Definition: Shape.h:195
static const bool DEFAULT_RELATIVEPATH
Definition: Shape.h:48
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:84
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
Definition: Shape.h:143
static const double DEFAULT_LAYER
Definition: Shape.h:43
static const double DEFAULT_LAYER_POI
Definition: Shape.h:45
void setShapeName(const std::string &name)
Sets a new shape name.
Definition: Shape.h:169
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:105
void setShapeLayer(const double layer)
Sets a new layer.
Definition: Shape.h:150
static const double DEFAULT_IMG_WIDTH
Definition: Shape.h:49
bool myRelativePath
Enable or disable save imgFile as relative path.
Definition: Shape.h:201
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
Definition: Shape.h:117
std::string myType
The type of the Shape.
Definition: Shape.h:183
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:47
static const double DEFAULT_LINEWIDTH
Definition: Shape.h:44
void setShapeType(const std::string &type)
Sets a new type.
Definition: Shape.h:129
static const double DEFAULT_ANGLE
Definition: Shape.h:46
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
Definition: Shape.h:176
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: Shape.h:157
virtual ~Shape()
Destructor.
Definition: Shape.cpp:57
static const std::string DEFAULT_NAME
Definition: Shape.h:51
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition: Shape.h:164
Shape(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, const std::string &name, bool relativePath)
Constructor.
Definition: Shape.cpp:44
static const double DEFAULT_IMG_HEIGHT
Definition: Shape.h:50
static const std::string DEFAULT_TYPE
Definition: Shape.h:42
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition: Shape.h:136
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:91
double myLayer
The layer of the Shape.
Definition: Shape.h:189
double myNaviDegreeAngle
The angle of the Shape.
Definition: Shape.h:192
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:98
static const Parameterised::Map DEFAULT_PARAMETERS
Definition: Shape.h:52
std::string myName
shape name
Definition: Shape.h:198
RGBColor myColor
The color of the Shape.
Definition: Shape.h:186
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:77