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-2024 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
71 void drawTesselation(const PositionVector& shape) const;
72
74 mutable std::vector<GLPrimitive> myTesselation;
75};
76
77/*
78 * @class GUIPolygon
79 * @brief The GUI-version of a polygon
80 */
82
83public:
97 GUIPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,
98 bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",
99 bool relativePath = false, const std::string& name = DEFAULT_NAME);
100
102 ~GUIPolygon();
103
105
106
115
124
126 double getExaggeration(const GUIVisualizationSettings& s) const override;
127
133 Boundary getCenteringBoundary() const override;
134
139 virtual void drawGL(const GUIVisualizationSettings& s) const override;
140
141 double getClickPriority() const override {
142 return getShapeLayer();
143 }
144
146 virtual const std::string getOptionalName() const override {
147 return getShapeName();
148 }
150
152 virtual void setShape(const PositionVector& shape) override;
153
157 virtual void setShapeNaviDegree(const double angle) override {
159 if (angle != 0.) {
161 }
162 }
163
165 static RGBColor setColor(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o, bool disableSelectionColor, int alphaOverride);
166
168 static bool checkDraw(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o);
169
171 static void drawInnerPolygon(const GUIVisualizationSettings& s, const TesselatedPolygon* polygon, const GUIGlObject* o,
172 const PositionVector shape, const double layer, const bool fill,
173 const bool disableSelectionColor = false,
174 const int alphaOverride = -1,
175 const bool disableText = false);
176
177 inline void activate(bool isActive) {
179 }
180
181 inline bool isActive(void) const {
182 return myIsActive;
183 }
184
185private:
187 mutable FXMutex myLock;
188
191
194};
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:181
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:157
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:141
PositionVector * myRotatedShape
shape rotated on the centroid, if rotation is needed, nullptr otherwise
Definition GUIPolygon.h:190
~GUIPolygon()
Destructor.
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
Definition GUIPolygon.h:187
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:146
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:177
bool myIsActive
Is the polygon will be drawn or not.
Definition GUIPolygon.h:193
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.
const std::string getShapeName() const
Returns the name of the Shape.
Definition Shape.h:110
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
~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
perform the tesselation / drawing
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