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-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 Shapes uses in netedit
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <netedit/GNEMoveElement.h>
27 
28 
29 // ===========================================================================
30 // class definitions
31 // ===========================================================================
32 
34 
35 public:
54  GNEShape(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, bool movementBlocked,
55  const std::vector<GNEJunction*>& junctionParents,
56  const std::vector<GNEEdge*>& edgeParents,
57  const std::vector<GNELane*>& laneParents,
58  const std::vector<GNEAdditional*>& additionalParents,
59  const std::vector<GNEShape*>& shapeParents,
60  const std::vector<GNETAZElement*>& TAZElementParents,
61  const std::vector<GNEDemandElement*>& demandElementParents,
62  const std::vector<GNEGenericData*>& genericDataParents);
63 
65  virtual ~GNEShape();
66 
70  virtual GNEMoveOperation* getMoveOperation(const double shapeOffset) = 0;
71 
73  virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;
74 
76  const std::string& getID() const;
77 
80 
82  virtual std::string generateChildID(SumoXMLTag childTag) = 0;
83 
88  virtual void setParameter(const std::string& key, const std::string& value) = 0;
89 
93  virtual void writeShape(OutputDevice& device) = 0;
94 
96  virtual GUIGlID getGlID() const = 0;
97 
99  bool isMovementBlocked() const;
100 
102  void draw(const Position& pos, double layer, double size = 0.5) const;
103 
106 
110  virtual void updateGeometry() = 0;
111 
113  Position getPositionInView() const;
114 
117 
119  virtual void updateCenteringBoundary(const bool updateGrid) = 0;
120 
122 
125 
134 
143 
148  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
150 
153  /* @brief method for getting the Attribute of an XML key
154  * @param[in] key The attribute key
155  * @return string with the value associated to key
156  */
157  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
158 
159  /* @brief method for setting the attribute and letting the object perform additional changes
160  * @param[in] key The attribute key
161  * @param[in] value The new value
162  * @param[in] undoList The undoList on which to register changes
163  */
164  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
165 
166  /* @brief method for checking if the key and their conrrespond attribute are valids
167  * @param[in] key The attribute key
168  * @param[in] value The value asociated to key key
169  * @return true if the value is valid, false in other case
170  */
171  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
172 
173  /* @brief method for enable attribute
174  * @param[in] key The attribute key
175  * @param[in] undoList The undoList on which to register changes
176  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
177  */
178  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
179 
180  /* @brief method for enable attribute
181  * @param[in] key The attribute key
182  * @param[in] undoList The undoList on which to register changes
183  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
184  */
185  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
186 
187  /* @brief method for check if the value for certain attribute is set
188  * @param[in] key The attribute key
189  */
190  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
191 
193  std::string getPopUpID() const;
194 
196  std::string getHierarchyName() const;
198 
200  virtual const std::map<std::string, std::string>& getACParametersMap() const = 0;
201 
202 protected:
205 
208 
210  void replaceShapeParentLanes(const std::string& value);
211 
212 private:
214  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
215 
217  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
218 
220  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
221 
223  void setEnabledAttribute(const int enabledAttributes);
224 
226  GNEShape(const GNEShape&) = delete;
227 
229  GNEShape& operator=(const GNEShape&) = delete;
230 };
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
move element
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:136
GNEShape(const GNEShape &)=delete
Invalidated copy constructor.
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:124
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
set attribute after validation
virtual std::string generateChildID(SumoXMLTag childTag)=0
gererate a new ID for an element child
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:118
Boundary myBoundary
object boundary
Definition: GNEShape.h:204
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:130
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEShape.cpp:106
virtual void setParameter(const std::string &key, const std::string &value)=0
Sets a parameter.
virtual void writeShape(OutputDevice &device)=0
writte shape element into a xml file
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
virtual void updateGeometry()=0
update pre-computed geometry information
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEShape.cpp:112
GNEShape(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, bool movementBlocked, 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.
Definition: GNEShape.cpp:34
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:148
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:65
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual GUIGlID getGlID() const =0
Returns the numerical id of the object.
virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)=0
remove geometry point in the clicked position
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEShape.cpp:59
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual const std::map< std::string, std::string > & getACParametersMap() const =0
get parameters map
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53
void draw(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:71
GNEShape & operator=(const GNEShape &)=delete
Invalidated assignment operator.
virtual ~GNEShape()
Destructor.
Definition: GNEShape.cpp:49
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:207
void replaceShapeParentLanes(const std::string &value)
replace shape parent lanes
Definition: GNEShape.cpp:142
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual GNEMoveOperation * getMoveOperation(const double shapeOffset)=0
get move operation for the given shapeOffset
The popup menu of a globject.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36