Path: blob/main/src/netedit/elements/demand/GNETranship.h
185790 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2016-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 GNETranship.h14/// @author Pablo Alvarez Lopez15/// @date Jun 202116///17// A class for visualizing tranships in Netedit18/****************************************************************************/19#pragma once20#include <config.h>21#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>2223#include "GNEDemandElement.h"24#include "GNEDemandElementPlan.h"2526// ===========================================================================27// class declarations28// ===========================================================================2930class GNEEdge;31class GNEConnection;32class GNEVehicle;3334// ===========================================================================35// class definitions36// ===========================================================================3738class GNETranship : public GNEDemandElement, public GNEDemandElementPlan {3940public:41/// @brief default constructor42GNETranship(SumoXMLTag tag, GNENet* net);4344/**@brief constructor called in buildTranship45* @param[in] tag tranship tag46* @param[in] containerParent demand element parent47* @param[in] planParameters plan parameters48* @param[in] departPosition depart pos49* @param[in] arrivalPosition arrival pos50* @param[in] speed tranship speed (not together with duration)51* @param[in] duraiton tranship duration (not together with speed)52*/53GNETranship(SumoXMLTag tag, GNEDemandElement* containerParent, const GNEPlanParents& planParameters,54const double departPosition, const double arrivalPosition, const double speed, const SUMOTime duration);5556/// @brief destructor57~GNETranship();5859/// @brief methods to retrieve the elements linked to this tranship60/// @{6162/// @brief get GNEMoveElement associated with this tranship63GNEMoveElement* getMoveElement() const override;6465/// @brief get parameters associated with this tranship66Parameterised* getParameters() override;6768/// @brief get parameters associated with this tranship (constant)69const Parameterised* getParameters() const override;7071/// @}7273/**@brief write demand element element into a xml file74* @param[in] device device in which write parameters of demand element element75*/76void writeDemandElement(OutputDevice& device) const override;7778/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)79Problem isDemandElementValid() const override;8081/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)82std::string getDemandElementProblem() const override;8384/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)85void fixDemandElementProblem() override;8687/// @name members and functions relative to elements common to all demand elements88/// @{89/// @brief obtain VClass related with this demand element90SUMOVehicleClass getVClass() const override;9192/// @brief get color93const RGBColor& getColor() const override;9495/// @}9697/// @name Functions related with geometry of element98/// @{99/// @brief update pre-computed geometry information100void updateGeometry() override;101102/// @brief Returns position of additional in view103Position getPositionInView() const override;104/// @}105106/// @name inherited from GUIGlObject107/// @{108109/**@brief Returns an own popup-menu110*111* @param[in] app The application needed to build the popup-menu112* @param[in] parent The parent window needed to build the popup-menu113* @return The built popup-menu114* @see GUIGlObject::getPopUpMenu115*/116GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;117118/**@brief Returns the name of the parent object119* @return This object's parent id120*/121std::string getParentName() const override;122123/**@brief Returns the boundary to which the view shall be centered in order to show the object124* @return The boundary the object is within125*/126Boundary getCenteringBoundary() const override;127128/// @brief split geometry129void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;130131/**@brief Draws the object132* @param[in] s The settings for the current view (may influence drawing)133* @see GUIGlObject::drawGL134*/135void drawGL(const GUIVisualizationSettings& s) const override;136137/// @}138139/// @name inherited from GNEPathElement140/// @{141142/// @brief compute pathElement143void computePathElement() override;144145/**@brief Draws partial object over lane146* @param[in] s The settings for the current view (may influence drawing)147* @param[in] segment lane segment148* @param[in] offsetFront front offset149*/150void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;151152/**@brief Draws partial object over junction153* @param[in] s The settings for the current view (may influence drawing)154* @param[in] segment junction segment155* @param[in] offsetFront front offset156*/157void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;158159/// @brief get first path lane160GNELane* getFirstPathLane() const override;161162/// @brief get last path lane163GNELane* getLastPathLane() const override;164/// @}165166/// @brief inherited from GNEAttributeCarrier167/// @{168/* @brief method for getting the Attribute of an XML key169* @param[in] key The attribute key170* @return string with the value associated to key171*/172std::string getAttribute(SumoXMLAttr key) const override;173174/* @brief method for getting the Attribute of an XML key in double format175* @param[in] key The attribute key176* @return double with the value associated to key177*/178double getAttributeDouble(SumoXMLAttr key) const override;179180/* @brief method for getting the Attribute of an XML key in position format181* @param[in] key The attribute key182* @return position with the value associated to key183*/184Position getAttributePosition(SumoXMLAttr key) const override;185186/* @brief method for setting the attribute and letting the object perform additional changes187* @param[in] key The attribute key188* @param[in] value The new value189* @param[in] undoList The undoList on which to register changes190* @param[in] net optionally the GNENet to inform about gui updates191*/192void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;193194/* @brief method for setting the attribute and letting the object perform additional changes195* @param[in] key The attribute key196* @param[in] value The new value197* @param[in] undoList The undoList on which to register changes198*/199bool isValid(SumoXMLAttr key, const std::string& value) override;200201/* @brief method for check if the value for certain attribute is set202* @param[in] key The attribute key203*/204bool isAttributeEnabled(SumoXMLAttr key) const override;205206/// @brief get PopPup ID (Used in AC Hierarchy)207std::string getPopUpID() const override;208209/// @brief get Hierarchy Name (Used in AC Hierarchy)210std::string getHierarchyName() const override;211/// @}212213protected:214/// @brief speed215double mySpeed = 0;216217/// @brief duration218SUMOTime myDuration = 0;219220private:221/// @brief method for setting the attribute and nothing else222void setAttribute(SumoXMLAttr key, const std::string& value) override;223224/// @brief Invalidated copy constructor.225GNETranship(GNETranship*) = delete;226227/// @brief Invalidated assignment operator.228GNETranship& operator=(GNETranship*) = delete;229};230231232