Path: blob/main/src/netedit/dialogs/elements/GNERerouterIntervalDialog.cpp
193716 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 GNERerouterIntervalDialog.cpp14/// @author Pablo Alvarez Lopez15/// @date eb 201716///17// Dialog for edit rerouter intervals18/****************************************************************************/1920#include <netedit/dialogs/basic/GNEWarningBasicDialog.h>21#include <netedit/elements/additional/GNEClosingLaneReroute.h>22#include <netedit/elements/additional/GNEClosingReroute.h>23#include <netedit/elements/additional/GNEDestProbReroute.h>24#include <netedit/elements/additional/GNEParkingAreaReroute.h>25#include <netedit/elements/additional/GNERouteProbReroute.h>26#include <netedit/GNENet.h>27#include <netedit/GNEUndoList.h>28#include <netedit/GNEViewParent.h>29#include <utils/gui/div/GUIDesigns.h>3031#include "GNEAttributeCarrierDialog.h"32#include "GNERerouterDialog.h"33#include "GNERerouterIntervalDialog.h"3435// ===========================================================================36// member method definitions37// ===========================================================================3839GNERerouterIntervalDialog::GNERerouterIntervalDialog(GNEAdditional* rerouterInterval, GNEDialog* rerouterDialogParent) :40GNETemplateElementDialog<GNEAdditional>(rerouterInterval, rerouterDialogParent, DialogType::REROUTERINTERVAL) {41// Create auxiliar frames for tables42FXHorizontalFrame* columns = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarHorizontalFrame);43FXVerticalFrame* columnLeft = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);44FXVerticalFrame* columnCenter = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);45FXVerticalFrame* columnRight = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);46// create closing reroute element list47myClosingReroutes = new ClosingReroutesList(this, columnLeft);48// create closing lane reroute element list49myClosingLaneReroutes = new ClosingLaneReroutesList(this, columnLeft);50// dest prob reroute51myDestProbReroutes = new DestProbReroutesList(this, columnCenter);52// route prob reroute53myRouteProbReroutes = new RouteProbReroutesList(this, columnCenter);54// parking area reroute55myParkingAreaReroutes = new ParkingAreaReroutesList(this, columnRight);56// open dialog57openDialog();58}596061GNERerouterIntervalDialog::~GNERerouterIntervalDialog() {}626364void65GNERerouterIntervalDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {66// nothing to do (yet)67}686970long71GNERerouterIntervalDialog::onCmdAccept(FXObject*, FXSelector, void*) {72// get rerouter parent73const auto rerouterParent = myElement->getParentAdditionals().at(0);74// declare strings75const std::string warningTitle = TLF("Error updating % of % '%'", myElement->getTagStr(), rerouterParent->getTagStr(), rerouterParent->getID());76const std::string infoA = TLF("% of % '%' cannot be updated because", myElement->getTagStr(), rerouterParent->getTagStr(), rerouterParent->getID());77std::string infoB;78// set infoB79if (myClosingReroutes->getEditedElements().empty() && myClosingLaneReroutes->getEditedElements().empty() &&80myRouteProbReroutes->getEditedElements().empty() && myDestProbReroutes->getEditedElements().empty() &&81myParkingAreaReroutes->getEditedElements().empty()) {82infoB = TLF("at least one % must be defined.", myElement->getTagStr());83} else if (!myClosingReroutes->isListValid()) {84infoB = TLF("there are invalid %s.", toString(SUMO_TAG_CLOSING_REROUTE));85} else if (!myClosingLaneReroutes->isListValid()) {86infoB = TLF("there are invalid %s.", toString(SUMO_TAG_CLOSING_LANE_REROUTE));87} else if (!myRouteProbReroutes->isListValid()) {88infoB = TLF("there are invalid %s.", toString(SUMO_TAG_ROUTE_PROB_REROUTE));89} else if (!myDestProbReroutes->isListValid()) {90infoB = TLF("there are invalid %s.", toString(SUMO_TAG_DEST_PROB_REROUTE));91} else if (!myParkingAreaReroutes->isListValid()) {92infoB = TLF("there are invalid %s.", toString(SUMO_TAG_PARKING_AREA_REROUTE));93}94// continue depending of info95if (infoB.size() > 0) {96// open question dialog box with two lines97GNEWarningBasicDialog(myElement->getNet()->getGNEApplicationWindow(),98warningTitle, infoA, infoB);99return 1;100} else {101// close dialog accepting changes102return acceptElementDialog();103}104}105106107long108GNERerouterIntervalDialog::onCmdReset(FXObject*, FXSelector, void*) {109// reset changes110resetChanges();111// update tables112myClosingReroutes->updateList();113myClosingLaneReroutes->updateList();114myDestProbReroutes->updateList();115myRouteProbReroutes->updateList();116myParkingAreaReroutes->updateList();117return 1;118}119120// ---------------------------------------------------------------------------121// GNERerouterIntervalDialog::ClosingReroutesList - methods122// ---------------------------------------------------------------------------123124GNERerouterIntervalDialog::ClosingReroutesList::ClosingReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,125FXVerticalFrame* contentFrame) :126GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_CLOSING_REROUTE,127GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::DIALOG_VCLASS | GNEElementList::Options::FIXED_HEIGHT) {128// disable if there are no edges in net129if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getEdges().size() == 0) {130disableList(TL("No edges in net"));131}132}133134135long136GNERerouterIntervalDialog::ClosingReroutesList::addNewElement() {137// get edge138const auto edge = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second;139// create closing reroute140return insertElement(new GNEClosingReroute(myElementDialogParent->getElement(), edge, SVC_AUTHORITY));141}142143144long145GNERerouterIntervalDialog::ClosingReroutesList::openElementDialog(const size_t rowIndex) {146// open attribute carrier dialog147GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front(), myElementDialogParent);148return 1;149}150151// ---------------------------------------------------------------------------152// GNERerouterIntervalDialog::ClosingLaneReroutesList - methods153// ---------------------------------------------------------------------------154155GNERerouterIntervalDialog::ClosingLaneReroutesList::ClosingLaneReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,156FXVerticalFrame* contentFrame) :157GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_CLOSING_LANE_REROUTE,158GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::DIALOG_VCLASS | GNEElementList::Options::FIXED_HEIGHT) {159// disable if there are no edges in net160if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getLanes().size() == 0) {161disableList(TL("No lanes in net"));162}163}164165166long167GNERerouterIntervalDialog::ClosingLaneReroutesList::addNewElement() {168// get lane169const auto lane = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second->getChildLanes().front();170// create closing lane reroute171return insertElement(new GNEClosingLaneReroute(myElementDialogParent->getElement(), lane, SVCAll));172}173174175long176GNERerouterIntervalDialog::ClosingLaneReroutesList::openElementDialog(const size_t rowIndex) {177// open attribute carrier dialog178GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentLanes().front(), myElementDialogParent);179return 1;180}181182// ---------------------------------------------------------------------------183// GNERerouterIntervalDialog::DestProbReroutesList - methods184// ---------------------------------------------------------------------------185186GNERerouterIntervalDialog::DestProbReroutesList::DestProbReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,187FXVerticalFrame* contentFrame) :188GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_DEST_PROB_REROUTE,189GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::FIXED_HEIGHT) {190// disable if there are no edges in net191if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getEdges().size() == 0) {192disableList(TL("No edges in net"));193}194}195196197long198GNERerouterIntervalDialog::DestProbReroutesList::addNewElement() {199// get edge200const auto edge = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second;201// create dest prob reroute202return insertElement(new GNEDestProbReroute(myElementDialogParent->getElement(), edge, 1));203}204205206long207GNERerouterIntervalDialog::DestProbReroutesList::openElementDialog(const size_t rowIndex) {208// open attribute carrier dialog209GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front(), myElementDialogParent);210return 1;211}212213// ---------------------------------------------------------------------------214// GNERerouterIntervalDialog::RouteProbReroutesList - methods215// ---------------------------------------------------------------------------216217GNERerouterIntervalDialog::RouteProbReroutesList::RouteProbReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,218FXVerticalFrame* contentFrame) :219GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_ROUTE_PROB_REROUTE,220GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::FIXED_HEIGHT) {221// disable if the rerouter has multiple edges (random routes can only work from one edge)222if (rerouterIntervalDialog->getElement()->getParentAdditionals().at(0)->getChildEdges().size() > 1) {223disableList(TL("Rerouter has more than one edge"));224}225// disable if there are no routes in net226if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE).size() == 0) {227disableList(TL("No routes in net"));228}229}230231232long233GNERerouterIntervalDialog::RouteProbReroutesList::addNewElement() {234// get route235const auto route = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE).begin()->second;236// create route prob reroute237return insertElement(new GNERouteProbReroute(myElementDialogParent->getElement(), route, 1));238}239240241long242GNERerouterIntervalDialog::RouteProbReroutesList::openElementDialog(const size_t rowIndex) {243// open attribute carrier dialog244GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentDemandElements().front(), myElementDialogParent);245return 1;246}247248// ---------------------------------------------------------------------------249// GNERerouterIntervalDialog::ParkingAreaReroutesList - methods250// ---------------------------------------------------------------------------251252GNERerouterIntervalDialog::ParkingAreaReroutesList::ParkingAreaReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,253FXVerticalFrame* contentFrame) :254GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_PARKING_AREA_REROUTE,255GNEElementList::Options::DIALOG_ELEMENT) {256// disable if there are no parking areas in net257if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getAdditionals().at(SUMO_TAG_PARKING_AREA).size() == 0) {258disableList(TL("No parkingAreas in net"));259}260}261262263long264GNERerouterIntervalDialog::ParkingAreaReroutesList::addNewElement() {265// get parking area266const auto parkingArea = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getAdditionals().at(SUMO_TAG_PARKING_AREA).begin()->second;267// create parking area reroute268return insertElement(new GNEParkingAreaReroute(myElementDialogParent->getElement(), parkingArea, 1, 1));269}270271272long273GNERerouterIntervalDialog::ParkingAreaReroutesList::openElementDialog(const size_t rowIndex) {274// open attribute carrier dialog275GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentAdditionals().back(), myElementDialogParent);276return 1;277}278279/****************************************************************************/280281282