Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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
29// ===========================================================================
30// class definitions
31// ===========================================================================
32
34
35public:
41 GNENetworkElement(GNENet* net, const std::string& id, SumoXMLTag tag);
42
44 virtual ~GNENetworkElement();
45
48
53
56
58 const GUIGlObject* getGUIGlObject() const;
59
61 virtual bool isNetworkElementValid() const;
62
64 virtual std::string getNetworkElementProblem() const;
65
68
70 virtual void updateGeometry() = 0;
71
73 virtual Position getPositionInView() const = 0;
74
76
79
81 virtual bool checkDrawFromContour() const = 0;
82
84 virtual bool checkDrawToContour() const = 0;
85
87 virtual bool checkDrawRelatedContour() const = 0;
88
90 virtual bool checkDrawOverContour() const = 0;
91
93 virtual bool checkDrawDeleteContour() const = 0;
94
96 virtual bool checkDrawDeleteContourSmall() const = 0;
97
99 virtual bool checkDrawSelectContour() const = 0;
100
102 virtual bool checkDrawMoveContour() const = 0;
103
105
108
117
126
128 virtual Boundary getCenteringBoundary() const = 0;
129
131 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
132
137 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
138
140 bool isGLObjectLocked() const;
141
143 void markAsFrontElement();
144
146 virtual void deleteGLObject() = 0;
147
149 void selectGLObject();
150
152 virtual const std::string getOptionalName() const;
153
155
158 /* @brief method for getting the Attribute of an XML key
159 * @param[in] key The attribute key
160 * @return string with the value associated to key
161 */
162 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
163
164 /* @brief method for getting the Attribute of an XML key in Position format
165 * @param[in] key The attribute key
166 * @return position with the value associated to key
167 */
169
170 /* @brief method for setting the attribute and letting the object perform additional changes
171 * @param[in] key The attribute key
172 * @param[in] value The new value
173 * @param[in] undoList The undoList on which to register changes
174 */
175 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
176
177 /* @brief method for checking if the key and their conrrespond attribute are valids
178 * @param[in] key The attribute key
179 * @param[in] value The value associated to key key
180 * @return true if the value is valid, false in other case
181 */
182 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
183
185 std::string getPopUpID() const;
186
188 std::string getHierarchyName() const;
190
193
195 void setShapeEdited(const bool value);
196
198 bool isShapeEdited() const;
199
202
204 void simplifyShapeEdited(GNEUndoList* undoList);
205
207 void straigthenShapeEdited(GNEUndoList* undoList);
208
210 void closeShapeEdited(GNEUndoList* undoList);
211
213 void openShapeEdited(GNEUndoList* undoList);
214
216 void setFirstGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
217
219 void deleteGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
220
222 void resetShapeEdited(GNEUndoList* undoList);
223
225
227 void setNetworkElementID(const std::string& newID);
228
230 virtual const Parameterised::Map& getACParametersMap() const = 0;
231
232protected:
235
238
239 // @brief check if we're drawing using a boundary but element was already selected
241
244
249 int getVertexIndex(const PositionVector& shape, const Position& pos);
250
251private:
253 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
254
257
260};
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
bool checkDrawingBoundarySelection() const
GNENetworkElement(const GNENetworkElement &)=delete
Invalidated copy constructor.
virtual bool checkDrawDeleteContourSmall() const =0
check if draw delete contour small (pink/white)
void closeShapeEdited(GNEUndoList *undoList)
close shape edited
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)
void setFirstGeometryPointShapeEdited(const int index, GNEUndoList *undoList)
set first geometry point shape edited
void openShapeEdited(GNEUndoList *undoList)
open shape edited
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)
virtual bool checkDrawMoveContour() const =0
check if draw move contour (red)
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
GNENetworkElement & operator=(const GNENetworkElement &)=delete
Invalidated assignment operator.
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
int getGeometryPointUnderCursorShapeEdited() const
get index geometry point under cursor of shape edited
void markAsFrontElement()
mark element as front element
bool myShapeEdited
flag to check if element shape is being edited
virtual PositionVector getAttributePositionVector(SumoXMLAttr key) const =0
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void simplifyShapeEdited(GNEUndoList *undoList)
simplify shape edited
void straigthenShapeEdited(GNEUndoList *undoList)
straigthen shape edited
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
virtual bool checkDrawToContour() const =0
check if draw from contour (magenta)
GUIGLObjectPopupMenu * getShapeEditedPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent, const PositionVector &shape)
get shape edited popup menu
void deleteGeometryPointShapeEdited(const int index, GNEUndoList *undoList)
delete geometry point shape edited
void resetShapeEdited(GNEUndoList *undoList)
reset shape edited
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
GNEHierarchicalElement * getHierarchicalElement()
get GNEHierarchicalElement associated with this AttributeCarrier
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)
int getVertexIndex(const PositionVector &shape, const Position &pos)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
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...
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
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.