Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAttributeCarrier.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// Abstract Base class for gui objects which carry attributes
19/****************************************************************************/
20
23#include <netedit/GNENet.h>
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNEViewNet.h>
37
38#include "GNEAttributeCarrier.h"
39
40// ===========================================================================
41// static members
42// ===========================================================================
43
44const std::string GNEAttributeCarrier::FEATURE_LOADED = "loaded";
45const std::string GNEAttributeCarrier::FEATURE_GUESSED = "guessed";
46const std::string GNEAttributeCarrier::FEATURE_MODIFIED = "modified";
47const std::string GNEAttributeCarrier::FEATURE_APPROVED = "approved";
48const std::string GNEAttributeCarrier::TRUE_STR = toString(true);
49const std::string GNEAttributeCarrier::FALSE_STR = toString(false);
50
51// ===========================================================================
52// method definitions
53// ===========================================================================
54
56 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
57 myNet(net),
58 myIsTemplate(true) {
59 // set default bucket for template elements
60 auto savingFilesHandler = net->getGNEApplicationWindow()->getFileBucketHandler();
62 myFileBucket = savingFilesHandler->getDefaultBucket(FileBucket::Type::NETWORK);
63 } else if (myTagProperty->saveInDataFile()) {
64 myFileBucket = savingFilesHandler->getDefaultBucket(FileBucket::Type::DATA);
65 } else if (myTagProperty->saveInDemandFile()) {
66 myFileBucket = savingFilesHandler->getDefaultBucket(FileBucket::Type::DEMAND);
67 } else if (myTagProperty->saveInMeanDataFile()) {
68 myFileBucket = savingFilesHandler->getDefaultBucket(FileBucket::Type::MEANDATA);
69 } else if (myTagProperty->saveInAdditionalFile()) {
70 // additional MUST be the last, because demand and data elements can be saved in additional files
71 myFileBucket = savingFilesHandler->getDefaultBucket(FileBucket::Type::ADDITIONAL);
72 }
73 // update counter in filebucket
74 if (myFileBucket) {
76 }
77}
78
80 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
81 myNet(net),
82 myFileBucket(fileBucket) {
83}
84
85
87 // update counter in filebucket
90 }
91}
92
94const std::string
98
99
100GNENet*
102 return myNet;
103}
104
105
106void
108 auto glObject = getGUIGlObject();
109 if (glObject && myTagProperty->isSelectable()) {
110 gSelected.select(glObject->getGlID());
111 mySelected = true;
112 }
113}
114
115
116void
118 auto glObject = getGUIGlObject();
119 if (glObject && myTagProperty->isSelectable()) {
120 gSelected.deselect(glObject->getGlID());
121 mySelected = false;
122 }
123}
124
125
126bool
130
131
132bool
134 // first check if element is selected
135 if (mySelected) {
136 // get flag for network element
137 const bool networkElement = myTagProperty->isNetworkElement() || myTagProperty->isAdditionalElement();
138 // check current supermode
139 if (networkElement && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
140 return true;
142 return true;
144 return true;
145 } else {
146 return false;
147 }
148 } else {
149 return false;
150 }
151}
152
153
154bool
156 // get modes
157 const auto& modes = myNet->getViewNet()->getEditModes();
158 // check conditions
160 return false;
161 } else if (modes.isCurrentSupermodeNetwork() && (modes.networkEditMode == NetworkEditMode::NETWORK_MOVE)) {
162 return true;
163 } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_MOVE)) {
164 return true;
165 } else {
166 return false;
167 }
168}
169
170
171void
176
177
178void
183
184
185bool
189
190
191void
192GNEAttributeCarrier::drawInLayer(double typeOrLayer, const double extraOffset) const {
193 if (myDrawInFront) {
194 glTranslated(0, 0, GLO_FRONTELEMENT + extraOffset);
195 } else {
196 glTranslated(0, 0, typeOrLayer + extraOffset);
197 }
198}
199
200
201void
203 myInGrid = value;
204}
205
206
207bool
209 return myInGrid;
210}
211
212
213bool
217
218
219bool
223
224
225void
227 if (allowUndoRedo) {
228 // reset within undo-redo
229 const auto undoList = myNet->getUndoList();
230 undoList->begin(myTagProperty->getGUIIcon(), TLF("reset %", myTagProperty->getTagStr()));
231 for (const auto& attrProperty : myTagProperty->getAttributeProperties()) {
232 if ((attrProperty->getAttr() != GNE_ATTR_SAVEFILE) && !attrProperty->isUnique() && attrProperty->hasDefaultValue()) {
233 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue(), undoList);
234 if (attrProperty->isActivatable()) {
235 if (attrProperty->getDefaultActivated()) {
236 enableAttribute(attrProperty->getAttr(), undoList);
237 } else {
238 disableAttribute(attrProperty->getAttr(), undoList);
239 }
240 }
241 }
242 }
243 undoList->end();
244 } else {
245 // simply reset every
246 for (const auto& attrProperty : myTagProperty->getAttributeProperties()) {
247 if ((attrProperty->getAttr() != GNE_ATTR_SAVEFILE) && attrProperty->hasDefaultValue()) {
248 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue());
249 if (attrProperty->isActivatable()) {
250 toggleAttribute(attrProperty->getAttr(), attrProperty->getDefaultActivated());
251 }
252 }
253 }
254 }
255}
256
257
258void
260 throw ProcessError(TL("Nothing to enable, implement in Children"));
261
262}
263
264
265void
267 throw ProcessError(TL("Nothing to disable, implement in Children"));
268}
269
270
271bool
273 switch (key) {
276 return false;
277 } else {
278 return (myFileBucket != nullptr);
279 }
280 default:
281 return true;
282 }
283}
284
285
286bool
288 // by default, all attributes aren't computed
289 return false;
290}
291
292
293bool
297
298// canParse functions
299
300template<> bool
301GNEAttributeCarrier::canParse<int>(const std::string& string) {
302 if (string == "INVALID_INT") {
303 return true;
304 } else {
305 return StringUtils::isInt(string);
306 }
307}
308
309
310template<> bool
311GNEAttributeCarrier::canParse<double>(const std::string& string) {
312 if (string == "INVALID_DOUBLE") {
313 return true;
314 } else {
315 return StringUtils::isDouble(string);
316 }
317}
318
319
320template<> bool
321GNEAttributeCarrier::canParse<SUMOTime>(const std::string& string) {
322 return isTime(string);
323}
324
325
326template<> bool
327GNEAttributeCarrier::canParse<bool>(const std::string& string) {
328 return StringUtils::isBool(string);
329}
330
331
332template<> bool
333GNEAttributeCarrier::canParse<Position>(const std::string& string) {
334 bool ok = true;
335 GeomConvHelper::parseShapeReporting(string, "position", 0, ok, true, false);
336 return ok;
337}
338
339
340template<> bool
341GNEAttributeCarrier::canParse<SUMOVehicleClass>(const std::string& string) {
342 return SumoVehicleClassStrings.hasString(string);
343}
344
345
346template<> bool
347GNEAttributeCarrier::canParse<RGBColor>(const std::string& string) {
348 return RGBColor::isColor(string);
349}
350
351
352template<> bool
353GNEAttributeCarrier::canParse<SumoXMLAttr>(const std::string& string) {
355}
356
357
358template<> bool
359GNEAttributeCarrier::canParse<SUMOVehicleShape>(const std::string& string) {
360 if (string.empty()) {
361 return true;
362 } else {
363 return SumoVehicleShapeStrings.hasString(string);
364 }
365}
366
367
368template<> bool
369GNEAttributeCarrier::canParse<PositionVector>(const std::string& string) {
370 bool ok = true;
371 GeomConvHelper::parseShapeReporting(string, "shape", 0, ok, true, false);
372 return ok;
373}
374
375
376template<> bool
377GNEAttributeCarrier::canParse<std::vector<int> >(const std::string& string) {
378 if (string.empty()) {
379 return true;
380 }
381 const auto values = StringTokenizer(string).getVector();
382 for (const auto& value : values) {
383 if (!canParse<int>(value)) {
384 return false;
385 }
386 }
387 return true;
388}
389
390
391template<> bool
392GNEAttributeCarrier::canParse<std::vector<double> >(const std::string& string) {
393 if (string.empty()) {
394 return true;
395 }
396 const auto values = StringTokenizer(string).getVector();
397 for (const auto& value : values) {
398 if (!canParse<double>(value)) {
399 return false;
400 }
401 }
402 return true;
403}
404
405
406template<> bool
407GNEAttributeCarrier::canParse<std::vector<bool> >(const std::string& string) {
408 if (string.empty()) {
409 return true;
410 }
411 const auto values = StringTokenizer(string).getVector();
412 for (const auto& value : values) {
413 if (!canParse<bool>(value)) {
414 return false;
415 }
416 }
417 return true;
418}
419
420
421template<> bool
422GNEAttributeCarrier::canParse<std::vector<SumoXMLAttr> >(const std::string& string) {
423 if (string.empty()) {
424 return true;
425 }
426 const auto values = StringTokenizer(string).getVector();
427 for (const auto& value : values) {
428 if (!canParse<SumoXMLAttr>(value)) {
429 return false;
430 }
431 }
432 return true;
433}
434
435// parse functions
436
437template<> int
438GNEAttributeCarrier::parse(const std::string& string) {
439 if (string == "INVALID_INT") {
440 return INVALID_INT;
441 } else {
442 return StringUtils::toInt(string);
443 }
444}
445
446
447template<> double
448GNEAttributeCarrier::parse(const std::string& string) {
449 if (string == "INVALID_DOUBLE") {
450 return INVALID_DOUBLE;
451 } else {
452 return StringUtils::toDouble(string);
453 }
454}
455
456
457template<> SUMOTime
458GNEAttributeCarrier::parse(const std::string& string) {
459 return string2time(string);
460}
461
462
463template<> bool
464GNEAttributeCarrier::parse(const std::string& string) {
465 return StringUtils::toBool(string);
466}
467
468
469template<> SUMOVehicleClass
470GNEAttributeCarrier::parse(const std::string& string) {
471 if (string.size() == 0) {
472 throw EmptyData();
473 } else if (!SumoVehicleClassStrings.hasString(string)) {
474 return SVC_IGNORING;
475 } else {
476 return SumoVehicleClassStrings.get(string);
477 }
478}
479
480
481template<> RGBColor
482GNEAttributeCarrier::parse(const std::string& string) {
483 if (string.empty()) {
484 return RGBColor::INVISIBLE;
485 } else {
486 return RGBColor::parseColor(string);
487 }
488}
489
490
491template<> Position
492GNEAttributeCarrier::parse(const std::string& string) {
493 // we handle empty strings as position invalids
494 if (string.size() == 0) {
495 return Position::INVALID;
496 } else {
497 bool ok = true;
498 PositionVector pos = GeomConvHelper::parseShapeReporting(string, "user-supplied position", 0, ok, false, false);
499 if (!ok || (pos.size() != 1)) {
500 throw NumberFormatException("(Position) " + string);
501 } else {
502 return pos[0];
503 }
504 }
505}
506
507
508template<> PositionVector
509GNEAttributeCarrier::parse(const std::string& string) {
510 PositionVector posVector;
511 // empty string are allowed (It means empty position vector)
512 if (string.empty()) {
513 return posVector;
514 } else {
515 bool ok = true;
516 posVector = GeomConvHelper::parseShapeReporting(string, "user-supplied shape", 0, ok, false, true);
517 if (!ok) {
518 throw NumberFormatException("(Position List) " + string);
519 } else {
520 return posVector;
521 }
522 }
523}
524
525
526template<> SUMOVehicleShape
527GNEAttributeCarrier::parse(const std::string& string) {
528 if (string.empty()) {
530 } else {
531 return SumoVehicleShapeStrings.get(string);
532 }
533}
534
535
536template<> std::vector<std::string>
537GNEAttributeCarrier::parse(const std::string& string) {
538 return StringTokenizer(string).getVector();
539}
540
541
542template<> std::set<std::string>
543GNEAttributeCarrier::parse(const std::string& string) {
544 const auto vectorString = StringTokenizer(string).getVector();
545 std::set<std::string> solution;
546 for (const auto& stringValue : vectorString) {
547 solution.insert(stringValue);
548 }
549 return solution;
550}
551
552
553template<> std::vector<int>
554GNEAttributeCarrier::parse(const std::string& string) {
555 const auto vectorInt = parse<std::vector<std::string> >(string);
556 std::vector<int> parsedIntValues;
557 for (const auto& intValue : vectorInt) {
558 parsedIntValues.push_back(parse<int>(intValue));
559 }
560 return parsedIntValues;
561}
562
563
564template<> std::vector<double>
565GNEAttributeCarrier::parse(const std::string& string) {
566 const auto vectorDouble = parse<std::vector<std::string> >(string);
567 std::vector<double> parsedDoubleValues;
568 for (const auto& doubleValue : vectorDouble) {
569 parsedDoubleValues.push_back(parse<double>(doubleValue));
570 }
571 return parsedDoubleValues;
572}
573
574
575template<> std::vector<bool>
576GNEAttributeCarrier::parse(const std::string& string) {
577 const auto vectorBool = parse<std::vector<std::string> >(string);
578 std::vector<bool> parsedBoolValues;
579 for (const auto& boolValue : vectorBool) {
580 parsedBoolValues.push_back(parse<bool>(boolValue));
581 }
582 return parsedBoolValues;
583}
584
585
586template<> std::vector<SumoXMLAttr>
587GNEAttributeCarrier::parse(const std::string& value) {
588 // Declare string vector
589 const auto attributesStr = parse<std::vector<std::string> > (value);
590 std::vector<SumoXMLAttr> attributes;
591 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
592 for (const auto& attributeStr : attributesStr) {
593 if (SUMOXMLDefinitions::Attrs.hasString(attributeStr)) {
594 attributes.push_back(static_cast<SumoXMLAttr>(SUMOXMLDefinitions::Attrs.get(attributeStr)));
595 } else {
596 throw FormatException("Error parsing attributes. Attribute '" + attributeStr + "' doesn't exist");
597 }
598 }
599 return attributes;
600}
601
602// can parse (network) functions
603
604template<> bool
605GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(const GNENet* net, const std::string& value, const bool checkConsecutivity) {
606 // Declare string vector
607 const auto edgeIds = parse<std::vector<std::string> > (value);
608 std::vector<GNEEdge*> parsedEdges;
609 parsedEdges.reserve(edgeIds.size());
610 for (const auto& edgeID : edgeIds) {
611 const auto edge = net->getAttributeCarriers()->retrieveEdge(edgeID, false);
612 if (edge == nullptr) {
613 return false;
614 } else if (checkConsecutivity) {
615 if ((parsedEdges.size() > 0) && (parsedEdges.back()->getToJunction() != edge->getFromJunction())) {
616 return false;
617 }
618 parsedEdges.push_back(edge);
619 }
620 }
621 return true;
622}
623
624
625template<> bool
626GNEAttributeCarrier::canParse<std::vector<GNELane*> >(const GNENet* net, const std::string& value, const bool checkConsecutivity) {
627 // Declare string vector
628 const auto laneIds = parse<std::vector<std::string> > (value);
629 std::vector<GNELane*> parsedLanes;
630 parsedLanes.reserve(laneIds.size());
631 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
632 for (const auto& laneID : laneIds) {
633 const auto lane = net->getAttributeCarriers()->retrieveLane(laneID, false);
634 if (lane == nullptr) {
635 return false;
636 } else if (checkConsecutivity) {
637 if ((parsedLanes.size() > 0) && (parsedLanes.back()->getParentEdge()->getToJunction() != lane->getParentEdge()->getFromJunction())) {
638 return false;
639 }
640 parsedLanes.push_back(lane);
641 }
642 }
643 return true;
644}
645
646// parse (network) functions
647
648template<> std::vector<GNEEdge*>
649GNEAttributeCarrier::parse(const GNENet* net, const std::string& value) {
650 // Declare string vector
651 const auto edgeIds = parse<std::vector<std::string> > (value);
652 std::vector<GNEEdge*> parsedEdges;
653 parsedEdges.reserve(edgeIds.size());
654 // Iterate over edges IDs, retrieve Edges and add it into parsedEdges
655 for (const auto& edgeID : edgeIds) {
656 parsedEdges.push_back(net->getAttributeCarriers()->retrieveEdge(edgeID));
657 }
658 return parsedEdges;
659}
660
661
662template<> std::vector<GNELane*>
663GNEAttributeCarrier::parse(const GNENet* net, const std::string& value) {
664 // Declare string vector
665 const auto laneIds = parse<std::vector<std::string> > (value);
666 std::vector<GNELane*> parsedLanes;
667 parsedLanes.reserve(laneIds.size());
668 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
669 for (const auto& laneID : laneIds) {
670 parsedLanes.push_back(net->getAttributeCarriers()->retrieveLane(laneID));
671 }
672 return parsedLanes;
673}
674
675// parse ID functions
676
677template<> std::string
678GNEAttributeCarrier::parseIDs(const std::vector<GNEEdge*>& ACs) {
679 // obtain ID's of edges and return their join
680 std::vector<std::string> edgeIDs;
681 for (const auto& AC : ACs) {
682 edgeIDs.push_back(AC->getID());
683 }
684 return joinToString(edgeIDs, " ");
685}
686
687
688template<> std::string
689GNEAttributeCarrier::parseIDs(const std::vector<GNELane*>& ACs) {
690 // obtain ID's of lanes and return their join
691 std::vector<std::string> laneIDs;
692 for (const auto& AC : ACs) {
693 laneIDs.push_back(AC->getID());
694 }
695 return joinToString(laneIDs, " ");
696}
697
698void
699GNEAttributeCarrier::setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters) {
700 // declare result string
701 std::string paramsStr;
702 // Generate an string using the following structure: "key1=value1|key2=value2|...
703 for (const auto& parameter : parameters) {
704 paramsStr += parameter.first + "=" + parameter.second + "|";
705 }
706 // remove the last "|"
707 if (!paramsStr.empty()) {
708 paramsStr.pop_back();
709 }
710 // set parameters
712}
713
714
715void
716GNEAttributeCarrier::setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList) {
717 // declare parametersMap
718 Parameterised::Map parametersMap;
719 // Generate an string using the following structure: "key1=value1|key2=value2|...
720 for (const auto& parameter : parameters) {
721 parametersMap[parameter.first] = parameter.second;
722 }
723 // set setACParameters map
724 setACParameters(parametersMap, undoList);
725}
726
727
728void
730 // declare result string
731 std::string paramsStr;
732 // Generate an string using the following structure: "key1=value1|key2=value2|...
733 for (const auto& parameter : parameters) {
734 paramsStr += parameter.first + "=" + parameter.second + "|";
735 }
736 // remove the last "|"
737 if (!paramsStr.empty()) {
738 paramsStr.pop_back();
739 }
740 // set parameters
741 setAttribute(GNE_ATTR_PARAMETERS, paramsStr, undoList);
742}
743
744
745std::string
747 switch (key) {
748 // Crossings
751 return "No TLS";
752 // connections
753 case SUMO_ATTR_DIR: {
754 // special case for connection directions
755 std::string direction = getAttribute(key);
756 if (direction == "s") {
757 return "Straight (s)";
758 } else if (direction == "t") {
759 return "Turn (t))";
760 } else if (direction == "l") {
761 return "Left (l)";
762 } else if (direction == "r") {
763 return "Right (r)";
764 } else if (direction == "L") {
765 return "Partially left (L)";
766 } else if (direction == "R") {
767 return "Partially right (R)";
768 } else if (direction == "invalid") {
769 return "No direction (Invalid))";
770 } else {
771 return "undefined";
772 }
773 }
774 case SUMO_ATTR_STATE: {
775 // special case for connection states
776 std::string state = getAttribute(key);
777 if (state == "-") {
778 return "Dead end (-)";
779 } else if (state == "=") {
780 return "equal (=)";
781 } else if (state == "m") {
782 return "Minor link (m)";
783 } else if (state == "M") {
784 return "Major link (M)";
785 } else if (state == "O") {
786 return "TLS controller off (O)";
787 } else if (state == "o") {
788 return "TLS yellow flashing (o)";
789 } else if (state == "y") {
790 return "TLS yellow minor link (y)";
791 } else if (state == "Y") {
792 return "TLS yellow major link (Y)";
793 } else if (state == "r") {
794 return "TLS red (r)";
795 } else if (state == "g") {
796 return "TLS green minor (g)";
797 } else if (state == "G") {
798 return "TLS green major (G)";
799 } else if (state == "Z") {
800 return "Zipper (Z)";
801 } else {
802 return "undefined";
803 }
804 }
805 default:
806 return getAttribute(key);
807 }
808}
809
810
811std::string
815
816
817const std::string&
821
822
823FXIcon*
825 // special case for vClass icons
826 if (myTagProperty->vClassIcon()) {
828 } else {
830 }
831}
832
833
834bool
838
839
840const GNETagProperties*
844
845
846std::string
848 switch (key) {
850 if (myFileBucket) {
851 return getFileBucket()->getFilename();
852 } else {
853 return TL("Parent filename");
854 }
858 if (mySelected) {
859 return TRUE_STR;
860 } else {
861 return FALSE_STR;
862 }
864 if (myDrawInFront) {
865 return TRUE_STR;
866 } else {
867 return FALSE_STR;
868 }
870 if (getParameters()) {
872 } else {
873 throw InvalidArgument(getTagStr() + " doesn't support parameters");
874 }
875 default:
876 throw InvalidArgument(getTagStr() + " doesn't have a common attribute of type '" + toString(key) + "'");
877 }
878}
879
880
881double
883 throw InvalidArgument(getTagStr() + " doesn't have a common double attribute of type '" + toString(key) + "'");
884}
885
886
889 throw InvalidArgument(getTagStr() + " doesn't have a common position attribute of type '" + toString(key) + "'");
890}
891
892
895 throw InvalidArgument(getTagStr() + " doesn't have a common positionVector attribute of type '" + toString(key) + "'");
896}
897
898
899void
900GNEAttributeCarrier::setCommonAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
901 switch (key) {
906 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
907 break;
908 default:
909 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
910 }
911}
912
913
914bool
915GNEAttributeCarrier::isCommonAttributeValid(SumoXMLAttr key, const std::string& value) const {
916 switch (key) {
920 } else {
921 return false;
922 }
925 return canParse<bool>(value);
928 default:
929 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
930 }
931}
932
933
934void
936 switch (key) {
939 break;
941 myCenterAfterCreation = parse<bool>(value);
942 break;
944 if (parse<bool>(value)) {
946 } else {
948 }
949 break;
951 if (getParameters()) {
953 } else {
954 throw InvalidArgument(getTagStr() + " doesn't support parameters");
955 }
956 break;
957 default:
958 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
959 }
960}
961
962// ===========================================================================
963// private
964// ===========================================================================
965
966void
967GNEAttributeCarrier::toggleAttribute(SumoXMLAttr /*key*/, const bool /*value*/) {
968 throw ProcessError(TL("Nothing to toggle, implement in Children"));
969}
970
971/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ DEMAND_MOVE
mode for moving demand elements
long long int SUMOTime
Definition GUI.h:36
@ GLO_FRONTELEMENT
front element (used in netedit)
GUISelectedStorage gSelected
A global holder of selected objects.
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
bool isTime(const std::string &r)
check if the given string is a valid time
Definition SUMOTime.cpp:69
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SUMOVehicleShape::UNKNOWN, false)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
@ UNKNOWN
not defined
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ GNE_ATTR_CENTER_AFTER_CREATION
flag to center camera after element creation
@ GNE_ATTR_SAVEFILE
save file
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_VCLASS
@ GNE_ATTR_FRONTELEMENT
@ SUMO_ATTR_ID
@ SUMO_ATTR_DIR
The abstract direction of a link.
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_STATE
The state of a link.
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
const int INVALID_INT
invalid int
Definition StdDefs.h:65
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:289
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void removeElement(const bool isTemplate)
remove element
void addElement(const bool isTemplate)
function related with Elements
const std::string & getFilename() const
get filename
FileBucket * updateAC(const GNEAttributeCarrier *AC, const std::string &filename)
update filename vinculated with this AC
bool checkFilename(const GNEAttributeCarrier *AC, const std::string &filename) const
check if the given filename can be assigned to the given AC
GNEApplicationWindowHelper::FileBucketHandler * getFileBucketHandler() const
get file bucket handler
bool drawMovingGeometryPoints() const
check if draw moving geometry points
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void markForDrawingFront()
mark for drawing front
virtual FileBucket * getFileBucket() const =0
get reference to fileBucket in which save this AC
double getCommonAttributeDouble(SumoXMLAttr key) const
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNEAttributeCarrier(const SumoXMLTag tag, GNENet *net)
Constructor for templates.
void setInGrid(bool value)
mark if this AC was inserted in grid or not
bool isMarkedForDrawingFront() const
check if this AC is marked for drawing front
bool myDrawInFront
boolean to check if drawn this AC over other elements
bool myCenterAfterCreation
boolean to check if center this element after creation
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
FileBucket * myFileBucket
filebucket vinculated whith this AC
static const std::string FALSE_STR
true value in string format(used for comparing boolean values in getAttribute(...))
static const std::string TRUE_STR
true value in string format (used for comparing boolean values in getAttribute(......
bool checkDrawFrontContour() const
check if draw front contour (green/blue)
const std::string getID() const override
get ID (all Attribute Carriers have one)
const bool myIsTemplate
whether the current object is a template object (used for edit attributes)
virtual void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
static const std::string FEATURE_LOADED
feature is still unchanged after being loaded (implies approval)
static const std::string FEATURE_APPROVED
feature has been approved but not changed (i.e. after being reguessed)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
virtual Parameterised * getParameters()=0
get parameters associated with this AttributeCarrier
bool myInGrid
boolean to check if this AC is in grid
std::string getAlternativeValueForDisabledAttributes(SumoXMLAttr key) const
virtual bool isAttributeComputed(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
virtual bool isAttributeEnabled(SumoXMLAttr key) const
const std::string & getTagStr() const
get tag assigned to this object in string format
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
bool isTemplate() const
check if this AC is template
void setACParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters (string vector)
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
void resetDefaultValues(const bool allowUndoRedo)
reset attribute carrier to their default values
bool hasAttribute(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
bool inGrid() const
check if this AC was inserted in grid
void unmarkForDrawingFront()
unmark for drawing front
GNENet * getNet() const
get pointer to net
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual ~GNEAttributeCarrier()
Destructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::string getCommonAttribute(SumoXMLAttr key) const
bool checkDrawInspectContour() const
check if draw inspect contour (black/white)
virtual GUIGlObject * getGUIGlObject()=0
get GUIGlObject associated with this AttributeCarrier
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
GNEApplicationWindow * getGNEApplicationWindow() const
get tag properties database
Definition GNENet.cpp:138
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
Definition GNENet.cpp:156
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
bool vClassIcon() const
return true if tag correspond to an element that has vClass icons
bool saveInDataFile() const
element is saved in a data file
bool isGenericData() const
data elements
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool saveInAdditionalFile() const
element is saved in an additional file
bool isNetworkElement() const
network elements
bool saveInDemandFile() const
element is saved in a demand file
bool isSelectable() const
return true if tag correspond to a selectable element
GUIIcon getGUIIcon() const
get GUI icon associated to this tag property
bool saveInMeanDataFile() const
element is saved in a meanData file
bool saveInParentFile() const
element is saved in the parent file
bool isDemandElement() const
return true if tag correspond to a demand element
const std::vector< const GNEAttributeProperties * > & getAttributeProperties() const
get all attribute properties
bool isAdditionalElement() const
return true if tag correspond to an additional element (note: this include TAZ, shapes and wires)
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
bool saveInNetworkFile() const
element is saved in a network file
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...
bool isACInspected(GNEAttributeCarrier *AC) const
void unmarkAC(GNEAttributeCarrier *AC)
unmark AC for drawing front
void markAC(GNEAttributeCarrier *AC)
mark AC as drawing front
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
GNEViewNetHelper::MarkFrontElements & getMarkFrontElements()
get marked for drawing front elements
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
void deselect(GUIGlID id)
Deselects the object with the given id.
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occurred errors.
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
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
A list of positions.
static const RGBColor INVISIBLE
Definition RGBColor.h:198
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition RGBColor.cpp:239
static bool isColor(std::string coldef)
check if the given string can be parsed to color
Definition RGBColor.cpp:329
static SequentialStringBijection Attrs
The names of SUMO-XML attributes for use in netbuild.
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
bool hasString(const std::string &str) const
std::vector< std::string > getVector()
return vector of strings
static bool isDouble(const std::string &sData)
check if the given sData can be conveted to double
static bool isBool(const std::string &sData)
check if the given value can be converted to bool
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool isInt(const std::string &sData)
check if the given sData can be converted to int
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
static FXIcon * getVClassIcon(const SUMOVehicleClass vc)
returns icon associated to the given vClass
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
bool shiftKeyPressed() const
check if SHIFT is pressed during current event