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-2020 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, bool blockMovement,
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  GUIGlObject(type, id),
44  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents),
45  myBlockMovement(blockMovement) {
46 }
47 
48 
49 GNETAZElement::GNETAZElement(GNETAZElement* TAZElementParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, bool blockMovement,
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<GNEShape*>& shapeParents,
55  const std::vector<GNETAZElement*>& TAZElementParents,
56  const std::vector<GNEDemandElement*>& demandElementParents,
57  const std::vector<GNEGenericData*>& genericDataParents) :
58  GUIGlObject(type, TAZElementParent->generateChildID(tag)),
59  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents),
60  myBlockMovement(blockMovement) {
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->retrieveTAZElement(childTag, getID() + toString(childTag) + toString(counter), false) != nullptr) {
83  counter++;
84  }
85  return (getID() + toString(childTag) + toString(counter));
86 }
87 
88 
89 bool
91  return myBlockMovement;
92 }
93 
94 
97  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
98  // build header
99  buildPopupHeader(ret, app);
100  // build menu command for center button and copy cursor position to clipboard
103  // buld menu commands for names
104  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " name to clipboard", nullptr, ret, MID_COPY_NAME);
105  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " typed name to clipboard", nullptr, ret, MID_COPY_TYPED_NAME);
106  new FXMenuSeparator(ret);
107  // build selection and show parameters menu
110  return ret;
111 }
112 
113 
116  // Create table
117  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
118  // Iterate over attributes
119  for (const auto& i : myTagProperty) {
120  // Add attribute and set it dynamic if aren't unique
121  if (i.isUnique()) {
122  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
123  } else {
124  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
125  }
126  }
127  // close building
128  ret->closeBuilding();
129  return ret;
130 }
131 
132 
133 const std::map<std::string, std::string>&
135  return getParametersMap();
136 }
137 
138 // ---------------------------------------------------------------------------
139 // GNETAZElement - protected methods
140 // ---------------------------------------------------------------------------
141 
142 bool
143 GNETAZElement::isValidTAZElementID(const std::string& newID) const {
144  if (SUMOXMLDefinitions::isValidAdditionalID(newID) && (myNet->retrieveTAZElement(myTagProperty.getTag(), newID, false) == nullptr)) {
145  return true;
146  } else {
147  return false;
148  }
149 }
150 
151 
152 void
154  //
155 }
156 
157 
158 void
160  //
161 }
162 
163 
164 bool
166  // throw exception because this function mus be implemented in child (see GNEE3Detector)
167  throw ProcessError("Calling non-implemented function checkChildTAZElementRestriction during saving of " + getTagStr() + ". It muss be reimplemented in child class");
168 }
169 
170 
171 void
172 GNETAZElement::setEnabledAttribute(const int /*enabledAttributes*/) {
173  //
174 }
175 
176 
177 /****************************************************************************/
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:403
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:401
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:44
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
const GNETagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
const std::vector< GNETAZElement * > & getChildTAZElements() const
get child TAZElements
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
Definition: GNENet.cpp:3001
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
bool isTAZElementBlocked() const
Check if TAZElement item is currently blocked (i.e. cannot be moved with mouse)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool isValidTAZElementID(const std::string &newID) const
check if a new TAZElement ID is valid
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
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
bool myBlockMovement
boolean to check if TAZElement element is blocked (i.e. cannot be moved with mouse)
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
GNETAZElement(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, bool blockMovement, 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)
Constructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:368
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:40
The popup menu of a globject.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
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.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object