Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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
29
30
31// ===========================================================================
32// class declarations
33// ===========================================================================
34class GNEAdditional;
36
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
41
43
44public:
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 virtual bool isNetworkElementValid() const;
81
83 virtual std::string getNetworkElementProblem() const;
84
87
89 virtual void updateGeometry() = 0;
90
92 virtual Position getPositionInView() const = 0;
93
95
98
100 virtual bool checkDrawFromContour() const = 0;
101
103 virtual bool checkDrawToContour() const = 0;
104
106 virtual bool checkDrawRelatedContour() const = 0;
107
109 virtual bool checkDrawOverContour() const = 0;
110
112 virtual bool checkDrawDeleteContour() const = 0;
113
115 virtual bool checkDrawSelectContour() const = 0;
116
118 virtual bool checkDrawMoveContour() const = 0;
119
121
124
133
142
144 virtual Boundary getCenteringBoundary() const = 0;
145
147 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
148
153 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
154
156 bool isGLObjectLocked() const;
157
159 void markAsFrontElement();
160
162 virtual void deleteGLObject() = 0;
163
165 void selectGLObject();
166
168 virtual const std::string getOptionalName() const;
169
171
174 /* @brief method for getting the Attribute of an XML key
175 * @param[in] key The attribute key
176 * @return string with the value associated to key
177 */
178 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
179
180 /* @brief method for getting the Attribute of an XML key in Position format
181 * @param[in] key The attribute key
182 * @return position with the value associated to key
183 */
185
186 /* @brief method for setting the attribute and letting the object perform additional changes
187 * @param[in] key The attribute key
188 * @param[in] value The new value
189 * @param[in] undoList The undoList on which to register changes
190 */
191 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
192
193 /* @brief method for checking if the key and their conrrespond attribute are valids
194 * @param[in] key The attribute key
195 * @param[in] value The value associated to key key
196 * @return true if the value is valid, false in other case
197 */
198 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
199
201 std::string getPopUpID() const;
202
204 std::string getHierarchyName() const;
206
209
211 void setShapeEdited(const bool value);
212
214 bool isShapeEdited() const;
215
218
220 void simplifyShapeEdited(GNEUndoList* undoList);
221
223 void straigthenShapeEdited(GNEUndoList* undoList);
224
226 void closeShapeEdited(GNEUndoList* undoList);
227
229 void openShapeEdited(GNEUndoList* undoList);
230
232 void setFirstGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
233
235 void deleteGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
236
238 void resetShapeEdited(GNEUndoList* undoList);
239
241
243 void setNetworkElementID(const std::string& newID);
244
246 virtual const Parameterised::Map& getACParametersMap() const = 0;
247
248protected:
251
254
255 // @brief check if we're drawing using a boundary but element was already selected
257
260
265 int getVertexIndex(const PositionVector& shape, const Position& pos);
266
267private:
269 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
270
273
276};
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.
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.
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
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.