Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIPolygon.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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/****************************************************************************/
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 const bool geo, const bool fill,
62 const double lineWidth = DEFAULT_LINEWIDTH,
63 const double layer = DEFAULT_LAYER,
64 const double angle = DEFAULT_ANGLE,
65 const std::string& imgFile = DEFAULT_IMG_FILE,
66 const std::string& name = DEFAULT_NAME,
67 const double height = DEFAULT_HEIGHT,
68 const Parameterised::Map& parameters = DEFAULT_PARAMETERS):
69 SUMOPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, name, height, parameters)
70 {}
71
74
76 void drawTesselation(const PositionVector& shape) const;
77
79 mutable std::vector<GLPrimitive> myTesselation;
80};
81
82/*
83 * @class GUIPolygon
84 * @brief The GUI-version of a polygon
85 */
87
88public:
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 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 }
148
150 virtual const std::string getOptionalName() const override {
151 return getShapeName();
152 }
154
156 virtual void setShape(const PositionVector& shape) override;
157
161 virtual void setShapeNaviDegree(const double angle) override {
163 if (angle != 0.) {
165 }
166 }
167
169 static RGBColor setColor(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o, bool disableSelectionColor, int alphaOverride);
170
172 static bool checkDraw(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o);
173
175 static void drawInnerPolygon(const GUIVisualizationSettings& s, const TesselatedPolygon* polygon, const GUIGlObject* o,
176 const PositionVector shape, const double layer, const bool fill,
177 const bool disableSelectionColor = false,
178 const int alphaOverride = -1,
179 const bool disableText = false);
180
181 inline void activate(bool isActive) {
183 }
184
185 inline bool isActive(void) const {
186 return myIsActive;
187 }
188
189private:
191 mutable FXMutex myLock;
192
195
198};
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.
bool isActive(void) const
Definition GUIPolygon.h:185
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() )
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
virtual void setShapeNaviDegree(const double angle) override
Sets a new angle in navigational degrees.
Definition GUIPolygon.h:161
virtual void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
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:194
~GUIPolygon()
Destructor.
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
Definition GUIPolygon.h:191
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
virtual const std::string getOptionalName() const override
Returns the name of the object (default "")
Definition GUIPolygon.h:150
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
void activate(bool isActive)
Definition GUIPolygon.h:181
bool myIsActive
Is the polygon will be drawn or not.
Definition GUIPolygon.h:197
virtual void setShape(const PositionVector &shape) override
set a new shape and update the tesselation
Stores the information about how to visualize structures.
std::map< std::string, std::string > Map
parameters map
A list of positions.
PositionVector myShape
The positions of the polygon.
static const double DEFAULT_LAYER
Definition Shape.h:43
static const double DEFAULT_HEIGHT
Definition Shape.h:50
static const std::string DEFAULT_IMG_FILE
Definition Shape.h:47
static const double DEFAULT_LINEWIDTH
Definition Shape.h:44
static const double DEFAULT_ANGLE
Definition Shape.h:46
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
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.cpp:111
const std::string & getShapeName() const
Returns the name of the Shape.
Definition Shape.cpp:129
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:79
~TesselatedPolygon()
Destructor.
Definition GUIPolygon.h:73
void drawTesselation(const PositionVector &shape) const
perform the tesselation / drawing
TesselatedPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, const bool geo, const bool fill, const double lineWidth=DEFAULT_LINEWIDTH, const double layer=DEFAULT_LAYER, const double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE, const std::string &name=DEFAULT_NAME, const double height=DEFAULT_HEIGHT, const Parameterised::Map &parameters=DEFAULT_PARAMETERS)
Constructor.
Definition GUIPolygon.h:60
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