/****************************************************************************/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 GNEDataSet.h14/// @author Pablo Alvarez Lopez15/// @date Jan 202016///17// A abstract class for data elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNEAttributeCarrier.h>23#include <netedit/elements/GNEHierarchicalElement.h>24#include <utils/common/Parameterised.h>2526// ===========================================================================27// class declarations28// ===========================================================================2930class GNENet;31class GNEDataInterval;3233// ===========================================================================34// class definitions35// ===========================================================================3637class GNEDataSet : public GNEAttributeCarrier, public GNEHierarchicalElement, public Parameterised {3839public:40/// @brief attribute colors41class AttributeColors {4243public:44/// @brief default constructor45AttributeColors();4647/// @brief update value for an specific attribute48void updateValues(const std::string& attribute, const double value);4950/// @brief update value for all attributes51void updateAllValues(const AttributeColors& attributeColors);5253/// @brief check if given attribute exist (needed for non-double attributes)54bool exist(const std::string& attribute) const;5556/// @brief get minimum value57double getMinValue(const std::string& attribute) const;5859/// @brief get maximum value60double getMaxValue(const std::string& attribute) const;6162/// @brief clear AttributeColors63void clear();6465private:66/// @brief map with the minimum and maximum value67std::map<std::string, std::pair<double, double> > myMinMaxValue;6869/// @brief Invalidated assignment operator.70AttributeColors& operator=(const AttributeColors&) = delete;71};7273/**@brief Constructor74* @param[in] net pointer to GNEViewNet of this data element element belongs75* @param[in] dataSetID data set ID76* @param[in] filename file in which this dataSet is stored77*/78GNEDataSet(const std::string& dataSetID, GNENet* net, const std::string& filename);7980/// @brief Destructor81~GNEDataSet();8283/// @brief get GNEHierarchicalElement associated with this AttributeCarrier84GNEHierarchicalElement* getHierarchicalElement();8586/// @brief get GUIGlObject associated with this AttributeCarrier87GUIGlObject* getGUIGlObject();8889/// @brief get GUIGlObject associated with this AttributeCarrier (constant)90const GUIGlObject* getGUIGlObject() const;9192/// @brief update attribute colors deprecated93void updateAttributeColors();9495/// @brief all attribute colors96const GNEDataSet::AttributeColors& getAllAttributeColors() const;9798/// @brief specific attribute colors99const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;100101/// @brief update pre-computed geometry information102void updateGeometry();103104/// @brief Returns element position in view105Position getPositionInView() const;106107/// @brief write data set108void writeDataSet(OutputDevice& device) const;109110/// @name Function related with contour drawing111/// @{112113/// @brief check if draw from contour (green)114bool checkDrawFromContour() const;115116/// @brief check if draw from contour (magenta)117bool checkDrawToContour() const;118119/// @brief check if draw related contour (cyan)120bool checkDrawRelatedContour() const;121122/// @brief check if draw over contour (orange)123bool checkDrawOverContour() const;124125/// @brief check if draw delete contour (pink/white)126bool checkDrawDeleteContour() const;127128/// @brief check if draw delete contour small (pink/white)129bool checkDrawDeleteContourSmall() const;130131/// @brief check if draw select contour (blue)132bool checkDrawSelectContour() const;133134/// @brief check if draw move contour (red)135bool checkDrawMoveContour() const;136137/// @}138139/// @name data interval children140/// @{141142/// @brief add data interval child143void addDataIntervalChild(GNEDataInterval* dataInterval);144145/// @brief add data interval child146void removeDataIntervalChild(GNEDataInterval* dataInterval);147148/// @brief check if given data interval exist149bool dataIntervalChildrenExist(GNEDataInterval* dataInterval) const;150151/// @brief update data interval begin152void updateDataIntervalBegin(const double oldBegin);153154/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet155bool checkNewInterval(const double newBegin, const double newEnd);156157/// @brief check if new begin or end for given GNEDataInterval is given158bool checkNewBeginEnd(const GNEDataInterval* dataInterval, const double newBegin, const double newEnd);159160/// @brief return interval161GNEDataInterval* retrieveInterval(const double begin, const double end) const;162163/// @brief get data interval children164const std::map<const double, GNEDataInterval*>& getDataIntervalChildren() const;165166/// @}167168/// @name inherited from GNEAttributeCarrier169/// @{170/* @brief method for getting the Attribute of an XML key171* @param[in] key The attribute key172* @return string with the value associated to key173*/174std::string getAttribute(SumoXMLAttr key) const;175176/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)177* @param[in] key The attribute key178* @return double with the value associated to key179*/180double getAttributeDouble(SumoXMLAttr key) const;181182/**@brief method for setting the attribute and letting the object perform data element changes183* @param[in] key The attribute key184* @param[in] value The new value185* @param[in] undoList The undoList on which to register changes186*/187void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);188189/**@brief method for checking if the key and their conrrespond attribute are valids190* @param[in] key The attribute key191* @param[in] value The value associated to key key192* @return true if the value is valid, false in other case193*/194bool isValid(SumoXMLAttr key, const std::string& value);195196/// @brief get PopPup ID (Used in AC Hierarchy)197std::string getPopUpID() const;198199/// @brief get Hierarchy Name (Used in AC Hierarchy)200std::string getHierarchyName() const;201/// @}202203/// @brief get parameters map204const Parameterised::Map& getACParametersMap() const;205206protected:207/// @brief dataSet ID208std::string myDataSetID;209210/// @brief map with dataIntervals children sorted by begin211std::map<const double, GNEDataInterval*> myDataIntervalChildren;212213/// @brief all attribute colors214GNEDataSet::AttributeColors myAllAttributeColors;215216/// @brief specific attribute colors217std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;218219private:220/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)221void setAttribute(SumoXMLAttr key, const std::string& value);222223/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet224static bool checkNewInterval(const std::map<const double, GNEDataInterval*>& dataIntervalMap, const double newBegin, const double newEnd);225226/// @brief Invalidated copy constructor.227GNEDataSet(const GNEDataSet&) = delete;228229/// @brief Invalidated assignment operator.230GNEDataSet& operator=(const GNEDataSet&) = delete;231};232233/****************************************************************************/234235236