56 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
80 myTagProperty(net->getTagPropertiesDatabase()->getTagProperty(tag, true)),
82 myFileBucket(fileBucket) {
202 glTranslated(0, 0, typeOrLayer + extraOffset);
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()) {
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());
266 throw ProcessError(
TL(
"Nothing to enable, implement in Children"));
273 throw ProcessError(
TL(
"Nothing to disable, implement in Children"));
307GNEAttributeCarrier::canParse<int>(
const std::string&
string) {
308 if (
string ==
"INVALID_INT") {
317GNEAttributeCarrier::canParse<double>(
const std::string&
string) {
318 if (
string ==
"INVALID_DOUBLE") {
327GNEAttributeCarrier::canParse<SUMOTime>(
const std::string&
string) {
333GNEAttributeCarrier::canParse<bool>(
const std::string&
string) {
339GNEAttributeCarrier::canParse<Position>(
const std::string&
string) {
347GNEAttributeCarrier::canParse<SUMOVehicleClass>(
const std::string&
string) {
353GNEAttributeCarrier::canParse<RGBColor>(
const std::string&
string) {
359GNEAttributeCarrier::canParse<SumoXMLAttr>(
const std::string&
string) {
365GNEAttributeCarrier::canParse<SUMOVehicleShape>(
const std::string&
string) {
366 if (
string.empty()) {
375GNEAttributeCarrier::canParse<PositionVector>(
const std::string&
string) {
383GNEAttributeCarrier::canParse<std::vector<int> >(
const std::string& string) {
384 if (
string.empty()) {
388 for (
const auto& value : values) {
389 if (!canParse<int>(value)) {
398GNEAttributeCarrier::canParse<std::vector<double> >(
const std::string& string) {
399 if (
string.empty()) {
403 for (
const auto& value : values) {
404 if (!canParse<double>(value)) {
413GNEAttributeCarrier::canParse<std::vector<bool> >(
const std::string& string) {
414 if (
string.empty()) {
418 for (
const auto& value : values) {
419 if (!canParse<bool>(value)) {
428GNEAttributeCarrier::canParse<std::vector<SumoXMLAttr> >(
const std::string& string) {
429 if (
string.empty()) {
433 for (
const auto& value : values) {
434 if (!canParse<SumoXMLAttr>(value)) {
445 if (
string ==
"INVALID_INT") {
455 if (
string ==
"INVALID_DOUBLE") {
477 if (
string.size() == 0) {
489 if (
string.empty()) {
500 if (
string.size() == 0) {
505 if (!ok || (pos.size() != 1)) {
518 if (
string.empty()) {
534 if (
string.empty()) {
542template<> std::vector<std::string>
548template<> std::set<std::string>
551 std::set<std::string> solution;
552 for (
const auto& stringValue : vectorString) {
553 solution.insert(stringValue);
559template<> std::vector<int>
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));
566 return parsedIntValues;
570template<> std::vector<double>
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));
577 return parsedDoubleValues;
581template<> std::vector<bool>
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));
588 return parsedBoolValues;
592template<> std::vector<SumoXMLAttr>
595 const auto attributesStr = parse<std::vector<std::string> > (value);
596 std::vector<SumoXMLAttr> attributes;
598 for (
const auto& attributeStr : attributesStr) {
602 throw FormatException(
"Error parsing attributes. Attribute '" + attributeStr +
"' doesn't exist");
611GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
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) {
620 }
else if (checkConsecutivity) {
621 if ((parsedEdges.size() > 0) && (parsedEdges.back()->getToJunction() != edge->getFromJunction())) {
624 parsedEdges.push_back(edge);
632GNEAttributeCarrier::canParse<std::vector<GNELane*> >(
const GNENet* net,
const std::string& value,
const bool checkConsecutivity) {
634 const auto laneIds = parse<std::vector<std::string> > (value);
635 std::vector<GNELane*> parsedLanes;
636 parsedLanes.reserve(laneIds.size());
638 for (
const auto& laneID : laneIds) {
639 const auto lane = net->getAttributeCarriers()->retrieveLane(laneID,
false);
640 if (lane ==
nullptr) {
642 }
else if (checkConsecutivity) {
643 if ((parsedLanes.size() > 0) && (parsedLanes.back()->getParentEdge()->getToJunction() != lane->getParentEdge()->getFromJunction())) {
646 parsedLanes.push_back(lane);
654template<> std::vector<GNEEdge*>
657 const auto edgeIds = parse<std::vector<std::string> > (value);
658 std::vector<GNEEdge*> parsedEdges;
659 parsedEdges.reserve(edgeIds.size());
661 for (
const auto& edgeID : edgeIds) {
668template<> std::vector<GNELane*>
671 const auto laneIds = parse<std::vector<std::string> > (value);
672 std::vector<GNELane*> parsedLanes;
673 parsedLanes.reserve(laneIds.size());
675 for (
const auto& laneID : laneIds) {
683template<> std::string
686 std::vector<std::string> edgeIDs;
687 for (
const auto& AC : ACs) {
688 edgeIDs.push_back(AC->getID());
694template<> std::string
697 std::vector<std::string> laneIDs;
698 for (
const auto& AC : ACs) {
699 laneIDs.push_back(AC->getID());
707 std::string paramsStr;
709 for (
const auto& parameter : parameters) {
710 paramsStr += parameter.first +
"=" + parameter.second +
"|";
713 if (!paramsStr.empty()) {
714 paramsStr.pop_back();
726 for (
const auto& parameter : parameters) {
727 parametersMap[parameter.first] = parameter.second;
737 std::string paramsStr;
739 for (
const auto& parameter : parameters) {
740 paramsStr += parameter.first +
"=" + parameter.second +
"|";
743 if (!paramsStr.empty()) {
744 paramsStr.pop_back();
762 if (direction ==
"s") {
763 return "Straight (s)";
764 }
else if (direction ==
"t") {
766 }
else if (direction ==
"l") {
768 }
else if (direction ==
"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))";
784 return "Dead end (-)";
785 }
else if (state ==
"=") {
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") {
859 return TL(
"Parent filename");
931 return canParse<bool>(value);
950 if (parse<bool>(value)) {
974 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.
@ 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_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)
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)
void selectAttributeCarrier()
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 > > ¶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
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
GNEApplicationWindow * getGNEApplicationWindow() const
get tag properties database
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
GNEViewNet * getViewNet() const
get view net (used for simplify code)
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 ¶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