Path: blob/main/src/netedit/frames/data/GNEEdgeRelDataFrame.cpp
193678 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 GNEEdgeRelDataFrame.cpp14/// @author Pablo Alvarez Lopez15/// @date Mar 202016///17// The Widget for add EdgeRelationData elements18/****************************************************************************/1920#include <netedit/GNEApplicationWindow.h>21#include <netedit/GNEViewNet.h>22#include <netedit/GNEViewParent.h>23#include <netedit/elements/data/GNEDataHandler.h>24#include <netedit/elements/data/GNEDataInterval.h>25#include <netedit/elements/network/GNEEdge.h>26#include <netedit/frames/GNEAttributesEditor.h>27#include <netedit/frames/GNEPathCreator.h>2829#include "GNEEdgeRelDataFrame.h"3031// ===========================================================================32// method definitions33// ===========================================================================3435GNEEdgeRelDataFrame::GNEEdgeRelDataFrame(GNEViewParent* viewParent, GNEViewNet* viewNet) :36GNEGenericDataFrame(viewParent, viewNet, SUMO_TAG_EDGEREL, true) {37}383940GNEEdgeRelDataFrame::~GNEEdgeRelDataFrame() {}414243bool44GNEEdgeRelDataFrame::addEdgeRelationData(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const GNEViewNetHelper::MouseButtonKeyPressed& mouseButtonKeyPressed) {45// first check if we clicked over an edge46if (viewObjects.getEdgeFront() && myDataSetSelector->getDataSet() && myIntervalSelector->getDataInterval()) {47return myPathCreator->addEdge(viewObjects.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());48} else {49// invalid parent parameters50return false;51}52}535455bool56GNEEdgeRelDataFrame::createPath(const bool /*useLastRoute*/) {57// first check that we have at least two edges and parameters are valid58if (myDataSetSelector->getDataSet() && myIntervalSelector->getDataInterval() &&59(myPathCreator->getSelectedEdges().size() > 1) && (myGenericDataAttributesEditor->checkAttributes(true))) {60GNEDataHandler dataHandler(myViewNet->getNet(), myDataSetSelector->getDataSet()->getFileBucket(),61myViewNet->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed());62// create data interval object and fill it63CommonXMLStructure::SumoBaseObject* dataIntervalObject = new CommonXMLStructure::SumoBaseObject(nullptr);64dataIntervalObject->addStringAttribute(SUMO_ATTR_ID, myIntervalSelector->getDataInterval()->getID());65dataIntervalObject->addDoubleAttribute(SUMO_ATTR_BEGIN, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_BEGIN));66dataIntervalObject->addDoubleAttribute(SUMO_ATTR_END, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_END));67CommonXMLStructure::SumoBaseObject* edgeRelationData = new CommonXMLStructure::SumoBaseObject(dataIntervalObject);68// obtain parameters69myGenericDataAttributesEditor->fillSumoBaseObject(edgeRelationData);70// create EdgeRelationData71dataHandler.buildEdgeRelationData(edgeRelationData, myPathCreator->getSelectedEdges().front()->getID(),72myPathCreator->getSelectedEdges().back()->getID(), edgeRelationData->getParameters());73// abort path creation74myPathCreator->abortPathCreation();75// delete data interval object (and child)76delete dataIntervalObject;77return true;78} else {79return false;80}81}8283/****************************************************************************/848586