/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIPolygon.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date June 200618///19// The GUI-version of a polygon20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include <utils/shapes/SUMOPolygon.h>26#include <utils/gui/globjects/GUIGlObject_AbstractAdd.h>27#include <utils/gui/globjects/GLIncludes.h>28#include <utils/gui/settings/GUIVisualizationSettings.h>293031// ===========================================================================32// class definitions33// ===========================================================================3435/// @brief most likely I'm reinventing the wheel here36struct GLPrimitive {37GLenum type;38std::vector<Position> vert;39};404142class TesselatedPolygon : public SUMOPolygon {4344public:4546/**@brief Constructor47* @param[in] id The name of the polygon48* @param[in] type The (abstract) type of the polygon49* @param[in] color The color of the polygon50* @param[in] layer The layer of the polygon51* @param[in] angle The rotation of the polygon52* @param[in] imgFile The raster image of the polygon53* @param[in] shape The shape of the polygon54* @param[in] geo specify if shape was loaded as GEO55* @param[in] fill Whether the polygon shall be filled56* @param[in] lineWidth Line width when drawing unfilled polygon57*/58TesselatedPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,59bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",60const std::string& name = DEFAULT_NAME, const Parameterised::Map& parameters = DEFAULT_PARAMETERS):61SUMOPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, name, parameters)62{}6364/// @brief Destructor65~TesselatedPolygon() {}6667/// @brief perform the tesselation / drawing68void drawTesselation(const PositionVector& shape) const;6970/// @brief id of the display list for the cached tesselation71mutable std::vector<GLPrimitive> myTesselation;72};7374/*75* @class GUIPolygon76* @brief The GUI-version of a polygon77*/78class GUIPolygon : public TesselatedPolygon, public GUIGlObject_AbstractAdd {7980public:81/** @brief Constructor82* @param[in] id The name of the polygon83* @param[in] type The (abstract) type of the polygon84* @param[in] color The color of the polygon85* @param[in] layer The layer of the polygon86* @param[in] angle The rotation of the polygon87* @param[in] imgFile The raster image of the polygon88* @param[in] shape The shape of the polygon89* @param[in] geo specify if shape was loaded as GEO90* @param[in] fill Whether the polygon shall be filled91* @param[in] lineWidth Line width when drawing unfilled polygon92*/93GUIPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,94bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",95const std::string& name = DEFAULT_NAME);9697/// @brief Destructor98~GUIPolygon();99100/// @name inherited from GUIGlObject101//@{102103/** @brief Returns an own popup-menu104*105* @param[in] app The application needed to build the popup-menu106* @param[in] parent The parent window needed to build the popup-menu107* @return The built popup-menu108* @see GUIGlObject::getPopUpMenu109*/110GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;111112/** @brief Returns an own parameter window113*114* @param[in] app The application needed to build the parameter window115* @param[in] parent The parent window needed to build the parameter window116* @return The built parameter window117* @see GUIGlObject::getParameterWindow118*/119GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;120121/// @brief return exaggeration associated with this GLObject122double getExaggeration(const GUIVisualizationSettings& s) const override;123124/** @brief Returns the boundary to which the view shall be centered in order to show the object125*126* @return The boundary the object is within127* @see GUIGlObject::getCenteringBoundary128*/129Boundary getCenteringBoundary() const override;130131/** @brief Draws the object132* @param[in] s The settings for the current view (may influence drawing)133* @see GUIGlObject::drawGL134*/135virtual void drawGL(const GUIVisualizationSettings& s) const override;136137double getClickPriority() const override {138return getShapeLayer();139}140141/// @brief Returns the name of the object (default "")142virtual const std::string getOptionalName() const override {143return getShapeName();144}145//@}146147/// @brief set a new shape and update the tesselation148virtual void setShape(const PositionVector& shape) override;149150/** @brief Sets a new angle in navigational degrees151* @param[in] layer The new angle to use152*/153virtual void setShapeNaviDegree(const double angle) override {154SUMOPolygon::setShapeNaviDegree(angle);155if (angle != 0.) {156setShape(myShape);157}158}159160/// @brief set color161static RGBColor setColor(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o, bool disableSelectionColor, int alphaOverride);162163/// @brief check if Polygon can be drawn164static bool checkDraw(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o);165166/// @brief draw inner Polygon (before pushName() )167static void drawInnerPolygon(const GUIVisualizationSettings& s, const TesselatedPolygon* polygon, const GUIGlObject* o,168const PositionVector shape, const double layer, const bool fill,169const bool disableSelectionColor = false,170const int alphaOverride = -1,171const bool disableText = false);172173inline void activate(bool isActive) {174myIsActive = isActive;175}176177inline bool isActive(void) const {178return myIsActive;179}180181private:182/// The mutex used to avoid concurrent updates of the shape183mutable FXMutex myLock;184185/// @brief shape rotated on the centroid, if rotation is needed, nullptr otherwise186PositionVector* myRotatedShape;187188/// @brief Is the polygon will be drawn or not189bool myIsActive;190};191192193