/****************************************************************************/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 GNETagProperties.h14/// @author Pablo Alvarez Lopez15/// @date Jan 202016///17// Abstract Base class for tag properties used in GNEAttributeCarrier18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/gui/globjects/GUIGlObjectTypes.h>23#include <utils/gui/images/GUIIcons.h>24#include <netedit/GNEViewNetHelper.h>25#include "GNEAttributeProperties.h"2627// ===========================================================================28// class definitions29// ===========================================================================3031class GNETagProperties {3233public:3435/// @brief tag types36enum class Type : int {37// basic types38NETWORKELEMENT = 1 << 0, // Network elements (Edges, Junctions, Lanes...)39ADDITIONALELEMENT = 1 << 1, // Additional elements (Bus Stops, Charging Stations, Detectors...)40DEMANDELEMENT = 1 << 2, // Demand elements (Routes, Vehicles, Trips...)41DATAELEMENT = 1 << 3, // Data elements (DataSets, Data Intervals, EdgeData...)42// sub additional elements43STOPPINGPLACE = 1 << 4, // StoppingPlaces (BusStops, ChargingStations...)44DETECTOR = 1 << 5, // Detectors (E1, E2...)45CALIBRATOR = 1 << 6, // Calibrators46SHAPE = 1 << 7, // Shapes (Polygons and POIs)47TAZELEMENT = 1 << 8, // Traffic Assignment Zones48WIRE = 1 << 9, // Wire elements49JUPEDSIM = 1 << 10, // JuPedSim elements50// sub demand elements51VTYPE = 1 << 11, // Vehicle types (vType and vTypeDistribution)52VEHICLE = 1 << 12, // Vehicles (Vehicles, trips, flows...)53ROUTE = 1 << 13, // Routes and embedded routes54STOP_VEHICLE = 1 << 14, // Vehicle stops55WAYPOINT_VEHICLE = 1 << 15, // Vehicle waypoints (note: All waypoints are also Stops)56FLOW = 1 << 16, // Flows57// persons58PERSON = 1 << 17, // Persons (Persons and personFlows)59PERSONPLAN = 1 << 18, // Person plans (Walks, rides, personTrips and stopPersons)60PERSONTRIP = 1 << 19, // Person Trips61WALK = 1 << 20, // Walks62RIDE = 1 << 21, // Rides63STOP_PERSON = 1 << 22, // Person stops64// containers65CONTAINER = 1 << 23, // Containers (Containers and personFlows)66CONTAINERPLAN = 1 << 24, // Container plans (transport, tranships and containerStops)67TRANSPORT = 1 << 25, // Transport68TRANSHIP = 1 << 26, // Tranship69STOP_CONTAINER = 1 << 27, // Container stops70// sub data elements71GENERICDATA = 1 << 28, // Generic data (GNEEdgeData, GNELaneData...)72MEANDATA = 1 << 29, // Mean datas73// other74INTERNALLANE = 1 << 30, // Internal Lane75OTHER = 1 << 31, // Other type (used for TAZSourceSinks, VTypes, etc.)76};7778/// @brief tag property79enum class Property : int {80NOTDRAWABLE = 1 << 0, // Element cannot be drawn in view81GEOSHAPE = 1 << 1, // Element's shape acn be defined using a GEO Shape82DIALOG = 1 << 2, // Element can be edited using a dialog (GNECalibratorDialog, GNERerouterDialog...)83XMLCHILD = 1 << 3, // Element is child of another element and will be written in XML (Example: E3Entry -> E3Detector...)84REPARENT = 1 << 4, // Element can be reparent85NOTSELECTABLE = 1 << 5, // Element cannot be selected86NOPARAMETERS = 1 << 6, // Element doesn't accept parameters "key1=value1|key2=value2|...|keyN=valueN" (by default all tags supports parameters)87RTREE = 1 << 7, // Element is placed in RTREE88CENTERAFTERCREATION = 1 << 8, // Camera is moved after element creation89REQUIRE_PROJ = 1 << 9, // Element require a geo-projection defined in network90VCLASS_ICON = 1 << 10, // Element returns icon depending of their vClass91SYMBOL = 1 << 11, // Element is a symbol (VSSSymbols, RerouterSymbols...)92EXTENDED = 1 << 12, // Element contains extended attributes (Usually vTypes)93HIERARCHICAL = 1 << 13, // Element is a hierarchical94LISTED = 1 << 14, // Element is a listed elements (for example, rerouter children)95NO_PROPERTY = 1 << 15, // Element doesn't have properties96};9798/// @brief element in which this element is placed99enum class Over : int {100VIEW = 1 << 0, // No parents101JUNCTION = 1 << 1, // Placed over junction102EDGE = 1 << 2, // Placed over edge103EDGES = 1 << 3, // Placed over edges104CONSECUTIVE_EDGES = 1 << 4, // Placed over consecutive105LANE = 1 << 5, // Placed over lane106LANES = 1 << 6, // Placed over lanes107CONSECUTIVE_LANES = 1 << 4, // Placed over consecutive lanes108ROUTE = 1 << 7, // Placed over route109ROUTE_EMBEDDED = 1 << 8, // Placed over route embedded110BUSSTOP = 1 << 9, // Placed over busStop111TRAINSTOP = 1 << 10, // Placed over trainStop112CONTAINERSTOP = 1 << 11, // Placed over containerStop113CHARGINGSTATION = 1 << 12, // Placed over charging station114PARKINGAREA = 1 << 13, // Placed over parking area115FROM_EDGE = 1 << 14, // Starts in edge116FROM_TAZ = 1 << 15, // Starts in TAZ117FROM_JUNCTION = 1 << 16, // Starts in junction118FROM_BUSSTOP = 1 << 17, // Starts in busStop119FROM_TRAINSTOP = 1 << 18, // Starts in trainStop120FROM_CONTAINERSTOP = 1 << 19, // Starts in containerStop121FROM_CHARGINGSTATION = 1 << 20, // Starts in chargingStation122FROM_PARKINGAREA = 1 << 21, // Starts in parkingArea123TO_EDGE = 1 << 22, // Ends in edge124TO_TAZ = 1 << 23, // Ends in TAZ125TO_JUNCTION = 1 << 24, // Ends in junction126TO_BUSSTOP = 1 << 25, // Ends in busStop127TO_TRAINSTOP = 1 << 26, // Ends in trainStop128TO_CONTAINERSTOP = 1 << 27, // Ends in containerStop129TO_CHARGINGSTATION = 1 << 28, // Ends in chargingStation130TO_PARKINGAREA = 1 << 29, // Ends in parkingArea131};132133// @brief conflicts134enum class Conflicts : int {135POS_LANE = 1 << 0, // Position over lane isn't valid136POS_LANE_START = 1 << 1, // Start position over lane isn't valid137POS_LANE_END = 1 << 2, // End position over lane isn't valid138NO_ADDITIONAL_CHILDREN = 1 << 3, // Element doesn't have additional children139NO_CONFLICTS = 1 << 4, // Element doesn't have conflicts140};141142/// @brief declare friend class143friend class GNEAttributeProperties;144145/// @brief parameter constructor146GNETagProperties(const SumoXMLTag tag, GNETagProperties* parent, const Type tagType, const Property tagProperty, const Over tagOver,147const Conflicts conflicts, const GUIIcon icon, const GUIGlObjectType GLType, const SumoXMLTag XMLTag,148const std::string tooltip, std::vector<SumoXMLTag> XMLParentTags = {},149const unsigned int backgroundColor = FXRGBA(255, 255, 255, 255), const std::string selectorText = "");150151/// @brief parameter constructor for hierarchical elements152GNETagProperties(const SumoXMLTag tag, GNETagProperties* parent, const GUIIcon icon, const std::string tooltip,153const unsigned int backgroundColor = FXRGBA(255, 255, 255, 255), const std::string selectorText = "");154155/// @brief destructor156~GNETagProperties();157158/// @brief get Tag vinculated with this attribute Property159SumoXMLTag getTag() const;160161/// @brief get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toString(...)162const std::string& getTagStr() const;163164/// @brief check Tag integrity (this include all their attributes)165void checkTagIntegrity() const;166167/// @brief get field string (by default tag in string format)168const std::string& getSelectorText() const;169170/// @brief get tooltip text171const std::string& getTooltipText() const;172173/// @brief get background color174unsigned int getBackGroundColor() const;175176/// @brief get all attribute properties177const std::vector<const GNEAttributeProperties*>& getAttributeProperties() const;178179/// @brief get attribute propety associated with the given Sumo XML Attribute (throw error if doesn't exist)180const GNEAttributeProperties* getAttributeProperties(SumoXMLAttr attr) const;181182/// @brief get attribute propety by index (throw error if doesn't exist)183const GNEAttributeProperties* getAttributeProperties(const int index) const;184185/// @brief get attribute value186const GNEAttributeProperties* at(int index) const;187188/// @brief check if current TagProperties owns the attribute "attr"189bool hasAttribute(SumoXMLAttr attr) const;190191/// @brief get number of attributes192int getNumberOfAttributes() const;193194/// @brief get GUI icon associated to this tag property195GUIIcon getGUIIcon() const;196197/// @brief get GUIGlObjectType associated with this tag property198GUIGlObjectType getGLType() const;199200/// @brief default values201/// @{202203/// @brief get XML tag204SumoXMLTag getXMLTag() const;205206/// @brief get XML parent tags207const std::vector<SumoXMLTag>& getXMLParentTags() const;208209/// @brief return true if tag correspond to an element that can be reparent210bool canBeReparent() const;211212/// @brief default values213/// @{214215/// @brief return the default value of the attribute of an element216const std::string& getDefaultStringValue(SumoXMLAttr attr) const;217218/// @brief get default int value219int getDefaultIntValue(SumoXMLAttr attr) const;220221/// @brief get default double value222double getDefaultDoubleValue(SumoXMLAttr attr) const;223224/// @brief get default time value225SUMOTime getDefaultTimeValue(SumoXMLAttr attr) const;226227/// @brief get default bool value228bool getDefaultBoolValue(SumoXMLAttr attr) const;229230/// @brief get default bool value231const RGBColor& getDefaultColorValue(SumoXMLAttr attr) const;232233/// @}234235/// @brief hierarchy functions236/// @{237238/// @brief get hierarchical parent of this element239const GNETagProperties* getHierarchicalParent() const;240241/// @brief get all parents, beginning from current element (root not included) until this element242const std::vector<const GNETagProperties*> getHierarchicalParentsRecuersively() const;243244/// @brief get children of this tag property245const std::vector<const GNETagProperties*>& getHierarchicalChildren() const;246247/// @brief get all children tags (Including children of their children)248std::vector<const GNETagProperties*> getHierarchicalChildrenRecursively() const;249250/// @brief get all children attributes sorted by name (Including this)251std::map<std::string, const GNEAttributeProperties*> getHierarchicalChildrenAttributesRecursively(const bool onlyCommon, const bool onlyDrawables) const;252253/// @}254255/// @brief get supermode associated with this tag256Supermode getSupermode() const;257258/// @brief check if this is a hierarchical tag259bool isHierarchicalTag() const;260261/// @brief network elements262/// @{263264/// @brief return true if tag correspond to a network element265bool isNetworkElement() const;266267/// @brief return true if tag correspond to an additional element (note: this include TAZ, shapes and wires)268bool isAdditionalElement() const;269270/// @brief return true if tag correspond to a pure additional element271bool isAdditionalPureElement() const;272273/// @brief return true if tag correspond to a demand element274bool isDemandElement() const;275276/// @brief return true if tag correspond to a data element277bool isDataElement() const;278279/// @brief return true if tag correspond to a other element (sourceSinks, vTypes, etc.)280bool isOtherElement() const;281282/// @}283284/// @brief additional elements285/// @{286/// @brief return true if tag correspond to a detector (Only used to group all stoppingPlaces in the output XML)287bool isStoppingPlace() const;288289/// @brief return true if tag correspond to a shape (Only used to group all detectors in the XML)290bool isDetector() const;291292/// @brief return true if tag correspond to a calibrator (Only used to group all detectors in the XML)293bool isCalibrator() const;294295/// @brief return true if tag correspond to a shape296bool isShapeElement() const;297298/// @brief return true if tag correspond to a TAZ element299bool isTAZElement() const;300301/// @brief return true if tag correspond to a Wire element302bool isWireElement() const;303304/// @brief return true if tag correspond to a JuPedSim element305bool isJuPedSimElement() const;306307/// @}308309/// @brief demand elements310/// @{311/// @brief return true if tag correspond to a vehicle/person/container type element312bool isType() const;313314/// @brief return true if tag correspond to a type distribution element315bool isTypeDist() const;316317/// @brief return true if tag correspond to a vehicle element318bool isVehicle() const;319320/// @brief return true if tag correspond to a route element321bool isRoute() const;322323/// @brief return true if tag correspond to a vehicle stop element324bool isVehicleStop() const;325326/// @brief return true if tag correspond to a vehicle waypoint element327bool isVehicleWaypoint() const;328329/// @brief return true if tag correspond to a flow element330bool isFlow() const;331332/// @brief return true if tag correspond to a person element333bool isPerson() const;334335/// @brief return true if tag correspond to a container element336bool isContainer() const;337338/// @brief return true if tag correspond to an element with a type as a first parent339bool hasTypeParent() const;340341/// @}342343/// @brief plans344/// @{345/// @brief return true if tag correspond to a plan346bool isPlan() const;347348/// @brief return true if tag correspond to a person plan349bool isPlanPerson() const;350351/// @brief return true if tag correspond to a container plan352bool isPlanContainer() const;353354/// @brief return true if tag correspond to a person trip plan355bool isPlanPersonTrip() const;356357/// @brief return true if tag correspond to a walk plan358bool isPlanWalk() const;359360/// @brief return true if tag correspond to a ride plan361bool isPlanRide() const;362363/// @brief return true if tag correspond to a transport364bool isPlanTransport() const;365366/// @brief return true if tag correspond to a tranship367bool isPlanTranship() const;368369/// @brief return true if tag correspond to a stop plan370bool isPlanStop() const;371372/// @brief return true if tag correspond to a person stop plan373bool isPlanStopPerson() const;374375/// @brief return true if tag correspond to a container stop plan376bool isPlanStopContainer() const;377378/// @}379380/// @brief data elements381/// @{382/// @brief return true if tag correspond to a generic data element383bool isGenericData() const;384385/// @brief return true if tag correspond to a mean data element386bool isMeanData() const;387388/// @}389390/// @brief plan parents391/// @{392393/// @brief return true if tag correspond to a vehicle placed over a route394bool vehicleRoute() const;395396/// @brief return true if tag correspond to a vehicle placed over an embedded route397bool vehicleRouteEmbedded() const;398399/// @brief return true if tag correspond to a vehicle placed over from-to edges400bool vehicleEdges() const;401402/// @brief return true if tag correspond to a vehicle placed over from-to junctions403bool vehicleJunctions() const;404405/// @brief return true if tag correspond to a vehicle placed over from-to TAZs406bool vehicleTAZs() const;407408/// @}409410/// @brief plan parents411/// @{412/// @brief return true if tag correspond to a plan placed over edges413bool planConsecutiveEdges() const;414415/// @brief return true if tag correspond to a plan placed over route416bool planRoute() const;417418/// @brief return true if tag correspond to a plan placed over edge419bool planEdge() const;420421/// @brief return true if tag correspond to a plan placed over busStop422bool planBusStop() const;423424/// @brief return true if tag correspond to a plan placed over trainStop425bool planTrainStop() const;426427/// @brief return true if tag correspond to a plan placed over containerStop428bool planContainerStop() const;429430/// @brief return true if tag correspond to a plan placed over chargingStation431bool planChargingStation() const;432433/// @brief return true if tag correspond to a plan placed over parkingArea434bool planParkingArea() const;435436/// @brief return true if tag correspond to a plan placed in stoppingPlace437bool planStoppingPlace() const;438439/// @brief return true if tag correspond to a plan with from-to parents440bool planFromTo() const;441442/// @brief return true if tag correspond to a plan that starts in edge443bool planFromEdge() const;444445/// @brief return true if tag correspond to a plan that starts in TAZ446bool planFromTAZ() const;447448/// @brief return true if tag correspond to a plan that starts in junction449bool planFromJunction() const;450451/// @brief return true if tag correspond to a plan that starts in busStop452bool planFromBusStop() const;453454/// @brief return true if tag correspond to a plan that starts in trainStop455bool planFromTrainStop() const;456457/// @brief return true if tag correspond to a plan that starts in containerStop458bool planFromContainerStop() const;459460/// @brief return true if tag correspond to a plan that starts in chargingStation461bool planFromChargingStation() const;462463/// @brief return true if tag correspond to a plan that starts in parkingAera464bool planFromParkingArea() const;465466/// @brief return true if tag correspond to a plan that starts in stoppingPlace467bool planFromStoppingPlace() const;468469/// @brief return true if tag correspond to a plan that starts in edge470bool planToEdge() const;471472/// @brief return true if tag correspond to a plan that starts in TAZ473bool planToTAZ() const;474475/// @brief return true if tag correspond to a plan that starts in junction476bool planToJunction() const;477478/// @brief return true if tag correspond to a plan that starts in busStop479bool planToBusStop() const;480481/// @brief return true if tag correspond to a plan that starts in trainStop482bool planToTrainStop() const;483484/// @brief return true if tag correspond to a plan that starts in containerStop485bool planToContainerStop() const;486487/// @brief return true if tag correspond to a plan that starts in chargingStation488bool planToChargingStation() const;489490/// @brief return true if tag correspond to a plan that starts in parkingArea491bool planToParkingArea() const;492493/// @brief return true if tag correspond to a plan that ends in stoppingPlace494bool planToStoppingPlace() const;495496/// @}497498/// @brief return true if tag correspond to an element child of another element (Example: E3->Entry/Exit)499bool isChild() const;500501/// @brief return true if tag correspond to a symbol element502bool isSymbol() const;503504/// @brief return true if tag correspond to an internal lane505bool isInternalLane() const;506507/// @brief return true if tag correspond to a drawable element508bool isDrawable() const;509510/// @brief return true if tag correspond to a selectable element511bool isSelectable() const;512513/// @brief return true if tag correspond to an element that can use a geo shape514bool hasGEOShape() const;515516/// @brief return true if tag correspond to an element that can be edited using a dialog517bool hasDialog() const;518519/// @brief return true if tag correspond to an element that contains extended attributes520bool hasExtendedAttributes() const;521522/// @brief return true if Tag correspond to an element that supports parameters "key1=value1|key2=value2|...|keyN=valueN"523bool hasParameters() const;524525/// @brief return true if Tag correspond to an element that has to be placed in RTREE526bool isPlacedInRTree() const;527528/// @brief return true if Tag correspond to a listed element529bool isListedElement() const;530531/// @brief return true if tag correspond to an element that center camera after creation532bool canCenterCameraAfterCreation() const;533534/// @brief return true if tag correspond to an element that requires a geo projection535bool requireProj() const;536537/// @brief return true if tag correspond to an element that has vClass icons538bool vClassIcon() const;539540protected:541/// @brief add child542void addChild(const GNETagProperties* child);543544private:545/// @brief Sumo XML Tag vinculated wit this tag Property546const SumoXMLTag myTag = SUMO_TAG_NOTHING;547548/// @brief Sumo XML Tag vinculated wit this tag Property in String format549const std::string myTagStr;550551/// @brief tag property parent552const GNETagProperties* myParent = nullptr;553554/// @brief tag property children555std::vector<const GNETagProperties*> myChildren;556557/// @brief tag Types558const Type myTagType = Type::OTHER;559560/// @brief tag properties561const Property myTagProperty = Property::NO_PROPERTY;562563/// @brief tag over564const Over myTagOver = Over::VIEW;565566/// @brief conflicts567const Conflicts myConflicts = Conflicts::NO_CONFLICTS;568569/// @brief vector with the attribute values vinculated with this Tag570std::vector<const GNEAttributeProperties*> myAttributeProperties;571572/// @brief icon associated to this tag property573const GUIIcon myIcon = GUIIcon::EMPTY;574575/// @brief GUIGlObjectType associated with this tag property576const GUIGlObjectType myGLType = GUIGlObjectType::GLO_MAX;577578/// @brief Tag written in XML and used in GNENetHelper::AttributeCarriers579const SumoXMLTag myXMLTag = SUMO_TAG_NOTHING;580581/// @brief tooltip text582const std::string myTooltipText;583584/// @brief vector with XML parent tags (used by child elements like access or spaces)585const std::vector<SumoXMLTag> myXMLParentTags;586587/// @brief text show in selector text588const std::string mySelectorText;589590/// @brief background color (used in labels and textFields, by default white)591const unsigned int myBackgroundColor = 0;592593/// @brief recursive function for get all children tag properites (Including this)594void getChildrenTagProperties(const GNETagProperties* tagProperties, std::vector<const GNETagProperties*>& result) const;595596/// @brief recursive function for get all children attributes (Including this)597void getChildrenAttributes(const GNETagProperties* tagProperties, std::map<std::string, const GNEAttributeProperties*>& result, const bool onlyDrawables) const;598599/// @brief default constructor600GNETagProperties() = delete;601602/// @brief Invalidated copy constructor.603GNETagProperties(const GNETagProperties&) = delete;604605/// @brief Invalidated assignment operator606GNETagProperties& operator=(const GNETagProperties& src) = delete;607};608609/// @brief override tag parent bit operator610constexpr GNETagProperties::Type operator|(GNETagProperties::Type a, GNETagProperties::Type b) {611return static_cast<GNETagProperties::Type>(static_cast<int>(a) | static_cast<int>(b));612}613614/// @brief override tag parent bit operator615constexpr bool operator&(GNETagProperties::Type a, GNETagProperties::Type b) {616return (static_cast<int>(a) & static_cast<int>(b)) != 0;617}618619/// @brief override tag parent bit operator620constexpr GNETagProperties::Property operator|(GNETagProperties::Property a, GNETagProperties::Property b) {621return static_cast<GNETagProperties::Property>(static_cast<int>(a) | static_cast<int>(b));622}623624/// @brief override tag parent bit operator625constexpr bool operator&(GNETagProperties::Property a, GNETagProperties::Property b) {626return (static_cast<int>(a) & static_cast<int>(b)) != 0;627}628629/// @brief override tag parent bit operator630constexpr GNETagProperties::Over operator|(GNETagProperties::Over a, GNETagProperties::Over b) {631return static_cast<GNETagProperties::Over>(static_cast<int>(a) | static_cast<int>(b));632}633634/// @brief override tag parent bit operator635constexpr bool operator&(GNETagProperties::Over a, GNETagProperties::Over b) {636return (static_cast<int>(a) & static_cast<int>(b)) != 0;637}638639/// @brief override tag parent bit operator640constexpr GNETagProperties::Conflicts operator|(GNETagProperties::Conflicts a, GNETagProperties::Conflicts b) {641return static_cast<GNETagProperties::Conflicts>(static_cast<int>(a) | static_cast<int>(b));642}643644/// @brief override tag parent bit operator645constexpr bool operator&(GNETagProperties::Conflicts a, GNETagProperties::Conflicts b) {646return (static_cast<int>(a) & static_cast<int>(b)) != 0;647}648649/****************************************************************************/650651652