/****************************************************************************/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 GNEPlanCreator.h14/// @author Pablo Alvarez Lopez15/// @date Mar 202216///17// Frame for create paths18/****************************************************************************/19#pragma once20#include <config.h>2122#include "GNEPlanSelector.h"2324// ===========================================================================25// class declaration26// ===========================================================================2728class GNEFrame;29class GNEPathManager;3031// ===========================================================================32// class definitions33// ===========================================================================3435class GNEPlanCreator : public MFXGroupBoxModule {36/// @brief FOX-declaration37FXDECLARE(GNEPlanCreator)3839public:40/// @brief class for path41class PlanPath {4243public:44/// @brief constructor for from-to edges45PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge);4647/// @brief constructor for from edge and to junction48PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction);4950/// @brief constructor for from junction and to edge51PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge);5253/// @brief constructor for from-to edges54PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction);5556/// @brief get sub path57const std::vector<GNEEdge*>& getSubPath() const;5859/// @brief check if current path is conflict due vClass60bool isConflictVClass() const;6162/// @brief check if current path is conflict due is disconnected63bool isConflictDisconnected() const;6465protected:66/// @brief sub path67std::vector<GNEEdge*> mySubPath;6869/// @brief flag to mark this path as conflicted70bool myConflictVClass;7172/// @brief flag to mark this path as disconnected73bool myConflictDisconnected;7475private:76/// @brief default constructor77PlanPath();7879/// @brief Invalidated copy constructor.80PlanPath(PlanPath*) = delete;8182/// @brief Invalidated assignment operator.83PlanPath& operator=(PlanPath*) = delete;84};8586/// @brief default constructor87GNEPlanCreator(GNEFrame* frameParent, GNEPathManager* pathManager);8889/// @brief destructor90~GNEPlanCreator();9192/// @brief check if plan can be created93bool planCanBeCreated(const GNEDemandElement* planTemplate) const;9495/// @brief show plan creator for the given tag property96void showPlanCreatorModule(const GNEPlanSelector* planSelector, const GNEDemandElement* previousPlan);9798/// @brief show GNEPlanCreator99void hidePathCreatorModule();100101/// @brief add route102bool addRoute(GNEDemandElement* route);103104/// @brief add edge (clicking over lanes)105bool addEdge(GNELane* lane);106107/// @brief add junction108bool addJunction(GNEJunction* junction);109110/// @brief add TAZ111bool addTAZ(GNEAdditional* taz);112113/// @brief add from to stoppingPlace114bool addStoppingPlace(GNEAdditional* stoppingPlace);115116/// @brief get plan parameters117const CommonXMLStructure::PlanParameters& getPlanParameteres() const;118119/// @brief get clicked position over lane120double getClickedPositionOverLane() const;121122/// @brief get path route123const std::vector<PlanPath>& getPath() const;124125/// @brief draw temporal route126void drawTemporalRoute(const GUIVisualizationSettings& s) const;127128/// @brief abort path creation129void abortPathCreation();130131/// @brief remove path element132void removeLastElement();133134/// @name FOX-callbacks135/// @{136/// @brief Called when the user click over button "Finish route creation"137long onCmdCreatePath(FXObject*, FXSelector, void*);138139/// @brief Called when the user click over button "Use last route"140long onCmdUseLastRoute(FXObject*, FXSelector, void*);141142/// @brief Called when update button "Use last route"143long onUpdUseLastRoute(FXObject*, FXSelector, void*);144145/// @brief Called when the user click over button "Abort route creation"146long onCmdAbortPathCreation(FXObject*, FXSelector, void*);147148/// @brief Called when the user click over button "Remove las inserted edge"149long onCmdRemoveLastElement(FXObject*, FXSelector, void*);150/// @}151152protected:153/// @brief FOX need this154FOX_CONSTRUCTOR(GNEPlanCreator)155156// @brief planParents157enum PlanParents {158CONSECUTIVE_EDGES = 1 << 0, // Plan is placed over consecutive edges159ROUTE = 1 << 1, // Plan is placed over a single route160EDGE = 1 << 2, // Plan is placed over a single edge161STOPPINGPLACE = 1 << 3, // Plan is placed over a stoppingPlace162START_EDGE = 1 << 4, // Plan begins in edge163START_TAZ = 1 << 5, // Plan begins in TAZ164START_JUNCTION = 1 << 6, // Plan begins in junction165START_STOPPINGPLACE = 1 << 7, // Plan begins in busStop166END_EDGE = 1 << 8, // Plan ends in edge167END_TAZ = 1 << 9, // Plan ends in TAZ168END_JUNCTION = 1 << 10, // Plan ends in junction169END_STOPPINGPLACE = 1 << 11, // Plan ends in stoppingPlace170};171172/// @brief clear edges173void clearPath();174175/// @brief recalculate path176void recalculatePath();177178/// @brief current frame parent179GNEFrame* myFrameParent;180181/// @brief path manager used in this plan creator182GNEPathManager* myPathManager;183184/// @brief current vClass185SUMOVehicleClass myVClass;186187/// @brief allowed plan parents188int myPlanParents;189190/// @brief previous person plan element191const GNEDemandElement* myPreviousPlanElement = nullptr;192193/// @brief plan parameters194CommonXMLStructure::PlanParameters myPlanParameteres;195196/// @brief clicked position over lane197double myClickedPositionOverLane = 0;198199/// @brief vector with current path200std::vector<PlanPath> myPath;201202/// @brief button for use last inserted route203FXButton* myUseLastRoute;204205/// @brief button for finish route creation206FXButton* myFinishCreationButton;207208/// @brief button for abort route creation209FXButton* myAbortCreationButton;210211/// @brief button for removing last inserted element212FXButton* myRemoveLastInsertedElement;213214/// @brief info label215FXLabel* myInfoLabel;216217private:218/// @brief get number of selected elements219int getNumberOfSelectedElements() const;220221/// @brief check if enable remove last item button222void updateRemoveLastItemButton() const;223224/// @brief show creation buttons225void showCreationButtons();226227/// @brief hide creation buttons228void hideCreationButtons();229230/// @brief update info label231void updateInfoLabel();232233/// @brief add edge234bool addSingleEdge(GNELane* lane);235236/// @brief add stoppingPlace237bool addSingleStoppingPlace(GNEAdditional* stoppingPlace);238239/// @brief add consecutive edge240bool addConsecutiveEdge(GNEEdge* edge);241242/// @brief add junction243bool addFromToJunction(GNEJunction* junction);244245/// @brief add TAZ246bool addFromToTAZ(GNEAdditional* taz);247248/// @brief add from to edge249bool addFromToEdge(GNEEdge* edge);250251/// @brief add from to stoppingPlace252bool addFromToStoppingPlace(GNEAdditional* stoppingPlace);253254/// @brief Invalidated copy constructor.255GNEPlanCreator(GNEPlanCreator*) = delete;256257/// @brief Invalidated assignment operator.258GNEPlanCreator& operator=(GNEPlanCreator*) = delete;259};260261262