Path: blob/main/src/netedit/frames/network/GNEConnectorFrame.h
193700 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 GNEConnectorFrame.h14/// @author Jakob Erdmann15/// @date May 201116///17// The Widget for modifying lane-to-lane connections18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netbuild/NBEdge.h>23#include <netedit/frames/GNEFrame.h>24#include <netedit/frames/common/GNEGroupBoxModule.h>2526// ===========================================================================27// class definitions28// ===========================================================================2930class GNEConnectorFrame : public GNEFrame {3132public:3334// ===========================================================================35// class CurrentLane36// ===========================================================================3738class CurrentLane : public GNEGroupBoxModule {3940public:41/// @brief constructor42CurrentLane(GNEConnectorFrame* connectorFrameParent);4344/// @brief destructor45~CurrentLane();4647/// @brief set current junction label48void updateCurrentLaneLabel(const std::string& laneID);4950private:51/// @brief Label for current Lane52FXLabel* myCurrentLaneLabel;53};5455// ===========================================================================56// class ConnectionModifications57// ===========================================================================5859class ConnectionModifications : public GNEGroupBoxModule {60/// @brief FOX-declaration61FXDECLARE(GNEConnectorFrame::ConnectionModifications)6263public:64/// @brief constructor65ConnectionModifications(GNEConnectorFrame* connectorFrameParent);6667/// @brief destructor68~ConnectionModifications();6970/// @name FOX-callbacks71/// @{7273/// @brief Called when the user presses the OK-Button saves any connection modifications74long onCmdSaveModifications(FXObject*, FXSelector, void*);7576/// @brief Called when the user presses the Cancel-button discards any connection modifications77long onCmdCancelModifications(FXObject*, FXSelector, void*);78/// @}7980protected:81FOX_CONSTRUCTOR(ConnectionModifications)8283private:84/// @brief pointer to connectorFrame parent85GNEConnectorFrame* myConnectorFrameParent;8687/// @brief "Cancel" button88FXButton* myCancelButton;8990/// @brief "OK" button91FXButton* mySaveButton;9293/// @brief protect routes checkbox94FXCheckButton* myProtectRoutesCheckBox;95};9697// ===========================================================================98// class ConnectionOperations99// ===========================================================================100101class ConnectionOperations : public GNEGroupBoxModule {102/// @brief FOX-declaration103FXDECLARE(GNEConnectorFrame::ConnectionOperations)104105public:106/// @brief constructor107ConnectionOperations(GNEConnectorFrame* connectorFrameParent);108109/// @brief destructor110~ConnectionOperations();111112/// @name FOX-callbacks113/// @{114115/// @brief Called when the user presses the select dead ends button116long onCmdSelectDeadEnds(FXObject*, FXSelector, void*);117118/// @brief Called when the user presses the select dead starts button119long onCmdSelectDeadStarts(FXObject*, FXSelector, void*);120121/// @brief Called when the user presses the select conflicts button122long onCmdSelectConflicts(FXObject*, FXSelector, void*);123124/// @brief Called when the user presses the select pass button125long onCmdSelectPass(FXObject*, FXSelector, void*);126127/// @brief Called when the user presses the clear selected connections button128long onCmdClearSelectedConnections(FXObject*, FXSelector, void*);129130/// @brief Called when the user presses the reset selected connections button131long onCmdResetSelectedConnections(FXObject*, FXSelector, void*);132/// @}133134protected:135FOX_CONSTRUCTOR(ConnectionOperations)136137private:138/// @brief pointer to connectorFrame parent139GNEConnectorFrame* myConnectorFrameParent;140141/// @brief "Select Dead Ends" button142FXButton* mySelectDeadEndsButton;143144/// @brief "Select Dead Starts" button145FXButton* mySelectDeadStartsButton;146147/// @brief "Select Conflicts" button148FXButton* mySelectConflictsButton;149150/// @brief "Select Edges which may always pass"151FXButton* mySelectPassingButton;152153/// @brief "Clear Selected"154FXButton* myClearSelectedButton;155156/// @brief "Reset Selected"157FXButton* myResetSelectedButton;158};159160// ===========================================================================161// class ConnectionSelection162// ===========================================================================163164class ConnectionSelection : public GNEGroupBoxModule {165166public:167/// @brief constructor168ConnectionSelection(GNEConnectorFrame* connectorFrameParent);169170/// @brief destructor171~ConnectionSelection();172};173174// ===========================================================================175// class Legend176// ===========================================================================177178class Legend : public GNEGroupBoxModule {179180public:181/// @brief constructor182Legend(GNEConnectorFrame* connectorFrameParent);183184/// @brief destructor185~Legend();186187private:188};189190/**@brief Constructor191* @brief viewParent GNEViewParent in which this GNEFrame is placed192* @brief viewNet viewNet that uses this GNEFrame193*/194GNEConnectorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);195196/// @brief Destructor197~GNEConnectorFrame();198199/**@brief either sets the current lane or toggles the connection of the200* @param viewObjects collection of objects under cursor after click over view201*/202void handleLaneClick(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);203204/// @brief get pointer to ConnectionModifications module205ConnectionModifications* getConnectionModifications() const;206207private:208/// @brief the status of a target lane209enum class LaneStatus {210UNCONNECTED,211CONNECTED,212CONNECTED_PASS,213CONFLICTED214};215216/**@brief either sets the current lane or toggles the connection of the217* current lane to this lane (if they share a junction)218* @param[in] lane Either the lane to set as current lane, or the destination from current lane219* @param[in] mayDefinitelyPass Whether new connections shall have the pass attribute set220* @param[in] toggle Whether non-existing connections shall be created221*/222void buildConnection(GNELane* lane, const bool mayDefinitelyPass, const bool allowConflict, const bool toggle);223224/// @brief init targets225void initTargets();226227/// @brief clean up when deselecting current lane228void cleanup();229230/// @brief remove connections231void removeConnections(GNELane* lane);232233/// @brief return the status of toLane234LaneStatus getLaneStatus(const std::vector<NBEdge::Connection>& connections, const GNELane* targetLane) const;235236/// @brief CurrentLane module237CurrentLane* myCurrentLane;238239/// @brief ConnectionModifications module240GNEConnectorFrame::ConnectionModifications* myConnectionModifications = nullptr;241242/// @brief ConnectionOperations module243GNEConnectorFrame::ConnectionOperations* myConnectionOperations = nullptr;244245/// @brief ConnectionSelection module246GNEConnectorFrame::ConnectionSelection* myConnectionSelection = nullptr;247248/// @brief Legend module249GNEConnectorFrame::Legend* myLegend = nullptr;250251/// @brief the lane of which connections are to be modified252GNELane* myCurrentEditedLane;253254/// @brief the set of lanes to which the current lane may be connected255std::set<GNELane*> myPotentialTargets;256257/// @brief number of changes258int myNumChanges;259260/// @brief the internal lanes belonging the current junction indexed by their tl-index261std::map<int, GNEInternalLane*> myInternalLanes;262263/// @brief vector of connections deleted in the current editing step264std::vector<NBEdge::Connection> myDeletedConnections;265};266267268