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.org/sumo
3 // Copyright (C) 2012-2022 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>
28 
29 
30 // ===========================================================================
31 // class definitions
32 // ===========================================================================
37 class Shape : public Named {
38 public:
41  static const std::string DEFAULT_TYPE;
42  static const double DEFAULT_LAYER;
43  static const double DEFAULT_LINEWIDTH;
44  static const double DEFAULT_LAYER_POI;
45  static const double DEFAULT_ANGLE;
46  static const std::string DEFAULT_IMG_FILE;
47  static const bool DEFAULT_RELATIVEPATH;
48  static const double DEFAULT_IMG_WIDTH;
49  static const double DEFAULT_IMG_HEIGHT;
50  static const std::string DEFAULT_NAME;
51  static const std::map<std::string, std::string> DEFAULT_PARAMETERS;
53 
64  Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
65  double angle, const std::string& imgFile, const std::string& name, bool relativePath);
66 
68  virtual ~Shape();
69 
72 
76  inline const std::string& getShapeType() const {
77  return myType;
78  }
79 
83  inline const RGBColor& getShapeColor() const {
84  return myColor;
85  }
86 
90  inline double getShapeLayer() const {
91  return myLayer;
92  }
93 
97  inline double getShapeNaviDegree() const {
98  return myNaviDegreeAngle;
99  }
100 
104  inline const std::string& getShapeImgFile() const {
105  return myImgFile;
106  }
107 
109  inline const std::string getShapeName() const {
110  return myName;
111  }
112 
116  inline bool getShapeRelativePath() const {
117  return myRelativePath;
118  }
120 
121 
124 
128  inline void setShapeType(const std::string& type) {
129  myType = type;
130  }
131 
135  inline void setShapeColor(const RGBColor& col) {
136  myColor = col;
137  }
138 
142  inline void setShapeAlpha(unsigned char alpha) {
143  myColor.setAlpha(alpha);
144  }
145 
149  inline void setShapeLayer(const double layer) {
150  myLayer = layer;
151  }
152 
156  virtual void setShapeNaviDegree(const double angle) {
157  myNaviDegreeAngle = angle;
158  }
159 
163  inline void setShapeImgFile(const std::string& imgFile) {
164  myImgFile = imgFile;
165  }
166 
168  inline void setShapeName(const std::string& name) {
169  myName = name;
170  }
171 
175  inline void setShapeRelativePath(bool relativePath) {
176  myRelativePath = relativePath;
177  }
179 
180 private:
182  std::string myType;
183 
186 
188  double myLayer;
189 
192 
194  std::string myImgFile;
195 
197  std::string myName;
198 
201 };
Base class for objects which have an id.
Definition: Named.h:54
void setAlpha(unsigned char alpha)
Sets a new alpha value.
Definition: RGBColor.cpp:108
A 2D- or 3D-Shape.
Definition: Shape.h:37
const std::string getShapeName() const
Returns the name of the Shape.
Definition: Shape.h:109
std::string myImgFile
The img file (include path)
Definition: Shape.h:194
static const bool DEFAULT_RELATIVEPATH
Definition: Shape.h:47
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:83
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
Definition: Shape.h:142
static const std::map< std::string, std::string > DEFAULT_PARAMETERS
Definition: Shape.h:51
static const double DEFAULT_LAYER
Definition: Shape.h:42
static const double DEFAULT_LAYER_POI
Definition: Shape.h:44
void setShapeName(const std::string &name)
Sets a new shape name.
Definition: Shape.h:168
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:104
void setShapeLayer(const double layer)
Sets a new layer.
Definition: Shape.h:149
static const double DEFAULT_IMG_WIDTH
Definition: Shape.h:48
bool myRelativePath
Enable or disable save imgFile as relative path.
Definition: Shape.h:200
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
Definition: Shape.h:116
std::string myType
The type of the Shape.
Definition: Shape.h:182
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:46
static const double DEFAULT_LINEWIDTH
Definition: Shape.h:43
void setShapeType(const std::string &type)
Sets a new type.
Definition: Shape.h:128
static const double DEFAULT_ANGLE
Definition: Shape.h:45
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
Definition: Shape.h:175
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: Shape.h:156
virtual ~Shape()
Destructor.
Definition: Shape.cpp:57
static const std::string DEFAULT_NAME
Definition: Shape.h:50
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition: Shape.h:163
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:49
static const std::string DEFAULT_TYPE
Definition: Shape.h:41
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition: Shape.h:135
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:90
double myLayer
The layer of the Shape.
Definition: Shape.h:188
double myNaviDegreeAngle
The angle of the Shape.
Definition: Shape.h:191
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:97
std::string myName
shape name
Definition: Shape.h:197
RGBColor myColor
The color of the Shape.
Definition: Shape.h:185
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:76