Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/network/GNENetworkElement.h
185850 views
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
/****************************************************************************/
14
/// @file GNENetworkElement.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2016
17
///
18
// A abstract class for network elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/elements/GNEAttributeCarrier.h>
24
#include <netedit/elements/GNEContour.h>
25
#include <netedit/elements/GNEHierarchicalElement.h>
26
#include <utils/gui/globjects/GUIGlObject.h>
27
28
// ===========================================================================
29
// class declaration
30
// ===========================================================================
31
32
class GNEMoveOperation;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNENetworkElement : public GNEAttributeCarrier, public GUIGlObject, public GNEHierarchicalElement {
39
40
public:
41
/**@brief Constructor for templates
42
* @param[in] tag SUMO Tag assigned to this type of object
43
* @param[in] net GNENet in which this AttributeCarrier is stored
44
*/
45
GNENetworkElement(GNENet* net, SumoXMLTag tag);
46
47
/**@brief Constructor.
48
* @param[in] net The net to inform about gui updates
49
* @param[in] id of the element
50
* @param[in] tag sumo xml tag of the element
51
*/
52
GNENetworkElement(GNENet* net, const std::string& id, SumoXMLTag tag);
53
54
/// @brief Destructor
55
virtual ~GNENetworkElement();
56
57
/// @brief methods to retrieve the elements linked to this network element
58
/// @{
59
60
/// @brief get GNEHierarchicalElement associated with this AttributeCarrier
61
GNEHierarchicalElement* getHierarchicalElement() override;
62
63
/// @brief get GUIGlObject associated with this AttributeCarrier
64
GUIGlObject* getGUIGlObject() override;
65
66
/// @brief get GUIGlObject associated with this AttributeCarrier (constant)
67
const GUIGlObject* getGUIGlObject() const override;
68
69
/// @}
70
71
/// @brief get reference to fileBucket in which save this AC
72
FileBucket* getFileBucket() const override;
73
74
/// @brief check if current network element is valid to be written into XML (by default true, can be reimplemented in children)
75
virtual bool isNetworkElementValid() const;
76
77
/// @brief return a string with the current network element problem (by default empty, can be reimplemented in children)
78
virtual std::string getNetworkElementProblem() const;
79
80
/// @name inherited from GUIGlObject
81
/// @{
82
83
/**@brief Returns an own parameter window
84
*
85
* @param[in] app The application needed to build the parameter window
86
* @param[in] parent The parent window needed to build the parameter window
87
* @return The built parameter window
88
* @see GUIGlObject::getParameterWindow
89
*/
90
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
91
92
/// @brief check if element is locked
93
bool isGLObjectLocked() const override;
94
95
/// @brief mark element as front element
96
void markAsFrontElement() override;
97
98
/// @brief select element
99
void selectGLObject() override;
100
101
/// @brief Returns the name of the object (default "")
102
virtual const std::string getOptionalName() const override;
103
104
/// @}
105
106
/// @name inherited from GNEAttributeCarrier
107
/// @{
108
109
/// @brief get PopPup ID (Used in AC Hierarchy)
110
std::string getPopUpID() const override;
111
112
/// @brief get Hierarchy Name (Used in AC Hierarchy)
113
std::string getHierarchyName() const override;
114
115
/// @}
116
117
/// @name functions related with shape editing
118
/// @{
119
120
/// @brief set shape edited
121
void setShapeEdited(const bool value);
122
123
/// @brief check if shape is being edited
124
bool isShapeEdited() const;
125
126
/// @brief get index geometry point under cursor of shape edited
127
int getGeometryPointUnderCursorShapeEdited() const;
128
129
/// @brief simplify shape edited
130
void simplifyShapeEdited(GNEUndoList* undoList);
131
132
/// @brief straighten shape edited
133
void straigthenShapeEdited(GNEUndoList* undoList);
134
135
/// @brief close shape edited
136
void closeShapeEdited(GNEUndoList* undoList);
137
138
/// @brief open shape edited
139
void openShapeEdited(GNEUndoList* undoList);
140
141
/// @brief set first geometry point shape edited
142
void setFirstGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
143
144
/// @brief delete geometry point shape edited
145
void deleteGeometryPointShapeEdited(const int index, GNEUndoList* undoList);
146
147
/// @brief reset shape edited
148
void resetShapeEdited(GNEUndoList* undoList);
149
150
/// @}
151
152
/// @brief set network element id
153
void setNetworkElementID(const std::string& newID);
154
155
protected:
156
/// @brief flag to check if element shape is being edited
157
bool myShapeEdited;
158
159
/// @brief network element contour
160
GNEContour myNetworkElementContour;
161
162
// @brief check if we're drawing using a boundary but element was already selected
163
bool checkDrawingBoundarySelection() const;
164
165
/// @brief get shape edited popup menu
166
GUIGLObjectPopupMenu* getShapeEditedPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, const PositionVector& shape);
167
168
/**@brief return index of a vertex of shape, or of a new vertex if position is over an shape's edge
169
* @param pos position of new/existent vertex
170
* @return index of position vector
171
*/
172
int getVertexIndex(const PositionVector& shape, const Position& pos);
173
174
private:
175
/// @brief Invalidated copy constructor.
176
GNENetworkElement(const GNENetworkElement&) = delete;
177
178
/// @brief Invalidated assignment operator.
179
GNENetworkElement& operator=(const GNENetworkElement&) = delete;
180
};
181
182