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-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/****************************************************************************/
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 std::string Shape::DEFAULT_NAME = "";
42
43// ===========================================================================
44// member definitions
45// ===========================================================================
46
47Shape::Shape(const std::string& id) :
48 Named(id),
49 myType(DEFAULT_TYPE),
50 myColor(RGBColor::BLACK),
51 myLayer(DEFAULT_LAYER),
52 myNaviDegreeAngle(DEFAULT_ANGLE),
53 myImgFile(DEFAULT_IMG_FILE),
54 myName(DEFAULT_NAME) {
55}
56
57
58Shape::Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
59 double angle, const std::string& imgFile, const std::string& name) :
60 Named(id),
61 myType(type),
62 myColor(color),
63 myLayer(layer),
64 myNaviDegreeAngle(angle),
65 myImgFile(imgFile),
66 myName(name) {
67}
68
69
71
72
73void
74Shape::writeShapeAttributes(OutputDevice& device, const RGBColor& defaultColor, const double defaultLayer) const {
75 // name
76 if (myName != DEFAULT_NAME) {
78 }
79 // type
80 if (myType != DEFAULT_TYPE) {
82 }
83 // color
84 if (myColor != defaultColor) {
86 }
87 // layer
88 if (myLayer != defaultLayer) {
90 }
91 // angle
94 }
95 // img file
98 }
99}
100
101
102const std::string&
104 return myType;
105}
106
107
108const RGBColor&
110 return myColor;
111}
112
113
114double
116 return myLayer;
117}
118
119
120double
124
125
126const std::string&
128 return myImgFile;
129}
130
131
132const std::string&
134 return myName;
135}
136
137
138void
139Shape::setShapeType(const std::string& type) {
140 myType = type;
141}
142
143
144void
146 myColor = col;
147}
148
149
150void
151Shape::setShapeAlpha(unsigned char alpha) {
152 myColor.setAlpha(alpha);
153}
154
155
156void
157Shape::setShapeLayer(const double layer) {
158 myLayer = layer;
159}
160
161
162void
163Shape::setShapeNaviDegree(const double angle) {
164 myNaviDegreeAngle = angle;
165}
166
167
168void
169Shape::setShapeImgFile(const std::string& imgFile) {
170 myImgFile = imgFile;
171}
172
173void
174Shape::setShapeName(const std::string& name) {
175 myName = name;
176}
177
178/****************************************************************************/
@ 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:54
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
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:108
std::string myImgFile
The img file (include path)
Definition Shape.h:164
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
Definition Shape.cpp:151
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.cpp:174
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.cpp:157
void writeShapeAttributes(OutputDevice &device, const RGBColor &defaultColor, const double defaultLayer) const
write shape attributes in a xml file
Definition Shape.cpp:74
static const double DEFAULT_IMG_WIDTH
Definition Shape.h:48
std::string myType
The type of the Shape.
Definition Shape.h:152
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:103
static const double DEFAULT_LINEWIDTH
Definition Shape.h:44
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.cpp:139
static const double DEFAULT_ANGLE
Definition Shape.h:46
virtual ~Shape()
Destructor.
Definition Shape.cpp:70
static const std::string DEFAULT_NAME
Definition Shape.h:50
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.cpp:163
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.cpp:169
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:145
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.cpp:115
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.cpp:127
Shape(const std::string &id)
default consructor
Definition Shape.cpp:47
double myLayer
The layer of the Shape.
Definition Shape.h:158
const std::string & getShapeName() const
Returns the name of the Shape.
Definition Shape.cpp:133
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.cpp:109
double myNaviDegreeAngle
The angle of the Shape.
Definition Shape.h:161
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.cpp:121
static const Parameterised::Map DEFAULT_PARAMETERS
Definition Shape.h:51
std::string myName
shape name
Definition Shape.h:167
RGBColor myColor
The color of the Shape.
Definition Shape.h:155
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.