54 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
57 myIsTemplate(isTemplate) {
204 glTranslated(0, 0, typeOrLayer + extraOffset);
240 if (!attrProperty->isUnique() && attrProperty->hasDefaultValue()) {
241 setAttribute(attrProperty->getAttr(), attrProperty->getDefaultStringValue(), undoList);
242 if (attrProperty->isActivatable()) {
243 if (attrProperty->getDefaultActivated()) {
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"));
301GNEAttributeCarrier::canParse<int>(
const std::string&
string) {
302 if (
string ==
"INVALID_INT") {
311GNEAttributeCarrier::canParse<double>(
const std::string&
string) {
312 if (
string ==
"INVALID_DOUBLE") {
321GNEAttributeCarrier::canParse<SUMOTime>(
const std::string&
string) {
327GNEAttributeCarrier::canParse<bool>(
const std::string&
string) {
333GNEAttributeCarrier::canParse<Position>(
const std::string&
string) {
341GNEAttributeCarrier::canParse<SUMOVehicleClass>(
const std::string&
string) {
347GNEAttributeCarrier::canParse<RGBColor>(
const std::string&
string) {
353GNEAttributeCarrier::canParse<SumoXMLAttr>(
const std::string&
string) {
359GNEAttributeCarrier::canParse<SUMOVehicleShape>(
const std::string&
string) {
360 if (
string.empty()) {
369GNEAttributeCarrier::canParse<PositionVector>(
const std::string&
string) {
377GNEAttributeCarrier::canParse<std::vector<int> >(
const std::string& string) {
378 if (
string.empty()) {
382 for (
const auto& value : values) {
383 if (!canParse<int>(value)) {
392GNEAttributeCarrier::canParse<std::vector<double> >(
const std::string& string) {
393 if (
string.empty()) {
397 for (
const auto& value : values) {
398 if (!canParse<double>(value)) {
407GNEAttributeCarrier::canParse<std::vector<bool> >(
const std::string& string) {
408 if (
string.empty()) {
412 for (
const auto& value : values) {
413 if (!canParse<bool>(value)) {
422GNEAttributeCarrier::canParse<std::vector<SumoXMLAttr> >(
const std::string& string) {
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>
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));
560 return parsedIntValues;
564template<> std::vector<double>
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));
571 return parsedDoubleValues;
575template<> std::vector<bool>
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));
582 return parsedBoolValues;
586template<> std::vector<SumoXMLAttr>
589 const auto attributesStr = parse<std::vector<std::string> > (value);
590 std::vector<SumoXMLAttr> attributes;
592 for (
const auto& attributeStr : attributesStr) {
596 throw FormatException(
"Error parsing attributes. Attribute '" + attributeStr +
"' doesn't exist");
605GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
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);
626GNEAttributeCarrier::canParse<std::vector<GNELane*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
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*>
651 const auto edgeIds = parse<std::vector<std::string> > (value);
652 std::vector<GNEEdge*> parsedEdges;
653 parsedEdges.reserve(edgeIds.size());
655 for (
const auto& edgeID : edgeIds) {
662template<> std::vector<GNELane*>
665 const auto laneIds = parse<std::vector<std::string> > (value);
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);
938 return canParse<bool>(value);
998 if (parse<bool>(value)) {
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.
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
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
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 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
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
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
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
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.
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
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