SUMO - Simulation of Urban MObility
GNENetElement.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A abstract class for net elements
16 /****************************************************************************/
17 #ifndef GNENetElement_h
18 #define GNENetElement_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <utility>
28 #include <vector>
29 #include <netbuild/NBConnection.h>
30 #include <netbuild/NBEdge.h>
31 #include <netbuild/NBNode.h>
32 #include <utils/geom/Boundary.h>
33 #include <utils/geom/Position.h>
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 
48 class GNEAdditional;
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
53 
55 
56 public:
63  GNENetElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag);
64 
67 
71  virtual void updateGeometry(bool updateGrid) = 0;
72 
74  GNENet* getNet() const;
75 
77  void addAdditionalParent(GNEAdditional* additional);
78 
80  void removeAdditionalParent(GNEAdditional* additional);
81 
83  void addAdditionalChild(GNEAdditional* additional);
84 
86  void removeAdditionalChild(GNEAdditional* additional);
87 
89  const std::vector<GNEAdditional*>& getAdditionalParents() const;
90 
92  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
93 
96 
105 
114 
116  virtual Boundary getCenteringBoundary() const = 0;
117 
122  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
124 
127 
129  void selectAttributeCarrier(bool changeFlag = true);
130 
132  void unselectAttributeCarrier(bool changeFlag = true);
133 
135  bool isAttributeCarrierSelected() const;
136 
137  /* @brief method for getting the Attribute of an XML key
138  * @param[in] key The attribute key
139  * @return string with the value associated to key
140  */
141  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
142 
143  /* @brief method for setting the attribute and letting the object perform additional changes
144  * @param[in] key The attribute key
145  * @param[in] value The new value
146  * @param[in] undoList The undoList on which to register changes
147  */
148  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
149 
150  /* @brief method for checking if the key and their conrrespond attribute are valids
151  * @param[in] key The attribute key
152  * @param[in] value The value asociated to key key
153  * @return true if the value is valid, false in other case
154  */
155  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
156 
158  std::string getPopUpID() const;
159 
161  std::string getHierarchyName() const;
163 
166 
168  virtual bool addGenericParameter(const std::string& key, const std::string& value) = 0;
169 
171  virtual bool removeGenericParameter(const std::string& key) = 0;
172 
174  virtual bool updateGenericParameter(const std::string& oldKey, const std::string& newKey) = 0;
175 
177  virtual bool updateGenericParameterValue(const std::string& key, const std::string& newValue) = 0;
178 
180  virtual std::string getGenericParametersStr() const = 0;
181 
183  virtual std::vector<std::pair<std::string, std::string> > getGenericParameters() const = 0;
184 
186  virtual void setGenericParametersStr(const std::string& value) = 0;
187 
189 
190 protected:
193 
196 
198  std::vector<GNEAdditional*> myFirstAdditionalParents;
199 
201  std::vector<GNEAdditional*> myAdditionalChilds;
202 
203 private:
205  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
206 
208  virtual void mouseOverObject(const GUIVisualizationSettings& s) const = 0;
209 
211  GNENetElement(const GNENetElement&) = delete;
212 
214  GNENetElement& operator=(const GNENetElement&) = delete;
215 };
216 
217 
218 #endif
219 
220 /****************************************************************************/
221 
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
virtual bool addGenericParameter(const std::string &key, const std::string &value)=0
add generic parameter
GNENet * myNet
the net to inform about updates
GUIGlObjectType
virtual bool removeGenericParameter(const std::string &key)=0
remove generic parameter
GNENet * getNet() const
get Net in which this element is placed
virtual void updateGeometry(bool updateGrid)=0
update pre-computed geometry information
Stores the information about how to visualize structures.
virtual void mouseOverObject(const GUIVisualizationSettings &s) const =0
method for check if mouse is over objects
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:80
virtual bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)=0
update generic parameter
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Boundary myMovingGeometryBoundary
boundary used during moving of elements
~GNENetElement()
Destructor.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
GNENetElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag)
Constructor.
const std::vector< GNEAdditional * > & getAdditionalParents() const
return vector of additionals that have as Parameter this edge (For example, Rerouters) ...
void addAdditionalParent(GNEAdditional *additional)
add additional child to this edge
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
virtual bool updateGenericParameterValue(const std::string &key, const std::string &newValue)=0
update value generic parameter
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:53
The popup menu of a globject.
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::vector< GNEAdditional * > myAdditionalChilds
list of Additional Childs of this NetElement
GNENetElement & operator=(const GNENetElement &)=delete
Invalidated assignment operator.
void removeAdditionalParent(GNEAdditional *additional)
remove additional child from this edge
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
std::vector< GNEAdditional * > myFirstAdditionalParents
list of Additional parents of this NetElement
A window containing a gl-object&#39;s parameter.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected