Path: blob/main/src/netedit/elements/data/GNEDataInterval.h
194314 views
/****************************************************************************/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 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 {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 methods to retrieve the elements linked to this dataInterval48/// @{4950/// @brief get GNEHierarchicalElement associated with this dataInterval51GNEHierarchicalElement* getHierarchicalElement() override;5253/// @brief get GNEMoveElement associated with this dataInterval54GNEMoveElement* getMoveElement() const override;5556/// @brief get parameters associated with this dataInterval57Parameterised* getParameters() override;5859/// @brief get parameters associated with this dataInterval (const)60const Parameterised* getParameters() const override;6162/// @brief get GUIGlObject associated with this dataInterval63GUIGlObject* getGUIGlObject() override;6465/// @brief get GUIGlObject associated with this dataInterval (constant)66const GUIGlObject* getGUIGlObject() const override;6768/// @}6970/// @brief update generic data child IDs71void updateGenericDataIDs();7273/// @brief update attribute colors deprecated74void updateAttributeColors();7576/// @brief all attribute colors77const GNEDataSet::AttributeColors& getAllAttributeColors() const;7879/// @brief specific attribute colors80const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;8182/// @brief update pre-computed geometry information83void updateGeometry() override;8485/// @brief Returns element position in view86Position getPositionInView() const;8788/// @name Function related with contour drawing89/// @{9091/// @brief check if draw from contour (green)92bool checkDrawFromContour() const override;9394/// @brief check if draw from contour (magenta)95bool checkDrawToContour() const override;9697/// @brief check if draw related contour (cyan)98bool checkDrawRelatedContour() const override;99100/// @brief check if draw over contour (orange)101bool checkDrawOverContour() const override;102103/// @brief check if draw delete contour (pink/white)104bool checkDrawDeleteContour() const override;105106/// @brief check if draw delete contour small (pink/white)107bool checkDrawDeleteContourSmall() const override;108109/// @brief check if draw select contour (blue)110bool checkDrawSelectContour() const override;111112/// @brief check if draw move contour (red)113bool checkDrawMoveContour() const override;114115/// @}116117/// @brief get reference to fileBucket in which save this AC118FileBucket* getFileBucket() const override;119120/// @name members and functions relative to write data elements into XML121/// @{122/// @brief check if current data element is valid to be written into XML (by default true, can be reimplemented in children)123bool isDataIntervalValid() const;124125/// @brief return a string with the current data element problem (by default empty, can be reimplemented in children)126std::string getDataIntervalProblem() const;127128/// @brief fix data element problem (by default throw an exception, has to be reimplemented in children)129void fixDataIntervalProblem();130/// @}131132/// @brief Returns a pointer to GNEDataSet parent133GNEDataSet* getDataSetParent() const;134135/// @name generic data children136/// @{137138/// @brief add generic data child139void addGenericDataChild(GNEGenericData* genericData);140141/// @brief add generic data child142void removeGenericDataChild(GNEGenericData* genericData);143144/// @brief check if given generic data is child of this data interval145bool hasGenericDataChild(GNEGenericData* genericData) const;146147/// @brief get generic data children148const std::vector<GNEGenericData*>& getGenericDataChildren() const;149150/// @brief check if there is already a edgeRel single defined in the given edge151bool edgeRelSingleExists(const GNEEdge* edge) const;152153/// @brief check if there is already a edgeRel defined between two edges154bool edgeRelExists(const GNEEdge* fromEdge, const GNEEdge* toEdge) const;155156/// @brief check if there is already a TAZRel defined in one TAZ157bool TAZRelExists(const GNEAdditional* TAZ) const;158159/// @brief check if there is already a TAZRel defined between two TAZs160bool TAZRelExists(const GNEAdditional* fromTAZ, const GNEAdditional* toTAZ) const;161162/// @}163164/// @name inherited from GNEAttributeCarrier165/// @{166/* @brief method for getting the Attribute of an XML key167* @param[in] key The attribute key168* @return string with the value associated to key169*/170std::string getAttribute(SumoXMLAttr key) const override;171172/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)173* @param[in] key The attribute key174* @return double with the value associated to key175*/176double getAttributeDouble(SumoXMLAttr key) const override;177178/* @brief method for getting the Attribute of an XML key in position format179* @param[in] key The attribute key180* @return position with the value associated to key181*/182Position getAttributePosition(SumoXMLAttr key) const override;183184/* @brief method for getting the Attribute of an XML key in positionVector format185* @param[in] key The attribute key186* @return positionVector with the value associated to key187*/188PositionVector getAttributePositionVector(SumoXMLAttr key) const override;189190/**@brief method for setting the attribute and letting the object perform data element changes191* @param[in] key The attribute key192* @param[in] value The new value193* @param[in] undoList The undoList on which to register changes194*/195void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;196197/**@brief method for checking if the key and their conrrespond attribute are valids198* @param[in] key The attribute key199* @param[in] value The value associated to key key200* @return true if the value is valid, false in other case201*/202bool isValid(SumoXMLAttr key, const std::string& value) override;203204/* @brief method for check if the value for certain attribute is set205* @param[in] key The attribute key206*/207bool isAttributeEnabled(SumoXMLAttr key) const override;208209/// @brief get PopPup ID (Used in AC Hierarchy)210std::string getPopUpID() const override;211212/// @brief get Hierarchy Name (Used in AC Hierarchy)213std::string getHierarchyName() const override;214/// @}215216protected:217/// @brief all attribute colors218GNEDataSet::AttributeColors myAllAttributeColors;219220/// @brief specific attribute colors221std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;222223/// @brief GNEDataSet parent to which this data interval belongs.224GNEDataSet* myDataSetParent;225226/// @brief begin interval227double myBegin;228229/// @brief end interval230double myEnd;231232/// @brief vector with generic data children233std::vector<GNEGenericData*> myGenericDataChildren;234235private:236/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)237void setAttribute(SumoXMLAttr key, const std::string& value) override;238239/// @brief Invalidated copy constructor.240GNEDataInterval(const GNEDataInterval&) = delete;241242/// @brief Invalidated assignment operator.243GNEDataInterval& operator=(const GNEDataInterval&) = delete;244};245246/****************************************************************************/247248249