Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/network/GNETAZFrame.h
169685 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 GNETAZFrame.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2018
17
///
18
// The Widget for add TAZ elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/frames/GNEFrame.h>
24
#include <netedit/GNEViewNetHelper.h>
25
26
// ===========================================================================
27
// class definitions
28
// ===========================================================================
29
30
class GNEAttributesEditor;
31
class GNEDrawingShape;
32
class GNETAZSourceSink;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
38
class GNETAZFrame : public GNEFrame {
39
40
public:
41
// ===========================================================================
42
// class CurrentTAZ
43
// ===========================================================================
44
45
class CurrentTAZ : public MFXGroupBoxModule {
46
47
public:
48
/// @brief struct for edges and the source/sink colors
49
class TAZEdgeColor {
50
51
public:
52
/// @brief constructor
53
TAZEdgeColor(CurrentTAZ* CurrentTAZParent, GNEEdge* _edge, GNETAZSourceSink* _source, GNETAZSourceSink* _sink);
54
55
/// @brief destructor (needed because RGBColors has to be deleted)
56
~TAZEdgeColor();
57
58
/// @brief update colors
59
void updateColors();
60
61
/// @brief TAZ edge
62
GNEEdge* edge;
63
64
/// @brief source TAZ
65
GNETAZSourceSink* source;
66
67
/// @brief sink TAZ
68
GNETAZSourceSink* sink;
69
70
/// @brief color by source [0-9]
71
int sourceColor;
72
73
/// @brief color by sink [0-9]
74
int sinkColor;
75
76
/// @brief color by source + sink [0-9]
77
int sourcePlusSinkColor;
78
79
/// @brief color by source - sink [0-9]
80
int sourceMinusSinkColor;
81
82
private:
83
/// @brief pointer to CurrentTAZParent
84
CurrentTAZ* myCurrentTAZParent;
85
86
/// @brief default color
87
TAZEdgeColor();
88
};
89
90
/// @brief constructor
91
CurrentTAZ(GNETAZFrame* TAZFrameParent);
92
93
/// @brief destructor
94
~CurrentTAZ();
95
96
/// @brief set current TAZ
97
void setTAZ(GNETAZ* editedTAZ);
98
99
/// @brief get current TAZ
100
GNETAZ* getTAZ() const;
101
102
/// @brief check if given edge belongs to current TAZ
103
bool isTAZEdge(GNEEdge* edge) const;
104
105
/// @brief get current selected edges
106
const std::vector<GNEEdge*>& getSelectedEdges() const;
107
108
/// @brief get TAZEdges
109
const std::vector<CurrentTAZ::TAZEdgeColor>& getTAZEdges() const;
110
111
/// @brief refresh TAZEdges
112
void refreshTAZEdges();
113
114
protected:
115
/// @brief add source sink
116
void addSourceSink(GNETAZSourceSink* additional);
117
118
private:
119
/// @brief pointer to TAZ Frame
120
GNETAZFrame* myTAZFrameParent;
121
122
/// @brief current edited TAZ
123
GNETAZ* myEditedTAZ;
124
125
/// @brief vector with pointers to selected edges
126
std::vector<GNEEdge*> mySelectedEdges;
127
128
/// @brief vector with TAZ's edges
129
std::vector<TAZEdgeColor> myTAZEdgeColors;
130
131
/// @brief Label for current TAZ
132
FXLabel* myCurrentTAZLabel;
133
134
/// @brief maximum source plus sink value of current TAZ Edges
135
double myMaxSourcePlusSinkWeight;
136
137
/// @brief minimum source plus sink value of current TAZ Edges
138
double myMinSourcePlusSinkWeight;
139
140
/// @brief maximum source minus sink value of current TAZ Edges
141
double myMaxSourceMinusSinkWeight;
142
143
/// @brief minimum source minus sink value of current TAZ Edges
144
double myMinSourceMinusSinkWeight;
145
};
146
147
// ===========================================================================
148
// class TAZCommonStatistics
149
// ===========================================================================
150
151
class TAZCommonStatistics : public MFXGroupBoxModule {
152
153
public:
154
/// @brief constructor
155
TAZCommonStatistics(GNETAZFrame* TAZFrameParent);
156
157
/// @brief destructor
158
~TAZCommonStatistics();
159
160
/// @brief show TAZ Common Statistics Module
161
void showTAZCommonStatisticsModule();
162
163
/// @brief hide TAZ Common Statistics Module
164
void hideTAZCommonStatisticsModule();
165
166
/// @brief update Statistics label
167
void updateStatistics();
168
169
private:
170
/// @brief pointer to TAZFrame parent
171
GNETAZFrame* myTAZFrameParent;
172
173
/// @brief Statistics labels
174
FXLabel* myStatisticsLabel;
175
};
176
177
// ===========================================================================
178
// class TAZSaveChanges
179
// ===========================================================================
180
181
class TAZSaveChanges : public MFXGroupBoxModule {
182
/// @brief FOX-declaration
183
FXDECLARE(GNETAZFrame::TAZSaveChanges)
184
185
public:
186
/// @brief constructor
187
TAZSaveChanges(GNETAZFrame* TAZFrameParent);
188
189
/// @brief destructor
190
~TAZSaveChanges();
191
192
/// @brief show TAZ Save Changes Module
193
void showTAZSaveChangesModule();
194
195
/// @brief hide TAZ Save Changes Module
196
void hideTAZSaveChangesModule();
197
198
/// @brief enable buttons save and cancel changes (And begin Undo List)
199
void enableButtonsAndBeginUndoList();
200
201
/// @brief return true if there is changes to save
202
bool isChangesPending() const;
203
204
/// @name FOX-callbacks
205
/// @{
206
/// @brief Called when the user press the button save changes
207
long onCmdSaveChanges(FXObject*, FXSelector, void*);
208
209
/// @brief Called when the user press the button cancel changes
210
long onCmdCancelChanges(FXObject*, FXSelector, void*);
211
/// @}
212
213
protected:
214
FOX_CONSTRUCTOR(TAZSaveChanges)
215
216
private:
217
/// @brief pointer to TAZFrame parent
218
GNETAZFrame* myTAZFrameParent;
219
220
/// @field FXButton for save changes in TAZEdges
221
FXButton* mySaveChangesButton;
222
223
/// @field FXButton for cancel changes in TAZEdges
224
FXButton* myCancelChangesButton;
225
};
226
227
// ===========================================================================
228
// class TAZChildDefaultParameters
229
// ===========================================================================
230
231
class TAZChildDefaultParameters : public MFXGroupBoxModule {
232
/// @brief FOX-declaration
233
FXDECLARE(GNETAZFrame::TAZChildDefaultParameters)
234
235
public:
236
/// @brief constructor
237
TAZChildDefaultParameters(GNETAZFrame* TAZFrameParent);
238
239
/// @brief destructor
240
~TAZChildDefaultParameters();
241
242
/// @brief extend TAZ child default parameters Module (if we have selected a TAZ)
243
void extendTAZChildDefaultParameters();
244
245
/// @brief collapse TAZ child default parameters Module (if we have selected a TAZ)
246
void collapseTAZChildDefaultParameters();
247
248
/// @brief update "select edges button"
249
void updateSelectEdgesButton();
250
251
/// @brief get default source weight
252
double getDefaultTAZSourceWeight() const;
253
254
/// @brief default sink weight
255
double getDefaultTAZSinkWeight() const;
256
257
/// @brief check if toggle membership is enabled
258
bool getToggleMembership() const;
259
260
/// @name FOX-callbacks
261
/// @{
262
/// @brief Called when the user changes default values
263
long onCmdSetDefaultValues(FXObject* obj, FXSelector, void*);
264
265
/// @brief Called when the user press "use selected edges" button
266
long onCmdUseSelectedEdges(FXObject* obj, FXSelector, void*);
267
268
/// @brief Called when the user press "zero fringe probabilities" button
269
long onCmdSetZeroFringeProbabilities(FXObject* obj, FXSelector, void*);
270
/// @}
271
272
protected:
273
/// @brief FOX need this
274
FOX_CONSTRUCTOR(TAZChildDefaultParameters)
275
276
private:
277
/// @brief pointer to TAZFrame parent
278
GNETAZFrame* myTAZFrameParent;
279
280
/// @brief CheckButton to enable or disable Toggle edge Membership
281
FXCheckButton* myToggleMembership;
282
283
/// @brief Horizontal Frame toggle membership
284
FXHorizontalFrame* myToggleMembershipFrame;
285
286
/// @brief Horizontal Frame for default TAZ Source Weight
287
FXHorizontalFrame* myDefaultTAZSourceFrame;
288
289
/// @brief textField to set a default value for TAZ Sources
290
FXTextField* myTextFieldDefaultValueTAZSources;
291
292
/// @brief Horizontal Frame for default TAZ Sink Weight
293
FXHorizontalFrame* myDefaultTAZSinkFrame;
294
295
/// @brief textField to set a default value for TAZ Sinks
296
FXTextField* myTextFieldDefaultValueTAZSinks;
297
298
/// @brief button for use selected edges
299
FXButton* myUseSelectedEdges;
300
301
/// @brief button for setting zero fringe probabilities
302
FXButton* myZeroFringeProbabilities;
303
304
/// @brief information label
305
FXLabel* myInformationLabel;
306
307
/// @brief default source weight
308
double myDefaultTAZSourceWeight;
309
310
/// @brief default sink weight
311
double myDefaultTAZSinkWeight;
312
};
313
314
// ===========================================================================
315
// class TAZSelectionStatistics
316
// ===========================================================================
317
318
class TAZSelectionStatistics : public MFXGroupBoxModule {
319
/// @brief FOX-declaration
320
FXDECLARE(GNETAZFrame::TAZSelectionStatistics)
321
322
public:
323
/// @brief constructor
324
TAZSelectionStatistics(GNETAZFrame* TAZFrameParent);
325
326
/// @brief destructor
327
~TAZSelectionStatistics();
328
329
/// @brief show TAZ Selection Statistics Module
330
void showTAZSelectionStatisticsModule();
331
332
/// @brief hide TAZ Selection Statistics Module
333
void hideTAZSelectionStatisticsModule();
334
335
/// @brief add an edge and their TAZ Children in the list of selected items
336
bool selectEdge(const CurrentTAZ::TAZEdgeColor& edge);
337
338
/// @brief un select an edge (and their TAZ Children)
339
bool unselectEdge(GNEEdge* edge);
340
341
/// @brief check if an edge is selected
342
bool isEdgeSelected(GNEEdge* edge);
343
344
/// @brief clear current TAZ children
345
void clearSelectedEdges();
346
347
/// @brief get map with edge and TAZChildren
348
const std::vector<CurrentTAZ::TAZEdgeColor>& getEdgeAndTAZChildrenSelected() const;
349
350
/// @name FOX-callbacks
351
/// @{
352
/// @brief Called when the user set a new value
353
long onCmdSetNewValues(FXObject* obj, FXSelector, void*);
354
355
/// @brief Called when the user press select edges
356
long onCmdSelectEdges(FXObject* obj, FXSelector, void*);
357
/// @}
358
359
protected:
360
FOX_CONSTRUCTOR(TAZSelectionStatistics)
361
362
/// @brief update TAZSelectionStatistics
363
void updateStatistics();
364
365
private:
366
/// @brief pointer to TAZFrame parent
367
GNETAZFrame* myTAZFrameParent;
368
369
/// @brief Horizontal Frame for default TAZ Source Weight
370
FXHorizontalFrame* myTAZSourceFrame;
371
372
/// @brief textField for TAZ Source weight
373
FXTextField* myTextFieldTAZSourceWeight;
374
375
/// @brief Horizontal Frame for default TAZ Sink Weight
376
FXHorizontalFrame* myTAZSinkFrame;
377
378
/// @brief textField for TAZ Sink weight
379
FXTextField* myTextFieldTAZSinkWeight;
380
381
/// @brief Statistics labels
382
FXLabel* myStatisticsLabel;
383
384
/// @brief vector with the current selected edges and their associated children
385
std::vector<CurrentTAZ::TAZEdgeColor> myEdgeAndTAZChildrenSelected;
386
};
387
388
// ===========================================================================
389
// class TAZEdgesGraphic
390
// ===========================================================================
391
392
class TAZEdgesGraphic : public MFXGroupBoxModule {
393
/// @brief FOX-declaration
394
FXDECLARE(GNETAZFrame::TAZEdgesGraphic)
395
396
public:
397
/// @brief constructor
398
TAZEdgesGraphic(GNETAZFrame* TAZFrameParent);
399
400
/// @brief destructor
401
~TAZEdgesGraphic();
402
403
/// @brief show TAZ Edges Graphic Module
404
void showTAZEdgesGraphicModule();
405
406
/// @brief hide TAZ Edges Graphic Module
407
void hideTAZEdgesGraphicModule();
408
409
/// @brief update edge colors;
410
void updateEdgeColors();
411
412
/// @name FOX-callbacks
413
/// @{
414
/// @brief Called when the user select one kind of representation
415
long onCmdChoosenBy(FXObject* obj, FXSelector, void*);
416
/// @}
417
418
protected:
419
FOX_CONSTRUCTOR(TAZEdgesGraphic)
420
421
private:
422
/// @brief pointer to TAZFrame parent
423
GNETAZFrame* myTAZFrameParent;
424
425
/// @brief add radio button "color by source"
426
FXRadioButton* myColorBySourceWeight;
427
428
/// @brief add radio button "color by sink"
429
FXRadioButton* myColorBySinkWeight;
430
431
/// @brief add radio button "color source + sink"
432
FXRadioButton* myColorBySourcePlusSinkWeight;
433
434
/// @brief add radio button "color source - Sink"
435
FXRadioButton* myColorBySourceMinusSinkWeight;
436
437
/// @brief default RGBColor for all edges
438
RGBColor myEdgeDefaultColor;
439
440
/// @brief RGBColor color for selected egdes
441
RGBColor myEdgeSelectedColor;
442
};
443
444
/**@brief Constructor
445
* @brief viewParent GNEViewParent in which this GNEFrame is placed
446
* @brief viewNet viewNet that uses this GNEFrame
447
*/
448
GNETAZFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
449
450
/// @brief Destructor
451
~GNETAZFrame();
452
453
/// @brief show TAZ Frame
454
void show();
455
456
/// @brief hide TAZ frame
457
void hide();
458
459
/**@brief process click over Viewnet
460
* @param[in] clickedPosition clicked position over ViewNet
461
* @param[in] viewObjects objects under cursors
462
* @return true if something (select TAZ or add edge) was successfully done
463
*/
464
bool processClick(const Position& clickedPosition, const GNEViewNetHelper::ViewObjectsSelector& viewObjects);
465
466
/// @brief process selection of edges in view net
467
void processEdgeSelection(const std::vector<GNEEdge*>& edges);
468
469
/// @brief get drawing mode module
470
GNEDrawingShape* getDrawingShapeModule() const;
471
472
/// @brief get Current TAZ module
473
CurrentTAZ* getCurrentTAZModule() const;
474
475
/// @brief get TAZ Selection Statistics module
476
TAZSelectionStatistics* getTAZSelectionStatisticsModule() const;
477
478
/// @brief get TAZ Save Changes module
479
TAZSaveChanges* getTAZSaveChangesModule() const;
480
481
protected:
482
/// @brief SumoBaseObject used for creating TAZ
483
CommonXMLStructure::SumoBaseObject* myBaseTAZ = nullptr;
484
485
/**@brief build a shaped element using the drawed shape
486
* return true if was successfully created
487
* @note called when user stop drawing shape
488
*/
489
bool shapeDrawed();
490
491
/// @brief add or remove a source and a sink, or remove it if edge is in the list of TAZ Children
492
bool addOrRemoveTAZMember(GNEEdge* edge);
493
494
/// @brief drop all TAZSources and TAZ Sinks of current TAZ
495
void dropTAZMembers();
496
497
private:
498
/// @brief current TAZ
499
CurrentTAZ* myCurrentTAZ = nullptr;
500
501
/// @brief TAZ Edges common parameters
502
TAZCommonStatistics* myTAZCommonStatistics = nullptr;
503
504
/// @brief TAZ parameters
505
GNEAttributesEditor* myTAZAttributesEditor = nullptr;
506
507
/// @brief Drawing shape
508
GNEDrawingShape* myDrawingShape = nullptr;
509
510
/// @brief save TAZ Edges
511
TAZSaveChanges* myTAZSaveChanges = nullptr;
512
513
/// @brief TAZ child defaults parameters
514
TAZChildDefaultParameters* myTAZChildDefaultParameters = nullptr;
515
516
/// @brief TAZ Edges selection parameters
517
TAZSelectionStatistics* myTAZSelectionStatistics = nullptr;
518
519
/// @brief TAZ Edges Graphic
520
TAZEdgesGraphic* myTAZEdgesGraphic = nullptr;
521
};
522
523