Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/data/GNEGenericData.h
169684 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 GNEGenericData.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jan 2020
17
///
18
// A abstract class for generic datas
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/elements/GNEAttributeCarrier.h>
24
#include <netedit/elements/GNEHierarchicalElement.h>
25
#include <netedit/elements/GNEPathElement.h>
26
#include <utils/gui/globjects/GUIGlObject.h>
27
#include <utils/common/Parameterised.h>
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
33
class GNEDataInterval;
34
class GNENet;
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
40
class GNEGenericData : public GNEAttributeCarrier, public GNEHierarchicalElement, public GUIGlObject, public GNEPathElement, public Parameterised {
41
42
public:
43
/// @brief default Constructor
44
GNEGenericData(SumoXMLTag tag, GNENet* net);
45
46
/**@brief Constructor
47
* @param[in] tag generic data Tag (edgeData, laneData, etc.)
48
* @param[in] dataIntervalParent pointer to data interval parent
49
* @param[in] parameters parameters map
50
*/
51
GNEGenericData(const SumoXMLTag tag, GNEDataInterval* dataIntervalParent,
52
const Parameterised::Map& parameters);
53
54
/// @brief Destructor
55
virtual ~GNEGenericData();
56
57
/// @brief check if current generic data is visible
58
virtual bool isGenericDataVisible() const = 0;
59
60
/// @brief get GNEHierarchicalElement associated with this AttributeCarrier
61
GNEHierarchicalElement* getHierarchicalElement();
62
63
/// @brief get GUIGlObject associated with this AttributeCarrier
64
GUIGlObject* getGUIGlObject();
65
66
/// @brief get GUIGlObject associated with this AttributeCarrier (constant)
67
const GUIGlObject* getGUIGlObject() const;
68
69
/// @brief get data interval parent
70
GNEDataInterval* getDataIntervalParent() const;
71
72
// @brief draw attribute
73
void drawAttribute(const PositionVector& shape) const;
74
75
/// @brief update pre-computed geometry information
76
virtual void updateGeometry() = 0;
77
78
/// @brief Returns element position in view
79
virtual Position getPositionInView() const = 0;
80
81
/// @name Function related with contour drawing
82
/// @{
83
84
/// @brief check if draw from contour (green)
85
bool checkDrawFromContour() const;
86
87
/// @brief check if draw from contour (magenta)
88
bool checkDrawToContour() const;
89
90
/// @brief check if draw related contour (cyan)
91
bool checkDrawRelatedContour() const;
92
93
/// @brief check if draw over contour (orange)
94
bool checkDrawOverContour() const;
95
96
/// @brief check if draw delete contour (pink/white)
97
bool checkDrawDeleteContour() const;
98
99
/// @brief check if draw delete contour small (pink/white)
100
bool checkDrawDeleteContourSmall() const;
101
102
/// @brief check if draw select contour (blue)
103
bool checkDrawSelectContour() const;
104
105
/// @brief check if draw move contour (red)
106
bool checkDrawMoveContour() const;
107
108
/// @}
109
110
/// @name members and functions relative to write data sets into XML
111
/// @{
112
/**@brief write data set element into a xml file
113
* @param[in] device device in which write parameters of data set element
114
*/
115
virtual void writeGenericData(OutputDevice& device) const = 0;
116
117
/// @brief check if current data set is valid to be written into XML (by default true, can be reimplemented in children)
118
virtual bool isGenericDataValid() const;
119
120
/// @brief return a string with the current data set problem (by default empty, can be reimplemented in children)
121
virtual std::string getGenericDataProblem() const;
122
123
/// @brief fix data set problem (by default throw an exception, has to be reimplemented in children)
124
virtual void fixGenericDataProblem();
125
/// @}
126
127
/// @name inherited from GUIGlObject
128
/// @{
129
/**@brief Returns an own popup-menu
130
*
131
* @param[in] app The application needed to build the popup-menu
132
* @param[in] parent The parent window needed to build the popup-menu
133
* @return The built popup-menu
134
* @see GUIGlObject::getPopUpMenu
135
*/
136
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent);
137
138
/**@brief Returns an own parameter window
139
*
140
* @param[in] app The application needed to build the parameter window
141
* @param[in] parent The parent window needed to build the parameter window
142
* @return The built parameter window
143
* @see GUIGlObject::getParameterWindow
144
*/
145
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent);
146
147
/**@brief Draws the object
148
* @param[in] s The settings for the current view (may influence drawing)
149
* @see GUIGlObject::drawGL
150
*/
151
virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
152
153
/// @brief delete element
154
void deleteGLObject();
155
156
/// @brief select element
157
void selectGLObject();
158
159
/// @brief update GLObject (geometry, ID, etc.)
160
void updateGLObject();
161
162
//// @brief Returns the boundary to which the view shall be centered in order to show the object
163
virtual Boundary getCenteringBoundary() const = 0;
164
165
/// @}
166
167
/// @name inherited from GNEPathElement
168
/// @{
169
170
/// @brief compute pathElement
171
virtual void computePathElement() = 0;
172
173
/// @brief check if path element is selected
174
bool isPathElementSelected() const;
175
176
/**@brief Draws partial object over lane
177
* @param[in] s The settings for the current view (may influence drawing)
178
* @param[in] segment lane segment
179
* @param[in] offsetFront front offset
180
*/
181
virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;
182
183
/**@brief Draws partial object over junction
184
* @param[in] s The settings for the current view (may influence drawing)
185
* @param[in] segment junction segment
186
* @param[in] offsetFront front offset
187
*/
188
virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;
189
190
/// @brief get first path lane
191
virtual GNELane* getFirstPathLane() const = 0;
192
193
/// @brief get last path lane
194
virtual GNELane* getLastPathLane() const = 0;
195
196
/// @}
197
198
/// @name inherited from GNEAttributeCarrier
199
/// @{
200
/* @brief method for getting the Attribute of an XML key
201
* @param[in] key The attribute key
202
* @return string with the value associated to key
203
*/
204
virtual std::string getAttribute(SumoXMLAttr key) const = 0;
205
206
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
207
* @param[in] key The attribute key
208
* @return double with the value associated to key
209
*/
210
virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
211
212
/**@brief method for setting the attribute and letting the object perform data set changes
213
* @param[in] key The attribute key
214
* @param[in] value The new value
215
* @param[in] undoList The undoList on which to register changes
216
*/
217
virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
218
219
/**@brief method for checking if the key and their conrrespond attribute are valids
220
* @param[in] key The attribute key
221
* @param[in] value The value associated to key key
222
* @return true if the value is valid, false in other case
223
*/
224
virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
225
226
/// @brief get PopPup ID (Used in AC Hierarchy)
227
virtual std::string getPopUpID() const = 0;
228
229
/// @brief get Hierarchy Name (Used in AC Hierarchy)
230
virtual std::string getHierarchyName() const = 0;
231
/// @}
232
233
/// @brief get parameters map
234
const Parameterised::Map& getACParametersMap() const;
235
236
protected:
237
/// @brief dataInterval Parent
238
GNEDataInterval* myDataIntervalParent;
239
240
/// @brief draw filtered attribute
241
void drawFilteredAttribute(const GUIVisualizationSettings& s, const PositionVector& laneShape, const std::string& attribute, const GNEDataInterval* dataIntervalParent) const;
242
243
/// @brief check if attribute is visible in inspect, delete or select mode
244
bool isVisibleInspectDeleteSelect() const;
245
246
/// @brief replace the first parent edge
247
void replaceFirstParentEdge(const std::string& value);
248
249
/// @brief replace the last parent edge
250
void replaceLastParentEdge(const std::string& value);
251
252
/// @brief replace the first parent TAZElement
253
void replaceParentTAZElement(const int index, const std::string& value);
254
255
/// @brief get partial ID
256
std::string getPartialID() const;
257
258
private:
259
/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
260
virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
261
262
/// @brief Invalidated copy constructor.
263
GNEGenericData(const GNEGenericData&) = delete;
264
265
/// @brief Invalidated assignment operator.
266
GNEGenericData& operator=(const GNEGenericData&) = delete;
267
};
268
269
/****************************************************************************/
270
271