Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/GNEMatchAttribute.cpp
169678 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 GNEMatchAttribute.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Feb 2020
17
///
18
// The Widget for modifying selections of network-elements
19
/****************************************************************************/
20
21
#include <netedit/frames/common/GNESelectorFrame.h>
22
#include <netedit/dialogs/basic/GNEHelpBasicDialog.h>
23
#include <netedit/GNENet.h>
24
#include <netedit/GNEViewNet.h>
25
#include <netedit/GNEViewParent.h>
26
#include <netedit/GNEApplicationWindow.h>
27
#include <netedit/GNETagProperties.h>
28
#include <netedit/GNEAttributeProperties.h>
29
#include <netedit/GNETagPropertiesDatabase.h>
30
#include <utils/foxtools/MFXComboBoxAttrProperty.h>
31
#include <utils/foxtools/MFXComboBoxTagProperty.h>
32
#include <utils/gui/div/GUIDesigns.h>
33
#include <utils/gui/windows/GUIAppEnum.h>
34
35
#include "GNEMatchAttribute.h"
36
37
// ===========================================================================
38
// FOX callback mapping
39
// ===========================================================================
40
41
FXDEFMAP(GNEMatchAttribute) GNEMatchAttributeMap[] = {
42
FXMAPFUNC(SEL_COMMAND, MID_GNE_SELECTORFRAME_SELECTTAG, GNEMatchAttribute::onCmdTagSelected),
43
FXMAPFUNC(SEL_COMMAND, MID_GNE_SELECTORFRAME_SELECTATTRIBUTE, GNEMatchAttribute::onCmdAttributeSelected),
44
FXMAPFUNC(SEL_COMMAND, MID_GNE_SELECTORFRAME_TOGGLECOMMON, GNEMatchAttribute::onCmdToogleOnlyCommon),
45
FXMAPFUNC(SEL_COMMAND, MID_GNE_SELECTORFRAME_PROCESSSTRING, GNEMatchAttribute::onCmdProcessString),
46
FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEMatchAttribute::onCmdHelp)
47
};
48
49
// Object implementation
50
FXIMPLEMENT(GNEMatchAttribute, MFXGroupBoxModule, GNEMatchAttributeMap, ARRAYNUMBER(GNEMatchAttributeMap))
51
52
// ===========================================================================
53
// method definitions
54
// ===========================================================================
55
56
// ---------------------------------------------------------------------------
57
// GNEMatchAttribute - methods
58
// ---------------------------------------------------------------------------
59
#ifdef _MSC_VER
60
#pragma warning(push)
61
#pragma warning(disable: 4355) // mask warning about "this" in initializers
62
#endif
63
GNEMatchAttribute::GNEMatchAttribute(GNESelectorFrame* selectorFrameParent) :
64
MFXGroupBoxModule(selectorFrameParent, TL("Match Attribute")),
65
mySelectorFrameParent(selectorFrameParent),
66
myCurrentEditedProperties(new CurrentEditedProperties(this)) {
67
const auto staticTooltipMenu = selectorFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu();
68
// Create MFXComboBoxIcons (sum 1 due children)
69
for (int i = 0; i < selectorFrameParent->getViewNet()->getNet()->getTagPropertiesDatabase()->getHierarchyDepth() + 1; i++) {
70
auto comboBoxIcon = new MFXComboBoxTagProperty(getCollapsableFrame(), staticTooltipMenu, true, GUIDesignComboBoxVisibleItems,
71
this, MID_GNE_SELECTORFRAME_SELECTTAG, GUIDesignComboBox);
72
myTagComboBoxVector.push_back(comboBoxIcon);
73
}
74
myShowOnlyCommonAttributes = new FXCheckButton(getCollapsableFrame(), TL("Only common"), this, MID_GNE_SELECTORFRAME_TOGGLECOMMON, GUIDesignCheckButton);
75
myShowOnlyCommonAttributes->setCheck(FALSE);
76
// Create MFXComboBoxIcon for Attributes
77
myAttributeComboBox = new MFXComboBoxAttrProperty(getCollapsableFrame(), staticTooltipMenu, true, GUIDesignComboBoxVisibleItems,
78
this, MID_GNE_SELECTORFRAME_SELECTATTRIBUTE, GUIDesignComboBox);
79
// Create TextField for Match string
80
myMatchString = new FXTextField(getCollapsableFrame(), GUIDesignTextFieldNCol, this, MID_GNE_SELECTORFRAME_PROCESSSTRING, GUIDesignTextField);
81
// create button
82
myMatchStringButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Apply selection"), "", "", nullptr, this, MID_GNE_SELECTORFRAME_PROCESSSTRING, GUIDesignButton);
83
// Create help button
84
GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Help"), "", "", nullptr, this, MID_HELP, GUIDesignButtonRectangular);
85
// refresh with the current tag and attr
86
refreshMatchAttribute();
87
}
88
#ifdef _MSC_VER
89
#pragma warning(pop)
90
#endif
91
92
GNEMatchAttribute::~GNEMatchAttribute() {
93
delete myCurrentEditedProperties;
94
}
95
96
97
void
98
GNEMatchAttribute::enableMatchAttribute() {
99
for (const auto& tagComboBox : myTagComboBoxVector) {
100
tagComboBox->enable();
101
}
102
myAttributeComboBox->enable();
103
myMatchString->enable();
104
myMatchStringButton->enable();
105
}
106
107
108
void
109
GNEMatchAttribute::disableMatchAttribute() {
110
for (const auto& tagComboBox : myTagComboBoxVector) {
111
tagComboBox->disable();
112
tagComboBox->setTextColor(GUIDesignTextColorBlack);
113
}
114
myAttributeComboBox->disable();
115
myMatchString->disable();
116
myMatchStringButton->disable();
117
// change colors to black (even if there are invalid values)
118
myAttributeComboBox->setTextColor(GUIDesignTextColorBlack);
119
myMatchString->setTextColor(GUIDesignTextColorBlack);
120
}
121
122
123
void
124
GNEMatchAttribute::showMatchAttribute() {
125
// refresh before show
126
refreshMatchAttribute();
127
// show groupbox
128
show();
129
}
130
131
132
void
133
GNEMatchAttribute::hideMatchAttribute() {
134
// hide groupbox
135
hide();
136
}
137
138
139
void
140
GNEMatchAttribute::refreshMatchAttribute() {
141
// continue depending of current
142
auto parentHierarchy = myCurrentEditedProperties->getTagProperties()->getHierarchicalParentsRecuersively();
143
// fill hierarchy
144
for (size_t i = 0; i < parentHierarchy.size(); i++) {
145
auto comboBox = myTagComboBoxVector.at(i);
146
// clear previous elements
147
comboBox->clearItems();
148
// add <all> always as first element
149
myTagComboBoxVector.at(i)->appendTagItem(myCurrentEditedProperties->getTagPropertiesAll());
150
// add siblings (except for root)
151
if (parentHierarchy.at(i)->getHierarchicalParent()) {
152
for (const auto tagSibling : parentHierarchy.at(i)->getHierarchicalParent()->getHierarchicalChildren()) {
153
if (tagSibling->isDrawable()) {
154
myTagComboBoxVector.at(i)->appendTagItem(tagSibling);
155
}
156
}
157
// update tag
158
if (myTagComboBoxVector.at(i)->hasTagProperty(parentHierarchy.at(i))) {
159
myTagComboBoxVector.at(i)->setCurrentItem(parentHierarchy.at(i), FALSE);
160
myTagComboBoxVector.at(i)->show();
161
} else {
162
myTagComboBoxVector.at(i)->hide();
163
}
164
}
165
}
166
// hide the two first combo boxes(root and supermode)
167
myTagComboBoxVector.at(0)->hide();
168
myTagComboBoxVector.at(1)->hide();
169
// hide comboBox with only one element (+ <all>)
170
if (myTagComboBoxVector.at(parentHierarchy.size() - 1)->getNumItems() == 2) {
171
myTagComboBoxVector.at(parentHierarchy.size() - 1)->hide();
172
}
173
// check if show children
174
auto comboBoxChildren = myTagComboBoxVector.at(parentHierarchy.size());
175
if (parentHierarchy.back()->getHierarchicalChildren().size() > 0) {
176
// clear previous elements
177
comboBoxChildren->clearItems();
178
// add <all> always as first element
179
comboBoxChildren->appendTagItem(myCurrentEditedProperties->getTagPropertiesAll());
180
for (const auto childTagProperty : parentHierarchy.back()->getHierarchicalChildren()) {
181
comboBoxChildren->appendTagItem(childTagProperty);
182
}
183
comboBoxChildren->show();
184
} else {
185
comboBoxChildren->hide();
186
}
187
// hide rest of combo boxes
188
for (size_t i = (parentHierarchy.size() + 1); i < myTagComboBoxVector.size(); i++) {
189
myTagComboBoxVector.at(i)->hide();
190
}
191
// now fill attributes
192
myAttributeComboBox->clearItems();
193
// get all children recursivelly
194
const auto attributes = myCurrentEditedProperties->getTagProperties()->getHierarchicalChildrenAttributesRecursively(myShowOnlyCommonAttributes->getCheck() == TRUE, true);
195
for (const auto& attribute : attributes) {
196
myAttributeComboBox->appendAttrItem(attribute.second);
197
}
198
// update tag
199
if (myAttributeComboBox->getNumItems() == 0) {
200
myAttributeComboBox->appendAttrItem(myCurrentEditedProperties->getAttributePropertiesNoCommon());
201
myAttributeComboBox->disable();
202
// set match string
203
myMatchString->setText("", FALSE);
204
myMatchString->disable();
205
} else {
206
myAttributeComboBox->enable();
207
if (myAttributeComboBox->hasAttrProperty(myCurrentEditedProperties->getAttributeProperties())) {
208
myAttributeComboBox->setCurrentItem(myCurrentEditedProperties->getAttributeProperties(), FALSE);
209
} else {
210
myAttributeComboBox->setCurrentItem(attributes.begin()->second, FALSE);
211
myCurrentEditedProperties->setAttributeProperties(myAttributeComboBox->getCurrentAttrProperty());
212
}
213
// set match string
214
myMatchString->setText(myCurrentEditedProperties->getMatchValue().c_str(), FALSE);
215
myMatchString->enable();
216
}
217
}
218
219
220
long
221
GNEMatchAttribute::onCmdTagSelected(FXObject* obj, FXSelector, void*) {
222
// iterate over all comboBoxes
223
int tagComboBoxIndex = 0;
224
for (int i = 0; i < (int)myTagComboBoxVector.size(); i++) {
225
if (myTagComboBoxVector.at(i) == obj) {
226
tagComboBoxIndex = i;
227
}
228
}
229
// check if tag property exist
230
if (myTagComboBoxVector.at(tagComboBoxIndex)->getCurrentTagProperty()) {
231
const auto selectedTag = myTagComboBoxVector.at(tagComboBoxIndex)->getCurrentTagProperty();
232
// if we select <all>, use parent tag
233
if (selectedTag == myCurrentEditedProperties->getTagPropertiesAll()) {
234
myCurrentEditedProperties->setTagProperties(myTagComboBoxVector.at(tagComboBoxIndex - 1)->getCurrentTagProperty());
235
} else {
236
myCurrentEditedProperties->setTagProperties(selectedTag);
237
}
238
refreshMatchAttribute();
239
}
240
return 0;
241
}
242
243
244
long
245
GNEMatchAttribute::onCmdAttributeSelected(FXObject*, FXSelector, void*) {
246
myCurrentEditedProperties->setAttributeProperties(myAttributeComboBox->getCurrentAttrProperty());
247
refreshMatchAttribute();
248
return 1;
249
}
250
251
252
long
253
GNEMatchAttribute::onCmdToogleOnlyCommon(FXObject*, FXSelector, void*) {
254
// simply refresh attribute
255
refreshMatchAttribute();
256
return 1;
257
}
258
259
260
long
261
GNEMatchAttribute::onCmdProcessString(FXObject*, FXSelector, void*) {
262
std::vector<GNEAttributeCarrier*> matches;
263
// obtain expresion
264
std::string expr = myMatchString->getText().text();
265
bool valid = true;
266
if (expr == "") {
267
// the empty expression matches all objects
268
matches = getMatches('@', 0, expr);
269
} else if (myCurrentEditedProperties->getAttributeProperties()->isNumerical()) {
270
// The expression must have the form
271
// <val matches if attr < val
272
// >val matches if attr > val
273
// =val matches if attr = val
274
// val matches if attr = val
275
char compOp = expr[0];
276
if (compOp == '<' || compOp == '>' || compOp == '=') {
277
expr = expr.substr(1);
278
} else {
279
compOp = '=';
280
}
281
// check if value can be parsed to double
282
if (GNEAttributeCarrier::canParse<double>(expr.c_str())) {
283
matches = getMatches(compOp, GNEAttributeCarrier::parse<double>(expr.c_str()), expr);
284
} else {
285
valid = false;
286
}
287
} else {
288
// The expression must have the form
289
// =str: matches if <str> is an exact match
290
// !str: matches if <str> is not a substring
291
// ^str: matches if <str> is not an exact match
292
// str: matches if <str> is a substring (sends compOp '@')
293
// Alternatively, if the expression is empty it matches all objects
294
char compOp = expr[0];
295
if (compOp == '=' || compOp == '!' || compOp == '^') {
296
expr = expr.substr(1);
297
} else {
298
compOp = '@';
299
}
300
matches = getMatches(compOp, 0, expr);
301
}
302
if (valid) {
303
mySelectorFrameParent->handleIDs(matches);
304
myMatchString->setTextColor(GUIDesignTextColorBlack);
305
myMatchString->killFocus();
306
} else {
307
myMatchString->setTextColor(GUIDesignTextColorRed);
308
}
309
return 1;
310
311
}
312
313
314
long
315
GNEMatchAttribute::onCmdHelp(FXObject*, FXSelector, void*) {
316
// set help text
317
std::ostringstream help;
318
help
319
<< TL("- The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection") << "\n"
320
<< TL(" according to the current 'Modification Mode'.") << "\n"
321
<< TL(" 1. Select an object type from the first input box") << "\n"
322
<< TL(" 2. Select an attribute from the second input box") << "\n"
323
<< TL(" 3. Enter a 'match expression' in the third input box and press <return>") << "\n"
324
<< "\n"
325
<< TL("- The empty expression matches all objects") << "\n"
326
<< TL("- For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.") << "\n"
327
<< TL("- An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'") << "\n"
328
<< "\n"
329
<< TL("- For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.") << "\n"
330
<< TL(" '' (no operator) matches if string is a substring of that object's attribute.") << "\n"
331
<< TL(" '=' matches if string is an exact match.") << "\n"
332
<< TL(" '!' matches if string is not a substring.") << "\n"
333
<< TL(" '^' matches if string is not an exact match.") << "\n"
334
<< "\n"
335
<< TL("- Examples:")
336
<< TL(" junction; id; 'foo' -> match all junctions that have 'foo' in their id") << "\n"
337
<< TL(" junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'") << "\n"
338
<< TL(" edge; speed; '>10' -> match all edges with a speed above 10");
339
// open help dialog
340
GNEHelpBasicDialog(mySelectorFrameParent->getViewNet()->getViewParent()->getGNEAppWindows(),
341
TL("Netedit parameters Help"), help);
342
return 1;
343
}
344
345
346
std::vector<GNEAttributeCarrier*>
347
GNEMatchAttribute::getMatches(const char compOp, const double val, const std::string& expr) {
348
std::vector<GNEAttributeCarrier*> result;
349
// first retrieve all ACs using ACTag
350
const auto allACbyTag = mySelectorFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveAttributeCarriers(myCurrentEditedProperties->getTagProperties()->getTag());
351
// iterate over all ACs
352
for (const auto& AC : allACbyTag) {
353
// first check if the attribute exist in the given tag
354
if (AC->getTagProperty()->hasAttribute(myCurrentEditedProperties->getAttributeProperties()->getAttr())) {
355
if (expr == "" && compOp == '@') {
356
result.push_back(AC);
357
} else if (myCurrentEditedProperties->getAttributeProperties()->isNumerical()) {
358
double acVal;
359
std::istringstream buf(AC->getAttribute(myCurrentEditedProperties->getAttributeProperties()->getAttr()));
360
buf >> acVal;
361
switch (compOp) {
362
case '<':
363
if (acVal < val) {
364
result.push_back(AC);
365
}
366
break;
367
case '>':
368
if (acVal > val) {
369
result.push_back(AC);
370
}
371
break;
372
case '=':
373
if (acVal == val) {
374
result.push_back(AC);
375
}
376
break;
377
}
378
} else {
379
// string match
380
std::string acVal = AC->getAttributeForSelection(myCurrentEditedProperties->getAttributeProperties()->getAttr());
381
switch (compOp) {
382
case '@':
383
if (acVal.find(expr) != std::string::npos) {
384
result.push_back(AC);
385
}
386
break;
387
case '!':
388
if (acVal.find(expr) == std::string::npos) {
389
result.push_back(AC);
390
}
391
break;
392
case '=':
393
if (acVal == expr) {
394
result.push_back(AC);
395
}
396
break;
397
case '^':
398
if (acVal != expr) {
399
result.push_back(AC);
400
}
401
break;
402
}
403
}
404
}
405
}
406
return result;
407
}
408
409
410
std::vector<GNEAttributeCarrier*>
411
GNEMatchAttribute::getGenericMatches(const std::vector<GNEGenericData*>& genericDatas, const std::string& attr, const char compOp, const double val, const std::string& expr) {
412
std::vector<GNEAttributeCarrier*> result;
413
// iterate over generic datas
414
for (const auto& genericData : genericDatas) {
415
if (expr == "" && compOp == '@') {
416
result.push_back(genericData);
417
} else if (attr != toString(GNE_ATTR_PARENT)) {
418
double acVal;
419
std::istringstream buf(genericData->getParameter(attr, "0"));
420
buf >> acVal;
421
switch (compOp) {
422
case '<':
423
if (acVal < val) {
424
result.push_back(genericData);
425
}
426
break;
427
case '>':
428
if (acVal > val) {
429
result.push_back(genericData);
430
}
431
break;
432
case '=':
433
if (acVal == val) {
434
result.push_back(genericData);
435
}
436
break;
437
}
438
} else {
439
// string match
440
std::string acVal = genericData->getAttributeForSelection(GNE_ATTR_PARENT);
441
switch (compOp) {
442
case '@':
443
if (acVal.find(expr) != std::string::npos) {
444
result.push_back(genericData);
445
}
446
break;
447
case '!':
448
if (acVal.find(expr) == std::string::npos) {
449
result.push_back(genericData);
450
}
451
break;
452
case '=':
453
if (acVal == expr) {
454
result.push_back(genericData);
455
}
456
break;
457
case '^':
458
if (acVal != expr) {
459
result.push_back(genericData);
460
}
461
break;
462
}
463
}
464
}
465
return result;
466
}
467
468
// ---------------------------------------------------------------------1------
469
// GNEMatchAttribute::CurrentEditedProperties - methods
470
// ---------------------------------------------------------------------------
471
472
GNEMatchAttribute::CurrentEditedProperties::CurrentEditedProperties(const GNEMatchAttribute* matchAttributeParent) :
473
myMatchAttributeParent(matchAttributeParent) {
474
// build special attributes
475
myTagPropertiesAllAttributes = new GNETagProperties(GNE_TAG_ATTRIBUTES_ALL,
476
nullptr,
477
GUIIcon::EMPTY,
478
TL("Show all attributes"),
479
FXRGBA(255, 255, 255, 255),
480
TL("<all>"));
481
myAttributePropertiesNoCommon = new GNEAttributeProperties(myTagPropertiesAllAttributes,
482
GNE_ATTR_NOCOMMON,
483
TL("No common attributes defined"));
484
// set default tag and attribute for every property
485
const auto database = myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getNet()->getTagPropertiesDatabase();
486
setTagProperties(database->getTagProperty(SUMO_TAG_EDGE, true));
487
setAttributeProperties(myNetworkTagProperties.back()->getAttributeProperties(SUMO_ATTR_SPEED));
488
myNetworkMatchValue = ">10";
489
setTagProperties(database->getTagProperty(SUMO_TAG_VEHICLE, true));
490
setAttributeProperties(myDemandTagProperties.back()->getAttributeProperties(SUMO_ATTR_ID));
491
setTagProperties(database->getTagProperty(GNE_TAG_DATAS, true));
492
}
493
494
495
GNEMatchAttribute::CurrentEditedProperties::~CurrentEditedProperties() {
496
delete myTagPropertiesAllAttributes;
497
}
498
499
500
const GNETagProperties*
501
GNEMatchAttribute::CurrentEditedProperties::getTagPropertiesAll() const {
502
return myTagPropertiesAllAttributes;
503
}
504
505
506
const GNEAttributeProperties*
507
GNEMatchAttribute::CurrentEditedProperties::getAttributePropertiesNoCommon() const {
508
return myAttributePropertiesNoCommon;
509
}
510
511
512
const GNETagProperties*
513
GNEMatchAttribute::CurrentEditedProperties::getTagProperties() const {
514
if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
515
return myNetworkTagProperties.back();
516
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
517
return myDemandTagProperties.back();
518
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData()) {
519
return myDataTagProperties.back();
520
} else {
521
throw ProcessError("Invalid supermode");
522
}
523
}
524
525
526
const GNEAttributeProperties*
527
GNEMatchAttribute::CurrentEditedProperties::getAttributeProperties() const {
528
if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
529
return myNetworkAttributeProperties;
530
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
531
return myDemandAttributeProperties;
532
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData()) {
533
return myDataAttributeProperties;
534
} else {
535
throw ProcessError("Invalid supermode");
536
}
537
}
538
539
540
const std::string&
541
GNEMatchAttribute::CurrentEditedProperties::getMatchValue() const {
542
if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
543
return myNetworkMatchValue;
544
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
545
return myDemandMatchValue;
546
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData()) {
547
return myDataMatchValue;
548
} else {
549
throw ProcessError("Invalid supermode");
550
}
551
}
552
553
554
void
555
GNEMatchAttribute::CurrentEditedProperties::setTagProperties(const GNETagProperties* tagProperty) {
556
if (tagProperty->getSupermode() == Supermode::NETWORK) {
557
myNetworkTagProperties = tagProperty->getHierarchicalParentsRecuersively();
558
} else if (tagProperty->getSupermode() == Supermode::DEMAND) {
559
myDemandTagProperties = tagProperty->getHierarchicalParentsRecuersively();
560
} else if (tagProperty->getSupermode() == Supermode::DATA) {
561
myDataTagProperties = tagProperty->getHierarchicalParentsRecuersively();
562
}
563
}
564
565
566
void
567
GNEMatchAttribute::CurrentEditedProperties::setAttributeProperties(const GNEAttributeProperties* attrProperty) {
568
if (attrProperty->getTagPropertyParent()->getSupermode() == Supermode::NETWORK) {
569
myNetworkAttributeProperties = attrProperty;
570
} else if (attrProperty->getTagPropertyParent()->getSupermode() == Supermode::DEMAND) {
571
myDemandAttributeProperties = attrProperty;
572
} else if (attrProperty->getTagPropertyParent()->getSupermode() == Supermode::DATA) {
573
myDataAttributeProperties = attrProperty;
574
}
575
}
576
577
578
void
579
GNEMatchAttribute::CurrentEditedProperties::setMatchValue(const std::string value) {
580
if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
581
myNetworkMatchValue = value;
582
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
583
myDemandMatchValue = value;
584
} else if (myMatchAttributeParent->mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData()) {
585
myDataMatchValue = value;
586
}
587
}
588
589
/****************************************************************************/
590
591