/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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 {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*/76GNEDataSet(GNENet* net);7778/**@brief Constructor79* @param[in] net pointer to GNEViewNet of this data element element belongs80* @param[in] dataSetID data set ID81* @param[in] fileBucket file in which this element is stored82*/83GNEDataSet(const std::string& dataSetID, GNENet* net, FileBucket* fileBucket);8485/// @brief Destructor86~GNEDataSet();8788/// @brief methods to retrieve the elements linked to this dataSet89/// @{9091/// @brief get GNEHierarchicalElement associated with this dataSet92GNEHierarchicalElement* getHierarchicalElement() override;9394/// @brief get GNEMoveElement associated with this dataSet95GNEMoveElement* getMoveElement() const override;9697/// @brief get parameters associated with this dataSet98Parameterised* getParameters() override;99100/// @brief get parameters associated with this dataSet (constant)101const Parameterised* getParameters() const override;102103/// @brief get GUIGlObject associated with this dataSet104GUIGlObject* getGUIGlObject() override;105106/// @brief get GUIGlObject associated with this dataSet (constant)107const GUIGlObject* getGUIGlObject() const override;108109/// @}110111/// @brief get reference to fileBucket in which save this AC112FileBucket* getFileBucket() const override;113114/// @brief update attribute colors deprecated115void updateAttributeColors();116117/// @brief all attribute colors118const GNEDataSet::AttributeColors& getAllAttributeColors() const;119120/// @brief specific attribute colors121const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;122123/// @brief update pre-computed geometry information124void updateGeometry() override;125126/// @brief Returns element position in view127Position getPositionInView() const;128129/// @brief write data set130void writeDataSet(OutputDevice& device) const;131132/// @name Function related with contour drawing133/// @{134135/// @brief check if draw from contour (green)136bool checkDrawFromContour() const override;137138/// @brief check if draw from contour (magenta)139bool checkDrawToContour() const override;140141/// @brief check if draw related contour (cyan)142bool checkDrawRelatedContour() const override;143144/// @brief check if draw over contour (orange)145bool checkDrawOverContour() const override;146147/// @brief check if draw delete contour (pink/white)148bool checkDrawDeleteContour() const override;149150/// @brief check if draw delete contour small (pink/white)151bool checkDrawDeleteContourSmall() const override;152153/// @brief check if draw select contour (blue)154bool checkDrawSelectContour() const override;155156/// @brief check if draw move contour (red)157bool checkDrawMoveContour() const override;158159/// @}160161/// @name data interval children162/// @{163164/// @brief add data interval child165void addDataIntervalChild(GNEDataInterval* dataInterval);166167/// @brief add data interval child168void removeDataIntervalChild(GNEDataInterval* dataInterval);169170/// @brief check if given data interval exist171bool dataIntervalChildrenExist(GNEDataInterval* dataInterval) const;172173/// @brief update data interval begin174void updateDataIntervalBegin(const double oldBegin);175176/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet177bool checkNewInterval(const double newBegin, const double newEnd);178179/// @brief check if new begin or end for given GNEDataInterval is given180bool checkNewBeginEnd(const GNEDataInterval* dataInterval, const double newBegin, const double newEnd);181182/// @brief return interval183GNEDataInterval* retrieveInterval(const double begin, const double end) const;184185/// @brief get data interval children186const std::map<const double, GNEDataInterval*>& getDataIntervalChildren() const;187188/// @}189190/// @name inherited from GNEAttributeCarrier191/// @{192/* @brief method for getting the Attribute of an XML key193* @param[in] key The attribute key194* @return string with the value associated to key195*/196std::string getAttribute(SumoXMLAttr key) const override;197198/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)199* @param[in] key The attribute key200* @return double with the value associated to key201*/202double getAttributeDouble(SumoXMLAttr key) const override;203204/* @brief method for getting the Attribute of an XML key in position format205* @param[in] key The attribute key206* @return position with the value associated to key207*/208Position getAttributePosition(SumoXMLAttr key) const override;209210/* @brief method for getting the Attribute of an XML key in positionVector format211* @param[in] key The attribute key212* @return positionVector with the value associated to key213*/214PositionVector getAttributePositionVector(SumoXMLAttr key) const override;215216/**@brief method for setting the attribute and letting the object perform data element changes217* @param[in] key The attribute key218* @param[in] value The new value219* @param[in] undoList The undoList on which to register changes220*/221void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;222223/**@brief method for checking if the key and their conrrespond attribute are valids224* @param[in] key The attribute key225* @param[in] value The value associated to key key226* @return true if the value is valid, false in other case227*/228bool isValid(SumoXMLAttr key, const std::string& value) override;229230/// @brief get PopPup ID (Used in AC Hierarchy)231std::string getPopUpID() const override;232233/// @brief get Hierarchy Name (Used in AC Hierarchy)234std::string getHierarchyName() const override;235/// @}236237protected:238/// @brief dataSet ID239std::string myDataSetID;240241/// @brief map with dataIntervals children sorted by begin242std::map<const double, GNEDataInterval*> myDataIntervalChildren;243244/// @brief all attribute colors245GNEDataSet::AttributeColors myAllAttributeColors;246247/// @brief specific attribute colors248std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;249250private:251/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)252void setAttribute(SumoXMLAttr key, const std::string& value) override;253254/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet255static bool checkNewInterval(const std::map<const double, GNEDataInterval*>& dataIntervalMap, const double newBegin, const double newEnd);256257/// @brief Invalidated copy constructor.258GNEDataSet(const GNEDataSet&) = delete;259260/// @brief Invalidated assignment operator.261GNEDataSet& operator=(const GNEDataSet&) = delete;262};263264/****************************************************************************/265266267