Eclipse SUMO - Simulation of Urban MObility
GNEFrameAttributeModules.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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/****************************************************************************/
18// Auxiliary class for GNEFrame Modules (only for attributes edition)
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
33
35#include "GNEFlowEditor.h"
36
37
38// ===========================================================================
39// FOX callback mapping
40// ===========================================================================
41
47};
48
51};
52
55};
56
60};
61
62// Object implementation
63FXIMPLEMENT(GNEFrameAttributeModules::AttributesEditorRow, FXHorizontalFrame, AttributesEditorRowMap, ARRAYNUMBER(AttributesEditorRowMap))
64FXIMPLEMENT(GNEFrameAttributeModules::AttributesEditor, MFXGroupBoxModule, AttributesEditorMap, ARRAYNUMBER(AttributesEditorMap))
65FXIMPLEMENT(GNEFrameAttributeModules::AttributesEditorExtended, MFXGroupBoxModule, AttributesEditorExtendedMap, ARRAYNUMBER(AttributesEditorExtendedMap))
66FXIMPLEMENT(GNEFrameAttributeModules::GenericDataAttributes, MFXGroupBoxModule, GenericDataAttributesMap, ARRAYNUMBER(GenericDataAttributesMap))
67
68
69// ===========================================================================
70// method definitions
71// ===========================================================================
72
73// ---------------------------------------------------------------------------
74// GNEFrameAttributeModules::AttributesEditorRow - methods
75// ---------------------------------------------------------------------------
76
78 const std::string& value, const bool attributeEnabled, const bool computed, GNEAttributeCarrier* ACParent) :
79 FXHorizontalFrame(attributeEditorParent->getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame),
80 myAttributesEditorParent(attributeEditorParent),
81 myACAttr(ACAttr),
82 myACParent(ACParent) {
83 // Create and hide label
84 myAttributeLabel = new MFXLabelTooltip(this,
85 attributeEditorParent->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
86 "attributeLabel", nullptr, GUIDesignLabelAttribute);
87 myAttributeLabel->hide();
88 // Create and hide check button
89 myAttributeCheckButton = new FXCheckButton(this, TL("attributeCheckButton"), this, MID_GNE_SET_ATTRIBUTE_BOOL, GUIDesignCheckButtonAttribute);
90 myAttributeCheckButton->hide();
91 // Create and hide ButtonCombinableChoices
92 myAttributeButtonCombinableChoices = new MFXButtonTooltip(this,
93 attributeEditorParent->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
94 "attributeButtonCombinableChoices", nullptr, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonAttribute);
95 myAttributeButtonCombinableChoices->hide();
96 // create and hide color editor
97 myAttributeColorButton = new MFXButtonTooltip(this,
98 attributeEditorParent->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
99 "attributeColorButton", nullptr, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonAttribute);
100 myAttributeColorButton->hide();
101 // create and hide color editor
102 myAttributeVTypeButton = new MFXButtonTooltip(this,
103 attributeEditorParent->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
104 "attributeVTypeButton", myACParent ? myACParent->getACIcon() : nullptr, this, MID_GNE_SET_ATTRIBUTE_VTYPE, GUIDesignButtonAttribute);
105 myAttributeVTypeButton->hide();
106 // Create and hide MFXTextFieldTooltip for string attributes
107 myValueTextField = new MFXTextFieldTooltip(this,
108 attributeEditorParent->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
110 myValueTextField->hide();
111 // Create and hide ComboBox
112 myValueComboBoxChoices = new MFXIconComboBox(this, GUIDesignComboBoxNCol, (ACAttr.getAttr() == SUMO_ATTR_VCLASS), this, MID_GNE_SET_ATTRIBUTE, GUIDesignComboBoxAttribute);
113 myValueComboBoxChoices->hide();
114 // Create and hide checkButton
115 myValueCheckButton = new FXCheckButton(this, "", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
116 myValueCheckButton->hide();
117 // only create if parent was created
118 if (getParent()->id()) {
119 // create AttributesEditorRow
120 FXHorizontalFrame::create();
121 // start enabling all elements, depending if attribute is enabled
122 if (attributeEnabled == false) {
123 myValueTextField->disable();
124 myValueComboBoxChoices->disable();
125 myValueCheckButton->disable();
126 } else {
127 myValueTextField->enable();
128 myValueComboBoxChoices->enable();
129 myValueCheckButton->enable();
130 }
131 // if Tag correspond to an network element but we're in demand mode (or vice versa), disable all elements
132 if (myACAttr.getAttr() != SUMO_ATTR_NOTHING) {
133 if (isSupermodeValid(myAttributesEditorParent->getFrameParent()->getViewNet(), myACAttr)) {
134 myAttributeButtonCombinableChoices->enable();
135 myAttributeColorButton->enable();
136 myAttributeVTypeButton->enable();
137 myAttributeCheckButton->enable();
138 } else {
139 myAttributeColorButton->disable();
140 myAttributeVTypeButton->disable();
141 myAttributeCheckButton->disable();
142 myValueTextField->disable();
143 myValueComboBoxChoices->disable();
144 myValueCheckButton->disable();
145 myAttributeButtonCombinableChoices->disable();
146 }
147 }
148 // set left column
149 if (myACParent) {
150 // show color button and set color text depending of computed
151 if (computed) {
152 myAttributeVTypeButton->setTextColor(FXRGB(0, 0, 255));
153 } else {
154 myAttributeVTypeButton->setTextColor(FXRGB(0, 0, 0));
155 myAttributeVTypeButton->killFocus();
156 }
157 myAttributeVTypeButton->setText(myACAttr.getAttrStr().c_str());
158 myAttributeVTypeButton->setTipText(("Inspect vehicle " + myACAttr.getAttrStr() + " parent").c_str());
159 myAttributeVTypeButton->setHelpText(("Inspect vehicle " + myACAttr.getAttrStr() + " parent").c_str());
160 myAttributeVTypeButton->show();
161 } else if (myACAttr.isColor()) {
162 // show color button and set color text depending of computed
163 if (computed) {
164 myAttributeColorButton->setTextColor(FXRGB(0, 0, 255));
165 } else {
166 myAttributeColorButton->setTextColor(FXRGB(0, 0, 0));
167 myAttributeColorButton->killFocus();
168 }
169 myAttributeColorButton->setText(myACAttr.getAttrStr().c_str());
170 myAttributeColorButton->setTipText("Open dialog for editing color");
171 myAttributeColorButton->setHelpText("Open dialog for editing color");
172 myAttributeColorButton->show();
173 } else if ((myACAttr.getAttr() == SUMO_ATTR_ALLOW) || (myACAttr.getAttr() == SUMO_ATTR_DISALLOW)) {
174 myAttributeButtonCombinableChoices->setText(myACAttr.getAttrStr().c_str());
175 myAttributeButtonCombinableChoices->setTipText("Open dialog for editing vClasses");
176 myAttributeButtonCombinableChoices->setHelpText("Open dialog for editing vClasses");
177 myAttributeButtonCombinableChoices->show();
178 } else if (myACAttr.isActivatable()) {
179 // show checkbox button and set color text depending of computed
180 if (computed) {
181 myAttributeCheckButton->setTextColor(FXRGB(0, 0, 255));
182 } else {
183 myAttributeCheckButton->setTextColor(FXRGB(0, 0, 0));
184 myAttributeCheckButton->killFocus();
185 }
186 myAttributeCheckButton->setText(myACAttr.getAttrStr().c_str());
187 myAttributeCheckButton->show();
188 // check or uncheck depending of attributeEnabled
189 if (attributeEnabled) {
190 myAttributeCheckButton->setCheck(TRUE);
191 } else {
192 myAttributeCheckButton->setCheck(FALSE);
193 }
194 } else {
195 // Show attribute Label
196 myAttributeLabel->setText(myACAttr.getAttrStr().c_str());
197 myAttributeLabel->setTipText(myACAttr.getDefinition().c_str());
198 myAttributeLabel->show();
199 }
200 // Set field depending of the type of value
201 if (myACAttr.isBool()) {
202 // first we need to check if all boolean values are equal
203 bool allBooleanValuesEqual = true;
204 // declare boolean vector
205 std::vector<bool> booleanVector;
206 // check if value can be parsed to a boolean vector
207 if (GNEAttributeCarrier::canParse<std::vector<bool> >(value)) {
208 booleanVector = GNEAttributeCarrier::parse<std::vector<bool> >(value);
209 }
210 // iterate over passed booleans comparing all element with the first
211 for (const auto& booleanValue : booleanVector) {
212 if (booleanValue != booleanVector.front()) {
213 allBooleanValuesEqual = false;
214 }
215 }
216 // use checkbox or textfield depending if all booleans are equal
217 if (allBooleanValuesEqual) {
218 // set check button
219 if ((booleanVector.size() > 0) && booleanVector.front()) {
220 myValueCheckButton->setCheck(true);
221 myValueCheckButton->setText(TL("true"));
222 } else {
223 myValueCheckButton->setCheck(false);
224 myValueCheckButton->setText(TL("false"));
225 }
226 // show check button
227 myValueCheckButton->show();
228 } else {
229 // show list of bools (0 1)
230 myValueTextField->setText(value.c_str());
231 // set text depending of computed
232 if (computed) {
233 myValueTextField->setTextColor(FXRGB(0, 0, 255));
234 } else {
235 myValueTextField->setTextColor(FXRGB(0, 0, 0));
236 myValueTextField->killFocus();
237 }
238 myValueTextField->show();
239 }
240 } else if (myACAttr.isDiscrete()) {
241 // Check if are VClasses
242 if ((myACAttr.getDiscreteValues().size() > 0) && myACAttr.isVClasses()) {
243 // hide label
244 myAttributeLabel->hide();
245 // Show button combinable choices
246 myAttributeButtonCombinableChoices->setText(myACAttr.getAttrStr().c_str());
247 myAttributeButtonCombinableChoices->setTipText("Open dialog for editing vClasses");
248 myAttributeButtonCombinableChoices->setHelpText("Open dialog for editing vClasses");
249 myAttributeButtonCombinableChoices->show();
250 // Show string with the values
251 myValueTextField->setText(value.c_str());
252 // set color depending of computed
253 if (computed) {
254 myValueTextField->setTextColor(FXRGB(0, 0, 255));
255 } else {
256 myValueTextField->setTextColor(FXRGB(0, 0, 0));
257 myValueTextField->killFocus();
258 }
259 myValueTextField->show();
260 } else {
261 // fill comboBox
262 myValueComboBoxChoices->clearItems();
263 // special case for VClass
264 if (ACAttr.getAttr() == SUMO_ATTR_VCLASS) {
265 // add all vClasses with their icons
266 for (const auto& vClassStr : SumoVehicleClassStrings.getStrings()) {
267 myValueComboBoxChoices->appendIconItem(vClassStr.c_str(), GNEAttributeCarrier::getVClassIcon(getVehicleClassID(vClassStr)));
268 }
269 } else {
270 for (const auto& discreteValue : myACAttr.getDiscreteValues()) {
271 myValueComboBoxChoices->appendIconItem(discreteValue.c_str());
272 }
273 }
274 // show combo box with values
275 myValueComboBoxChoices->setNumVisible(myValueComboBoxChoices->getNumItems() < 10 ? myValueComboBoxChoices->getNumItems() : 10);
276 const int itemIndex = myValueComboBoxChoices->findItem(value.c_str());
277 if (itemIndex == -1) {
278 myValueComboBoxChoices->setText(value.c_str());
279 } else {
280 myValueComboBoxChoices->setCurrentItem(itemIndex);
281 }
282 // set color depending of computed
283 if (computed) {
284 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 255));
285 } else {
286 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 0));
287 myValueComboBoxChoices->killFocus();
288 }
289 myValueComboBoxChoices->show();
290 }
291 } else {
292 // In any other case (String, list, etc.), show value as String
293 myValueTextField->setText(value.c_str());
294 // set color depending of computed
295 if (computed) {
296 myValueTextField->setTextColor(FXRGB(0, 0, 255));
297 } else {
298 myValueTextField->setTextColor(FXRGB(0, 0, 0));
299 myValueTextField->killFocus();
300 }
301 myValueTextField->show();
302 }
303 // Show AttributesEditorRow
304 show();
305 }
306}
307
308
309void
311 // only destroy if parent was created
312 if (getParent()->id()) {
313 FXHorizontalFrame::destroy();
314 }
315}
316
317
318void
320 const bool forceRefresh, const bool attributeEnabled, const bool computed, GNEAttributeCarrier* ACParent) {
321 if (ACParent) {
322 myACParent = ACParent;
323 }
324 // start enabling all elements, depending if attribute is enabled
325 if (attributeEnabled == false) {
326 myValueTextField->disable();
327 myValueComboBoxChoices->disable();
328 myValueCheckButton->disable();
329 } else {
330 myValueTextField->enable();
331 myValueComboBoxChoices->enable();
332 myValueCheckButton->enable();
333 }
334 // if Tag correspond to an network element but we're in demand mode (or vice versa), disable all elements
335 if (myACAttr.getAttr() != SUMO_ATTR_NOTHING) {
336 if (isSupermodeValid(myAttributesEditorParent->getFrameParent()->getViewNet(), myACAttr)) {
337 myAttributeButtonCombinableChoices->enable();
338 myAttributeColorButton->enable();
339 myAttributeCheckButton->enable();
340 } else {
341 myAttributeColorButton->disable();
342 myAttributeCheckButton->disable();
343 myValueTextField->disable();
344 myValueComboBoxChoices->disable();
345 myValueCheckButton->disable();
346 myAttributeButtonCombinableChoices->disable();
347 }
348 }
349 // set check button
350 if (myAttributeCheckButton->shown()) {
351 myAttributeCheckButton->setCheck(attributeEnabled);
352 }
353 if (myValueTextField->shown()) {
354 // set last valid value and restore color if onlyValid is disabled
355 if (myValueTextField->getTextColor() == FXRGB(0, 0, 0) || myValueTextField->getTextColor() == FXRGB(0, 0, 255) || forceRefresh) {
356 myValueTextField->setText(value.c_str());
357 // set blue color if is an computed value
358 if (computed) {
359 myValueTextField->setTextColor(FXRGB(0, 0, 255));
360 } else {
361 myValueTextField->setTextColor(FXRGB(0, 0, 0));
362 myValueTextField->killFocus();
363 }
364 }
365 } else if (myValueComboBoxChoices->shown()) {
366 // fill comboBox
367 myValueComboBoxChoices->clearItems();
368 // special case for VClass
369 if (myACAttr.getAttr() == SUMO_ATTR_VCLASS) {
370 // add all vClasses with their icons
371 for (const auto& vClassStr : SumoVehicleClassStrings.getStrings()) {
372 myValueComboBoxChoices->appendIconItem(vClassStr.c_str(), GNEAttributeCarrier::getVClassIcon(getVehicleClassID(vClassStr)));
373 }
374 } else {
375 for (const auto& discreteValue : myACAttr.getDiscreteValues()) {
376 myValueComboBoxChoices->appendIconItem(discreteValue.c_str());
377 }
378 }
379 // show combo box with values
380 myValueComboBoxChoices->setNumVisible(myValueComboBoxChoices->getNumItems() < 10 ? myValueComboBoxChoices->getNumItems() : 10);
381 myValueComboBoxChoices->setCurrentItem(myValueComboBoxChoices->findItem(value.c_str()));
382 // set blue color if is an computed value
383 if (computed) {
384 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 255));
385 } else {
386 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 0));
387 myValueComboBoxChoices->killFocus();
388 }
389 myValueComboBoxChoices->show();
390 } else if (myValueCheckButton->shown()) {
391 if (GNEAttributeCarrier::canParse<bool>(value)) {
392 myValueCheckButton->setCheck(GNEAttributeCarrier::parse<bool>(value));
393 } else {
394 myValueCheckButton->setCheck(false);
395 }
396 }
397}
398
399
400bool
402 return ((myValueTextField->getTextColor() == FXRGB(0, 0, 0)) || (myValueTextField->getTextColor() == FXRGB(0, 0, 255))) &&
403 ((myValueComboBoxChoices->getTextColor() == FXRGB(0, 0, 0)) || (myValueComboBoxChoices->getTextColor() == FXRGB(0, 0, 255)));
404}
405
406
407long
409 const auto& ACs = myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers();
410 if (obj == myAttributeColorButton) {
411 // create FXColorDialog
412 FXColorDialog colordialog(this, tr("Color Dialog"));
413 colordialog.setTarget(this);
414 // If previous attribute wasn't correct, set black as default color
415 if (GNEAttributeCarrier::canParse<RGBColor>(myValueTextField->getText().text())) {
416 colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(myValueTextField->getText().text())));
417 } else if (!myACAttr.getDefaultValue().empty()) {
418 colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(myACAttr.getDefaultValue())));
419 } else {
420 colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::BLACK));
421 }
422 // execute dialog to get a new color
423 if (colordialog.execute()) {
424 std::string newValue = toString(MFXUtils::getRGBColor(colordialog.getRGBA()));
425 myValueTextField->setText(newValue.c_str());
426 if (myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers().front()->isValid(myACAttr.getAttr(), newValue)) {
427 // if its valid for the first AC than its valid for all (of the same type)
428 if (ACs.size() > 1) {
429 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->begin(ACs.front()->getTagProperty().getGUIIcon(), "Change multiple attributes");
430 }
431 // Set new value of attribute in all selected ACs
432 for (const auto& inspectedAC : myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers()) {
433 inspectedAC->setAttribute(myACAttr.getAttr(), newValue, myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList());
434 }
435 // finish change multiple attributes
436 if (ACs.size() > 1) {
437 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->end();
438 }
439 // If previously value was incorrect, change font color to black
440 myValueTextField->setTextColor(FXRGB(0, 0, 0));
441 myValueTextField->killFocus();
442 }
443 }
444 return 0;
445 } else if (obj == myAttributeButtonCombinableChoices) {
446 // if its valid for the first AC than its valid for all (of the same type)
447 if (ACs.size() > 1) {
448 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->begin(ACs.front()->getTagProperty().getGUIIcon(), "Change multiple attributes");
449 }
450 // get attribute to modify
451 SumoXMLAttr modifiedAttr = (myACAttr.getAttr() == SUMO_ATTR_DISALLOW) ? SUMO_ATTR_ALLOW : myACAttr.getAttr();
452 // declare accept changes
453 bool acceptChanges = false;
454 // open GNEAllowVClassesDialog (also used to modify SUMO_ATTR_CHANGE_LEFT etc
455 GNEAllowVClassesDialog(myAttributesEditorParent->getFrameParent()->getViewNet(), myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers().front(), modifiedAttr, &acceptChanges).execute();
456 // continue depending of acceptChanges
457 if (acceptChanges) {
458 std::string allowed = myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers().front()->getAttribute(modifiedAttr);
459 // Set new value of attribute in all selected ACs
460 for (const auto& inspectedAC : myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers()) {
461 inspectedAC->setAttribute(modifiedAttr, allowed, myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList());
462 }
463 // finish change multiple attributes
464 if (ACs.size() > 1) {
465 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->end();
466 }
467 // update frame parent after attribute successfully set
468 myAttributesEditorParent->getFrameParent()->attributeUpdated();
469 }
470 return 1;
471 } else {
472 throw ProcessError("Invalid call to onCmdOpenAttributeDialog");
473 }
474}
475
476
477long
479 auto viewnet = myAttributesEditorParent->getFrameParent()->getViewNet();
480 viewnet->getViewParent()->getInspectorFrame()->inspectChild(myACParent, viewnet->getInspectedAttributeCarriers().front());
481 return 1;
482}
483
484
485long
487 // Declare changed value
488 std::string newVal;
489 // First, obtain the string value of the new attribute depending of their type
490 if (myACAttr.isBool()) {
491 // first check if we're editing boolean as a list of string or as a checkbox
492 if (myValueCheckButton->shown()) {
493 // Set true o false depending of the checkBox
494 if (myValueCheckButton->getCheck()) {
495 myValueCheckButton->setText(TL("true"));
496 newVal = "true";
497 } else {
498 myValueCheckButton->setText(TL("false"));
499 newVal = "false";
500 }
501 } else {
502 // obtain boolean value of myValueTextField (because we're inspecting multiple attribute carriers with different values)
503 newVal = myValueTextField->getText().text();
504 }
505 } else if (myACAttr.isDiscrete()) {
506 // Check if are VClasses
507 if ((myACAttr.getDiscreteValues().size() > 0) && myACAttr.isVClasses()) {
508 // Get value obtained using AttributesEditor
509 newVal = myValueTextField->getText().text();
510 } else {
511 // Get value of ComboBox
512 newVal = myValueComboBoxChoices->getText().text();
513 }
514 } else {
515 // Check if default value of attribute must be set
516 if (myValueTextField->getText().empty() && myACAttr.hasDefaultValue()) {
517 newVal = myACAttr.getDefaultValue();
518 myValueTextField->setText(newVal.c_str());
519 } else if (myACAttr.isInt() && GNEAttributeCarrier::canParse<double>(myValueTextField->getText().text())) {
520 // filter int attributes
521 double doubleValue = GNEAttributeCarrier::parse<double>(myValueTextField->getText().text());
522 // check if myValueTextField has to be updated
523 if ((doubleValue - (int)doubleValue) == 0) {
524 newVal = toString((int)doubleValue);
525 myValueTextField->setText(newVal.c_str(), FALSE);
526 }
527 } else if ((myACAttr.getAttr() == SUMO_ATTR_ANGLE) && GNEAttributeCarrier::canParse<double>(myValueTextField->getText().text())) {
528 // filter angle
529 double angle = GNEAttributeCarrier::parse<double>(myValueTextField->getText().text());
530 // filter if angle isn't between [0,360]
531 if ((angle < 0) || (angle > 360)) {
532 // apply module
533 angle = fmod(angle, 360);
534 }
535 // set newVal
536 newVal = toString(angle);
537 // update Textfield
538 myValueTextField->setText(newVal.c_str(), FALSE);
539 } else {
540 // obtain value of myValueTextField
541 newVal = myValueTextField->getText().text();
542 }
543 }
544 // we need a extra check for Position and Shape Values, due #2658
545 if ((myACAttr.getAttr() == SUMO_ATTR_POSITION) || (myACAttr.getAttr() == SUMO_ATTR_SHAPE)) {
546 newVal = stripWhitespaceAfterComma(newVal);
547 }
548 // get inspected ACs (for code cleaning)
549 const auto& inspectedACs = myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers();
550 // check if use default value
551 const bool useDefaultValue = (newVal.empty() && myACAttr.hasDefaultValue());
552 // Check if attribute must be changed
553 if ((inspectedACs.size() > 0) && (inspectedACs.front()->isValid(myACAttr.getAttr(), newVal) || useDefaultValue)) {
554 // check if we're merging junction
555 if (!mergeJunction(myACAttr.getAttr(), inspectedACs, newVal)) {
556 // if its valid for the first AC than its valid for all (of the same type)
557 if (inspectedACs.size() > 1) {
558 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->begin(inspectedACs.front()->getTagProperty().getGUIIcon(), "Change multiple attributes");
559 } else if (myACAttr.getAttr() == SUMO_ATTR_ID) {
560 // IDs attribute has to be encapsulated
561 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->begin(inspectedACs.front()->getTagProperty().getGUIIcon(), "change " + myACAttr.getTagPropertyParent().getTagStr() + " attribute");
562 }
563 // Set new value of attribute in all selected ACs
564 for (const auto& inspectedAC : inspectedACs) {
565 if (useDefaultValue) {
566 inspectedAC->setAttribute(myACAttr.getAttr(), myACAttr.getDefaultValue(), myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList());
567 } else {
568 inspectedAC->setAttribute(myACAttr.getAttr(), newVal, myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList());
569 }
570 }
571 // finish change multiple attributes or ID Attributes
572 if (inspectedACs.size() > 1) {
573 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->end();
574 } else if (myACAttr.getAttr() == SUMO_ATTR_ID) {
575 myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList()->end();
576 }
577 // If previously value was incorrect, change font color to black
578 if (myACAttr.isVClasses()) {
579 myValueTextField->setTextColor(FXRGB(0, 0, 0));
580 myValueTextField->setBackColor(FXRGB(255, 255, 255));
581 myValueTextField->killFocus();
582 // in this case, we need to refresh the other values (For example, allow/Disallow objects)
583 myAttributesEditorParent->refreshAttributeEditor(false, false);
584 } else if (myACAttr.isDiscrete()) {
585 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 0));
586 myValueComboBoxChoices->setBackColor(FXRGB(255, 255, 255));
587 myValueComboBoxChoices->killFocus();
588 } else if (myValueTextField != nullptr) {
589 myValueTextField->setTextColor(FXRGB(0, 0, 0));
590 myValueTextField->setBackColor(FXRGB(255, 255, 255));
591 myValueTextField->killFocus();
592 }
593 // update frame parent after attribute successfully set
594 myAttributesEditorParent->getFrameParent()->attributeUpdated();
595 }
596 } else {
597 // If value of TextField isn't valid, change color to Red depending of type
598 if (myACAttr.isVClasses()) {
599 myValueTextField->setTextColor(FXRGB(255, 0, 0));
600 if (newVal.empty()) {
601 myValueTextField->setBackColor(FXRGBA(255, 213, 213, 255));
602 }
603 } else if (myACAttr.isDiscrete()) {
604 myValueComboBoxChoices->setTextColor(FXRGB(255, 0, 0));
605 if (newVal.empty()) {
606 myValueComboBoxChoices->setBackColor(FXRGBA(255, 213, 213, 255));
607 }
608 } else if (myValueTextField != nullptr) {
609 myValueTextField->setTextColor(FXRGB(255, 0, 0));
610 if (newVal.empty()) {
611 myValueTextField->setBackColor(FXRGBA(255, 213, 213, 255));
612 }
613 }
614 // Write Warning in console if we're in testing mode
615 WRITE_DEBUG("Value '" + newVal + "' for attribute " + myACAttr.getAttrStr() + " of " + myACAttr.getTagPropertyParent().getTagStr() + " isn't valid");
616 }
617 return 1;
618}
619
620
621long
623 const auto& ACs = myAttributesEditorParent->getFrameParent()->getViewNet()->getInspectedAttributeCarriers();
624 // obtain undoList (To improve code legibly)
625 GNEUndoList* undoList = myAttributesEditorParent->getFrameParent()->getViewNet()->getUndoList();
626 // check if we have to enable or disable
627 if (myAttributeCheckButton->getCheck()) {
628 // enable input values
629 myValueCheckButton->enable();
630 myValueTextField->enable();
631 // enable attribute
632 undoList->begin(ACs.front()->getTagProperty().getGUIIcon(), "enable attribute '" + myACAttr.getAttrStr() + "'");
633 ACs.front()->enableAttribute(myACAttr.getAttr(), undoList);
634 undoList->end();
635 } else {
636 // disable input values
637 myValueCheckButton->disable();
638 myValueTextField->disable();
639 // disable attribute
640 undoList->begin(ACs.front()->getTagProperty().getGUIIcon(), "disable attribute '" + myACAttr.getAttrStr() + "'");
641 ACs.front()->disableAttribute(myACAttr.getAttr(), undoList);
642 undoList->end();
643 }
644 return 0;
645}
646
647
649 myAttributesEditorParent(nullptr) {
650}
651
652
653std::string
655 std::string result(stringValue);
656 while (result.find(", ") != std::string::npos) {
657 result = StringUtils::replace(result, ", ", ",");
658 }
659 return result;
660}
661
662
663bool
664GNEFrameAttributeModules::AttributesEditorRow::mergeJunction(SumoXMLAttr attr, const std::vector<GNEAttributeCarrier*>& inspectedACs, const std::string& newVal) const {
665 // check if we're editing junction position
666 if ((inspectedACs.size() == 1) && (inspectedACs.front()->getTagProperty().getTag() == SUMO_TAG_JUNCTION) && (attr == SUMO_ATTR_POSITION)) {
667 // retrieve original junction
668 GNEJunction* movedJunction = myAttributesEditorParent->getFrameParent()->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(inspectedACs.front()->getID());
669 // parse position
670 const Position newPosition = GNEAttributeCarrier::parse<Position>(newVal);
671 // iterate over network junction
672 for (const auto& junction : myAttributesEditorParent->getFrameParent()->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
673 // check distance position
674 if ((junction.second->getPositionInView().distanceTo2D(newPosition) < POSITION_EPS) &&
675 myAttributesEditorParent->getFrameParent()->getViewNet()->mergeJunctions(movedJunction, junction.second)) {
676 return true;
677 }
678 }
679 }
680 // nothing to merge
681 return false;
682}
683
684// ---------------------------------------------------------------------------
685// GNEFrameAttributeModules::AttributesEditor - methods
686// ---------------------------------------------------------------------------
687
689 MFXGroupBoxModule(frameParent, TL("Internal attributes")),
690 myFrameParent(frameParent),
691 myIncludeExtended(true) {
692 // resize myAttributesEditorRows
694 // create myAttributesFlowEditor
695 myAttributesEditorFlow = new GNEFlowEditor(frameParent->getViewNet(), frameParent);
696 // leave it hidden
698 // Create help button
699 myHelpButton = new FXButton(getCollapsableFrame(), TL("Help"), nullptr, this, MID_HELP, GUIDesignButtonRectangular);
700}
701
702
703void
704GNEFrameAttributeModules::AttributesEditor::showAttributeEditorModule(bool includeExtended, bool forceAttributeEnabled) {
705 myIncludeExtended = includeExtended;
706 // first remove all rows
707 for (auto& row : myAttributesEditorRows) {
708 // destroy and delete all rows
709 if (row != nullptr) {
710 row->destroy();
711 delete row;
712 row = nullptr;
713 }
714 }
715 // get inspected ACs
716 const auto& ACs = myFrameParent->getViewNet()->getInspectedAttributeCarriers();
717 // declare flag to check if flow editor has to be shown
718 bool showFlowEditor = false;
719 if (ACs.size() > 0) {
720 // Iterate over attributes
721 for (const auto& attrProperty : ACs.front()->getTagProperty()) {
722 // declare flag to show/hide attribute
723 bool editAttribute = true;
724 // disable editing for unique attributes in case of multi-selection
725 if ((ACs.size() > 1) && attrProperty.isUnique()) {
726 editAttribute = false;
727 }
728 // disable editing of extended attributes if includeExtended isn't enabled
729 if (attrProperty.isExtended() && !includeExtended) {
730 editAttribute = false;
731 }
732 // disable editing of flow definition attributes, but enable flow editor
733 if (attrProperty.isFlowDefinition()) {
734 editAttribute = false;
735 showFlowEditor = true;
736 }
737 // continue if attribute is editable
738 if (editAttribute) {
739 // Declare a set of occurring values and insert attribute's values of item (note: We use a set to avoid repeated values)
740 std::set<std::string> occurringValues;
741 // iterate over edited attributes
742 for (const auto& inspectedAC : ACs) {
743 occurringValues.insert(inspectedAC->getAttribute(attrProperty.getAttr()));
744 }
745 // get current value
746 std::ostringstream oss;
747 for (auto values = occurringValues.begin(); values != occurringValues.end(); values++) {
748 if (values != occurringValues.begin()) {
749 oss << " ";
750 }
751 oss << *values;
752 }
753 // obtain value to be shown in row
754 std::string value = oss.str();
755 // declare a flag for enabled attributes
756 bool attributeEnabled = ACs.front()->isAttributeEnabled(attrProperty.getAttr());
757 // overwrite value if attribute is disabled (used by LinkIndex)
758 if (attributeEnabled == false) {
759 value = ACs.front()->getAlternativeValueForDisabledAttributes(attrProperty.getAttr());
760 }
761 // extra check for Triggered and container Triggered
762 if (ACs.front()->getTagProperty().isStop() || ACs.front()->getTagProperty().isStopPerson()) {
763 if ((attrProperty.getAttr() == SUMO_ATTR_EXPECTED) && (ACs.front()->isAttributeEnabled(SUMO_ATTR_TRIGGERED) == false)) {
764 attributeEnabled = false;
765 } else if ((attrProperty.getAttr() == SUMO_ATTR_EXPECTED_CONTAINERS) && (ACs.front()->isAttributeEnabled(SUMO_ATTR_CONTAINER_TRIGGERED) == false)) {
766 attributeEnabled = false;
767 }
768 }
769 // if forceAttributeEnabled is enabled, force attributeEnabled (except for ID)
770 if (forceAttributeEnabled && (attrProperty.getAttr() != SUMO_ATTR_ID)) {
771 attributeEnabled = true;
772 }
773 // check if this attribute is computed
774 const bool computed = (ACs.size() > 1) ? false : ACs.front()->isAttributeComputed(attrProperty.getAttr());
775 // if is a Vtype, obtain icon
776 GNEAttributeCarrier* ACParent = nullptr;
777 if ((ACs.size() == 1) && attrProperty.isVType()) {
778 if (attrProperty.getAttr() == SUMO_ATTR_TYPE) {
779 ACParent = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, ACs.front()->getAttribute(SUMO_ATTR_TYPE));
780 } else if (ACs.front()->getAttribute(GNE_ATTR_VTYPE_DISTRIBUTION).size() > 0) {
781 ACParent = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE_DISTRIBUTION, ACs.front()->getAttribute(GNE_ATTR_VTYPE_DISTRIBUTION));
782 }
783 }
784 // create attribute editor row
785 myAttributesEditorRows[attrProperty.getPositionListed()] = new AttributesEditorRow(this, attrProperty, value, attributeEnabled, computed, ACParent);
786 }
787 }
788 // check if Flow editor has to be shown
789 if (showFlowEditor) {
790 myAttributesEditorFlow->showFlowEditor(ACs);
791 } else {
792 myAttributesEditorFlow->hideFlowEditor();
793 }
794 // show AttributesEditor
795 show();
796 } else {
797 myAttributesEditorFlow->hideFlowEditor();
798 }
799 // reparent help button (to place it at bottom)
800 myHelpButton->reparent(this);
801}
802
803
804void
806 // hide AttributesEditorFlowModule
807 myAttributesEditorFlow->hideFlowEditor();
808 // hide also AttributesEditor
809 hide();
810}
811
812
813void
814GNEFrameAttributeModules::AttributesEditor::refreshAttributeEditor(bool forceRefreshShape, bool forceRefreshPosition) {
815 // get inspected ACs
816 const auto& ACs = myFrameParent->getViewNet()->getInspectedAttributeCarriers();
817 // first check if there is inspected attribute carriers
818 if (ACs.size() > 0) {
819 // Iterate over inspected attribute carriers
820 for (const auto& attrProperty : ACs.front()->getTagProperty()) {
821 // declare flag to show/hide attribute
822 bool editAttribute = true;
823 // disable editing for unique attributes in case of multi-selection
824 if ((ACs.size() > 1) && attrProperty.isUnique()) {
825 editAttribute = false;
826 }
827 // disable editing of extended attributes if includeExtended isn't enabled
828 if (attrProperty.isExtended() && !myIncludeExtended) {
829 editAttribute = false;
830 }
831 // disable editing of flow definition attributes, but enable flow editor
832 if (attrProperty.isFlowDefinition()) {
833 editAttribute = false;
834 }
835 // continue if attribute is editable
836 if (editAttribute) {
837 // Declare a set of occurring values and insert attribute's values of item (note: We use a set to avoid repeated values)
838 std::set<std::string> occurringValues;
839 // iterate over edited attributes
840 for (const auto& inspectedAC : ACs) {
841 occurringValues.insert(inspectedAC->getAttribute(attrProperty.getAttr()));
842 }
843 // get current value
844 std::ostringstream oss;
845 for (auto values = occurringValues.begin(); values != occurringValues.end(); values++) {
846 if (values != occurringValues.begin()) {
847 oss << " ";
848 }
849 oss << *values;
850 }
851 // obtain value to be shown in row
852 std::string value = oss.str();
853 // declare a flag for enabled attributes
854 bool attributeEnabled = ACs.front()->isAttributeEnabled(attrProperty.getAttr());
855 // overwrite value if attribute is disabled (used by LinkIndex)
856 if (attributeEnabled == false) {
857 value = ACs.front()->getAlternativeValueForDisabledAttributes(attrProperty.getAttr());
858 }
859 // extra check for Triggered and container Triggered
860 if (ACs.front()->getTagProperty().isStop() || ACs.front()->getTagProperty().isStopPerson()) {
861 if ((attrProperty.getAttr() == SUMO_ATTR_EXPECTED) && (ACs.front()->isAttributeEnabled(SUMO_ATTR_TRIGGERED) == false)) {
862 attributeEnabled = false;
863 } else if ((attrProperty.getAttr() == SUMO_ATTR_EXPECTED_CONTAINERS) && (ACs.front()->isAttributeEnabled(SUMO_ATTR_CONTAINER_TRIGGERED) == false)) {
864 attributeEnabled = false;
865 }
866 }
867 // check if this attribute is computed
868 const bool computed = (ACs.size() > 1) ? false : ACs.front()->isAttributeComputed(attrProperty.getAttr());
869 // Check if Position or Shape refresh has to be forced
870 if ((attrProperty.getAttr() == SUMO_ATTR_SHAPE) && forceRefreshShape) {
871 myAttributesEditorRows[attrProperty.getPositionListed()]->refreshAttributesEditorRow(value, true, attributeEnabled, computed, nullptr);
872 } else if ((attrProperty.getAttr() == SUMO_ATTR_POSITION) && forceRefreshPosition) {
873 myAttributesEditorRows[attrProperty.getPositionListed()]->refreshAttributesEditorRow(value, true, attributeEnabled, computed, nullptr);
874 } else if (attrProperty.getAttr() == SUMO_ATTR_TYPE && (attrProperty.getTagPropertyParent().isVehicle() || attrProperty.getTagPropertyParent().isPerson() ||
875 attrProperty.getTagPropertyParent().isContainer())) {
876 // update vType parent
877 auto vTypeParent = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, ACs.front()->getAttribute(SUMO_ATTR_TYPE), false);
878 myAttributesEditorRows[attrProperty.getPositionListed()]->refreshAttributesEditorRow(value, false, attributeEnabled, computed, vTypeParent);
879 } else {
880 // Refresh attributes maintain invalid values
881 myAttributesEditorRows[attrProperty.getPositionListed()]->refreshAttributesEditorRow(value, false, attributeEnabled, computed, nullptr);
882 }
883 }
884 }
885 // check if flow editor has to be update
886 if (myAttributesEditorFlow->shownFlowEditor()) {
887 myAttributesEditorFlow->refreshFlowEditor();
888 }
889 }
890}
891
892
895 return myFrameParent;
896}
897
898
899long
901 // open Help attributes dialog if there is inspected ACs
902 if (myFrameParent->getViewNet()->getInspectedAttributeCarriers().size() > 0) {
903 // open Help attributes dialog
904 myFrameParent->openHelpAttributesDialog(myFrameParent->getViewNet()->getInspectedAttributeCarriers().front());
905 }
906 return 1;
907}
908
909// ---------------------------------------------------------------------------
910// GNEFrameAttributeModules::AttributesEditorExtended- methods
911// ---------------------------------------------------------------------------
912
914 MFXGroupBoxModule(frameParent, TL("Extended attributes")),
915 myFrameParent(frameParent) {
916 // Create open dialog button
917 new FXButton(getCollapsableFrame(), TL("Open attributes editor"), nullptr, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButton);
918}
919
920
922
923
924void
926 show();
927}
928
929
930void
932 hide();
933}
934
935
936long
938 // open GNEAttributesCreator extended dialog
939 myFrameParent->attributesEditorExtendedDialogOpened();
940 return 1;
941}
942
943// ---------------------------------------------------------------------------
944// GNEFrameAttributeModules::GenericDataAttributes - methods
945// ---------------------------------------------------------------------------
946
948 MFXGroupBoxModule(frameParent, TL("Attributes")),
949 myFrameParent(frameParent) {
950 // create textfield and buttons
952 myButtonEditParameters = new FXButton(getCollapsableFrame(), TL("Edit attributes"), nullptr, this, MID_GNE_OPEN_PARAMETERS_DIALOG, GUIDesignButton);
953}
954
955
957
958
959void
961 // refresh GenericDataAttributes
962 refreshGenericDataAttributes();
963 // show groupbox
964 show();
965}
966
967
968void
970 // hide groupbox
971 hide();
972}
973
974
975void
977 myTextFieldParameters->setText(getParametersStr().c_str());
978 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
979 myTextFieldParameters->killFocus();
980}
981
982
985 return myParameters;
986}
987
988
989std::string
991 std::string result;
992 // Generate an string using the following structure: "key1=value1|key2=value2|...
993 for (const auto& parameter : myParameters) {
994 result += parameter.first + "=" + parameter.second + "|";
995 }
996 // remove the last "|"
997 if (!result.empty()) {
998 result.pop_back();
999 }
1000 return result;
1001}
1002
1003
1004std::vector<std::pair<std::string, std::string> >
1006 std::vector<std::pair<std::string, std::string> > result;
1007 // Generate a vector string using the following structure: "<key1,value1>, <key2, value2>,...
1008 for (const auto& parameter : myParameters) {
1009 result.push_back(std::make_pair(parameter.first, parameter.second));
1010 }
1011 return result;
1012}
1013
1014
1015void
1016GNEFrameAttributeModules::GenericDataAttributes::setParameters(const std::vector<std::pair<std::string, std::string> >& parameters) {
1017 // declare result string
1018 std::string result;
1019 // Generate an string using the following structure: "key1=value1|key2=value2|...
1020 for (const auto& parameter : parameters) {
1021 result += parameter.first + "=" + parameter.second + "|";
1022 }
1023 // remove the last "|"
1024 if (!result.empty()) {
1025 result.pop_back();
1026 }
1027 // set result in textField (and call onCmdEditParameters)
1028 myTextFieldParameters->setText(result.c_str(), TRUE);
1029}
1030
1031
1032GNEFrame*
1034 return myFrameParent;
1035}
1036
1037
1038bool
1040 if (myTextFieldParameters->getText().empty()) {
1041 return true;
1042 } else if (myTextFieldParameters->getTextColor() == FXRGB(255, 0, 0)) {
1043 return false;
1044 } else {
1045 return Parameterised::areAttributesValid(getParametersStr());
1046 }
1047}
1048
1049
1050long
1052 // write debug information
1053 WRITE_DEBUG("Open single parameters dialog");
1054 if (GNESingleParametersDialog(this).execute()) {
1055 // write debug information
1056 WRITE_DEBUG("Close single parameters dialog");
1057 // Refresh parameter EditorCreator
1058 refreshGenericDataAttributes();
1059 } else {
1060 // write debug information
1061 WRITE_DEBUG("Cancel single parameters dialog");
1062 }
1063 return 1;
1064}
1065
1066
1067long
1069 // clear current existent parameters
1070 myParameters.clear();
1071 // check if current given string is valid
1072 if (Parameterised::areParametersValid(myTextFieldParameters->getText().text(), true)) {
1073 // parsed parameters ok, then set text field black and continue
1074 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
1075 myTextFieldParameters->killFocus();
1076 // obtain parameters "key=value"
1077 std::vector<std::string> parameters = StringTokenizer(myTextFieldParameters->getText().text(), "|", true).getVector();
1078 // iterate over parameters
1079 for (const auto& parameter : parameters) {
1080 // obtain key, value
1081 std::vector<std::string> keyParam = StringTokenizer(parameter, "=", true).getVector();
1082 // save it in myParameters
1083 myParameters[keyParam.front()] = keyParam.back();
1084 }
1085 // overwrite myTextFieldParameters (to remove duplicated parameters
1086 myTextFieldParameters->setText(getParametersStr().c_str(), FALSE);
1087 } else {
1088 myTextFieldParameters->setTextColor(FXRGB(255, 0, 0));
1089 }
1090 return 1;
1091}
1092
1093
1094bool
1096 if (viewNet->getEditModes().isCurrentSupermodeNetwork() &&
1098 return true;
1099 } else if (viewNet->getEditModes().isCurrentSupermodeDemand() &&
1101 return true;
1102 } else if (viewNet->getEditModes().isCurrentSupermodeData() &&
1103 AC->getTagProperty().isDataElement()) {
1104 return true;
1105 } else {
1106 return false;
1107 }
1108}
1109
1110
1111bool
1114 return (viewNet->getEditModes().isCurrentSupermodeNetwork());
1115 } else if (ACAttr.getTagPropertyParent().isDemandElement()) {
1116 return (viewNet->getEditModes().isCurrentSupermodeDemand());
1117 } else if (ACAttr.getTagPropertyParent().isDataElement()) {
1118 return (viewNet->getEditModes().isCurrentSupermodeData());
1119 } else {
1120 return false;
1121 }
1122}
1123
1124/****************************************************************************/
FXDEFMAP(GNEFrameAttributeModules::AttributesEditorRow) AttributesEditorRowMap[]
@ MID_GNE_SET_ATTRIBUTE_VTYPE
inspect attribute vType/vTypeDistribution
Definition: GUIAppEnum.h:906
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:870
@ MID_GNE_OPEN_PARAMETERS_DIALOG
open parameters dialog
Definition: GUIAppEnum.h:908
@ MID_GNE_SET_ATTRIBUTE_DIALOG
attribute edited trough dialog
Definition: GUIAppEnum.h:904
@ MID_HELP
help button
Definition: GUIAppEnum.h:641
@ MID_GNE_SET_ATTRIBUTE_BOOL
bool attribute edited
Definition: GUIAppEnum.h:902
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
Definition: GUIDesigns.h:80
#define GUIDesignButton
Definition: GUIDesigns.h:77
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
Definition: GUIDesigns.h:315
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:321
#define GUIDesignTextField
Definition: GUIDesigns.h:48
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:397
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame
Definition: GUIDesigns.h:241
#define GUIDesignButtonRectangular
little button rectangula used in frames (For example, in "help" buttons)
Definition: GUIDesigns.h:83
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:69
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:169
#define GUIDesignCheckButtonAttribute
checkButton without thick extended over the frame used for attributes
Definition: GUIDesigns.h:175
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
#define TL(string)
Definition: MsgHandler.h:282
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_CONTAINER_TRIGGERED
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ GNE_ATTR_VTYPE_DISTRIBUTION
vehicle type distribution
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_NOTHING
invalid attribute
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Dialog for edit rerouters.
static FXIcon * getVClassIcon(const SUMOVehicleClass vc)
returns icon associated to the given vClass
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
GNENet * getNet() const
get pointer to net
static const size_t MAXNUMBEROFATTRIBUTES
max number of attributes allowed for every tag
const GNETagProperties & getTagPropertyParent() const
get reference to tagProperty parent
void hideFlowEditor()
hide group box
void showAttributesEditorExtendedModule()
show AttributesEditorExtended modul
AttributesEditorExtended(GNEFrame *frameParent)
FOX-declaration.
void refreshAttributeEditor(bool forceRefreshShape, bool forceRefreshPosition)
refresh attribute editor (only the valid values will be refresh)
void showAttributeEditorModule(bool includeExtended, bool forceAttributeEnabled)
show attributes of multiple ACs
GNEFlowEditor * myAttributesEditorFlow
GNEFlowEditor modul.
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
long onCmdAttributesEditorHelp(FXObject *, FXSelector, void *)
std::vector< AttributesEditorRow * > myAttributesEditorRows
list of Attribute editor rows
AttributesEditor(GNEFrame *inspectorFrameParent)
FOX-declaration.
void refreshAttributesEditorRow(const std::string &value, const bool forceRefresh, const bool attributeEnabled, const bool computed, GNEAttributeCarrier *ACParent)
refresh current row
bool mergeJunction(SumoXMLAttr attr, const std::vector< GNEAttributeCarrier * > &inspectedACs, const std::string &newVal) const
check junction merging
long onCmdSetAttribute(FXObject *, FXSelector, void *)
try to set new attribute value
std::string stripWhitespaceAfterComma(const std::string &stringValue)
removed invalid spaces of Positions and shapes
long onCmdInspectVTypeParent(FXObject *, FXSelector, void *)
inspect vType/VTypeDistribution parent
bool isAttributesEditorRowValid() const
check if current attribute of TextField/ComboBox is valid
void destroy()
destroy GNEAttributesCreatorRow (but don't delete)
long onCmdOpenAttributeDialog(FXObject *, FXSelector, void *)
open model dialog for more comfortable attribute editing
long onCmdSelectCheckButton(FXObject *, FXSelector, void *)
called when user press a check button
long onCmdSetParameters(FXObject *, FXSelector, void *)
Called when user udpate the parameter text field.
bool areAttributesValid() const
check if current attributes are valid
const Parameterised::Map & getParametersMap() const
get parameters as map
FXButton * myButtonEditParameters
button for edit parameters using specific dialog
void refreshGenericDataAttributes()
refresh netedit attributes
FXTextField * myTextFieldParameters
text field for write parameters
void showGenericDataAttributes()
show netedit attributes EditorCreator
long onCmdEditParameters(FXObject *, FXSelector, void *)
GNEFrame * getFrameParent() const
pointer to frame parent
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
std::string getParametersStr() const
get parameters as string
GenericDataAttributes(GNEFrame *frameParent)
FOX-declaration.
void hideGenericDataAttributes()
hide netedit attributes EditorCreator
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
static bool isSupermodeValid(const GNEViewNet *viewNet, const GNEAttributeCarrier *AC)
return true if AC can be edited in the current supermode
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:150
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
Dialog for edit parameters.
bool isNetworkElement() const
return true if tag correspond to a network element
bool isDataElement() const
return true if tag correspond to a data element
bool isDemandElement() const
return true if tag correspond to a demand element
bool isAdditionalElement() const
return true if tag correspond to an additional element (note: this include TAZ, shapes and wires)
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
ComboBox with icon.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:112
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:106
static bool areAttributesValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to an attributes map "key1=value1|key2=value2|....
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const RGBColor BLACK
Definition: RGBColor.h:193
std::vector< std::string > getVector()
return vector of strings
static std::string replace(std::string str, const std::string &what, const std::string &by)
Definition: json.hpp:4471
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network