Eclipse 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-2019 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 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 
35 class GNEAdditional;
36 class GNEDemandElement;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
43 
44 public:
49 
51  void clearGeometry();
52 
55 
58 
60  std::vector<double> shapeRotations;
61 
63  std::vector<double> shapeLengths;
64  };
65 
72  GNENetElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag);
73 
76 
78  virtual std::string generateChildID(SumoXMLTag childTag) = 0;
79 
83  const NetElementGeometry& getGeometry() const;
84 
86  virtual void updateGeometry() = 0;
87 
89  virtual Position getPositionInView() const = 0;
91 
93  GNENet* getNet() const;
94 
97 
106 
115 
117  virtual Boundary getCenteringBoundary() const = 0;
118 
123  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
125 
128 
130  void selectAttributeCarrier(bool changeFlag = true);
131 
133  void unselectAttributeCarrier(bool changeFlag = true);
134 
136  bool isAttributeCarrierSelected() const;
137 
139  bool drawUsingSelectColor() const;
140 
141  /* @brief method for getting the Attribute of an XML key
142  * @param[in] key The attribute key
143  * @return string with the value associated to key
144  */
145  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
146 
147  /* @brief method for setting the attribute and letting the object perform additional changes
148  * @param[in] key The attribute key
149  * @param[in] value The new value
150  * @param[in] undoList The undoList on which to register changes
151  */
152  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
153 
154  /* @brief method for checking if the key and their conrrespond attribute are valids
155  * @param[in] key The attribute key
156  * @param[in] value The value asociated to key key
157  * @return true if the value is valid, false in other case
158  */
159  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
160 
161  /* @brief method for enabling attribute
162  * @param[in] key The attribute key
163  * @param[in] undoList The undoList on which to register changes
164  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
165  */
166  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
167 
168  /* @brief method for check if the value for certain attribute is set
169  * @param[in] key The attribute key
170  */
171  bool isAttributeEnabled(SumoXMLAttr key) const;
172 
174  std::string getPopUpID() const;
175 
177  std::string getHierarchyName() const;
179 
182 
184  virtual std::string getGenericParametersStr() const = 0;
185 
187  virtual std::vector<std::pair<std::string, std::string> > getGenericParameters() const = 0;
188 
190  virtual void setGenericParametersStr(const std::string& value) = 0;
191 
193 
194 protected:
197 
200 
203 
204 private:
206  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
207 
209  void setEnabledAttribute(const int enabledAttributes);
210 
212  GNENetElement(const GNENetElement&) = delete;
213 
215  GNENetElement& operator=(const GNENetElement&) = delete;
216 };
217 
218 
219 #endif
220 
221 /****************************************************************************/
222 
GUIGlObject.h
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:54
GNENetElement::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:148
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GNENetElement::operator=
GNENetElement & operator=(const GNENetElement &)=delete
Invalidated assignment operator.
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNENetElement::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNENetElement::~GNENetElement
~GNENetElement()
Destructor.
Definition: GNENetElement.cpp:91
GNEHierarchicalElementChildren.h
GNENetElement::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNENetElement.cpp:179
GNEHierarchicalElementParents
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalElementParents.h:48
GNENetElement::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNENetElement.cpp:169
PositionVector
A list of positions.
Definition: PositionVector.h:46
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNENetElement::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNENetElement.cpp:215
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNENetElement::NetElementGeometry::shape
PositionVector shape
The shape of the netElement element.
Definition: GNENetElement.h:57
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:40
GNENetElement::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNENetElement.cpp:185
GNENetElement::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNENetElement.cpp:201
GNENetElement::getGenericParameters
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
GNENetElement::NetElementGeometry::shapeRotations
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNENetElement.h:60
GNENetElement::myGeometry
NetElementGeometry myGeometry
netElement geometry
Definition: GNENetElement.h:199
GNENetElement::getCenteringBoundary
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
GNENetElement::drawGL
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
GNENetElement::NetElementGeometry::calculateShapeRotationsAndLengths
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
Definition: GNENetElement.cpp:55
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNENetElement::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNENetElement::setGenericParametersStr
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
GNENetElement::generateChildID
virtual std::string generateChildID(SumoXMLTag childTag)=0
gererate a new ID for an element child
Definition: GNENetElement.cpp:101
GNENetElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNENetElement.cpp:163
GNENetElement
Definition: GNENetElement.h:42
GUIGlObject
Definition: GUIGlObject.h:66
GNENetElement::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENetElement.cpp:113
GNENetElement::NetElementGeometry::clearGeometry
void clearGeometry()
reset geometry
Definition: GNENetElement.cpp:47
GNENetElement::isValid
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
GNENetElement::getGeometry
const NetElementGeometry & getGeometry() const
Definition: GNENetElement.cpp:95
GNENetElement::getPopUpMenu
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
GUIMainWindow
Definition: GUIMainWindow.h:47
GNENetElement::getNet
GNENet * getNet() const
get Net in which this element is placed
Definition: GNENetElement.cpp:107
GNENetElement::getGenericParametersStr
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
GNENetElement::GNENetElement
GNENetElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag)
Constructor.
Definition: GNENetElement.cpp:81
GNEHierarchicalElementParents.h
GNENetElement::NetElementGeometry::NetElementGeometry
NetElementGeometry()
constructor
Definition: GNENetElement.cpp:43
GNENetElement::myNet
GNENet * myNet
the net to inform about updates
Definition: GNENetElement.h:196
GNENetElement::setAttribute
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
config.h
GNENetElement::NetElementGeometry
struct for pack all variables related with geometry of elemement
Definition: GNENetElement.h:46
GNENetElement::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:132
GNEUndoList
Definition: GNEUndoList.h:49
GNENetElement::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNENetElement.cpp:191
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
PositionVector.h
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEHierarchicalElementChildren
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalElementChildren.h:46
GNENetElement::NetElementGeometry::shapeLengths
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNENetElement.h:63
GNENetElement::myMovingGeometryBoundary
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNENetElement.h:202
GNENetElement::getPositionInView
virtual Position getPositionInView() const =0
Returns position of hierarchical element in view.