Path: blob/main/src/netedit/elements/additional/GNEPOI.h
169684 views
/****************************************************************************/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 GNEPOI.h14/// @author Pablo Alvarez Lopez15/// @date Jun 201716///17// A class for visualizing and editing POIS in netedit (adapted from18// GUIPointOfInterest and NLHandler)19/****************************************************************************/20#pragma once21#include <config.h>2223#include <utils/shapes/PointOfInterest.h>24#include <utils/xml/CommonXMLStructure.h>2526#include "GNEAdditional.h"2728// ===========================================================================29// class declarations30// ===========================================================================3132class GNELane;3334// ===========================================================================35// class definitions36// ===========================================================================3738class GNEPOI : public PointOfInterest, public GNEAdditional {3940public:41/// @brief needed to avoid diamond problem between PointOfInterest and GNEAdditional42using GNEAdditional::getID;4344/// @brief Constructor45GNEPOI(SumoXMLTag tag, GNENet* net);4647/**@brief Constructor48* @param[in] id The name of the POI49* @param[in] net net in which this polygon is placed50* @param[in] filename file in which this element is stored51* @param[in] type The (abstract) type of the POI52* @param[in] color The color of the POI53* @param[in] lon The position X or Lon of the POI54* @param[in] lat The position Y or Lat of the POI55* @param[in[ geo use GEO coordinates (lon/lat)56* @param[in] icon the POI icon57* @param[in] layer The layer of the POI58* @param[in] angle The rotation of the POI59* @param[in] imgFile The raster image of the shape60* @param[in] width The width of the POI image61* @param[in] height The height of the POI image62* @param[in] name POI's name63* @param[in] parameters generic parameters64*/65GNEPOI(const std::string& id, GNENet* net, const std::string& filename, const std::string& type, const RGBColor& color, const double xLon,66const double yLat, const bool geo, const std::string& icon, const double layer, const double angle, const std::string& imgFile,67const double width, const double height, const std::string& name, const Parameterised::Map& parameters);6869/**@brief Constructor70* @param[in] id The name of the POI71* @param[in] net net in which this polygon is placed72* @param[in] filename file in which this element is stored73* @param[in] type The (abstract) type of the POI74* @param[in] color The color of the POI75* @param[in] icon the POI icon76* @param[in] layer The layer of the POI77* @param[in] angle The rotation of the POI78* @param[in] imgFile The raster image of the shape79* @param[in] lane lane in which this POILane is placed80* @param[in] posOverLane Position over lane in which this POILane is placed81* @param[in] posLat Lateral position over lane82* @param[in] width The width of the POI image83* @param[in] height The height of the POI image84* @param[in] name POI's name85* @param[in] parameters generic parameters86*/87GNEPOI(const std::string& id, GNENet* net, const std::string& filename, const std::string& type, const RGBColor& color, GNELane* lane,88const double posOverLane, const bool friendlyPos, const double posLat, const std::string& icon, const double layer, const double angle,89const std::string& imgFile, const double width, const double height, const std::string& name, const Parameterised::Map& parameters);9091/// @brief Destructor92~GNEPOI();9394/**@brief get move operation95* @note returned GNEMoveOperation can be nullptr96*/97GNEMoveOperation* getMoveOperation() override;9899/// @brief remove geometry point in the clicked position100void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;101102/// @brief gererate a new ID for an element child103std::string generateChildID(SumoXMLTag childTag);104105/// @brief get SUMOBaseObject with all POIattributes106CommonXMLStructure::SumoBaseObject* getSumoBaseObject() const;107108/// @name inherited from GNEAdditional109/// @{110111/// @brief update pre-computed geometry information112void updateGeometry() override;113114/// @brief Returns position of shape in view115Position getPositionInView() const override;116117/// @brief return exaggeration associated with this GLObject118double getExaggeration(const GUIVisualizationSettings& s) const override;119120/// @brief update centering boundary (implies change in RTREE)121void updateCenteringBoundary(const bool updateGrid) override;122123/// @brief split geometry124void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,125const GNENetworkElement* newElement, GNEUndoList* undoList) override;126127/**@brief write additional element into a xml file128* @param[in] device device in which write parameters of additional element129*/130void writeAdditional(OutputDevice& device) const override;131132/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)133bool isAdditionalValid() const override;134135/// @brief return a string with the current additional problem (must be reimplemented in all detector children)136std::string getAdditionalProblem() const override;137138/// @brief fix additional problem (must be reimplemented in all detector children)139void fixAdditionalProblem() override;140141/// @brief Returns the numerical id of the object142GUIGlID getGlID() const;143144/// @}145146/// @name Function related with contour drawing147/// @{148149/// @brief check if draw move contour (red)150bool checkDrawMoveContour() const override;151152/// @}153154/// @name inherited from GUIGlObject155/// @{156/**@brief Returns the name of the parent object157* @return This object's parent id158*/159std::string getParentName() const override;160161/**@brief Returns an own popup-menu162*163* @param[in] app The application needed to build the popup-menu164* @param[in] parent The parent window needed to build the popup-menu165* @return The built popup-menu166* @see GUIGlObject::getPopUpMenu167*/168GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;169170/**@brief Draws the object171* @param[in] s The settings for the current view (may influence drawing)172* @see GUIGlObject::drawGL173*/174void drawGL(const GUIVisualizationSettings& s) const override;175176/// @}177178/// @name inherited from GNEAttributeCarrier179/// @{180181/**@brief method for getting the Attribute of an XML key182* @param[in] key The attribute key183* @return string with the value associated to key184*/185std::string getAttribute(SumoXMLAttr key) const override;186187/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)188* @param[in] key The attribute key189* @return double with the value associated to key190*/191double getAttributeDouble(SumoXMLAttr key) const override;192193/// @brief get parameters map194const Parameterised::Map& getACParametersMap() const override;195196/**@brief method for setting the attribute and letting the object perform additional changes197* @param[in] key The attribute key198* @param[in] value The new value199* @param[in] undoList The undoList on which to register changes200*/201void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;202203/**@brief method for checking if the key and their correspond attribute are valids204* @param[in] key The attribute key205* @param[in] value The value associated to key key206* @return true if the value is valid, false in other case207*/208bool isValid(SumoXMLAttr key, const std::string& value) override;209210/* @brief method for check if the value for certain attribute is set211* @param[in] key The attribute key212*/213bool isAttributeEnabled(SumoXMLAttr key) const override;214215/// @}216217/// @brief get PopPup ID (Used in AC Hierarchy)218std::string getPopUpID() const override;219220/// @brief get Hierarchy Name (Used in AC Hierarchy)221std::string getHierarchyName() const override;222223protected:224/// @brief shape width of POI225PositionVector myShapeWidth;226227/// @brief shape height of POI228PositionVector myShapeHeight;229230/// @brief variable used for moving contour up231GNEContour myMovingContourUp;232233/// @brief variable used for moving contour down234GNEContour myMovingContourDown;235236/// @brief variable used for moving contour left237GNEContour myMovingContourLeft;238239/// @brief variable used for moving contour right240GNEContour myMovingContourRight;241242private:243/// @brief draw POI244void drawPOI(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,245const bool movingGeometryPoints) const;246247/// @brief calculate contour248void calculatePOIContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,249const double exaggeration, const bool movingGeometryPoints) const;250251/// @brief set attribute after validation252void setAttribute(SumoXMLAttr key, const std::string& value) override;253254/// @brief set move shape255void setMoveShape(const GNEMoveResult& moveResult) override;256257/// @brief commit move shape258void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;259260/// @brief Invalidated copy constructor.261GNEPOI(const GNEPOI&) = delete;262263/// @brief Invalidated assignment operator.264GNEPOI& operator=(const GNEPOI&) = delete;265};266267268