Eclipse SUMO - Simulation of Urban MObility
GNEShape.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 // Abstract class for Shapes uses in netedit
16 /****************************************************************************/
17 #ifndef GNEShape_h
18 #define GNEShape_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
34 
36 public:
52  GNEShape(GNENet* net, SumoXMLTag tag, bool movementBlocked,
53  const std::vector<GNEEdge*>& edgeParents,
54  const std::vector<GNELane*>& laneParents,
55  const std::vector<GNEShape*>& shapeParents,
56  const std::vector<GNEAdditional*>& additionalParents,
57  const std::vector<GNEDemandElement*>& demandElementParents,
58  const std::vector<GNEEdge*>& edgeChildren,
59  const std::vector<GNELane*>& laneChildren,
60  const std::vector<GNEShape*>& shapeChildren,
61  const std::vector<GNEAdditional*>& additionalChildren,
62  const std::vector<GNEDemandElement*>& demandElementChildren);
63 
65  ~GNEShape();
66 
68  virtual std::string generateChildID(SumoXMLTag childTag) = 0;
69 
73  virtual void writeShape(OutputDevice& device) = 0;
74 
76  virtual GUIGlID getGlID() const = 0;
77 
79  GNENet* getNet() const;
80 
82  bool isMovementBlocked() const;
83 
85  void draw(const Position& pos, double layer, double size = 0.5) const;
86 
90  virtual void startGeometryMoving() = 0;
91 
93  virtual void endGeometryMoving() = 0;
94 
98  virtual void updateGeometry() = 0;
99 
101  virtual Position getPositionInView() const = 0;
102 
104  virtual Boundary getCenteringBoundary() const = 0;
105 
107 
110 
119 
128 
133  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
135 
139  void selectAttributeCarrier(bool changeFlag = true);
140 
142  void unselectAttributeCarrier(bool changeFlag = true);
143 
145  bool isAttributeCarrierSelected() const;
146 
148  bool drawUsingSelectColor() const;
149 
150  /* @brief method for getting the Attribute of an XML key
151  * @param[in] key The attribute key
152  * @return string with the value associated to key
153  */
154  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
155 
156  /* @brief method for setting the attribute and letting the object perform additional changes
157  * @param[in] key The attribute key
158  * @param[in] value The new value
159  * @param[in] undoList The undoList on which to register changes
160  */
161  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
162 
163  /* @brief method for checking if the key and their conrrespond attribute are valids
164  * @param[in] key The attribute key
165  * @param[in] value The value asociated to key key
166  * @return true if the value is valid, false in other case
167  */
168  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
169 
170  /* @brief method for enabling attribute
171  * @param[in] key The attribute key
172  * @param[in] undoList The undoList on which to register changes
173  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
174  */
175  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
176 
177  /* @brief method for check if the value for certain attribute is set
178  * @param[in] key The attribute key
179  */
180  bool isAttributeEnabled(SumoXMLAttr key) const;
181 
183  std::string getPopUpID() const;
184 
186  std::string getHierarchyName() const;
188 
191 
193  virtual std::string getGenericParametersStr() const = 0;
194 
196  virtual std::vector<std::pair<std::string, std::string> > getGenericParameters() const = 0;
197 
199  virtual void setGenericParametersStr(const std::string& value) = 0;
200 
202 
203 protected:
206 
209 
212 
213 private:
215  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
216 
218  void setEnabledAttribute(const int enabledAttributes);
219 
221  virtual const GUIGlObject* getGUIGlObject() const = 0;
222 
224  GNEShape(const GNEShape&) = delete;
225 
227  GNEShape& operator=(const GNEShape&) = delete;
228 };
229 
230 
231 #endif
232 
233 /****************************************************************************/
234 
GNEShape::myMovingGeometryBoundary
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNEShape.h:208
GNEShape::getPositionInView
virtual Position getPositionInView() const =0
Returns position of additional in view.
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GNEShape::getPopUpMenu
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNEShape::~GNEShape
~GNEShape()
Destructor.
Definition: GNEShape.cpp:58
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GNEShape::getGUIGlObject
virtual const GUIGlObject * getGUIGlObject() const =0
get GUIGlObject associated to this GNEShape
GNEShape::generateChildID
virtual std::string generateChildID(SumoXMLTag childTag)=0
gererate a new ID for an element child
GNEShape::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEShape.cpp:109
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNEShape::getCenteringBoundary
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
GNEShape::setGenericParametersStr
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
GNEShape::writeShape
virtual void writeShape(OutputDevice &device)=0
writte shape element into a xml file
GNEShape::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:173
GNEShape::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:179
GNEHierarchicalElementChildren.h
GNEShape::startGeometryMoving
virtual void startGeometryMoving()=0
GNEHierarchicalElementParents
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalElementParents.h:48
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNEShape::isValid
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
GNEShape::isMovementBlocked
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:68
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNEShape::operator=
GNEShape & operator=(const GNEShape &)=delete
Invalidated assignment operator.
GNEShape::getGenericParametersStr
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
GNEShape::drawGL
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
GNEShape::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:167
GNEShape::getParameterWindow
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
GNEShape
Definition: GNEShape.h:35
GNEShape::myNet
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:205
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNEShape::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEShape.cpp:145
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEShape::getNet
GNENet * getNet() const
get Net in which this element is placed
Definition: GNEShape.cpp:62
GUIGlObject
Definition: GUIGlObject.h:66
GNEShape::myBlockMovement
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:211
GNEShape::getGlID
virtual GUIGlID getGlID() const =0
Returns the numerical id of the object.
GUIMainWindow
Definition: GUIMainWindow.h:47
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GNEShape::setAttribute
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
GNEShape::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNEHierarchicalElementParents.h
GNEShape::getGenericParameters
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
GNEShape::draw
void draw(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:74
config.h
GNEShape::endGeometryMoving
virtual void endGeometryMoving()=0
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
GNEShape::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:155
GNEUndoList
Definition: GNEUndoList.h:49
GNEShape::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEShape.cpp:161
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEHierarchicalElementChildren
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalElementChildren.h:46
GNEShape::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEShape.cpp:124
GNEShape::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEShape::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEShape.cpp:139
GNEShape::GNEShape
GNEShape(GNENet *net, SumoXMLTag tag, bool movementBlocked, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEEdge * > &edgeChildren, const std::vector< GNELane * > &laneChildren, const std::vector< GNEShape * > &shapeChildren, const std::vector< GNEAdditional * > &additionalChildren, const std::vector< GNEDemandElement * > &demandElementChildren)
Constructor.
Definition: GNEShape.cpp:39