Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/data/GNEEdgeRelDataFrame.cpp
193678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNEEdgeRelDataFrame.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2020
17
///
18
// The Widget for add EdgeRelationData elements
19
/****************************************************************************/
20
21
#include <netedit/GNEApplicationWindow.h>
22
#include <netedit/GNEViewNet.h>
23
#include <netedit/GNEViewParent.h>
24
#include <netedit/elements/data/GNEDataHandler.h>
25
#include <netedit/elements/data/GNEDataInterval.h>
26
#include <netedit/elements/network/GNEEdge.h>
27
#include <netedit/frames/GNEAttributesEditor.h>
28
#include <netedit/frames/GNEPathCreator.h>
29
30
#include "GNEEdgeRelDataFrame.h"
31
32
// ===========================================================================
33
// method definitions
34
// ===========================================================================
35
36
GNEEdgeRelDataFrame::GNEEdgeRelDataFrame(GNEViewParent* viewParent, GNEViewNet* viewNet) :
37
GNEGenericDataFrame(viewParent, viewNet, SUMO_TAG_EDGEREL, true) {
38
}
39
40
41
GNEEdgeRelDataFrame::~GNEEdgeRelDataFrame() {}
42
43
44
bool
45
GNEEdgeRelDataFrame::addEdgeRelationData(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const GNEViewNetHelper::MouseButtonKeyPressed& mouseButtonKeyPressed) {
46
// first check if we clicked over an edge
47
if (viewObjects.getEdgeFront() && myDataSetSelector->getDataSet() && myIntervalSelector->getDataInterval()) {
48
return myPathCreator->addEdge(viewObjects.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
49
} else {
50
// invalid parent parameters
51
return false;
52
}
53
}
54
55
56
bool
57
GNEEdgeRelDataFrame::createPath(const bool /*useLastRoute*/) {
58
// first check that we have at least two edges and parameters are valid
59
if (myDataSetSelector->getDataSet() && myIntervalSelector->getDataInterval() &&
60
(myPathCreator->getSelectedEdges().size() > 1) && (myGenericDataAttributesEditor->checkAttributes(true))) {
61
GNEDataHandler dataHandler(myViewNet->getNet(), myDataSetSelector->getDataSet()->getFileBucket(),
62
myViewNet->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed());
63
// create data interval object and fill it
64
CommonXMLStructure::SumoBaseObject* dataIntervalObject = new CommonXMLStructure::SumoBaseObject(nullptr);
65
dataIntervalObject->addStringAttribute(SUMO_ATTR_ID, myIntervalSelector->getDataInterval()->getID());
66
dataIntervalObject->addDoubleAttribute(SUMO_ATTR_BEGIN, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_BEGIN));
67
dataIntervalObject->addDoubleAttribute(SUMO_ATTR_END, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_END));
68
CommonXMLStructure::SumoBaseObject* edgeRelationData = new CommonXMLStructure::SumoBaseObject(dataIntervalObject);
69
// obtain parameters
70
myGenericDataAttributesEditor->fillSumoBaseObject(edgeRelationData);
71
// create EdgeRelationData
72
dataHandler.buildEdgeRelationData(edgeRelationData, myPathCreator->getSelectedEdges().front()->getID(),
73
myPathCreator->getSelectedEdges().back()->getID(), edgeRelationData->getParameters());
74
// abort path creation
75
myPathCreator->abortPathCreation();
76
// delete data interval object (and child)
77
delete dataIntervalObject;
78
return true;
79
} else {
80
return false;
81
}
82
}
83
84
/****************************************************************************/
85
86