Eclipse SUMO - Simulation of Urban MObility
GNEEdgeDataFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 edgeData elements
19 /****************************************************************************/
20 #include <config.h>
21 
26 #include <netedit/GNEViewNet.h>
27 
28 #include "GNEEdgeDataFrame.h"
29 
30 
31 // ===========================================================================
32 // method definitions
33 // ===========================================================================
34 
36  GNEGenericDataFrame(viewParent, viewNet, GNE_TAG_EDGEREL_SINGLE, false) {
37 }
38 
39 
41 
42 
43 bool
45  // first check if we clicked over an edge
47  // first check if the given interval there is already a EdgeData for the given ID
48  for (const auto& genericData : myIntervalSelector->getDataInterval()->getGenericDataChildren()) {
49  if ((genericData->getTagProperty().getTag() == GNE_TAG_EDGEREL_SINGLE) && (genericData->getParentEdges().front() == viewObjects.getEdgeFront())) {
50  // write warning
51  WRITE_WARNINGF(TL("There is already a % in edge '%'"), genericData->getTagStr(), viewObjects.getEdgeFront()->getID());
52  // abort edge data creation
53  return false;
54  }
55  }
56  // check if parameters are valid
58  // create interval base object
63  // create genericData base object
64  CommonXMLStructure::SumoBaseObject* genericDataBaseObject = new CommonXMLStructure::SumoBaseObject(intervalBaseObject);
65  // finally create edgeData
66  GNEDataHandler dataHandler(myViewNet->getNet(), "", true, false);
67  dataHandler.buildEdgeData(genericDataBaseObject, viewObjects.getEdgeFront()->getID(), myGenericDataAttributes->getParametersMap());
68  // delete intervalBaseObject (and genericDataBaseObject)
69  delete intervalBaseObject;
70  // edgeData created, then return true
71  return true;
72  } else {
73  return false;
74  }
75  } else {
76  // invalid parent parameters
77  return false;
78  }
79 }
80 
81 
82 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define TL(string)
Definition: MsgHandler.h:315
@ GNE_TAG_EDGEREL_SINGLE
@ 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)
add string attribute into current SumoBaseObject node
const std::string getID() const
get ID (all Attribute Carriers have one)
void buildEdgeData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const Parameterised::Map &parameters)
Builds edgeData.
double getAttributeDouble(SumoXMLAttr key) const
const std::vector< GNEGenericData * > & getGenericDataChildren() const
get generic data children
~GNEEdgeDataFrame()
Destructor.
bool addEdgeData(const GNEViewNetHelper::ViewObjectsSelector &viewObjects, const GNEViewNetHelper::MouseButtonKeyPressed &mouseButtonKeyPressed)
add additional element
GNEEdgeDataFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
bool areAttributesValid() const
check if current attributes are valid
const Parameterised::Map & getParametersMap() const
get parameters as map
GNEViewNet * myViewNet
FOX need this.
Definition: GNEFrame.h:117
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
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
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:88
class used to group all variables related with mouse buttons and key pressed after certain events