Eclipse SUMO - Simulation of Urban MObility
GUIPolygon.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-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/****************************************************************************/
20// The GUI-version of a polygon
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
30
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
35
38 GLenum type;
39 std::vector<Position> vert;
40};
41
42
44
45public:
46
60 TesselatedPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,
61 bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",
62 bool relativePath = false, const std::string& name = DEFAULT_NAME,
63 const Parameterised::Map& parameters = DEFAULT_PARAMETERS):
64 SUMOPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name, parameters)
65 {}
66
69
70 // @brief perform the tesselation / drawing
71 void drawTesselation(const PositionVector& shape) const;
72
74 mutable std::vector<GLPrimitive> myTesselation;
75
77 return myShape;
78 }
79};
80
81/*
82 * @class GUIPolygon
83 * @brief The GUI-version of a polygon
84 */
86
87public:
101 GUIPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,
102 bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",
103 bool relativePath = false, const std::string& name = DEFAULT_NAME);
104
106 ~GUIPolygon();
107
109
110
119
128
130 double getExaggeration(const GUIVisualizationSettings& s) const override;
131
137 Boundary getCenteringBoundary() const override;
138
143 virtual void drawGL(const GUIVisualizationSettings& s) const override;
144
145 double getClickPriority() const override {
146 return getShapeLayer();
147 }
149
151 virtual void setShape(const PositionVector& shape) override;
152
156 virtual void setShapeNaviDegree(const double angle) override {
158 if (angle != 0.) {
160 }
161 }
162
164 static RGBColor setColor(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o, bool disableSelectionColor, int alphaOverride);
165
167 static bool checkDraw(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o);
168
170 static void drawInnerPolygon(const GUIVisualizationSettings& s, const TesselatedPolygon* polygon, const GUIGlObject* o,
171 const PositionVector shape, const double layer, const bool fill,
172 const bool disableSelectionColor = false,
173 const int alphaOverride = -1,
174 const bool disableText = false);
175
176private:
178 mutable FXMutex myLock;
179
182};
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The popup menu of a globject.
A window containing a gl-object's parameter.
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
Definition: GUIPolygon.cpp:329
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Definition: GUIPolygon.cpp:307
virtual void setShapeNaviDegree(const double angle) override
Sets a new angle in navigational degrees.
Definition: GUIPolygon.h:156
virtual void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIPolygon.cpp:238
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIPolygon.cpp:228
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GUIPolygon.h:145
PositionVector * myRotatedShape
shape rotated on the centroid, if rotation is needed, nullptr otherwise
Definition: GUIPolygon.h:181
GUIPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=0, double angle=0, const std::string &imgFile="", bool relativePath=false, const std::string &name=DEFAULT_NAME)
Constructor.
Definition: GUIPolygon.cpp:174
~GUIPolygon()
Destructor.
Definition: GUIPolygon.cpp:187
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
Definition: GUIPolygon.h:178
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUIPolygon.cpp:209
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUIPolygon.cpp:193
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
Definition: GUIPolygon.cpp:278
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GUIPolygon.cpp:222
virtual void setShape(const PositionVector &shape) override
set a new shape and update the tesselation
Definition: GUIPolygon.cpp:257
Stores the information about how to visualize structures.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A list of positions.
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:121
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: Shape.h:157
static const std::string DEFAULT_NAME
Definition: Shape.h:51
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:91
static const Parameterised::Map DEFAULT_PARAMETERS
Definition: Shape.h:52
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition: GUIPolygon.h:74
PositionVector & getShapeRef()
Definition: GUIPolygon.h:76
~TesselatedPolygon()
Destructor.
Definition: GUIPolygon.h:68
TesselatedPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=0, double angle=0, const std::string &imgFile="", bool relativePath=false, const std::string &name=DEFAULT_NAME, const Parameterised::Map &parameters=DEFAULT_PARAMETERS)
Constructor.
Definition: GUIPolygon.h:60
void drawTesselation(const PositionVector &shape) const
Definition: GUIPolygon.cpp:118
most likely I'm reinventing the wheel here
Definition: GUIPolygon.h:37
std::vector< Position > vert
Definition: GUIPolygon.h:39
GLenum type
Definition: GUIPolygon.h:38