56 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
59 myIsTemplate(isTemplate) {
188 glTranslated(0, 0, typeOrLayer + extraOffset);
224 if (!attrProperty->isUnique() && attrProperty->hasDefaultValue()) {
225 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue(), undoList);
226 if (attrProperty->isActivatable()) {
227 if (attrProperty->getDefaultActivated()) {
239 if (attrProperty->hasDefaultValue()) {
240 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue());
241 if (attrProperty->isActivatable()) {
242 toggleAttribute(attrProperty->getAttr(), attrProperty->getDefaultActivated());
252 throw ProcessError(
TL(
"Nothing to enable, implement in Children"));
259 throw ProcessError(
TL(
"Nothing to disable, implement in Children"));
285GNEAttributeCarrier::canParse<int>(
const std::string&
string) {
286 if (
string ==
"INVALID_INT") {
295GNEAttributeCarrier::canParse<double>(
const std::string&
string) {
296 if (
string ==
"INVALID_DOUBLE") {
305GNEAttributeCarrier::canParse<SUMOTime>(
const std::string&
string) {
311GNEAttributeCarrier::canParse<bool>(
const std::string&
string) {
317GNEAttributeCarrier::canParse<Position>(
const std::string&
string) {
325GNEAttributeCarrier::canParse<SUMOVehicleClass>(
const std::string&
string) {
331GNEAttributeCarrier::canParse<RGBColor>(
const std::string&
string) {
337GNEAttributeCarrier::canParse<SumoXMLAttr>(
const std::string&
string) {
343GNEAttributeCarrier::canParse<SUMOVehicleShape>(
const std::string&
string) {
344 if (
string.empty()) {
353GNEAttributeCarrier::canParse<PositionVector>(
const std::string&
string) {
361GNEAttributeCarrier::canParse<std::vector<int> >(
const std::string& string) {
362 if (
string.empty()) {
366 for (
const auto& value : values) {
367 if (!canParse<int>(value)) {
376GNEAttributeCarrier::canParse<std::vector<double> >(
const std::string& string) {
377 if (
string.empty()) {
381 for (
const auto& value : values) {
382 if (!canParse<double>(value)) {
391GNEAttributeCarrier::canParse<std::vector<bool> >(
const std::string& string) {
392 if (
string.empty()) {
396 for (
const auto& value : values) {
397 if (!canParse<bool>(value)) {
406GNEAttributeCarrier::canParse<std::vector<SumoXMLAttr> >(
const std::string& string) {
407 if (
string.empty()) {
411 for (
const auto& value : values) {
412 if (!canParse<SumoXMLAttr>(value)) {
423 if (
string ==
"INVALID_INT") {
433 if (
string ==
"INVALID_DOUBLE") {
455 if (
string.size() == 0) {
467 if (
string.empty()) {
478 if (
string.size() == 0) {
483 if (!ok || (pos.size() != 1)) {
496 if (
string.empty()) {
512 if (
string.empty()) {
520template<> std::vector<std::string>
526template<> std::set<std::string>
529 std::set<std::string> solution;
530 for (
const auto& stringValue : vectorString) {
531 solution.insert(stringValue);
537template<> std::vector<int>
539 const auto vectorInt = parse<std::vector<std::string> >(string);
540 std::vector<int> parsedIntValues;
541 for (
const auto& intValue : vectorInt) {
542 parsedIntValues.push_back(parse<int>(intValue));
544 return parsedIntValues;
548template<> std::vector<double>
550 const auto vectorDouble = parse<std::vector<std::string> >(string);
551 std::vector<double> parsedDoubleValues;
552 for (
const auto& doubleValue : vectorDouble) {
553 parsedDoubleValues.push_back(parse<double>(doubleValue));
555 return parsedDoubleValues;
559template<> std::vector<bool>
561 const auto vectorBool = parse<std::vector<std::string> >(string);
562 std::vector<bool> parsedBoolValues;
563 for (
const auto& boolValue : vectorBool) {
564 parsedBoolValues.push_back(parse<bool>(boolValue));
566 return parsedBoolValues;
570template<> std::vector<SumoXMLAttr>
573 const auto attributesStr = parse<std::vector<std::string> > (value);
574 std::vector<SumoXMLAttr> attributes;
576 for (
const auto& attributeStr : attributesStr) {
580 throw FormatException(
"Error parsing attributes. Attribute '" + attributeStr +
"' doesn't exist");
589GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
591 const auto edgeIds = parse<std::vector<std::string> > (value);
592 std::vector<GNEEdge*> parsedEdges;
593 parsedEdges.reserve(edgeIds.size());
594 for (
const auto& edgeID : edgeIds) {
595 const auto edge = net->getAttributeCarriers()->retrieveEdge(edgeID,
false);
596 if (edge ==
nullptr) {
598 }
else if (checkConsecutivity) {
599 if ((parsedEdges.size() > 0) && (parsedEdges.back()->getToJunction() != edge->getFromJunction())) {
602 parsedEdges.push_back(edge);
610GNEAttributeCarrier::canParse<std::vector<GNELane*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
612 const auto laneIds = parse<std::vector<std::string> > (value);
613 std::vector<GNELane*> parsedLanes;
614 parsedLanes.reserve(laneIds.size());
616 for (
const auto& laneID : laneIds) {
617 const auto lane = net->getAttributeCarriers()->retrieveLane(laneID,
false);
618 if (lane ==
nullptr) {
620 }
else if (checkConsecutivity) {
621 if ((parsedLanes.size() > 0) && (parsedLanes.back()->getParentEdge()->getToJunction() != lane->getParentEdge()->getFromJunction())) {
624 parsedLanes.push_back(lane);
632template<> std::vector<GNEEdge*>
635 const auto edgeIds = parse<std::vector<std::string> > (value);
636 std::vector<GNEEdge*> parsedEdges;
637 parsedEdges.reserve(edgeIds.size());
639 for (
const auto& edgeID : edgeIds) {
646template<> std::vector<GNELane*>
649 const auto laneIds = parse<std::vector<std::string> > (value);
650 std::vector<GNELane*> parsedLanes;
651 parsedLanes.reserve(laneIds.size());
653 for (
const auto& laneID : laneIds) {
661template<> std::string
664 std::vector<std::string> edgeIDs;
665 for (
const auto& AC : ACs) {
666 edgeIDs.push_back(AC->getID());
672template<> std::string
675 std::vector<std::string> laneIDs;
676 for (
const auto& AC : ACs) {
677 laneIDs.push_back(AC->getID());
683template<> std::string
688 result += parameter.first +
"=" + parameter.second +
"|";
691 if (!result.empty()) {
698template<> std::vector<std::pair<std::string, std::string> >
700 std::vector<std::pair<std::string, std::string> > result;
703 result.push_back(std::make_pair(parameter.first, parameter.second));
716 while (parametersTokenizer.
hasNext()) {
719 if (keyValue.size() == 2) {
720 parametersMap[keyValue.front()] = keyValue.back();
733 for (
const auto& parameter : parameters) {
734 parametersMap[parameter.first] = parameter.second;
744 std::string paramsStr;
746 for (
const auto& parameter : parameters) {
747 paramsStr += parameter.first +
"=" + parameter.second +
"|";
750 if (!paramsStr.empty()) {
751 paramsStr.pop_back();
763 parametersMap[key] = attribute;
776 if (std::find(keepKeys.begin(), keepKeys.end(), parameter.first) != keepKeys.end()) {
777 newParametersMap.insert(parameter);
796 if (direction ==
"s") {
797 return "Straight (s)";
798 }
else if (direction ==
"t") {
800 }
else if (direction ==
"l") {
802 }
else if (direction ==
"r") {
804 }
else if (direction ==
"L") {
805 return "Partially left (L)";
806 }
else if (direction ==
"R") {
807 return "Partially right (R)";
808 }
else if (direction ==
"invalid") {
809 return "No direction (Invalid))";
818 return "Dead end (-)";
819 }
else if (state ==
"=") {
821 }
else if (state ==
"m") {
822 return "Minor link (m)";
823 }
else if (state ==
"M") {
824 return "Major link (M)";
825 }
else if (state ==
"O") {
826 return "TLS controller off (O)";
827 }
else if (state ==
"o") {
828 return "TLS yellow flashing (o)";
829 }
else if (state ==
"y") {
830 return "TLS yellow minor link (y)";
831 }
else if (state ==
"Y") {
832 return "TLS yellow major link (Y)";
833 }
else if (state ==
"r") {
834 return "TLS red (r)";
835 }
else if (state ==
"g") {
836 return "TLS green minor (g)";
837 }
else if (state ==
"G") {
838 return "TLS green major (G)";
839 }
else if (state ==
"Z") {
891 throw ProcessError(
TL(
"Nothing to toggle, implement in Children"));
932 additionalChild->setAttribute(key, value, undoList);
939 demandChild->setAttribute(key,
myFilename, undoList);
965 return canParse<bool>(value);
1001 if (value.empty()) {
1012 if (value.empty()) {
1025 if (parse<bool>(value)) {
@ GLO_FRONTELEMENT
front element (used in netedit)
GUISelectedStorage gSelected
A global holder of selected objects.
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)
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void markForDrawingFront()
mark for drawing front
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
static const std::string LANE_START
lane start
void setInGrid(bool value)
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)
void setACParameters(const std::string ¶meters, GNEUndoList *undoList)
set parameters (string)
bool checkDrawFrontContour() const
check if draw front contour (green/blue)
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 LANE_END
lane end
static const std::string FEATURE_LOADED
feature is still unchanged after being loaded (implies approval)
std::string getCommonAttribute(const Parameterised *parameterised, SumoXMLAttr key) const
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....
bool myInGrid
boolean to check if this AC is in grid
std::string getAlternativeValueForDisabledAttributes(SumoXMLAttr key) const
virtual bool isAttributeComputed(SumoXMLAttr key) const
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
std::string myFilename
filename in which save this AC
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
void removeACParametersKeys(const std::vector< std::string > &keepKeys, GNEUndoList *undoList)
remove keys
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
virtual const Parameterised::Map & getACParametersMap() const =0
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
void addACParameters(const std::string &key, const std::string &attribute, GNEUndoList *undoList)
add (or update attribute) key and attribute
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
get GNEHierarchicalElement associated with this AttributeCarrier
GNENet * myNet
pointer to net
bool inGrid() const
check if this AC was inserted in grid
void unmarkForDrawingFront()
unmark for drawing front
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
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)
static const std::string False
true value in string format(used for comparing boolean values in getAttribute(...))
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
T getACParameters() const
get parameters
virtual ~GNEAttributeCarrier()
Destructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool checkDrawInspectContour() const
check if draw inspect contour (black/white)
virtual GUIGlObject * getGUIGlObject()=0
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
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
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
const std::vector< std::string > & getAdditionalFilenames() const
get vector with additional elements saving files (starting with default)
void addDataFilename(const GNEAttributeCarrier *dataElement)
data elements
void addMeanDataFilename(const GNEAttributeCarrier *meanDataElement)
meanData elements
const std::vector< std::string > & getDemandFilenames() const
get vector with demand elements saving files (starting with default)
const std::vector< std::string > & getMeanDataFilenames() const
get vector with meanData elements saving files (starting with default)
const std::vector< std::string > & getDataFilenames() const
get vector with data elements saving files (starting with default)
void addDemandFilename(const GNEAttributeCarrier *demandElement)
demand elements
void addAdditionalFilename(const GNEAttributeCarrier *additionalElement)
additional elements
A NBNetBuilder extended by visualisation and editing capabilities.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
GNENetHelper::SavingFilesHandler * getSavingFilesHandler() const
get saving files handler
GNEViewNet * getViewNet() const
get view net
bool isMeanData() const
return true if tag correspond to a mean data element
bool vClassIcon() const
return true if tag correspond to an element that has vClass icons
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 isNetworkElement() const
network elements
bool isDataElement() const
return true if tag correspond to a data element
bool isSelectable() const
return true if tag correspond to a selectable element
GUIIcon getGUIIcon() const
get GUI icon associated to this tag property
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"
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
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
GNEViewNetHelper::MarkFrontElements & getMarkFrontElements()
get marked for drawing front elements
GNEUndoList * getUndoList() const
get the undoList object
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.
An upper class for objects with additional parameters.
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)
bool hasString(const std::string &str) const
std::vector< std::string > getVector()
return vector of strings
bool hasNext()
returns the information whether further substrings exist
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
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