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-2022 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:
55  GNEShape(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag,
56  const std::vector<GNEJunction*>& junctionParents,
57  const std::vector<GNEEdge*>& edgeParents,
58  const std::vector<GNELane*>& laneParents,
59  const std::vector<GNEAdditional*>& additionalParents,
60  const std::vector<GNEShape*>& shapeParents,
61  const std::vector<GNETAZElement*>& TAZElementParents,
62  const std::vector<GNEDemandElement*>& demandElementParents,
63  const std::vector<GNEGenericData*>& genericDataParents);
64 
66  ~GNEShape();
67 
72 
74  virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;
75 
77  const std::string& getID() const;
78 
81 
83  virtual std::string generateChildID(SumoXMLTag childTag) = 0;
84 
89  virtual void setParameter(const std::string& key, const std::string& value) = 0;
90 
94  virtual void writeShape(OutputDevice& device) = 0;
95 
97  virtual GUIGlID getGlID() const = 0;
98 
101 
105  virtual void updateGeometry() = 0;
106 
108  virtual Position getPositionInView() const = 0;
109 
111  virtual double getExaggeration(const GUIVisualizationSettings& s) const = 0;
112 
115 
117  virtual void updateCenteringBoundary(const bool updateGrid) = 0;
118 
120 
123 
132 
141 
146  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
148 
151  /* @brief method for getting the Attribute of an XML key
152  * @param[in] key The attribute key
153  * @return string with the value associated to key
154  */
155  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
156 
157  /* @brief method for setting the attribute and letting the object perform shape changes
158  * @param[in] key The attribute key
159  * @param[in] value The new value
160  * @param[in] undoList The undoList on which to register changes
161  */
162  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
163 
164  /* @brief method for checking if the key and their conrrespond attribute are valids
165  * @param[in] key The attribute key
166  * @param[in] value The value asociated to key key
167  * @return true if the value is valid, false in other case
168  */
169  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
170 
171  /* @brief method for enable attribute
172  * @param[in] key The attribute key
173  * @param[in] undoList The undoList on which to register changes
174  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
175  */
176  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
177 
178  /* @brief method for enable attribute
179  * @param[in] key The attribute key
180  * @param[in] undoList The undoList on which to register changes
181  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
182  */
183  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
184 
185  /* @brief method for check if the value for certain attribute is set
186  * @param[in] key The attribute key
187  */
188  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
189 
190  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
191  * @param[in] key The attribute key
192  */
193  bool isAttributeComputed(SumoXMLAttr key) const;
194 
196  std::string getPopUpID() const;
197 
199  std::string getHierarchyName() const;
201 
203  virtual const std::map<std::string, std::string>& getACParametersMap() const = 0;
204 
205 protected:
208 
210  void replaceShapeParentLanes(const std::string& value);
211 
213  void shiftLaneIndex();
214 
215 private:
217  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
218 
220  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
221 
223  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
224 
226  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
227 
229  GNEShape(const GNEShape&) = delete;
230 
232  GNEShape& operator=(const GNEShape&) = delete;
233 };
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:42
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:95
GNEShape(const GNEShape &)=delete
Invalidated copy constructor.
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:77
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:71
Boundary myBoundary
object boundary
Definition: GNEShape.h:207
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:89
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.
void shiftLaneIndex()
shift lane index
Definition: GNEShape.cpp:107
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:65
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
GNEShape(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, 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:35
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:116
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
virtual double getExaggeration(const GUIVisualizationSettings &s) const =0
return exaggeration asociated with this GLObject
GNEShape & operator=(const GNEShape &)=delete
Invalidated assignment operator.
~GNEShape()
Destructor.
Definition: GNEShape.cpp:49
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNEShape.cpp:83
void replaceShapeParentLanes(const std::string &value)
replace shape parent lanes
Definition: GNEShape.cpp:101
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual Position getPositionInView() const =0
Returns position of shape in view.
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:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37