Eclipse SUMO - Simulation of Urban MObility
GNENetworkElement.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 // A abstract class for network elements
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
28 #include <netedit/GNEMoveElement.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GNEAdditional;
35 class GNEDemandElement;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
43 
44 public:
57  GNENetworkElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon,
58  const std::vector<GNEJunction*>& junctionParents,
59  const std::vector<GNEEdge*>& edgeParents,
60  const std::vector<GNELane*>& laneParents,
61  const std::vector<GNEAdditional*>& additionalParents,
62  const std::vector<GNEDemandElement*>& demandElementParents,
63  const std::vector<GNEGenericData*>& genericDataParents);
64 
66  virtual ~GNENetworkElement();
67 
72 
75 
77  const GUIGlObject* getGUIGlObject() const;
78 
80  void setShapeEdited(const bool value);
81 
83  bool isShapeEdited() const;
84 
86  virtual bool isNetworkElementValid() const;
87 
89  virtual std::string getNetworkElementProblem() const;
90 
93 
95  virtual void updateGeometry() = 0;
96 
98  virtual Position getPositionInView() const = 0;
99 
101 
104 
106  virtual bool checkDrawFromContour() const = 0;
107 
109  virtual bool checkDrawToContour() const = 0;
110 
112  virtual bool checkDrawRelatedContour() const = 0;
113 
115  virtual bool checkDrawOverContour() const = 0;
116 
118  virtual bool checkDrawDeleteContour() const = 0;
119 
121  virtual bool checkDrawSelectContour() const = 0;
122 
124  virtual bool checkDrawMoveContour() const = 0;
125 
127 
130 
139 
148 
150  virtual Boundary getCenteringBoundary() const = 0;
151 
153  virtual void updateCenteringBoundary(const bool updateGrid) = 0;
154 
159  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
160 
162  bool isGLObjectLocked() const;
163 
165  void markAsFrontElement();
166 
168  virtual void deleteGLObject() = 0;
169 
171  void selectGLObject();
172 
174  virtual const std::string getOptionalName() const;
176 
179  /* @brief method for getting the Attribute of an XML key
180  * @param[in] key The attribute key
181  * @return string with the value associated to key
182  */
183  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
184 
185  /* @brief method for setting the attribute and letting the object perform additional changes
186  * @param[in] key The attribute key
187  * @param[in] value The new value
188  * @param[in] undoList The undoList on which to register changes
189  */
190  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
191 
192  /* @brief method for checking if the key and their conrrespond attribute are valids
193  * @param[in] key The attribute key
194  * @param[in] value The value associated to key key
195  * @return true if the value is valid, false in other case
196  */
197  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
198 
200  std::string getPopUpID() const;
201 
203  std::string getHierarchyName() const;
205 
207  void setNetworkElementID(const std::string& newID);
208 
210  virtual const Parameterised::Map& getACParametersMap() const = 0;
211 
212 protected:
215 
218 
219  // @brief check if we're drawing using a boundary but element was already selected
220  bool checkDrawingBoundarySelection() const;
221 
222 private:
224  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
225 
228 
231 };
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
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
move element
move operation
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
bool checkDrawingBoundarySelection() const
GNENetworkElement(const GNENetworkElement &)=delete
Invalidated copy constructor.
virtual bool isNetworkElementValid() const
check if current network element is valid to be written into XML (by default true,...
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEContour myNetworkElementContour
network element contour
virtual bool checkDrawDeleteContour() const =0
check if draw delete contour (pink/white)
GNENetworkElement & operator=(const GNENetworkElement &)=delete
Invalidated assignment operator.
virtual bool checkDrawMoveContour() const =0
check if draw move contour (red)
virtual bool checkDrawSelectContour() const =0
check if draw select contour (blue)
void selectGLObject()
select element
void setShapeEdited(const bool value)
set shape edited
virtual void deleteGLObject()=0
delete element
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
void markAsFrontElement()
mark element as front element
bool myShapeEdited
flag to check if element shape is being edited
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
virtual bool checkDrawToContour() const =0
check if draw from contour (magenta)
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
virtual Position getPositionInView() const =0
Returns position of hierarchical element in view.
virtual void updateGeometry()=0
update pre-computed geometry information
GNENetworkElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag, FXIcon *icon, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
void setNetworkElementID(const std::string &newID)
set network element id
bool isShapeEdited() const
check if shape is being edited
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
virtual ~GNENetworkElement()
Destructor.
virtual bool checkDrawOverContour() const =0
check if draw over contour (orange)
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
virtual bool checkDrawFromContour() const =0
check if draw from contour (green)
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
set attribute after validation
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual bool checkDrawRelatedContour() const =0
check if draw related contour (cyan)
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
virtual std::string getNetworkElementProblem() const
return a string with the current network element problem (by default empty, can be reimplemented in c...
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
bool isGLObjectLocked() const
check if element is locked
The popup menu of a globject.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37