Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/data/GNEDataInterval.h
194314 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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 GNEDataInterval.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jan 2020
17
///
18
// A abstract class for data elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEDataSet.h"
24
25
// ===========================================================================
26
// class declarations
27
// ===========================================================================
28
29
class GNEGenericData;
30
31
// ===========================================================================
32
// class definitions
33
// ===========================================================================
34
35
class GNEDataInterval : public GNEAttributeCarrier, public GNEHierarchicalElement {
36
37
public:
38
/**@brief Constructor
39
* @param[in] dataSetParent GNEDataSet to which this data interval belongs.
40
* @param[in] begin interval begin
41
* @param[in] end interval end
42
*/
43
GNEDataInterval(GNEDataSet* dataSetParent, const double begin, const double end);
44
45
/// @brief Destructor
46
~GNEDataInterval();
47
48
/// @brief methods to retrieve the elements linked to this dataInterval
49
/// @{
50
51
/// @brief get GNEHierarchicalElement associated with this dataInterval
52
GNEHierarchicalElement* getHierarchicalElement() override;
53
54
/// @brief get GNEMoveElement associated with this dataInterval
55
GNEMoveElement* getMoveElement() const override;
56
57
/// @brief get parameters associated with this dataInterval
58
Parameterised* getParameters() override;
59
60
/// @brief get parameters associated with this dataInterval (const)
61
const Parameterised* getParameters() const override;
62
63
/// @brief get GUIGlObject associated with this dataInterval
64
GUIGlObject* getGUIGlObject() override;
65
66
/// @brief get GUIGlObject associated with this dataInterval (constant)
67
const GUIGlObject* getGUIGlObject() const override;
68
69
/// @}
70
71
/// @brief update generic data child IDs
72
void updateGenericDataIDs();
73
74
/// @brief update attribute colors deprecated
75
void updateAttributeColors();
76
77
/// @brief all attribute colors
78
const GNEDataSet::AttributeColors& getAllAttributeColors() const;
79
80
/// @brief specific attribute colors
81
const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
82
83
/// @brief update pre-computed geometry information
84
void updateGeometry() override;
85
86
/// @brief Returns element position in view
87
Position getPositionInView() const;
88
89
/// @name Function related with contour drawing
90
/// @{
91
92
/// @brief check if draw from contour (green)
93
bool checkDrawFromContour() const override;
94
95
/// @brief check if draw from contour (magenta)
96
bool checkDrawToContour() const override;
97
98
/// @brief check if draw related contour (cyan)
99
bool checkDrawRelatedContour() const override;
100
101
/// @brief check if draw over contour (orange)
102
bool checkDrawOverContour() const override;
103
104
/// @brief check if draw delete contour (pink/white)
105
bool checkDrawDeleteContour() const override;
106
107
/// @brief check if draw delete contour small (pink/white)
108
bool checkDrawDeleteContourSmall() const override;
109
110
/// @brief check if draw select contour (blue)
111
bool checkDrawSelectContour() const override;
112
113
/// @brief check if draw move contour (red)
114
bool checkDrawMoveContour() const override;
115
116
/// @}
117
118
/// @brief get reference to fileBucket in which save this AC
119
FileBucket* getFileBucket() const override;
120
121
/// @name members and functions relative to write data elements into XML
122
/// @{
123
/// @brief check if current data element is valid to be written into XML (by default true, can be reimplemented in children)
124
bool isDataIntervalValid() const;
125
126
/// @brief return a string with the current data element problem (by default empty, can be reimplemented in children)
127
std::string getDataIntervalProblem() const;
128
129
/// @brief fix data element problem (by default throw an exception, has to be reimplemented in children)
130
void fixDataIntervalProblem();
131
/// @}
132
133
/// @brief Returns a pointer to GNEDataSet parent
134
GNEDataSet* getDataSetParent() const;
135
136
/// @name generic data children
137
/// @{
138
139
/// @brief add generic data child
140
void addGenericDataChild(GNEGenericData* genericData);
141
142
/// @brief add generic data child
143
void removeGenericDataChild(GNEGenericData* genericData);
144
145
/// @brief check if given generic data is child of this data interval
146
bool hasGenericDataChild(GNEGenericData* genericData) const;
147
148
/// @brief get generic data children
149
const std::vector<GNEGenericData*>& getGenericDataChildren() const;
150
151
/// @brief check if there is already a edgeRel single defined in the given edge
152
bool edgeRelSingleExists(const GNEEdge* edge) const;
153
154
/// @brief check if there is already a edgeRel defined between two edges
155
bool edgeRelExists(const GNEEdge* fromEdge, const GNEEdge* toEdge) const;
156
157
/// @brief check if there is already a TAZRel defined in one TAZ
158
bool TAZRelExists(const GNEAdditional* TAZ) const;
159
160
/// @brief check if there is already a TAZRel defined between two TAZs
161
bool TAZRelExists(const GNEAdditional* fromTAZ, const GNEAdditional* toTAZ) const;
162
163
/// @}
164
165
/// @name inherited from GNEAttributeCarrier
166
/// @{
167
/* @brief method for getting the Attribute of an XML key
168
* @param[in] key The attribute key
169
* @return string with the value associated to key
170
*/
171
std::string getAttribute(SumoXMLAttr key) const override;
172
173
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
174
* @param[in] key The attribute key
175
* @return double with the value associated to key
176
*/
177
double getAttributeDouble(SumoXMLAttr key) const override;
178
179
/* @brief method for getting the Attribute of an XML key in position format
180
* @param[in] key The attribute key
181
* @return position with the value associated to key
182
*/
183
Position getAttributePosition(SumoXMLAttr key) const override;
184
185
/* @brief method for getting the Attribute of an XML key in positionVector format
186
* @param[in] key The attribute key
187
* @return positionVector with the value associated to key
188
*/
189
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
190
191
/**@brief method for setting the attribute and letting the object perform data element changes
192
* @param[in] key The attribute key
193
* @param[in] value The new value
194
* @param[in] undoList The undoList on which to register changes
195
*/
196
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
197
198
/**@brief method for checking if the key and their conrrespond attribute are valids
199
* @param[in] key The attribute key
200
* @param[in] value The value associated to key key
201
* @return true if the value is valid, false in other case
202
*/
203
bool isValid(SumoXMLAttr key, const std::string& value) override;
204
205
/* @brief method for check if the value for certain attribute is set
206
* @param[in] key The attribute key
207
*/
208
bool isAttributeEnabled(SumoXMLAttr key) const override;
209
210
/// @brief get PopPup ID (Used in AC Hierarchy)
211
std::string getPopUpID() const override;
212
213
/// @brief get Hierarchy Name (Used in AC Hierarchy)
214
std::string getHierarchyName() const override;
215
/// @}
216
217
protected:
218
/// @brief all attribute colors
219
GNEDataSet::AttributeColors myAllAttributeColors;
220
221
/// @brief specific attribute colors
222
std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
223
224
/// @brief GNEDataSet parent to which this data interval belongs.
225
GNEDataSet* myDataSetParent;
226
227
/// @brief begin interval
228
double myBegin;
229
230
/// @brief end interval
231
double myEnd;
232
233
/// @brief vector with generic data children
234
std::vector<GNEGenericData*> myGenericDataChildren;
235
236
private:
237
/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
238
void setAttribute(SumoXMLAttr key, const std::string& value) override;
239
240
/// @brief Invalidated copy constructor.
241
GNEDataInterval(const GNEDataInterval&) = delete;
242
243
/// @brief Invalidated assignment operator.
244
GNEDataInterval& operator=(const GNEDataInterval&) = delete;
245
};
246
247
/****************************************************************************/
248
249