Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Shape.cpp
Go to the documentation of this file.
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/****************************************************************************/
19// A 2D- or 3D-Shape
20/****************************************************************************/
21#include <config.h>
22
25
26#include "Shape.h"
27
28// ===========================================================================
29// static member definitions
30// ===========================================================================
31
32const std::string Shape::DEFAULT_TYPE = "";
33const double Shape::DEFAULT_LAYER = 0;
34const double Shape::DEFAULT_LINEWIDTH = 1;
35const double Shape::DEFAULT_LAYER_POI = (double)GLO_POI;
36const double Shape::DEFAULT_ANGLE = 0;
37const std::string Shape::DEFAULT_IMG_FILE = "";
38const double Shape::DEFAULT_IMG_WIDTH = 2.6;
39const double Shape::DEFAULT_IMG_HEIGHT = 1;
40const double Shape::DEFAULT_HEIGHT = 0;
41const std::string Shape::DEFAULT_NAME = "";
43
44// ===========================================================================
45// member definitions
46// ===========================================================================
47
48Shape::Shape(const std::string& id) :
49 Named(id),
50 myName(DEFAULT_NAME) {
51}
52
53
54Shape::Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
55 double angle, const std::string& imgFile, const std::string& name) :
56 Named(id),
57 myType(type),
58 myColor(color),
59 myLayer(layer),
60 myNaviDegreeAngle(angle),
61 myImgFile(imgFile),
62 myName(name) {
63}
64
65
67
68
69void
70Shape::writeShapeAttributes(OutputDevice& device, const RGBColor& defaultColor, const double defaultLayer) const {
71 // name
72 if (myName != DEFAULT_NAME) {
74 }
75 // type
76 if (myType != DEFAULT_TYPE) {
78 }
79 // color
80 if (myColor != defaultColor) {
82 }
83 // layer
84 if (myLayer != defaultLayer) {
86 }
87 // angle
90 }
91 // img file
94 }
95}
96
97
98const std::string&
100 return myType;
101}
102
103
104const RGBColor&
106 return myColor;
107}
108
109
110double
112 return myLayer;
113}
114
115
116double
120
121
122const std::string&
124 return myImgFile;
125}
126
127
128const std::string&
130 return myName;
131}
132
133
134void
135Shape::setShapeType(const std::string& type) {
136 myType = type;
137}
138
139
140void
142 myColor = col;
143}
144
145
146void
147Shape::setShapeAlpha(unsigned char alpha) {
148 myColor.setAlpha(alpha);
149}
150
151
152void
153Shape::setShapeLayer(const double layer) {
154 myLayer = layer;
155}
156
157
158void
159Shape::setShapeNaviDegree(const double angle) {
160 myNaviDegreeAngle = angle;
161}
162
163
164void
165Shape::setShapeImgFile(const std::string& imgFile) {
166 myImgFile = imgFile;
167}
168
169void
170Shape::setShapeName(const std::string& name) {
171 myName = name;
172}
173
174/****************************************************************************/
@ GLO_POI
poi (over view, geo and lane)
@ SUMO_ATTR_NAME
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_IMGFILE
Base class for objects which have an id.
Definition Named.h:53
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
std::map< std::string, std::string > Map
parameters map
void setAlpha(unsigned char alpha)
Sets a new alpha value.
Definition RGBColor.cpp:112
std::string myImgFile
The img file (include path)
Definition Shape.h:165
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
Definition Shape.cpp:147
static const double DEFAULT_LAYER
Definition Shape.h:43
static const double DEFAULT_HEIGHT
Definition Shape.h:50
static const double DEFAULT_LAYER_POI
Definition Shape.h:45
void setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.cpp:170
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.cpp:153
void writeShapeAttributes(OutputDevice &device, const RGBColor &defaultColor, const double defaultLayer) const
write shape attributes in a xml file
Definition Shape.cpp:70
static const double DEFAULT_IMG_WIDTH
Definition Shape.h:48
std::string myType
The type of the Shape.
Definition Shape.h:153
static const std::string DEFAULT_IMG_FILE
Definition Shape.h:47
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.cpp:99
static const double DEFAULT_LINEWIDTH
Definition Shape.h:44
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.cpp:135
static const double DEFAULT_ANGLE
Definition Shape.h:46
virtual ~Shape()
Destructor.
Definition Shape.cpp:66
static const std::string DEFAULT_NAME
Definition Shape.h:51
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.cpp:159
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.cpp:165
static const double DEFAULT_IMG_HEIGHT
Definition Shape.h:49
static const std::string DEFAULT_TYPE
Definition Shape.h:42
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.cpp:141
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.cpp:111
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.cpp:123
Shape(const std::string &id)
default consructor
Definition Shape.cpp:48
double myLayer
The layer of the Shape.
Definition Shape.h:159
const std::string & getShapeName() const
Returns the name of the Shape.
Definition Shape.cpp:129
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.cpp:105
double myNaviDegreeAngle
The angle of the Shape.
Definition Shape.h:162
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.cpp:117
static const Parameterised::Map DEFAULT_PARAMETERS
Definition Shape.h:52
std::string myName
shape name
Definition Shape.h:168
RGBColor myColor
The color of the Shape.
Definition Shape.h:156
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.