Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/data/GNEDataInterval.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 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, public Parameterised {
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 get GNEHierarchicalElement associated with this AttributeCarrier
49
GNEHierarchicalElement* getHierarchicalElement();
50
51
/// @brief update generic data child IDs
52
void updateGenericDataIDs();
53
54
/// @brief update attribute colors deprecated
55
void updateAttributeColors();
56
57
/// @brief all attribute colors
58
const GNEDataSet::AttributeColors& getAllAttributeColors() const;
59
60
/// @brief specific attribute colors
61
const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
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 update pre-computed geometry information
70
void updateGeometry();
71
72
/// @brief Returns element position in view
73
Position getPositionInView() const;
74
75
/// @name Function related with contour drawing
76
/// @{
77
78
/// @brief check if draw from contour (green)
79
bool checkDrawFromContour() const;
80
81
/// @brief check if draw from contour (magenta)
82
bool checkDrawToContour() const;
83
84
/// @brief check if draw related contour (cyan)
85
bool checkDrawRelatedContour() const;
86
87
/// @brief check if draw over contour (orange)
88
bool checkDrawOverContour() const;
89
90
/// @brief check if draw delete contour (pink/white)
91
bool checkDrawDeleteContour() const;
92
93
/// @brief check if draw delete contour small (pink/white)
94
bool checkDrawDeleteContourSmall() const;
95
96
/// @brief check if draw select contour (blue)
97
bool checkDrawSelectContour() const;
98
99
/// @brief check if draw move contour (red)
100
bool checkDrawMoveContour() const;
101
102
/// @}
103
104
/// @name members and functions relative to write data elements into XML
105
/// @{
106
/// @brief check if current data element is valid to be written into XML (by default true, can be reimplemented in children)
107
bool isDataIntervalValid() const;
108
109
/// @brief return a string with the current data element problem (by default empty, can be reimplemented in children)
110
std::string getDataIntervalProblem() const;
111
112
/// @brief fix data element problem (by default throw an exception, has to be reimplemented in children)
113
void fixDataIntervalProblem();
114
/// @}
115
116
/// @brief Returns a pointer to GNEDataSet parent
117
GNEDataSet* getDataSetParent() const;
118
119
/// @name generic data children
120
/// @{
121
122
/// @brief add generic data child
123
void addGenericDataChild(GNEGenericData* genericData);
124
125
/// @brief add generic data child
126
void removeGenericDataChild(GNEGenericData* genericData);
127
128
/// @brief check if given generic data is child of this data interval
129
bool hasGenericDataChild(GNEGenericData* genericData) const;
130
131
/// @brief get generic data children
132
const std::vector<GNEGenericData*>& getGenericDataChildren() const;
133
134
/// @brief check if there is already a edgeRel single defined in the given edge
135
bool edgeRelSingleExists(const GNEEdge* edge) const;
136
137
/// @brief check if there is already a edgeRel defined between two edges
138
bool edgeRelExists(const GNEEdge* fromEdge, const GNEEdge* toEdge) const;
139
140
/// @brief check if there is already a TAZRel defined in one TAZ
141
bool TAZRelExists(const GNEAdditional* TAZ) const;
142
143
/// @brief check if there is already a TAZRel defined between two TAZs
144
bool TAZRelExists(const GNEAdditional* fromTAZ, const GNEAdditional* toTAZ) const;
145
146
/// @}
147
148
/// @name inherited from GNEAttributeCarrier
149
/// @{
150
/* @brief method for getting the Attribute of an XML key
151
* @param[in] key The attribute key
152
* @return string with the value associated to key
153
*/
154
std::string getAttribute(SumoXMLAttr key) const;
155
156
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
157
* @param[in] key The attribute key
158
* @return double with the value associated to key
159
*/
160
double getAttributeDouble(SumoXMLAttr key) const;
161
162
/**@brief method for setting the attribute and letting the object perform data element changes
163
* @param[in] key The attribute key
164
* @param[in] value The new value
165
* @param[in] undoList The undoList on which to register changes
166
*/
167
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
168
169
/**@brief method for checking if the key and their conrrespond attribute are valids
170
* @param[in] key The attribute key
171
* @param[in] value The value associated to key key
172
* @return true if the value is valid, false in other case
173
*/
174
bool isValid(SumoXMLAttr key, const std::string& value);
175
176
/* @brief method for check if the value for certain attribute is set
177
* @param[in] key The attribute key
178
*/
179
bool isAttributeEnabled(SumoXMLAttr key) const;
180
181
/// @brief get PopPup ID (Used in AC Hierarchy)
182
std::string getPopUpID() const;
183
184
/// @brief get Hierarchy Name (Used in AC Hierarchy)
185
std::string getHierarchyName() const;
186
/// @}
187
188
/// @brief get parameters map
189
const Parameterised::Map& getACParametersMap() const;
190
191
protected:
192
/// @brief all attribute colors
193
GNEDataSet::AttributeColors myAllAttributeColors;
194
195
/// @brief specific attribute colors
196
std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
197
198
/// @brief GNEDataSet parent to which this data interval belongs.
199
GNEDataSet* myDataSetParent;
200
201
/// @brief begin interval
202
double myBegin;
203
204
/// @brief end interval
205
double myEnd;
206
207
/// @brief vector with generic data children
208
std::vector<GNEGenericData*> myGenericDataChildren;
209
210
private:
211
/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
212
void setAttribute(SumoXMLAttr key, const std::string& value);
213
214
/// @brief Invalidated copy constructor.
215
GNEDataInterval(const GNEDataInterval&) = delete;
216
217
/// @brief Invalidated assignment operator.
218
GNEDataInterval& operator=(const GNEDataInterval&) = delete;
219
};
220
221
/****************************************************************************/
222
223