Path: blob/main/src/utils/gui/globjects/GUIShapeContainer.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2009-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 GUIShapeContainer.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @author Jakob Erdmann17/// @date 08.10.200918///19// Storage for geometrical objects extended by mutexes20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/foxtools/fxheader.h>25#include <utils/shapes/ShapeContainer.h>26#include <utils/gui/globjects/GUIGlObject.h>27#include <utils/gui/globjects/GUIPolygon.h>2829// ===========================================================================30// class declarations31// ===========================================================================32class SUMORTree;33class Position;343536// ===========================================================================37// class definitions38// ===========================================================================39/**40* @class GUIShapeContainer41* @brief Storage for geometrical objects extended by mutexes42* @see ShapeContainer43*/44class GUIShapeContainer : public ShapeContainer {45public:46/// @brief Constructor47GUIShapeContainer(SUMORTree& vis);4849/// @brief Destructor50virtual ~GUIShapeContainer();5152/** @brief Builds a polygon using the given values and adds it to the container53* @param[in] id The name of the polygon54* @param[in] type The (abstract) type of the polygon55* @param[in] color The color of the polygon56* @param[in] layer The layer of the polygon57* @param[in] angle The rotation of the polygon58* @param[in] imgFile The raster image of the polygon59* @param[in] shape The shape of the polygon60* @param[in] geo specify if shape was loaded as GEO coordinate61* @param[in] fill Whether the polygon shall be filled62* @param[in] lineWidth Line width when drawing unfilled polygon63* @return whether the polygon could be added64*/65virtual bool addPolygon(const std::string& id, const std::string& type, const RGBColor& color, double layer,66double angle, const std::string& imgFile, const PositionVector& shape, bool geo,67bool fill, double lineWidth, bool ignorePruning = false,68const std::string& name = Shape::DEFAULT_NAME) override;6970/// @brief Adds dynamics to the given Polygon, @see ShapeContainer addPolygonDynamics71/// @note Supplies the visualisation RTree to the dynamics for updating the object when moving72PolygonDynamics* addPolygonDynamics(double simtime,73std::string polyID,74SUMOTrafficObject* trackedObject,75const std::vector<double>& timeSpan,76const std::vector<double>& alphaSpan,77bool looped,78bool rotate) override;7980/// @brief Update PolygonDynamics, @see ShapeContainer81/// @note Locks the visualisation RTree82SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics* pd) override;8384/** @brief Builds a POI using the given values and adds it to the container85* @param[in] id The name of the POI86* @param[in] type The (abstract) type of the POI87* @param[in] color The color of the POI88* @param[in] pos The position of the POI89* @param[in[ geo use GEO coordinates (lon/lat)90* @param[in] lane The Lane in which this POI is placed91* @param[in] posOverLane The position over Lane92* @param[in] friendlyPos enable or disable friendly position over lane93* @param[in] posLat The position lateral over Lane94* @param[in] icon The icon of the POI95* @param[in] layer The layer of the POI96* @param[in] angle The rotation of the POI97* @param[in] imgFile The raster image of the POI98* @param[in] width The width of the POI image99* @param[in] height The height of the POI image100* @return whether the poi could be added101*/102virtual bool addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,103const std::string& lane, double posOverLane, bool friendlyPos, double posLat, const std::string& icon,104double layer, double angle, const std::string& imgFile, double width, double height,105bool ignorePruning = false) override;106107/** @brief Removes a polygon from the container108* @param[in] id The id of the polygon109* @return Whether the polygon could be removed110*/111virtual bool removePolygon(const std::string& id, bool useLock = true) override;112113/** @brief Removes a PoI from the container114* @param[in] id The id of the PoI115* @return Whether the poi could be removed116*/117virtual bool removePOI(const std::string& id) override;118119/** @brief Assigns a new position to the named PoI120* @param[in] id The id of the PoI to move121* @param[in] pos The PoI's new position122*/123virtual void movePOI(const std::string& id, const Position& pos) override;124125/** @brief Assigns a shape to the named polygon126* @param[in] id The id of the polygon to reshape127* @param[in] shape The polygon's new shape128*/129virtual void reshapePolygon(const std::string& id, const PositionVector& shape) override;130131/// @brief Returns the gl-ids of all pois132std::vector<GUIGlID> getPOIIds() const;133134/// @brief Returns the gl-ids of all polygons135std::vector<GUIGlID> getPolygonIDs() const;136137/// @brief allow replacement138void allowReplacement();139140inline const std::set<std::string>& getInactiveTypes(void) const {141return myInactivePolygonTypes;142};143144/// @brief Sets polygon types that define which one is active or not.145/// @param inactivePolygonTypes The whole set of inactive polygon types.146void setInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);147148/// @brief Adds new polygon types to the set of inactive ones.149/// @param inactivePolygonTypes Some set of inactive polygon types.150void addInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);151152/// @brief Remove some polygon types that were deemed as inactive.153/// @param inactivePolygonTypes Some set of inactive polygon types.154void removeInactivePolygonTypes(std::set<std::string> inactivePolygonTypes);155156private:157/// @brief The mutex for adding/removing operations158mutable FXMutex myLock;159160/// @brief The RTree structure to add and remove visualization elements161SUMORTree& myVis;162163/// @brief whether existing ids shall be replaced164bool myAllowReplacement;165166/// @brief The polygon types that define the inactive polygons.167std::set<std::string> myInactivePolygonTypes;168169/// @brief Determine which polygons are active based on their type.170void computeActivePolygons(void);171};172173174