Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/data/GNEDataSet.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 GNEDataSet.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 <netedit/elements/GNEAttributeCarrier.h>
24
#include <netedit/elements/GNEHierarchicalElement.h>
25
#include <utils/common/Parameterised.h>
26
27
// ===========================================================================
28
// class declarations
29
// ===========================================================================
30
31
class GNENet;
32
class GNEDataInterval;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNEDataSet : public GNEAttributeCarrier, public GNEHierarchicalElement, public Parameterised {
39
40
public:
41
/// @brief attribute colors
42
class AttributeColors {
43
44
public:
45
/// @brief default constructor
46
AttributeColors();
47
48
/// @brief update value for an specific attribute
49
void updateValues(const std::string& attribute, const double value);
50
51
/// @brief update value for all attributes
52
void updateAllValues(const AttributeColors& attributeColors);
53
54
/// @brief check if given attribute exist (needed for non-double attributes)
55
bool exist(const std::string& attribute) const;
56
57
/// @brief get minimum value
58
double getMinValue(const std::string& attribute) const;
59
60
/// @brief get maximum value
61
double getMaxValue(const std::string& attribute) const;
62
63
/// @brief clear AttributeColors
64
void clear();
65
66
private:
67
/// @brief map with the minimum and maximum value
68
std::map<std::string, std::pair<double, double> > myMinMaxValue;
69
70
/// @brief Invalidated assignment operator.
71
AttributeColors& operator=(const AttributeColors&) = delete;
72
};
73
74
/**@brief Constructor
75
* @param[in] net pointer to GNEViewNet of this data element element belongs
76
* @param[in] dataSetID data set ID
77
* @param[in] filename file in which this dataSet is stored
78
*/
79
GNEDataSet(const std::string& dataSetID, GNENet* net, const std::string& filename);
80
81
/// @brief Destructor
82
~GNEDataSet();
83
84
/// @brief get GNEHierarchicalElement associated with this AttributeCarrier
85
GNEHierarchicalElement* getHierarchicalElement();
86
87
/// @brief get GUIGlObject associated with this AttributeCarrier
88
GUIGlObject* getGUIGlObject();
89
90
/// @brief get GUIGlObject associated with this AttributeCarrier (constant)
91
const GUIGlObject* getGUIGlObject() const;
92
93
/// @brief update attribute colors deprecated
94
void updateAttributeColors();
95
96
/// @brief all attribute colors
97
const GNEDataSet::AttributeColors& getAllAttributeColors() const;
98
99
/// @brief specific attribute colors
100
const std::map<SumoXMLTag, GNEDataSet::AttributeColors>& getSpecificAttributeColors() const;
101
102
/// @brief update pre-computed geometry information
103
void updateGeometry();
104
105
/// @brief Returns element position in view
106
Position getPositionInView() const;
107
108
/// @brief write data set
109
void writeDataSet(OutputDevice& device) const;
110
111
/// @name Function related with contour drawing
112
/// @{
113
114
/// @brief check if draw from contour (green)
115
bool checkDrawFromContour() const;
116
117
/// @brief check if draw from contour (magenta)
118
bool checkDrawToContour() const;
119
120
/// @brief check if draw related contour (cyan)
121
bool checkDrawRelatedContour() const;
122
123
/// @brief check if draw over contour (orange)
124
bool checkDrawOverContour() const;
125
126
/// @brief check if draw delete contour (pink/white)
127
bool checkDrawDeleteContour() const;
128
129
/// @brief check if draw delete contour small (pink/white)
130
bool checkDrawDeleteContourSmall() const;
131
132
/// @brief check if draw select contour (blue)
133
bool checkDrawSelectContour() const;
134
135
/// @brief check if draw move contour (red)
136
bool checkDrawMoveContour() const;
137
138
/// @}
139
140
/// @name data interval children
141
/// @{
142
143
/// @brief add data interval child
144
void addDataIntervalChild(GNEDataInterval* dataInterval);
145
146
/// @brief add data interval child
147
void removeDataIntervalChild(GNEDataInterval* dataInterval);
148
149
/// @brief check if given data interval exist
150
bool dataIntervalChildrenExist(GNEDataInterval* dataInterval) const;
151
152
/// @brief update data interval begin
153
void updateDataIntervalBegin(const double oldBegin);
154
155
/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet
156
bool checkNewInterval(const double newBegin, const double newEnd);
157
158
/// @brief check if new begin or end for given GNEDataInterval is given
159
bool checkNewBeginEnd(const GNEDataInterval* dataInterval, const double newBegin, const double newEnd);
160
161
/// @brief return interval
162
GNEDataInterval* retrieveInterval(const double begin, const double end) const;
163
164
/// @brief get data interval children
165
const std::map<const double, GNEDataInterval*>& getDataIntervalChildren() const;
166
167
/// @}
168
169
/// @name inherited from GNEAttributeCarrier
170
/// @{
171
/* @brief method for getting the Attribute of an XML key
172
* @param[in] key The attribute key
173
* @return string with the value associated to key
174
*/
175
std::string getAttribute(SumoXMLAttr key) const;
176
177
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
178
* @param[in] key The attribute key
179
* @return double with the value associated to key
180
*/
181
double getAttributeDouble(SumoXMLAttr key) const;
182
183
/**@brief method for setting the attribute and letting the object perform data element changes
184
* @param[in] key The attribute key
185
* @param[in] value The new value
186
* @param[in] undoList The undoList on which to register changes
187
*/
188
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
189
190
/**@brief method for checking if the key and their conrrespond attribute are valids
191
* @param[in] key The attribute key
192
* @param[in] value The value associated to key key
193
* @return true if the value is valid, false in other case
194
*/
195
bool isValid(SumoXMLAttr key, const std::string& value);
196
197
/// @brief get PopPup ID (Used in AC Hierarchy)
198
std::string getPopUpID() const;
199
200
/// @brief get Hierarchy Name (Used in AC Hierarchy)
201
std::string getHierarchyName() const;
202
/// @}
203
204
/// @brief get parameters map
205
const Parameterised::Map& getACParametersMap() const;
206
207
protected:
208
/// @brief dataSet ID
209
std::string myDataSetID;
210
211
/// @brief map with dataIntervals children sorted by begin
212
std::map<const double, GNEDataInterval*> myDataIntervalChildren;
213
214
/// @brief all attribute colors
215
GNEDataSet::AttributeColors myAllAttributeColors;
216
217
/// @brief specific attribute colors
218
std::map<SumoXMLTag, GNEDataSet::AttributeColors> mySpecificAttributeColors;
219
220
private:
221
/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
222
void setAttribute(SumoXMLAttr key, const std::string& value);
223
224
/// @brief check if a new GNEDataInterval with the given begin and end can be inserted in current GNEDataSet
225
static bool checkNewInterval(const std::map<const double, GNEDataInterval*>& dataIntervalMap, const double newBegin, const double newEnd);
226
227
/// @brief Invalidated copy constructor.
228
GNEDataSet(const GNEDataSet&) = delete;
229
230
/// @brief Invalidated assignment operator.
231
GNEDataSet& operator=(const GNEDataSet&) = delete;
232
};
233
234
/****************************************************************************/
235
236