Eclipse SUMO - Simulation of Urban MObility
SUMOPolygon.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-2020 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 /****************************************************************************/
21 // A 2D- or 3D-polygon
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
28 #include "Shape.h"
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class OutputDevice;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
44 class SUMOPolygon : public Shape, public Parameterised {
45 
46 public:
48  friend class PolygonDynamics;
49 
63  SUMOPolygon(const std::string& id, const std::string& type,
64  const RGBColor& color, const PositionVector& shape,
65  bool geo, bool fill, double lineWidth,
66  double layer = DEFAULT_LAYER,
67  double angle = DEFAULT_ANGLE,
68  const std::string& imgFile = DEFAULT_IMG_FILE,
69  bool relativePath = DEFAULT_RELATIVEPATH);
70 
71 
73  virtual ~SUMOPolygon();
74 
75 
78 
82  inline const PositionVector& getShape() const {
83  return myShape;
84  }
85 
86 
90  inline bool getFill() const {
91  return myFill;
92  }
93 
97  inline double getLineWidth() const {
98  return myLineWidth;
99  }
101 
102 
105 
109  inline void setFill(bool fill) {
110  myFill = fill;
111  }
112 
113  inline void setLineWidth(double lineWidth) {
114  myLineWidth = lineWidth;
115  }
116 
117 
121  inline virtual void setShape(const PositionVector& shape) {
122  myShape = shape;
123  }
125 
126  /* @brief polygon definition to the given device
127  * @param[in] geo Whether to write the output in geo-coordinates
128  */
129  void writeXML(OutputDevice& out, bool geo = false);
130 
131 protected:
134 
136  bool myGEO;
137 
139  bool myFill;
140 
142  double myLineWidth;
143 };
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A list of positions.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: SUMOPolygon.h:82
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:133
double myLineWidth
The line width for drawing an unfilled polygon.
Definition: SUMOPolygon.h:142
virtual ~SUMOPolygon()
Destructor.
Definition: SUMOPolygon.cpp:45
void setFill(bool fill)
Sets whether the polygon shall be filled.
Definition: SUMOPolygon.h:109
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
Definition: SUMOPolygon.h:136
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
Definition: SUMOPolygon.h:121
void writeXML(OutputDevice &out, bool geo=false)
Definition: SUMOPolygon.cpp:49
void setLineWidth(double lineWidth)
Definition: SUMOPolygon.h:113
SUMOPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=DEFAULT_LAYER, double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE, bool relativePath=DEFAULT_RELATIVEPATH)
Constructor.
Definition: SUMOPolygon.cpp:34
double getLineWidth() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.h:97
bool myFill
Information whether the polygon has to be filled.
Definition: SUMOPolygon.h:139
bool getFill() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.h:90
A 2D- or 3D-Shape.
Definition: Shape.h:36
static const bool DEFAULT_RELATIVEPATH
Definition: Shape.h:46
static const double DEFAULT_LAYER
Definition: Shape.h:41
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:45
static const double DEFAULT_ANGLE
Definition: Shape.h:44