Path: blob/main/src/netedit/elements/data/GNEGenericData.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 GNEGenericData.h14/// @author Pablo Alvarez Lopez15/// @date Jan 202016///17// A abstract class for generic datas18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNEAttributeCarrier.h>23#include <netedit/elements/GNEHierarchicalElement.h>24#include <netedit/elements/GNEPathElement.h>25#include <utils/gui/globjects/GUIGlObject.h>26#include <utils/common/Parameterised.h>2728// ===========================================================================29// class declarations30// ===========================================================================3132class GNEDataInterval;33class GNENet;3435// ===========================================================================36// class definitions37// ===========================================================================3839class GNEGenericData : public GNEAttributeCarrier, public GNEHierarchicalElement, public GUIGlObject, public GNEPathElement, public Parameterised {4041public:42/// @brief default Constructor43GNEGenericData(SumoXMLTag tag, GNENet* net);4445/**@brief Constructor46* @param[in] tag generic data Tag (edgeData, laneData, etc.)47* @param[in] dataIntervalParent pointer to data interval parent48* @param[in] parameters parameters map49*/50GNEGenericData(const SumoXMLTag tag, GNEDataInterval* dataIntervalParent,51const Parameterised::Map& parameters);5253/// @brief Destructor54virtual ~GNEGenericData();5556/// @brief check if current generic data is visible57virtual bool isGenericDataVisible() const = 0;5859/// @brief get GNEHierarchicalElement associated with this AttributeCarrier60GNEHierarchicalElement* getHierarchicalElement();6162/// @brief get GUIGlObject associated with this AttributeCarrier63GUIGlObject* getGUIGlObject();6465/// @brief get GUIGlObject associated with this AttributeCarrier (constant)66const GUIGlObject* getGUIGlObject() const;6768/// @brief get data interval parent69GNEDataInterval* getDataIntervalParent() const;7071// @brief draw attribute72void drawAttribute(const PositionVector& shape) const;7374/// @brief update pre-computed geometry information75virtual void updateGeometry() = 0;7677/// @brief Returns element position in view78virtual Position getPositionInView() const = 0;7980/// @name Function related with contour drawing81/// @{8283/// @brief check if draw from contour (green)84bool checkDrawFromContour() const;8586/// @brief check if draw from contour (magenta)87bool checkDrawToContour() const;8889/// @brief check if draw related contour (cyan)90bool checkDrawRelatedContour() const;9192/// @brief check if draw over contour (orange)93bool checkDrawOverContour() const;9495/// @brief check if draw delete contour (pink/white)96bool checkDrawDeleteContour() const;9798/// @brief check if draw delete contour small (pink/white)99bool checkDrawDeleteContourSmall() const;100101/// @brief check if draw select contour (blue)102bool checkDrawSelectContour() const;103104/// @brief check if draw move contour (red)105bool checkDrawMoveContour() const;106107/// @}108109/// @name members and functions relative to write data sets into XML110/// @{111/**@brief write data set element into a xml file112* @param[in] device device in which write parameters of data set element113*/114virtual void writeGenericData(OutputDevice& device) const = 0;115116/// @brief check if current data set is valid to be written into XML (by default true, can be reimplemented in children)117virtual bool isGenericDataValid() const;118119/// @brief return a string with the current data set problem (by default empty, can be reimplemented in children)120virtual std::string getGenericDataProblem() const;121122/// @brief fix data set problem (by default throw an exception, has to be reimplemented in children)123virtual void fixGenericDataProblem();124/// @}125126/// @name inherited from GUIGlObject127/// @{128/**@brief Returns an own popup-menu129*130* @param[in] app The application needed to build the popup-menu131* @param[in] parent The parent window needed to build the popup-menu132* @return The built popup-menu133* @see GUIGlObject::getPopUpMenu134*/135GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent);136137/**@brief Returns an own parameter window138*139* @param[in] app The application needed to build the parameter window140* @param[in] parent The parent window needed to build the parameter window141* @return The built parameter window142* @see GUIGlObject::getParameterWindow143*/144GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent);145146/**@brief Draws the object147* @param[in] s The settings for the current view (may influence drawing)148* @see GUIGlObject::drawGL149*/150virtual void drawGL(const GUIVisualizationSettings& s) const = 0;151152/// @brief delete element153void deleteGLObject();154155/// @brief select element156void selectGLObject();157158/// @brief update GLObject (geometry, ID, etc.)159void updateGLObject();160161//// @brief Returns the boundary to which the view shall be centered in order to show the object162virtual Boundary getCenteringBoundary() const = 0;163164/// @}165166/// @name inherited from GNEPathElement167/// @{168169/// @brief compute pathElement170virtual void computePathElement() = 0;171172/// @brief check if path element is selected173bool isPathElementSelected() const;174175/**@brief Draws partial object over lane176* @param[in] s The settings for the current view (may influence drawing)177* @param[in] segment lane segment178* @param[in] offsetFront front offset179*/180virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;181182/**@brief Draws partial object over junction183* @param[in] s The settings for the current view (may influence drawing)184* @param[in] segment junction segment185* @param[in] offsetFront front offset186*/187virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;188189/// @brief get first path lane190virtual GNELane* getFirstPathLane() const = 0;191192/// @brief get last path lane193virtual GNELane* getLastPathLane() const = 0;194195/// @}196197/// @name inherited from GNEAttributeCarrier198/// @{199/* @brief method for getting the Attribute of an XML key200* @param[in] key The attribute key201* @return string with the value associated to key202*/203virtual std::string getAttribute(SumoXMLAttr key) const = 0;204205/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)206* @param[in] key The attribute key207* @return double with the value associated to key208*/209virtual double getAttributeDouble(SumoXMLAttr key) const = 0;210211/**@brief method for setting the attribute and letting the object perform data set changes212* @param[in] key The attribute key213* @param[in] value The new value214* @param[in] undoList The undoList on which to register changes215*/216virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;217218/**@brief method for checking if the key and their conrrespond attribute are valids219* @param[in] key The attribute key220* @param[in] value The value associated to key key221* @return true if the value is valid, false in other case222*/223virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;224225/// @brief get PopPup ID (Used in AC Hierarchy)226virtual std::string getPopUpID() const = 0;227228/// @brief get Hierarchy Name (Used in AC Hierarchy)229virtual std::string getHierarchyName() const = 0;230/// @}231232/// @brief get parameters map233const Parameterised::Map& getACParametersMap() const;234235protected:236/// @brief dataInterval Parent237GNEDataInterval* myDataIntervalParent;238239/// @brief draw filtered attribute240void drawFilteredAttribute(const GUIVisualizationSettings& s, const PositionVector& laneShape, const std::string& attribute, const GNEDataInterval* dataIntervalParent) const;241242/// @brief check if attribute is visible in inspect, delete or select mode243bool isVisibleInspectDeleteSelect() const;244245/// @brief replace the first parent edge246void replaceFirstParentEdge(const std::string& value);247248/// @brief replace the last parent edge249void replaceLastParentEdge(const std::string& value);250251/// @brief replace the first parent TAZElement252void replaceParentTAZElement(const int index, const std::string& value);253254/// @brief get partial ID255std::string getPartialID() const;256257private:258/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)259virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;260261/// @brief Invalidated copy constructor.262GNEGenericData(const GNEGenericData&) = delete;263264/// @brief Invalidated assignment operator.265GNEGenericData& operator=(const GNEGenericData&) = delete;266};267268/****************************************************************************/269270271