Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/demand/GNEDistributionFrame.h
194347 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 GNEDistributionFrame.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2023
17
///
18
// The Widget for edit distribution elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/frames/GNEFrame.h>
24
#include <netedit/frames/common/GNEGroupBoxModule.h>
25
#include <utils/gui/images/GUIIcons.h>
26
#include <utils/xml/SUMOXMLDefinitions.h>
27
28
// ===========================================================================
29
// class definitions
30
// ===========================================================================
31
32
class GNEAttributesEditor;
33
class GNEDemandElement;
34
class MFXComboBoxIcon;
35
class MFXTextFieldIcon;
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
41
class GNEDistributionFrame {
42
43
public:
44
// ===========================================================================
45
// class declaration
46
// ===========================================================================
47
48
class DistributionValuesEditor;
49
class DistributionSelector;
50
51
// ===========================================================================
52
// class DistributionEditor
53
// ===========================================================================
54
55
class DistributionEditor : public GNEGroupBoxModule {
56
/// @brief FOX-declaration
57
FXDECLARE(GNEDistributionFrame::DistributionEditor)
58
59
/// @brief declare friend class
60
friend class DistributionValuesEditor;
61
62
public:
63
/// @brief constructor
64
DistributionEditor(GNEFrame* frameParent, SumoXMLTag distributionTag, GUIIcon icon);
65
66
/// @brief destructor
67
~DistributionEditor();
68
69
/// @brief get distribution tag
70
SumoXMLTag getDistributionTag() const;
71
72
/// @name FOX-callbacks
73
/// @{
74
75
/// @brief Called when "create distribution" button is clicked
76
long onCmdCreateDistribution(FXObject*, FXSelector, void*);
77
78
/// @brief Called when "Delete distribution" button is clicked
79
long onCmdDeleteDistribution(FXObject*, FXSelector, void*);
80
81
/// @brief Called when "Delete distribution" button is updated
82
long onUpdDeleteDistribution(FXObject* sender, FXSelector, void*);
83
84
/// @}
85
86
protected:
87
/// @brief FOX needs this
88
FOX_CONSTRUCTOR(DistributionEditor)
89
90
private:
91
/// @brief pointer to frame parent
92
GNEFrame* myFrameParent;
93
94
/// @briuef distribution tag
95
SumoXMLTag myDistributionTag;
96
97
/// @brief distribution selector
98
DistributionSelector* myDistributionSelector = nullptr;
99
100
/// @brief "create Distribution" button
101
MFXButtonTooltip* myCreateDistributionButton = nullptr;
102
103
/// @brief "delete Distribution" button
104
MFXButtonTooltip* myDeleteDistributionButton = nullptr;
105
106
/// @brief Invalidated copy constructor.
107
DistributionEditor(const DistributionEditor&) = delete;
108
109
/// @brief Invalidated assignment operator
110
DistributionEditor& operator=(const DistributionEditor& src) = delete;
111
};
112
113
// ===========================================================================
114
// class DistributionSelector
115
// ===========================================================================
116
117
class DistributionSelector : public GNEGroupBoxModule {
118
/// @brief FOX-declaration
119
FXDECLARE(GNEDistributionFrame::DistributionSelector)
120
121
/// @brief declare friend class
122
friend class DistributionValuesEditor;
123
124
public:
125
/// @brief constructor
126
DistributionSelector(GNEFrame* frameParent);
127
128
/// @brief destructor
129
~DistributionSelector();
130
131
/// @brief refresh modul
132
void setDistribution(GNEDemandElement* distribution);
133
134
/// @brief current distribution
135
GNEDemandElement* getCurrentDistribution() const;
136
137
/// @brief refresh distribution IDs (only call when user change ID in internal attributes)
138
void refreshDistributionIDs();
139
140
/// @brief refresh modul
141
void refreshDistributionSelector();
142
143
/// @name FOX-callbacks
144
/// @{
145
146
/// @brief Called when the user select distribution in ComboBox
147
long onCmdSelectDistribution(FXObject*, FXSelector, void*);
148
149
/// @brief update distribution comboBox
150
long onCmdUpdateDistribution(FXObject* sender, FXSelector, void*);
151
152
/// @}
153
154
protected:
155
/// @brief FOX need this
156
FOX_CONSTRUCTOR(DistributionSelector)
157
158
/// @brief fill distribution comboBox
159
std::map<std::string, GNEDemandElement*> fillDistributionComboBox();
160
161
private:
162
/// @brief pointer to Frame Parent
163
GNEFrame* myFrameParent;
164
165
/// @brief pointer to distribution editor
166
DistributionEditor* myDistributionEditor = nullptr;
167
168
/// @brief attributes editor
169
GNEAttributesEditor* myAttributesEditor = nullptr;
170
171
/// @brief distribution values editor
172
DistributionValuesEditor* myDistributionValuesEditor = nullptr;
173
174
/// @brief comboBox with the list of distributions
175
MFXComboBoxIcon* myDistributionsComboBox = nullptr;
176
177
/// @brief current distribution element
178
GNEDemandElement* myCurrentDistribution = nullptr;
179
180
/// @brief Invalidated copy constructor.
181
DistributionSelector(const DistributionSelector&) = delete;
182
183
/// @brief Invalidated assignment operator
184
DistributionSelector& operator=(const DistributionSelector& src) = delete;
185
};
186
187
// ===========================================================================
188
// class DistributionRow
189
// ===========================================================================
190
191
class DistributionRow : protected FXHorizontalFrame {
192
/// @brief FOX-declaration
193
FXDECLARE(GNEDistributionFrame::DistributionRow)
194
195
public:
196
/// @brief constructor for key-probability attributes
197
DistributionRow(DistributionValuesEditor* attributeEditorParent, GNEDemandElement* distributionReference);
198
199
/// @brief destroy DistributionRow (but don't delete)
200
void destroy();
201
202
/// @brief get pointer to distributionReference
203
GNEDemandElement* getDistributionReference() const;
204
205
/// @brief get delete row button
206
MFXButtonTooltip* getDeleteRowButton() const;
207
208
/// @name FOX-callbacks
209
/// @{
210
211
/// @brief try to set new probability
212
long onCmdSetProbability(FXObject*, FXSelector, void*);
213
214
/// @}
215
216
protected:
217
/// @brief FOX need this
218
FOX_CONSTRUCTOR(DistributionRow)
219
220
private:
221
/// @brief pointer to DistributionValuesEditor parent
222
DistributionValuesEditor* myDistributionValuesEditorParent;
223
224
/// @brief pointer to distributionReference
225
GNEDemandElement* myDistributionReference = nullptr;
226
227
/// @brief delete row button
228
MFXButtonTooltip* myDeleteRowButton = nullptr;
229
230
/// @brief label
231
FXLabel* myIconLabel = nullptr;
232
233
/// @brief comboBox with ID
234
MFXTextFieldIcon* myIDTextField = nullptr;
235
236
/// @brief textField to modify the probability attribute
237
MFXTextFieldIcon* myProbabilityTextField = nullptr;
238
239
/// @brief Invalidated copy constructor.
240
DistributionRow(const DistributionRow&) = delete;
241
242
/// @brief Invalidated assignment operator
243
DistributionRow& operator=(const DistributionRow& src) = delete;
244
};
245
246
// ===========================================================================
247
// class DistributionValuesEditor
248
// ===========================================================================
249
250
class DistributionValuesEditor : public GNEGroupBoxModule {
251
/// @brief FOX-declaration
252
FXDECLARE(GNEDistributionFrame::DistributionValuesEditor)
253
254
/// @brief declare friend class
255
friend class DistributionRow;
256
257
public:
258
/// @brief constructor
259
DistributionValuesEditor(GNEFrame* frameParent, DistributionEditor* distributionEditor,
260
DistributionSelector* distributionSelector,
261
GNEAttributesEditor* attributesEditor);
262
263
/// @brief show attributes of multiple ACs
264
void showDistributionValuesEditor();
265
266
/// @brief hide attribute editor
267
void hideDistributionValuesEditor();
268
269
/// @brief refresh rows
270
void refreshRows();
271
272
/// @brief pointer to GNEFrame parent
273
GNEFrame* getFrameParent() const;
274
275
/// @name FOX-callbacks
276
/// @{
277
278
/// @brief Called when user press the add button
279
long onCmdAddRow(FXObject*, FXSelector, void*);
280
281
/// @brief Called when user press the add button
282
long onCmdRemoveRow(FXObject* obj, FXSelector, void*);
283
284
/// @}
285
286
protected:
287
/// @brief FOX need this
288
FOX_CONSTRUCTOR(DistributionValuesEditor)
289
290
/// @brief update sum label
291
void updateSumLabel();
292
293
private:
294
/// @brief pointer to frame parent
295
GNEFrame* myFrameParent;
296
297
/// @brief distribution editor
298
DistributionEditor* myDistributionEditor;
299
300
/// @brief distribution selector
301
DistributionSelector* myDistributionSelector;
302
303
/// @brief attributes editor
304
GNEAttributesEditor* myAttributesEditor;
305
306
/// @brief list of Attribute editor rows
307
std::vector<DistributionRow*> myDistributionRows;
308
309
/// @brief bot frame
310
FXHorizontalFrame* myBotFrame = nullptr;
311
312
/// @brief add buton
313
MFXButtonTooltip* myAddButton = nullptr;
314
315
/// @brief sum label
316
FXLabel* mySumLabel = nullptr;
317
318
/// @brief Invalidated copy constructor.
319
DistributionValuesEditor(const DistributionValuesEditor&) = delete;
320
321
/// @brief Invalidated assignment operator
322
DistributionValuesEditor& operator=(const DistributionValuesEditor& src) = delete;
323
};
324
};
325
326