Path: blob/main/src/netedit/elements/data/GNEDataInterval.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 GNEDataInterval.h14/// @author Pablo Alvarez Lopez15/// @date Jan 202016///17// A abstract class for data elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include "GNEDataSet.h"2324// ===========================================================================25// class declarations26// ===========================================================================2728class GNEGenericData;2930// ===========================================================================31// class definitions32// ===========================================================================3334class GNEDataInterval : public GNEAttributeCarrier, public GNEHierarchicalElement, public Parameterised {3536public:37/**@brief Constructor38* @param[in] dataSetParent GNEDataSet to which this data interval belongs.39* @param[in] begin interval begin40* @param[in] end interval end41*/42GNEDataInterval(GNEDataSet* dataSetParent, const double begin, const double end);4344/// @brief Destructor45~GNEDataInterval();4647/// @brief get GNEHierarchicalElement associated with this AttributeCarrier48GNEHierarchicalElement* getHierarchicalElement();4950/// @brief update generic data child IDs51void updateGenericDataIDs();5253/// @brief update attribute colors deprecated54void updateAttributeColors();5556/// @brief all attribute colors57const GNEDataSet::AttributeColors& getAllAttributeColors() const;5859/// @brief specific attribute colors60const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;6162/// @brief get GUIGlObject associated with this AttributeCarrier63GUIGlObject* getGUIGlObject();6465/// @brief get GUIGlObject associated with this AttributeCarrier (constant)66const GUIGlObject* getGUIGlObject() const;6768/// @brief update pre-computed geometry information69void updateGeometry();7071/// @brief Returns element position in view72Position getPositionInView() const;7374/// @name Function related with contour drawing75/// @{7677/// @brief check if draw from contour (green)78bool checkDrawFromContour() const;7980/// @brief check if draw from contour (magenta)81bool checkDrawToContour() const;8283/// @brief check if draw related contour (cyan)84bool checkDrawRelatedContour() const;8586/// @brief check if draw over contour (orange)87bool checkDrawOverContour() const;8889/// @brief check if draw delete contour (pink/white)90bool checkDrawDeleteContour() const;9192/// @brief check if draw delete contour small (pink/white)93bool checkDrawDeleteContourSmall() const;9495/// @brief check if draw select contour (blue)96bool checkDrawSelectContour() const;9798/// @brief check if draw move contour (red)99bool checkDrawMoveContour() const;100101/// @}102103/// @name members and functions relative to write data elements into XML104/// @{105/// @brief check if current data element is valid to be written into XML (by default true, can be reimplemented in children)106bool isDataIntervalValid() const;107108/// @brief return a string with the current data element problem (by default empty, can be reimplemented in children)109std::string getDataIntervalProblem() const;110111/// @brief fix data element problem (by default throw an exception, has to be reimplemented in children)112void fixDataIntervalProblem();113/// @}114115/// @brief Returns a pointer to GNEDataSet parent116GNEDataSet* getDataSetParent() const;117118/// @name generic data children119/// @{120121/// @brief add generic data child122void addGenericDataChild(GNEGenericData* genericData);123124/// @brief add generic data child125void removeGenericDataChild(GNEGenericData* genericData);126127/// @brief check if given generic data is child of this data interval128bool hasGenericDataChild(GNEGenericData* genericData) const;129130/// @brief get generic data children131const std::vector<GNEGenericData*>& getGenericDataChildren() const;132133/// @brief check if there is already a edgeRel single defined in the given edge134bool edgeRelSingleExists(const GNEEdge* edge) const;135136/// @brief check if there is already a edgeRel defined between two edges137bool edgeRelExists(const GNEEdge* fromEdge, const GNEEdge* toEdge) const;138139/// @brief check if there is already a TAZRel defined in one TAZ140bool TAZRelExists(const GNEAdditional* TAZ) const;141142/// @brief check if there is already a TAZRel defined between two TAZs143bool TAZRelExists(const GNEAdditional* fromTAZ, const GNEAdditional* toTAZ) const;144145/// @}146147/// @name inherited from GNEAttributeCarrier148/// @{149/* @brief method for getting the Attribute of an XML key150* @param[in] key The attribute key151* @return string with the value associated to key152*/153std::string getAttribute(SumoXMLAttr key) const;154155/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)156* @param[in] key The attribute key157* @return double with the value associated to key158*/159double getAttributeDouble(SumoXMLAttr key) const;160161/**@brief method for setting the attribute and letting the object perform data element changes162* @param[in] key The attribute key163* @param[in] value The new value164* @param[in] undoList The undoList on which to register changes165*/166void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);167168/**@brief method for checking if the key and their conrrespond attribute are valids169* @param[in] key The attribute key170* @param[in] value The value associated to key key171* @return true if the value is valid, false in other case172*/173bool isValid(SumoXMLAttr key, const std::string& value);174175/* @brief method for check if the value for certain attribute is set176* @param[in] key The attribute key177*/178bool isAttributeEnabled(SumoXMLAttr key) const;179180/// @brief get PopPup ID (Used in AC Hierarchy)181std::string getPopUpID() const;182183/// @brief get Hierarchy Name (Used in AC Hierarchy)184std::string getHierarchyName() const;185/// @}186187/// @brief get parameters map188const Parameterised::Map& getACParametersMap() const;189190protected:191/// @brief all attribute colors192GNEDataSet::AttributeColors myAllAttributeColors;193194/// @brief specific attribute colors195std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;196197/// @brief GNEDataSet parent to which this data interval belongs.198GNEDataSet* myDataSetParent;199200/// @brief begin interval201double myBegin;202203/// @brief end interval204double myEnd;205206/// @brief vector with generic data children207std::vector<GNEGenericData*> myGenericDataChildren;208209private:210/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)211void setAttribute(SumoXMLAttr key, const std::string& value);212213/// @brief Invalidated copy constructor.214GNEDataInterval(const GNEDataInterval&) = delete;215216/// @brief Invalidated assignment operator.217GNEDataInterval& operator=(const GNEDataInterval&) = delete;218};219220/****************************************************************************/221222223