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-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
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 myFileBucket = fileBucket;
109}
110
111
112void
114 auto glObject = getGUIGlObject();
115 if (glObject && myTagProperty->isSelectable()) {
116 gSelected.select(glObject->getGlID());
117 mySelected = true;
118 }
119}
120
121
122void
124 auto glObject = getGUIGlObject();
125 if (glObject && myTagProperty->isSelectable()) {
126 gSelected.deselect(glObject->getGlID());
127 mySelected = false;
128 }
129}
130
131
132bool
136
137
138bool
140 // first check if element is selected
141 if (mySelected) {
142 // get flag for network element
143 const bool networkElement = myTagProperty->isNetworkElement() || myTagProperty->isAdditionalElement();
144 // check current supermode
145 if (networkElement && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
146 return true;
148 return true;
150 return true;
151 } else {
152 return false;
153 }
154 } else {
155 return false;
156 }
157}
158
159
160bool
162 // get modes
163 const auto& modes = myNet->getViewNet()->getEditModes();
164 // check conditions
166 return false;
167 } else if (modes.isCurrentSupermodeNetwork() && (modes.networkEditMode == NetworkEditMode::NETWORK_MOVE)) {
168 return true;
169 } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_MOVE)) {
170 return true;
171 } else {
172 return false;
173 }
174}
175
176
177void
182
183
184void
189
190
191bool
195
196
197void
198GNEAttributeCarrier::drawInLayer(double typeOrLayer, const double extraOffset) const {
199 if (myDrawInFront) {
200 glTranslated(0, 0, GLO_FRONTELEMENT + extraOffset);
201 } else {
202 glTranslated(0, 0, typeOrLayer + extraOffset);
203 }
204}
205
206
207void
209 myInGrid = value;
210}
211
212
213bool
215 return myInGrid;
216}
217
218
219bool
223
224
225bool
229
230
231void
233 if (allowUndoRedo) {
234 // reset within undo-redo
235 const auto undoList = myNet->getUndoList();
236 undoList->begin(myTagProperty->getGUIIcon(), TLF("reset %", myTagProperty->getTagStr()));
237 for (const auto& attrProperty : myTagProperty->getAttributeProperties()) {
238 if ((attrProperty->getAttr() != GNE_ATTR_SAVEFILE) && !attrProperty->isUnique() && attrProperty->hasDefaultValue()) {
239 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue(), undoList);
240 if (attrProperty->isActivatable()) {
241 if (attrProperty->getDefaultActivated()) {
242 enableAttribute(attrProperty->getAttr(), undoList);
243 } else {
244 disableAttribute(attrProperty->getAttr(), undoList);
245 }
246 }
247 }
248 }
249 undoList->end();
250 } else {
251 // simply reset every
252 for (const auto& attrProperty : myTagProperty->getAttributeProperties()) {
253 if ((attrProperty->getAttr() != GNE_ATTR_SAVEFILE) && attrProperty->hasDefaultValue()) {
254 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue());
255 if (attrProperty->isActivatable()) {
256 toggleAttribute(attrProperty->getAttr(), attrProperty->getDefaultActivated());
257 }
258 }
259 }
260 }
261}
262
263
264void
266 throw ProcessError(TL("Nothing to enable, implement in Children"));
267
268}
269
270
271void
273 throw ProcessError(TL("Nothing to disable, implement in Children"));
274}
275
276
277bool
279 switch (key) {
282 return false;
283 } else {
284 return (myFileBucket != nullptr);
285 }
286 default:
287 return true;
288 }
289}
290
291
292bool
294 // by default, all attributes aren't computed
295 return false;
296}
297
298
299bool
303
304// canParse functions
305
306template<> bool
307GNEAttributeCarrier::canParse<int>(const std::string& string) {
308 if (string == "INVALID_INT") {
309 return true;
310 } else {
311 return StringUtils::isInt(string);
312 }
313}
314
315
316template<> bool
317GNEAttributeCarrier::canParse<double>(const std::string& string) {
318 if (string == "INVALID_DOUBLE") {
319 return true;
320 } else {
321 return StringUtils::isDouble(string);
322 }
323}
324
325
326template<> bool
327GNEAttributeCarrier::canParse<SUMOTime>(const std::string& string) {
328 return isTime(string);
329}
330
331
332template<> bool
333GNEAttributeCarrier::canParse<bool>(const std::string& string) {
334 return StringUtils::isBool(string);
335}
336
337
338template<> bool
339GNEAttributeCarrier::canParse<Position>(const std::string& string) {
340 bool ok = true;
341 GeomConvHelper::parseShapeReporting(string, "position", 0, ok, true, false);
342 return ok;
343}
344
345
346template<> bool
347GNEAttributeCarrier::canParse<SUMOVehicleClass>(const std::string& string) {
348 return SumoVehicleClassStrings.hasString(string);
349}
350
351
352template<> bool
353GNEAttributeCarrier::canParse<RGBColor>(const std::string& string) {
354 return RGBColor::isColor(string);
355}
356
357
358template<> bool
359GNEAttributeCarrier::canParse<SumoXMLAttr>(const std::string& string) {
361}
362
363
364template<> bool
365GNEAttributeCarrier::canParse<SUMOVehicleShape>(const std::string& string) {
366 if (string.empty()) {
367 return true;
368 } else {
369 return SumoVehicleShapeStrings.hasString(string);
370 }
371}
372
373
374template<> bool
375GNEAttributeCarrier::canParse<PositionVector>(const std::string& string) {
376 bool ok = true;
377 GeomConvHelper::parseShapeReporting(string, "shape", 0, ok, true, false);
378 return ok;
379}
380
381
382template<> bool
383GNEAttributeCarrier::canParse<std::vector<int> >(const std::string& string) {
384 if (string.empty()) {
385 return true;
386 }
387 const auto values = StringTokenizer(string).getVector();
388 for (const auto& value : values) {
389 if (!canParse<int>(value)) {
390 return false;
391 }
392 }
393 return true;
394}
395
396
397template<> bool
398GNEAttributeCarrier::canParse<std::vector<double> >(const std::string& string) {
399 if (string.empty()) {
400 return true;
401 }
402 const auto values = StringTokenizer(string).getVector();
403 for (const auto& value : values) {
404 if (!canParse<double>(value)) {
405 return false;
406 }
407 }
408 return true;
409}
410
411
412template<> bool
413GNEAttributeCarrier::canParse<std::vector<bool> >(const std::string& string) {
414 if (string.empty()) {
415 return true;
416 }
417 const auto values = StringTokenizer(string).getVector();
418 for (const auto& value : values) {
419 if (!canParse<bool>(value)) {
420 return false;
421 }
422 }
423 return true;
424}
425
426
427template<> bool
428GNEAttributeCarrier::canParse<std::vector<SumoXMLAttr> >(const std::string& string) {
429 if (string.empty()) {
430 return true;
431 }
432 const auto values = StringTokenizer(string).getVector();
433 for (const auto& value : values) {
434 if (!canParse<SumoXMLAttr>(value)) {
435 return false;
436 }
437 }
438 return true;
439}
440
441// parse functions
442
443template<> int
444GNEAttributeCarrier::parse(const std::string& string) {
445 if (string == "INVALID_INT") {
446 return INVALID_INT;
447 } else {
448 return StringUtils::toInt(string);
449 }
450}
451
452
453template<> double
454GNEAttributeCarrier::parse(const std::string& string) {
455 if (string == "INVALID_DOUBLE") {
456 return INVALID_DOUBLE;
457 } else {
458 return StringUtils::toDouble(string);
459 }
460}
461
462
463template<> SUMOTime
464GNEAttributeCarrier::parse(const std::string& string) {
465 return string2time(string);
466}
467
468
469template<> bool
470GNEAttributeCarrier::parse(const std::string& string) {
471 return StringUtils::toBool(string);
472}
473
474
475template<> SUMOVehicleClass
476GNEAttributeCarrier::parse(const std::string& string) {
477 if (string.size() == 0) {
478 throw EmptyData();
479 } else if (!SumoVehicleClassStrings.hasString(string)) {
480 return SVC_IGNORING;
481 } else {
482 return SumoVehicleClassStrings.get(string);
483 }
484}
485
486
487template<> RGBColor
488GNEAttributeCarrier::parse(const std::string& string) {
489 if (string.empty()) {
490 return RGBColor::INVISIBLE;
491 } else {
492 return RGBColor::parseColor(string);
493 }
494}
495
496
497template<> Position
498GNEAttributeCarrier::parse(const std::string& string) {
499 // we handle empty strings as position invalids
500 if (string.size() == 0) {
501 return Position::INVALID;
502 } else {
503 bool ok = true;
504 PositionVector pos = GeomConvHelper::parseShapeReporting(string, "user-supplied position", 0, ok, false, false);
505 if (!ok || (pos.size() != 1)) {
506 throw NumberFormatException("(Position) " + string);
507 } else {
508 return pos[0];
509 }
510 }
511}
512
513
514template<> PositionVector
515GNEAttributeCarrier::parse(const std::string& string) {
516 PositionVector posVector;
517 // empty string are allowed (It means empty position vector)
518 if (string.empty()) {
519 return posVector;
520 } else {
521 bool ok = true;
522 posVector = GeomConvHelper::parseShapeReporting(string, "user-supplied shape", 0, ok, false, true);
523 if (!ok) {
524 throw NumberFormatException("(Position List) " + string);
525 } else {
526 return posVector;
527 }
528 }
529}
530
531
532template<> SUMOVehicleShape
533GNEAttributeCarrier::parse(const std::string& string) {
534 if (string.empty()) {
536 } else {
537 return SumoVehicleShapeStrings.get(string);
538 }
539}
540
541
542template<> std::vector<std::string>
543GNEAttributeCarrier::parse(const std::string& string) {
544 return StringTokenizer(string).getVector();
545}
546
547
548template<> std::set<std::string>
549GNEAttributeCarrier::parse(const std::string& string) {
550 const auto vectorString = StringTokenizer(string).getVector();
551 std::set<std::string> solution;
552 for (const auto& stringValue : vectorString) {
553 solution.insert(stringValue);
554 }
555 return solution;
556}
557
558
559template<> std::vector<int>
560GNEAttributeCarrier::parse(const std::string& string) {
561 const auto vectorInt = parse<std::vector<std::string> >(string);
562 std::vector<int> parsedIntValues;
563 for (const auto& intValue : vectorInt) {
564 parsedIntValues.push_back(parse<int>(intValue));
565 }
566 return parsedIntValues;
567}
568
569
570template<> std::vector<double>
571GNEAttributeCarrier::parse(const std::string& string) {
572 const auto vectorDouble = parse<std::vector<std::string> >(string);
573 std::vector<double> parsedDoubleValues;
574 for (const auto& doubleValue : vectorDouble) {
575 parsedDoubleValues.push_back(parse<double>(doubleValue));
576 }
577 return parsedDoubleValues;
578}
579
580
581template<> std::vector<bool>
582GNEAttributeCarrier::parse(const std::string& string) {
583 const auto vectorBool = parse<std::vector<std::string> >(string);
584 std::vector<bool> parsedBoolValues;
585 for (const auto& boolValue : vectorBool) {
586 parsedBoolValues.push_back(parse<bool>(boolValue));
587 }
588 return parsedBoolValues;
589}
590
591
592template<> std::vector<SumoXMLAttr>
593GNEAttributeCarrier::parse(const std::string& value) {
594 // Declare string vector
595 const auto attributesStr = parse<std::vector<std::string> > (value);
596 std::vector<SumoXMLAttr> attributes;
597 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
598 for (const auto& attributeStr : attributesStr) {
599 if (SUMOXMLDefinitions::Attrs.hasString(attributeStr)) {
600 attributes.push_back(static_cast<SumoXMLAttr>(SUMOXMLDefinitions::Attrs.get(attributeStr)));
601 } else {
602 throw FormatException("Error parsing attributes. Attribute '" + attributeStr + "' doesn't exist");
603 }
604 }
605 return attributes;
606}
607
608// can parse (network) functions
609
610template<> bool
611GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(const GNENet* net, const std::string& value, const bool checkConsecutivity) {
612 // Declare string vector
613 const auto edgeIds = parse<std::vector<std::string> > (value);
614 std::vector<GNEEdge*> parsedEdges;
615 parsedEdges.reserve(edgeIds.size());
616 for (const auto& edgeID : edgeIds) {
617 const auto edge = net->getAttributeCarriers()->retrieveEdge(edgeID, false);
618 if (edge == nullptr) {
619 return false;
620 } else if (checkConsecutivity) {
621 if ((parsedEdges.size() > 0) && (parsedEdges.back()->getToJunction() != edge->getFromJunction())) {
622 return false;
623 }
624 parsedEdges.push_back(edge);
625 }
626 }
627 return true;
628}
629
630
631template<> bool
632GNEAttributeCarrier::canParse<std::vector<GNELane*> >(const GNENet* net, const std::string& value, const bool checkConsecutivity) {
633 // Declare string vector
634 const auto laneIds = parse<std::vector<std::string> > (value);
635 std::vector<GNELane*> parsedLanes;
636 parsedLanes.reserve(laneIds.size());
637 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
638 for (const auto& laneID : laneIds) {
639 const auto lane = net->getAttributeCarriers()->retrieveLane(laneID, false);
640 if (lane == nullptr) {
641 return false;
642 } else if (checkConsecutivity) {
643 if ((parsedLanes.size() > 0) && (parsedLanes.back()->getParentEdge()->getToJunction() != lane->getParentEdge()->getFromJunction())) {
644 return false;
645 }
646 parsedLanes.push_back(lane);
647 }
648 }
649 return true;
650}
651
652// parse (network) functions
653
654template<> std::vector<GNEEdge*>
655GNEAttributeCarrier::parse(const GNENet* net, const std::string& value) {
656 // Declare string vector
657 const auto edgeIds = parse<std::vector<std::string> > (value);
658 std::vector<GNEEdge*> parsedEdges;
659 parsedEdges.reserve(edgeIds.size());
660 // Iterate over edges IDs, retrieve Edges and add it into parsedEdges
661 for (const auto& edgeID : edgeIds) {
662 parsedEdges.push_back(net->getAttributeCarriers()->retrieveEdge(edgeID));
663 }
664 return parsedEdges;
665}
666
667
668template<> std::vector<GNELane*>
669GNEAttributeCarrier::parse(const GNENet* net, const std::string& value) {
670 // Declare string vector
671 const auto laneIds = parse<std::vector<std::string> > (value);
672 std::vector<GNELane*> parsedLanes;
673 parsedLanes.reserve(laneIds.size());
674 // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes
675 for (const auto& laneID : laneIds) {
676 parsedLanes.push_back(net->getAttributeCarriers()->retrieveLane(laneID));
677 }
678 return parsedLanes;
679}
680
681// parse ID functions
682
683template<> std::string
684GNEAttributeCarrier::parseIDs(const std::vector<GNEEdge*>& ACs) {
685 // obtain ID's of edges and return their join
686 std::vector<std::string> edgeIDs;
687 for (const auto& AC : ACs) {
688 edgeIDs.push_back(AC->getID());
689 }
690 return joinToString(edgeIDs, " ");
691}
692
693
694template<> std::string
695GNEAttributeCarrier::parseIDs(const std::vector<GNELane*>& ACs) {
696 // obtain ID's of lanes and return their join
697 std::vector<std::string> laneIDs;
698 for (const auto& AC : ACs) {
699 laneIDs.push_back(AC->getID());
700 }
701 return joinToString(laneIDs, " ");
702}
703
704void
705GNEAttributeCarrier::setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters) {
706 // declare result string
707 std::string paramsStr;
708 // Generate an string using the following structure: "key1=value1|key2=value2|...
709 for (const auto& parameter : parameters) {
710 paramsStr += parameter.first + "=" + parameter.second + "|";
711 }
712 // remove the last "|"
713 if (!paramsStr.empty()) {
714 paramsStr.pop_back();
715 }
716 // set parameters
718}
719
720
721void
722GNEAttributeCarrier::setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList) {
723 // declare parametersMap
724 Parameterised::Map parametersMap;
725 // Generate an string using the following structure: "key1=value1|key2=value2|...
726 for (const auto& parameter : parameters) {
727 parametersMap[parameter.first] = parameter.second;
728 }
729 // set setACParameters map
730 setACParameters(parametersMap, undoList);
731}
732
733
734void
736 // declare result string
737 std::string paramsStr;
738 // Generate an string using the following structure: "key1=value1|key2=value2|...
739 for (const auto& parameter : parameters) {
740 paramsStr += parameter.first + "=" + parameter.second + "|";
741 }
742 // remove the last "|"
743 if (!paramsStr.empty()) {
744 paramsStr.pop_back();
745 }
746 // set parameters
747 setAttribute(GNE_ATTR_PARAMETERS, paramsStr, undoList);
748}
749
750
751std::string
753 switch (key) {
754 // Crossings
757 return "No TLS";
758 // connections
759 case SUMO_ATTR_DIR: {
760 // special case for connection directions
761 std::string direction = getAttribute(key);
762 if (direction == "s") {
763 return "Straight (s)";
764 } else if (direction == "t") {
765 return "Turn (t))";
766 } else if (direction == "l") {
767 return "Left (l)";
768 } else if (direction == "r") {
769 return "Right (r)";
770 } else if (direction == "L") {
771 return "Partially left (L)";
772 } else if (direction == "R") {
773 return "Partially right (R)";
774 } else if (direction == "invalid") {
775 return "No direction (Invalid))";
776 } else {
777 return "undefined";
778 }
779 }
780 case SUMO_ATTR_STATE: {
781 // special case for connection states
782 std::string state = getAttribute(key);
783 if (state == "-") {
784 return "Dead end (-)";
785 } else if (state == "=") {
786 return "equal (=)";
787 } else if (state == "m") {
788 return "Minor link (m)";
789 } else if (state == "M") {
790 return "Major link (M)";
791 } else if (state == "O") {
792 return "TLS controller off (O)";
793 } else if (state == "o") {
794 return "TLS yellow flashing (o)";
795 } else if (state == "y") {
796 return "TLS yellow minor link (y)";
797 } else if (state == "Y") {
798 return "TLS yellow major link (Y)";
799 } else if (state == "r") {
800 return "TLS red (r)";
801 } else if (state == "g") {
802 return "TLS green minor (g)";
803 } else if (state == "G") {
804 return "TLS green major (G)";
805 } else if (state == "Z") {
806 return "Zipper (Z)";
807 } else {
808 return "undefined";
809 }
810 }
811 default:
812 return getAttribute(key);
813 }
814}
815
816
817std::string
821
822
823const std::string&
827
828
829FXIcon*
831 // special case for vClass icons
832 if (myTagProperty->vClassIcon()) {
834 } else {
836 }
837}
838
839
840bool
844
845
846const GNETagProperties*
850
851
852std::string
854 switch (key) {
856 if (myFileBucket) {
857 return getFileBucket()->getFilename();
858 } else {
859 return TL("Parent filename");
860 }
864 if (mySelected) {
865 return TRUE_STR;
866 } else {
867 return FALSE_STR;
868 }
870 if (myDrawInFront) {
871 return TRUE_STR;
872 } else {
873 return FALSE_STR;
874 }
876 if (getParameters()) {
878 } else {
879 throw InvalidArgument(getTagStr() + " doesn't support parameters");
880 }
881 default:
882 throw InvalidArgument(getTagStr() + " doesn't have a common attribute of type '" + toString(key) + "'");
883 }
884}
885
886
887double
889 throw InvalidArgument(getTagStr() + " doesn't have a common double attribute of type '" + toString(key) + "'");
890}
891
892
895 throw InvalidArgument(getTagStr() + " doesn't have a common position attribute of type '" + toString(key) + "'");
896}
897
898
901 throw InvalidArgument(getTagStr() + " doesn't have a common positionVector attribute of type '" + toString(key) + "'");
902}
903
904
905void
906GNEAttributeCarrier::setCommonAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
907 switch (key) {
912 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
913 break;
914 default:
915 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
916 }
917}
918
919
920bool
921GNEAttributeCarrier::isCommonAttributeValid(SumoXMLAttr key, const std::string& value) const {
922 switch (key) {
926 } else {
927 return false;
928 }
931 return canParse<bool>(value);
934 default:
935 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
936 }
937}
938
939
940void
942 switch (key) {
945 break;
947 myCenterAfterCreation = parse<bool>(value);
948 break;
950 if (parse<bool>(value)) {
952 } else {
954 }
955 break;
957 if (getParameters()) {
959 } else {
960 throw InvalidArgument(getTagStr() + " doesn't support parameters");
961 }
962 break;
963 default:
964 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
965 }
966}
967
968// ===========================================================================
969// private
970// ===========================================================================
971
972void
973GNEAttributeCarrier::toggleAttribute(SumoXMLAttr /*key*/, const bool /*value*/) {
974 throw ProcessError(TL("Nothing to toggle, implement in Children"));
975}
976
977/****************************************************************************/
@ 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:47
bool isTime(const std::string &r)
check if the given string is a valid time
Definition SUMOTime.cpp:70
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:322
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
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
virtual void setFileBucket(FileBucket *fileBucket)
set reference to fileBucket in which save this AC
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:214
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition RGBColor.cpp:267
static bool isColor(std::string coldef)
check if the given string can be parsed to color
Definition RGBColor.cpp:357
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