Eclipse SUMO - Simulation of Urban MObility
GNETAZElement.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 // Abstract class for TAZElements uses in netedit
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
27 
28 #include "GNETAZElement.h"
29 
30 // ===========================================================================
31 // member method definitions
32 // ===========================================================================
33 
34 GNETAZElement::GNETAZElement(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag,
35  const std::vector<GNEJunction*>& junctionParents,
36  const std::vector<GNEEdge*>& edgeParents,
37  const std::vector<GNELane*>& laneParents,
38  const std::vector<GNEAdditional*>& additionalParents,
39  const std::vector<GNETAZElement*>& TAZElementParents,
40  const std::vector<GNEDemandElement*>& demandElementParents,
41  const std::vector<GNEGenericData*>& genericDataParents,
42  const std::map<std::string, std::string>& parameters) :
43  GUIGlObject(type, id),
44  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, TAZElementParents, demandElementParents, genericDataParents),
45  Parameterised(parameters) {
46 }
47 
48 
50  const std::vector<GNEJunction*>& junctionParents,
51  const std::vector<GNEEdge*>& edgeParents,
52  const std::vector<GNELane*>& laneParents,
53  const std::vector<GNEAdditional*>& additionalParents,
54  const std::vector<GNETAZElement*>& TAZElementParents,
55  const std::vector<GNEDemandElement*>& demandElementParents,
56  const std::vector<GNEGenericData*>& genericDataParents,
57  const std::map<std::string, std::string>& parameters) :
58  GUIGlObject(type, TAZElementParent->generateChildID(tag)),
59  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, TAZElementParents, demandElementParents, genericDataParents),
60  Parameterised(parameters) {
61 }
62 
63 
65 
66 
67 const std::string&
69  return getMicrosimID();
70 }
71 
72 
75  return this;
76 }
77 
78 
79 std::string
81  int counter = (int)getChildTAZElements().size();
82  while (myNet->getAttributeCarriers()->retrieveTAZElement(childTag, getID() + toString(childTag) + toString(counter), false) != nullptr) {
83  counter++;
84  }
85  return (getID() + toString(childTag) + toString(counter));
86 }
87 
88 
91  // Create table
92  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
93  // Iterate over attributes
94  for (const auto& i : myTagProperty) {
95  // Add attribute and set it dynamic if aren't unique
96  if (i.isUnique()) {
97  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
98  } else {
99  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
100  }
101  }
102  // close building
103  ret->closeBuilding();
104  return ret;
105 }
106 
107 
108 const std::map<std::string, std::string>&
110  return getParametersMap();
111 }
112 
113 // ---------------------------------------------------------------------------
114 // GNETAZElement - protected methods
115 // ---------------------------------------------------------------------------
116 
117 void
119  //
120 }
121 
122 
123 void
125  //
126 }
127 
128 
129 bool
131  return false;
132 }
133 
134 
135 bool
137  // throw exception because this function mus be implemented in child (see GNEE3Detector)
138  throw ProcessError("Calling non-implemented function checkChildTAZElementRestriction during saving of " + getTagStr() + ". It muss be reimplemented in child class");
139 }
140 
141 
142 void
143 GNETAZElement::toogleAttribute(SumoXMLAttr /*key*/, const bool /*value*/) {
144  throw InvalidArgument("Nothing to enable");
145 }
146 
147 /****************************************************************************/
GNETAZElement::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNETAZElement.cpp:124
GNETAZElement::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNETAZElement.cpp:80
GNETAZElement::isAttributeComputed
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNETAZElement.cpp:130
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:60
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:70
GUIParameterTableWindow.h
GNETAZElement::getID
const std::string & getID() const
get ID
Definition: GNETAZElement.cpp:68
GNETAZElement::getGUIGlObject
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNETAZElement.cpp:74
GNEAttributeCarrier::myTagProperty
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
Definition: GNEAttributeCarrier.h:278
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
GUIGLObjectPopupMenu.h
GNETAZElement::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNETAZElement.cpp:118
GUIDesigns.h
GNENet::getAttributeCarriers
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:124
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:39
GNETAZElement::toogleAttribute
void toogleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNETAZElement.cpp:143
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:248
GNETAZElement::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEAttributeCarrier::myNet
GNENet * myNet
pointer to net
Definition: GNEAttributeCarrier.h:281
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:37
Parameterised::getParametersMap
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Definition: Parameterised.cpp:126
GNETAZElement::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNETAZElement.cpp:90
GUIParameterTableWindow::mkItem
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Definition: GUIParameterTableWindow.h:106
GNEViewNet.h
GNETAZElement::getACParametersMap
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNETAZElement.cpp:109
ProcessError
Definition: UtilExceptions.h:37
GNETAZElement::~GNETAZElement
virtual ~GNETAZElement()
Destructor.
Definition: GNETAZElement.cpp:64
GNENetHelper::AttributeCarriers::retrieveTAZElement
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
Definition: GNENetHelper.cpp:1138
GUIGlObject
Definition: GUIGlObject.h:63
GNETAZElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
GUIMainWindow
Definition: GUIMainWindow.h:44
InvalidArgument
Definition: UtilExceptions.h:54
GNETAZElement::GNETAZElement
GNETAZElement(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNETAZElement * > &TAZElementParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents, const std::map< std::string, std::string > &parameters)
Constructor.
Definition: GNETAZElement.cpp:34
GNETAZElement.h
GUIGlObject::getMicrosimID
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:133
GNEHierarchicalElement::getChildTAZElements
const std::vector< GNETAZElement * > & getChildTAZElements() const
get child TAZElements
Definition: GNEHierarchicalElement.cpp:185
GNEHierarchicalElement
Definition: GNEHierarchicalElement.h:37
config.h
GNETAZElement::checkChildTAZElementRestriction
virtual bool checkChildTAZElementRestriction() const
check restriction with the number of children
Definition: GNETAZElement.cpp:136
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:572
GNEUndoList
Definition: GNEUndoList.h:42
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:463
GNENet.h