/****************************************************************************/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 GNEPathCreator.h14/// @author Pablo Alvarez Lopez15/// @date Mar 202216///17// Frame for create paths18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/common/SUMOVehicleClass.h>23#include <netedit/frames/common/GNEGroupBoxModule.h>24#include <utils/gui/settings/GUIVisualizationSettings.h>2526// ===========================================================================27// class declaration28// ===========================================================================2930class GNEDemandElement;31class GNEEdge;32class GNEFrame;33class GNEJunction;34class GNEPathManager;35class GNETagProperties;36class GNETAZ;3738// ===========================================================================39// class definitions40// ===========================================================================4142class GNEPathCreator : public GNEGroupBoxModule {43/// @brief FOX-declaration44FXDECLARE(GNEPathCreator)4546public:47/// @brief class for path48class Path {4950public:51/// @brief constructor for single edge52Path(const SUMOVehicleClass vClass, GNEEdge* edge);5354/// @brief constructor for two edges55Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* edgeFrom, GNEEdge* edgeTo);5657/// @brief constructor for two junctions58Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* junctionFrom, GNEJunction* junctionTo);5960/// @brief get sub path61const std::vector<GNEEdge*>& getSubPath() const;6263/// @brief check if current path is conflict due vClass64bool isConflictVClass() const;6566/// @brief check if current path is conflict due is disconnected67bool isConflictDisconnected() const;6869protected:70/// @brief sub path71std::vector<GNEEdge*> mySubPath;7273/// @brief flag to mark this path as conflicted74bool myConflictVClass;7576/// @brief flag to mark this path as disconnected77bool myConflictDisconnected;7879private:80/// @brief default constructor81Path();8283/// @brief Invalidated copy constructor.84Path(Path*) = delete;8586/// @brief Invalidated assignment operator.87Path& operator=(Path*) = delete;88};8990/// @brief default constructor91GNEPathCreator(GNEFrame* frameParent, GNEPathManager* pathManager);9293/// @brief destructor94~GNEPathCreator();9596/// @brief show GNEPathCreator for the given tag97void showPathCreatorModule(const GNETagProperties* tagProperty, const bool consecutives);9899/// @brief show GNEPathCreator100void hidePathCreatorModule();101102/// @brief get vClass103SUMOVehicleClass getVClass() const;104105/// @brief set vClass106void setVClass(SUMOVehicleClass vClass);107108/// @brief add junction109bool addJunction(GNEJunction* junction);110111/// @brief add TAZ112bool addTAZ(GNETAZ* taz);113114/// @brief add edge115bool addEdge(GNEEdge* edge, const bool shiftKeyPressed, const bool controlKeyPressed);116117/// @brief get current selected edges118const std::vector<GNEEdge*>& getSelectedEdges() const;119120/// @brief get current selected junctions121const std::vector<GNEJunction*>& getSelectedJunctions() const;122123/// @brief get current selected TAZs124const std::vector<GNETAZ*>& getSelectedTAZs() const;125126/// @brief add route127bool addRoute(GNEDemandElement* route);128129/// @brief get route130GNEDemandElement* getRoute() const;131132/// @brief get path route133const std::vector<Path>& getPath() const;134135/// @brief draw candidate edges with special color (Only for candidates, special and conflicted)136bool drawCandidateEdgesWithSpecialColor() const;137138/// @brief update junction colors139void updateJunctionColors();140141/// @brief update edge colors142void updateEdgeColors();143144/// @brief clear junction colors145void clearJunctionColors();146147/// @brief clear edge colors148void clearEdgeColors();149150/// @brief draw temporal route151void drawTemporalRoute(const GUIVisualizationSettings& s) const;152153/// @brief create path154bool createPath(const bool useLastRoute);155156/// @brief abort path creation157void abortPathCreation();158159/// @brief remove path element160void removeLastElement();161162/// @name FOX-callbacks163/// @{164/// @brief Called when the user click over button "Finish route creation"165long onCmdCreatePath(FXObject*, FXSelector, void*);166167/// @brief Called when the user click over button "Use last route"168long onCmdUseLastRoute(FXObject*, FXSelector, void*);169170/// @brief Called when update button "Use last route"171long onUpdUseLastRoute(FXObject*, FXSelector, void*);172173/// @brief Called when the user click over button "Abort route creation"174long onCmdAbortPathCreation(FXObject*, FXSelector, void*);175176/// @brief Called when the user click over button "Remove las inserted edge"177long onCmdRemoveLastElement(FXObject*, FXSelector, void*);178179/// @brief Called when the user click over check button "show candidate edges"180long onCmdShowCandidateEdges(FXObject*, FXSelector, void*);181/// @}182183protected:184FOX_CONSTRUCTOR(GNEPathCreator)185186// @brief creation mode187enum Mode {188ONLY_FROMTO = 1 << 0, // Path only had two elements (first and last)189CONSECUTIVE_EDGES = 1 << 1, // Path's edges are consecutives190NONCONSECUTIVE_EDGES = 1 << 2, // Path's edges aren't consecutives191START_EDGE = 1 << 3, // Path begins in edge192END_EDGE = 1 << 4, // Path ends in edge193START_JUNCTION = 1 << 5, // Path begins in junction194END_JUNCTION = 1 << 6, // Path ends in junction195START_TAZ = 1 << 7, // Path begins in TAZ196END_TAZ = 1 << 8, // Path ends in TAZ197ROUTE = 1 << 9, // Path is over an existent edge198SHOW_CANDIDATE_EDGES = 1 << 10, // Show candidate edges199SHOW_CANDIDATE_JUNCTIONS = 1 << 11, // show candidate junctions200};201202/// @brief update InfoRouteLabel203void updateInfoRouteLabel();204205/// @brief clear edges (and restore colors)206void clearPath();207208/// @brief recalculate path209void recalculatePath();210211/// @brief set special candidates (This function will be called recursively)212void setSpecialCandidates(GNEEdge* originEdge);213214/// @brief set edgereachability (This function will be called recursively)215void setPossibleCandidates(GNEEdge* originEdge, const SUMOVehicleClass vClass);216217/// @brief current frame parent218GNEFrame* myFrameParent;219220/// @brief path manager221GNEPathManager* myPathManager;222223/// @brief current vClass224SUMOVehicleClass myVClass;225226/// @brief current creation mode227int myCreationMode;228229/// @brief vector with selected junctions230std::vector<GNEJunction*> mySelectedJunctions;231232/// @brief vector with selected TAZs233std::vector<GNETAZ*> mySelectedTAZs;234235/// @brief vector with selected edges236std::vector<GNEEdge*> mySelectedEdges;237238/// @brief route (usually a busStop)239GNEDemandElement* myRoute;240241/// @brief vector with current path242std::vector<Path> myPath;243244/// @brief label with route info245FXLabel* myInfoRouteLabel;246247/// @brief button for use last inserted route248FXButton* myUseLastRoute;249250/// @brief button for finish route creation251FXButton* myFinishCreationButton;252253/// @brief button for abort route creation254FXButton* myAbortCreationButton;255256/// @brief button for removing last inserted element257FXButton* myRemoveLastInsertedElement;258259/// @brief CheckBox for show candidate edges260FXCheckButton* myShowCandidateEdges;261262/// @brief label for shift information263FXLabel* myShiftLabel;264265/// @brief label for control information266FXLabel* myControlLabel;267268/// @brief label for backSpace information269FXLabel* myBackSpaceLabel;270private:271/// @brief Invalidated copy constructor.272GNEPathCreator(GNEPathCreator*) = delete;273274/// @brief Invalidated assignment operator.275GNEPathCreator& operator=(GNEPathCreator*) = delete;276};277278279