61 if (myTagProperty->isAdditionalElement()) {
62 net->getSavingFilesHandler()->addAdditionalFilename(this);
64 net->getSavingFilesHandler()->addDemandFilename(this);
66 net->getSavingFilesHandler()->addDataFilename(this);
68 net->getSavingFilesHandler()->addMeanDataFilename(this);
72 if (myTagProperty->isAdditionalElement() && (net->getSavingFilesHandler()->getAdditionalFilenames().size() > 0)) {
73 myFilename = net->getSavingFilesHandler()->getAdditionalFilenames().front();
74 }
else if (myTagProperty->isDemandElement() && (net->getSavingFilesHandler()->getDemandFilenames().size() > 0)) {
75 myFilename = net->getSavingFilesHandler()->getDemandFilenames().front();
76 }
else if (myTagProperty->isDataElement() && (net->getSavingFilesHandler()->getDataFilenames().size() > 0)) {
77 myFilename = net->getSavingFilesHandler()->getDataFilenames().front();
78 }
else if (myTagProperty->isMeanData() && (net->getSavingFilesHandler()->getMeanDataFilenames().size() > 0)) {
79 myFilename = net->getSavingFilesHandler()->getMeanDataFilenames().front();
147 if (networkElement &&
myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
149 }
else if (
myTagProperty->isDemandElement() &&
myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
151 }
else if (
myTagProperty->isGenericData() &&
myNet->getViewNet()->getEditModes().isCurrentSupermodeData()) {
165 const auto& modes =
myNet->getViewNet()->getEditModes();
167 if (!
myNet->getViewNet()->getMouseButtonKeyPressed().shiftKeyPressed()) {
181 myNet->getViewNet()->getMarkFrontElements().markAC(
this);
188 myNet->getViewNet()->getMarkFrontElements().unmarkAC(
this);
204 glTranslated(0, 0, typeOrLayer + extraOffset);
223 return myNet->getViewNet()->getInspectedElements().isACInspected(
this);
237 const auto undoList =
myNet->getViewNet()->getUndoList();
239 for (
const auto& attrProperty :
myTagProperty->getAttributeProperties()) {
240 if (!attrProperty->isUnique() && attrProperty->hasDefaultValue()) {
241 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue(), undoList);
242 if (attrProperty->isActivatable()) {
243 if (attrProperty->getDefaultActivated()) {
254 for (
const auto& attrProperty :
myTagProperty->getAttributeProperties()) {
255 if (attrProperty->hasDefaultValue()) {
256 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue());
257 if (attrProperty->isActivatable()) {
258 toggleAttribute(attrProperty->getAttr(), attrProperty->getDefaultActivated());
268 throw ProcessError(
TL(
"Nothing to enable, implement in Children"));
275 throw ProcessError(
TL(
"Nothing to disable, implement in Children"));
302 if (
string ==
"INVALID_INT") {
312 if (
string ==
"INVALID_DOUBLE") {
360 if (
string.empty()) {
378 if (
string.empty()) {
382 for (
const auto&
value : values) {
383 if (!canParse<int>(
value)) {
393 if (
string.empty()) {
397 for (
const auto&
value : values) {
398 if (!canParse<double>(
value)) {
408 if (
string.empty()) {
412 for (
const auto&
value : values) {
413 if (!canParse<bool>(
value)) {
423 if (
string.empty()) {
427 for (
const auto&
value : values) {
428 if (!canParse<SumoXMLAttr>(
value)) {
439 if (
string ==
"INVALID_INT") {
449 if (
string ==
"INVALID_DOUBLE") {
471 if (
string.size() == 0) {
483 if (
string.empty()) {
494 if (
string.size() == 0) {
499 if (!ok || (pos.size() != 1)) {
512 if (
string.empty()) {
528 if (
string.empty()) {
536template<> std::vector<std::string>
542template<> std::set<std::string>
545 std::set<std::string> solution;
546 for (
const auto& stringValue : vectorString) {
547 solution.insert(stringValue);
553template<> std::vector<int>
556 std::vector<int> parsedIntValues;
557 for (
const auto& intValue : vectorInt) {
558 parsedIntValues.push_back(
parse<int>(intValue));
560 return parsedIntValues;
564template<> std::vector<double>
567 std::vector<double> parsedDoubleValues;
568 for (
const auto& doubleValue : vectorDouble) {
571 return parsedDoubleValues;
575template<> std::vector<bool>
578 std::vector<bool> parsedBoolValues;
579 for (
const auto& boolValue : vectorBool) {
580 parsedBoolValues.push_back(
parse<bool>(boolValue));
582 return parsedBoolValues;
586template<> std::vector<SumoXMLAttr>
590 std::vector<SumoXMLAttr> attributes;
592 for (
const auto& attributeStr : attributesStr) {
596 throw FormatException(
"Error parsing attributes. Attribute '" + attributeStr +
"' doesn't exist");
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) {
614 }
else if (checkConsecutivity) {
615 if ((parsedEdges.size() > 0) && (parsedEdges.back()->getToJunction() != edge->getFromJunction())) {
618 parsedEdges.push_back(edge);
628 const auto laneIds = parse<std::vector<std::string> > (
value);
629 std::vector<GNELane*> parsedLanes;
630 parsedLanes.reserve(laneIds.size());
632 for (
const auto& laneID : laneIds) {
633 const auto lane = net->getAttributeCarriers()->retrieveLane(laneID,
false);
634 if (lane ==
nullptr) {
636 }
else if (checkConsecutivity) {
637 if ((parsedLanes.size() > 0) && (parsedLanes.back()->getParentEdge()->getToJunction() != lane->getParentEdge()->getFromJunction())) {
640 parsedLanes.push_back(lane);
648template<> std::vector<GNEEdge*>
652 std::vector<GNEEdge*> parsedEdges;
653 parsedEdges.reserve(edgeIds.size());
655 for (
const auto& edgeID : edgeIds) {
662template<> std::vector<GNELane*>
666 std::vector<GNELane*> parsedLanes;
667 parsedLanes.reserve(laneIds.size());
669 for (
const auto& laneID : laneIds) {
677template<> std::string
680 std::vector<std::string> edgeIDs;
681 for (
const auto& AC : ACs) {
682 edgeIDs.push_back(AC->getID());
688template<> std::string
691 std::vector<std::string> laneIDs;
692 for (
const auto& AC : ACs) {
693 laneIDs.push_back(AC->getID());
701 std::string paramsStr;
703 for (
const auto& parameter : parameters) {
704 paramsStr += parameter.first +
"=" + parameter.second +
"|";
707 if (!paramsStr.empty()) {
708 paramsStr.pop_back();
720 for (
const auto& parameter : parameters) {
721 parametersMap[parameter.first] = parameter.second;
731 std::string paramsStr;
733 for (
const auto& parameter : parameters) {
734 paramsStr += parameter.first +
"=" + parameter.second +
"|";
737 if (!paramsStr.empty()) {
738 paramsStr.pop_back();
756 if (direction ==
"s") {
757 return "Straight (s)";
758 }
else if (direction ==
"t") {
760 }
else if (direction ==
"l") {
762 }
else if (direction ==
"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))";
778 return "Dead end (-)";
779 }
else if (state ==
"=") {
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") {
905 additionalChild->setAttribute(key,
value, undoList);
912 demandChild->setAttribute(key,
myFilename, undoList);
954 if (
myNet->getSavingFilesHandler()->getAdditionalFilenames().size() > 0) {
955 myFilename =
myNet->getSavingFilesHandler()->getAdditionalFilenames().front();
958 myNet->getSavingFilesHandler()->addAdditionalFilename(
this);
965 if (
myNet->getSavingFilesHandler()->getDemandFilenames().size() > 0) {
966 myFilename =
myNet->getSavingFilesHandler()->getDemandFilenames().front();
969 myNet->getSavingFilesHandler()->addDemandFilename(
this);
976 if (
myNet->getSavingFilesHandler()->getDataFilenames().size() > 0) {
977 myFilename =
myNet->getSavingFilesHandler()->getDataFilenames().front();
980 myNet->getSavingFilesHandler()->addDataFilename(
this);
987 if (
myNet->getSavingFilesHandler()->getMeanDataFilenames().size() > 0) {
988 myFilename =
myNet->getSavingFilesHandler()->getMeanDataFilenames().front();
991 myNet->getSavingFilesHandler()->addMeanDataFilename(
this);
1022 throw ProcessError(
TL(
"Nothing to toggle, implement in Children"));
@ NETWORK_MOVE
mode for moving network elements
@ DEMAND_MOVE
mode for moving demand elements
@ GLO_FRONTELEMENT
front element (used in netedit)
GUISelectedStorage gSelected
A global holder of selected objects.
const std::string invalid_return< std::string >::value
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
bool isTime(const std::string &r)
check if the given string is a valid time
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SUMOVehicleShape::UNKNOWN, false)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
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.
@ GNE_ATTR_MEANDATA_FILE
meanData data file
@ GNE_ATTR_DEMAND_FILE
demand demand file
@ 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_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ GNE_ATTR_ADDITIONAL_FILE
additional save file
@ GNE_ATTR_DATA_FILE
data data file
@ 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
const int INVALID_INT
invalid int
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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
double getCommonAttributeDouble(SumoXMLAttr key) const
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
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)
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
std::string myFilename
filename in which save this AC
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 > > ¶meters)
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
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
void resetDefaultValues(const bool allowUndoRedo)
reset attribute carrier to their default values
const std::string & getFilename() const
get filename in which save this AC
bool hasAttribute(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNEAttributeCarrier(const SumoXMLTag tag, GNENet *net, const std::string &filename, const bool isTemplate)
Constructor.
virtual GNEHierarchicalElement * getHierarchicalElement()=0
methods to retrieve the elements linked to this AttributeCarrier
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
void changeDefaultFilename(const std::string &file)
change defaultFilename (only used in SavingFilesHandler)
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
A NBNetBuilder extended by visualisation and editing capabilities.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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 ¶msString, 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.
static const Position INVALID
used to indicate that a position is valid
static const RGBColor INVISIBLE
static RGBColor parseColor(std::string coldef)
Parses a color information.
static bool isColor(std::string coldef)
check if the given string can be parsed to color
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)
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