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