Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/common/GNESelectorFrame.h
193874 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 GNESelectorFrame.h
15
/// @author Jakob Erdmann
16
/// @date Mar 2011
17
///
18
// The Widget for modifying selections of network-elements
19
// (some elements adapted from GUIDialog_GLChosenEditor)
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <unordered_map>
25
26
#include <netedit/frames/GNEFrame.h>
27
#include <netedit/GNEViewNetHelper.h>
28
#include "GNEGroupBoxModule.h"
29
30
// ===========================================================================
31
// class declaration
32
// ===========================================================================
33
34
class GNEMatchAttribute;
35
class MFXComboBoxIcon;
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
41
class GNESelectorFrame : public GNEFrame {
42
43
public:
44
// ===========================================================================
45
// class SelectionInformation
46
// ===========================================================================
47
48
class SelectionInformation : public GNEGroupBoxModule {
49
50
public:
51
/// @brief constructor
52
SelectionInformation(GNESelectorFrame* selectorFrameParent);
53
54
/// @brief destructor
55
~SelectionInformation();
56
57
/// @brief update information label
58
void updateInformationLabel();
59
60
protected:
61
/// @brief update information label
62
void updateInformationLabel(const std::string& element, int number);
63
64
private:
65
/// @brief string for keep information
66
std::string myInformation;
67
68
/// @brief information label
69
FXLabel* myInformationLabel;
70
71
/// @brief pointer to Selector Frame Parent
72
GNESelectorFrame* mySelectorFrameParent;
73
74
/// @brief Invalidated copy constructor.
75
SelectionInformation(const SelectionInformation&) = delete;
76
77
/// @brief Invalidated assignment operator.
78
SelectionInformation& operator=(const SelectionInformation&) = delete;
79
};
80
81
// ===========================================================================
82
// class ModificationMode
83
// ===========================================================================
84
85
class ModificationMode : public GNEGroupBoxModule {
86
/// @brief FOX-declaration
87
FXDECLARE(GNESelectorFrame::ModificationMode)
88
89
public:
90
/// @brief operations of selector
91
enum class Operation {
92
ADD,
93
SUB,
94
RESTRICT,
95
REPLACE,
96
DEFAULT
97
};
98
99
/// @brief constructor
100
ModificationMode(GNESelectorFrame* selectorFrameParent);
101
102
/// @brief destructor
103
~ModificationMode();
104
105
/// @brief get current modification mode
106
Operation getModificationMode() const;
107
108
/// @name FOX-callbacks
109
/// @{
110
/// @brief called when user change type of selection operation
111
long onCmdSelectModificationMode(FXObject*, FXSelector, void*);
112
113
/// @}
114
115
protected:
116
/// @brief FOX need this
117
FOX_CONSTRUCTOR(ModificationMode)
118
119
private:
120
/// @brief add radio button
121
FXRadioButton* myAddRadioButton;
122
123
/// @brief remove radio button
124
FXRadioButton* myRemoveRadioButton;
125
126
/// @brief keep button
127
FXRadioButton* myKeepRadioButton;
128
129
/// @brief replace radio button
130
FXRadioButton* myReplaceRadioButton;
131
132
/// @brief how to modify selection
133
Operation myModificationModeType;
134
135
/// @brief Invalidated copy constructor.
136
ModificationMode(const ModificationMode&) = delete;
137
138
/// @brief Invalidated assignment operator.
139
ModificationMode& operator=(const ModificationMode&) = delete;
140
};
141
142
// ===========================================================================
143
// class VisualScaling
144
// ===========================================================================
145
146
class VisualScaling : public GNEGroupBoxModule {
147
/// @brief FOX-declaration
148
FXDECLARE(GNESelectorFrame::VisualScaling)
149
150
public:
151
/// @brief constructor
152
VisualScaling(GNESelectorFrame* selectorFrameParent);
153
154
/// @brief destructor
155
~VisualScaling();
156
157
/// @name FOX-callbacks
158
/// @{
159
160
/// @brief Called when the user changes visual scaling
161
long onCmdScaleSelection(FXObject*, FXSelector, void*);
162
163
/// @}
164
165
protected:
166
/// @brief FOX need this
167
FOX_CONSTRUCTOR(VisualScaling)
168
169
private:
170
/// @brief pointer to Selector Frame Parent
171
GNESelectorFrame* mySelectorFrameParent;
172
173
/// @brief Spinner for selection scaling
174
FXRealSpinner* mySelectionScaling;
175
176
/// @brief Invalidated copy constructor.
177
VisualScaling(const VisualScaling&) = delete;
178
179
/// @brief Invalidated assignment operator.
180
VisualScaling& operator=(const VisualScaling&) = delete;
181
};
182
183
// ===========================================================================
184
// class SelectionOperation
185
// ===========================================================================
186
187
class SelectionOperation : public GNEGroupBoxModule {
188
/// @brief FOX-declaration
189
FXDECLARE(GNESelectorFrame::SelectionOperation)
190
191
public:
192
/// @brief constructor
193
SelectionOperation(GNESelectorFrame* selectorFrameParent);
194
195
/// @brief destructor
196
~SelectionOperation();
197
198
/// @brief load from file
199
void loadFromFile(const std::string& file) const;
200
201
/// @name FOX-callbacks
202
/// @{
203
204
/**@brief Called when the user presses the Load-button
205
* @note Opens a file dialog and forces the parent to load the list of selected
206
* objects when a file was chosen. Rebuilds the list, then, and redraws itself.
207
*/
208
long onCmdLoad(FXObject*, FXSelector, void*);
209
210
/** @brief Called when the user presses the Save-button
211
* @note Opens a file dialog and forces the selection container to save the list
212
of selected objects when a file was chosen. If the saving failed, a message window is shown.
213
*/
214
long onCmdSave(FXObject*, FXSelector, void*);
215
216
/**@brief Called when the user presses the Clear-button
217
* @note Clear the internal list and calls GUISelectedStorage::clear and repaints itself
218
*/
219
long onCmdClear(FXObject*, FXSelector, void*);
220
221
/**@brief Called when the user presses the delete-button
222
*/
223
long onCmdDelete(FXObject*, FXSelector, void*);
224
225
/**@brief Called when the user presses the Invert-button
226
* @note invert the selection and repaints itself
227
*/
228
long onCmdInvert(FXObject*, FXSelector, void*);
229
230
/**@brief Called when the user presses the Reduce-button
231
* @note Reduce network
232
*/
233
long onCmdReduce(FXObject*, FXSelector, void*);
234
235
/// @}
236
237
protected:
238
/// @brief FOX need this
239
FOX_CONSTRUCTOR(SelectionOperation)
240
241
/// @brief struct used for massive selections
242
struct MassiveSelection {
243
244
/// @brief constructor with bucket size (normally the max number of elements)
245
MassiveSelection(const int bucketSize);
246
247
/// @brief destructor
248
~MassiveSelection();
249
250
/// @brief check if there are element to process
251
bool isElementToProcess() const;
252
253
/// @brief ACs to select (the bool flag shows if element is locked)
254
std::unordered_map<GNEAttributeCarrier*, bool> ACsToSelect;
255
256
/// @brief ACs to select (the bool flag shows if element is locked)
257
std::unordered_map<GNEAttributeCarrier*, bool> ACsToUnselect;
258
259
/// @brief locked types
260
std::map<GUIGlObjectType, bool> lockedTypes;
261
262
private:
263
/// @brief constructor (invalidated)
264
MassiveSelection();
265
};
266
267
/// @brief process massive network element selection
268
MassiveSelection processMassiveNetworkElementSelection(const bool filterLanes) const;
269
270
/// @brief process massive demand element selection
271
MassiveSelection processMassiveDemandElementSelection() const;
272
273
/// @brief process massive dataelement selection
274
MassiveSelection processMassiveDataElementSelection() const;
275
276
/// @brief ask if continue due locking
277
bool askContinueIfLock() const;
278
279
private:
280
/// @brief pointer to Selector Frame Parent
281
GNESelectorFrame* mySelectorFrameParent;
282
283
/// @brief Invalidated copy constructor.
284
SelectionOperation(const SelectionOperation&) = delete;
285
286
/// @brief Invalidated assignment operator.
287
SelectionOperation& operator=(const SelectionOperation&) = delete;
288
};
289
290
// ===========================================================================
291
// class SelectionHierarchy
292
// ===========================================================================
293
294
class SelectionHierarchy : public GNEGroupBoxModule {
295
/// @brief FOX-declaration
296
FXDECLARE(GNESelectorFrame::SelectionHierarchy)
297
298
public:
299
/// @brief constructor
300
SelectionHierarchy(GNESelectorFrame* selectorFrameParent);
301
302
/// @brief destructor
303
~SelectionHierarchy();
304
305
/// @name FOX-callbacks
306
/// @{
307
308
/// @brief called when user select an item in comboBox
309
long onCmdSelectItem(FXObject* obj, FXSelector, void*);
310
311
/// @brief called when user press select/unselect parents button
312
long onCmdParents(FXObject* obj, FXSelector, void*);
313
314
/// @brief called when user press select/unselect children button
315
long onCmdChildren(FXObject* obj, FXSelector, void*);
316
317
/// @}
318
319
protected:
320
/// @brief FOX need this
321
FOX_CONSTRUCTOR(SelectionHierarchy)
322
323
private:
324
/// @brief enum used in comboBox
325
enum class Selection {
326
ALL,
327
JUNCTION,
328
EDGE,
329
LANE,
330
CONNECTION,
331
CROSSING,
332
ADDITIONAL,
333
WIRE,
334
SHAPE,
335
DEMAND,
336
DATA,
337
NOTHING,
338
};
339
340
/// @brief pointer to Selector Frame Parent
341
GNESelectorFrame* mySelectorFrameParent;
342
343
/// @brief comboBox for parents
344
MFXComboBoxIcon* myParentsComboBox = nullptr;
345
346
/// @brief comboBox for children
347
MFXComboBoxIcon* myChildrenComboBox = nullptr;
348
349
/// @brief select parents button
350
FXButton* mySelectParentsButton = nullptr;
351
352
/// @brief unselect parents button
353
FXButton* myUnselectParentsButton = nullptr;
354
355
/// @brief select children button
356
FXButton* mySelectChildrenButton = nullptr;
357
358
/// @brief unselect parents button
359
FXButton* myUnselectChildrenButton = nullptr;
360
361
// @brief items
362
const std::vector<std::pair<Selection, std::string> > myItems = {
363
std::make_pair(Selection::ALL, "all"),
364
std::make_pair(Selection::JUNCTION, "junction"),
365
std::make_pair(Selection::EDGE, "edge"),
366
std::make_pair(Selection::LANE, "lane"),
367
std::make_pair(Selection::CONNECTION, "connection"),
368
std::make_pair(Selection::CROSSING, "crossing"),
369
std::make_pair(Selection::ADDITIONAL, "additionalElements"),
370
std::make_pair(Selection::WIRE, "wireElements"),
371
std::make_pair(Selection::SHAPE, "shapeElements"),
372
std::make_pair(Selection::DEMAND, "demandElements"),
373
std::make_pair(Selection::DATA, "dataElements")
374
};
375
376
/// @brief current selected parent
377
Selection myCurrentSelectedParent;
378
379
/// @brief current selected child
380
Selection myCurrentSelectedChild;
381
382
/// @brief Invalidated copy constructor.
383
SelectionHierarchy(const SelectionHierarchy&) = delete;
384
385
/// @brief Invalidated assignment operator.
386
SelectionHierarchy& operator=(const SelectionHierarchy&) = delete;
387
};
388
389
// ===========================================================================
390
// class Legend
391
// ===========================================================================
392
393
class Information : public GNEGroupBoxModule {
394
395
public:
396
/// @brief constructor
397
Information(GNESelectorFrame* selectorFrameParent);
398
399
/// @brief destructor
400
~Information();
401
};
402
403
/**@brief Constructor
404
* @brief viewParent GNEViewParent in which this GNEFrame is placed
405
* @brief viewNet viewNet that uses this GNEFrame
406
*/
407
GNESelectorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
408
409
/// @brief Destructor
410
~GNESelectorFrame();
411
412
/// @brief show Frame
413
void show();
414
415
/// @brief hide Frame
416
void hide();
417
418
/// @brief function called after undo/redo in the current frame
419
void updateFrameAfterUndoRedo();
420
421
/// @brief clear current selection with possibility of undo/redo
422
void clearCurrentSelection() const;
423
424
/**@brief select attribute carrier (element)
425
* @param viewObjects objects under cursors
426
*/
427
bool selectAttributeCarrier(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);
428
429
/**@brief apply list of ids to the current selection according to Operation,
430
* @note if setop==DEFAULT than the currently set mode (myOperation) is used
431
*/
432
void handleIDs(const std::vector<GNEAttributeCarrier*>& ACs, const ModificationMode::Operation setop = ModificationMode::Operation::DEFAULT);
433
434
/// @brief get vertical frame that holds all widgets of frame
435
FXVerticalFrame* getContentFrame() const;
436
437
/// @brief get modification mode modul
438
ModificationMode* getModificationModeModul() const;
439
440
/// @brief get selection operation modul
441
GNESelectorFrame::SelectionOperation* getSelectionOperationModul() const;
442
443
/// @brief get modul for selection information
444
SelectionInformation* getSelectionInformation() const;
445
446
private:
447
/// @brief modul for selection information
448
GNESelectorFrame::SelectionInformation* mySelectionInformation = nullptr;
449
450
/// @brief modul for change modification mode
451
GNESelectorFrame::ModificationMode* myModificationMode = nullptr;
452
453
/// @brief modul for match attribute
454
GNEMatchAttribute* myMatchAttribute = nullptr;
455
456
/// @brief modul for visual scaling
457
GNESelectorFrame::VisualScaling* myVisualScaling = nullptr;
458
459
/// @brief modul for selection operations
460
GNESelectorFrame::SelectionOperation* mySelectionOperation = nullptr;
461
462
/// @brief modul for selection hierarchy
463
GNESelectorFrame::SelectionHierarchy* mySelectionHierarchy = nullptr;
464
465
/// @brief information modul
466
GNESelectorFrame::Information* myInformation = nullptr;
467
468
/// @brief Invalidated copy constructor.
469
GNESelectorFrame(const GNESelectorFrame&) = delete;
470
471
/// @brief Invalidated assignment operator.
472
GNESelectorFrame& operator=(const GNESelectorFrame&) = delete;
473
};
474
475