Eclipse SUMO - Simulation of Urban MObility
GNEEdgeRelDataFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 /****************************************************************************/
18 // The Widget for add EdgeRelationData elements
19 /****************************************************************************/
20 #include <config.h>
21 
25 #include <netedit/GNEViewNet.h>
26 
27 #include "GNEEdgeRelDataFrame.h"
28 
29 
30 // ===========================================================================
31 // method definitions
32 // ===========================================================================
33 
34 GNEEdgeRelDataFrame::GNEEdgeRelDataFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
35  GNEGenericDataFrame(horizontalFrameParent, viewNet, SUMO_TAG_EDGEREL, true) {
36 }
37 
38 
40 
41 
42 bool
44  // first check if we clicked over an edge
45  if (objectsUnderCursor.getEdgeFront() && myDataSetSelector->getDataSet() && myIntervalSelector->getDataInterval()) {
46  return myPathCreator->addEdge(objectsUnderCursor.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
47  } else {
48  // invalid parent parameters
49  return false;
50  }
51 }
52 
53 
54 void
56  // first check that we have at least two edges
57  if (myPathCreator->getSelectedEdges().size() > 1) {
58  GNEDataHandler dataHandler(myViewNet->getNet(), "", true);
59  // create data interval object and fill it
64  CommonXMLStructure::SumoBaseObject* edgeRelationData = new CommonXMLStructure::SumoBaseObject(dataIntervalObject);
65  // create EdgeRelationData
66  dataHandler.buildEdgeRelationData(edgeRelationData, myPathCreator->getSelectedEdges().front()->getID(),
68  // abort path creation
70  delete dataIntervalObject;
71  }
72 }
73 
74 /****************************************************************************/
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
void buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::map< std::string, std::string > &parameters)
Builds edgeRelationData.
double getAttributeDouble(SumoXMLAttr key) const
const std::string & getID() const
get ID
void createPath()
create path
bool addEdgeRelationData(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor, const GNEViewNetHelper::MouseButtonKeyPressed &mouseButtonKeyPressed)
add additional element
GNEEdgeRelDataFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
~GNEEdgeRelDataFrame()
Destructor.
const std::map< std::string, std::string > & getParametersMap() const
get parameters as map
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:114
bool addEdge(GNEEdge *edge, const bool shiftKeyPressed, const bool controlKeyPressed)
add edge
void abortPathCreation()
abort path creation
const std::vector< GNEEdge * > & getSelectedEdges() const
get current selected edges
GNEDataSet * getDataSet() const
get current select data set ID
GNEDataInterval * getDataInterval() const
get current select data set ID
GNEFrameAttributeModules::GenericDataAttributes * myGenericDataAttributes
parameters editor creator
IntervalSelector * myIntervalSelector
interval selector modul
GNEFrameModules::PathCreator * myPathCreator
edge path creator (used for Walks, rides and trips)
DataSetSelector * myDataSetSelector
dataSet selector modul
class used to group all variables related with objects under cursor after a click over view
GNEEdge * getEdgeFront() const
get front edge or a pointer to nullptr
GNENet * getNet() const
get the net object
class used to group all variables related with mouse buttons and key pressed after certain events
bool shiftKeyPressed() const
check if SHIFT is pressed during current event
bool controlKeyPressed() const
check if CONTROL is pressed during current event