diff --git a/src/netedit/frames/GNEFrameModuls.cpp b/src/netedit/frames/GNEFrameModuls.cpp index 4af751cbe9e4..fed410ca7111 100644 --- a/src/netedit/frames/GNEFrameModuls.cpp +++ b/src/netedit/frames/GNEFrameModuls.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include "GNEFrameModuls.h" @@ -43,7 +45,6 @@ // =========================================================================== FXDEFMAP(GNEFrameModuls::TagSelector) TagSelectorMap[] = { - FXMAPFUNC(SEL_COMMAND, MID_GNE_TAGTYPE_SELECTED, GNEFrameModuls::TagSelector::onCmdSelectTagType), FXMAPFUNC(SEL_COMMAND, MID_GNE_TAG_SELECTED, GNEFrameModuls::TagSelector::onCmdSelectTag) }; @@ -99,11 +100,55 @@ FXIMPLEMENT(GNEFrameModuls::PathCreator, FXGroupBox, PathCrea // GNEFrameModuls::TagSelector - methods // --------------------------------------------------------------------------- -GNEFrameModuls::TagSelector::TagSelector(GNEFrame* frameParent, GNETagProperties::TagType type, bool onlyDrawables) : +GNEFrameModuls::TagSelector::TagSelector(GNEFrame* frameParent, GNETagProperties::TagType type, SumoXMLTag tag, bool onlyDrawables) : FXGroupBox(frameParent->myContentFrame, "Element", GUIDesignGroupBoxFrame), - myFrameParent(frameParent) { - // first check that property is valid - switch (type) { + myFrameParent(frameParent), + myTagType(type), + myCurrentTemplateAC(nullptr) { + // Create MFXIconComboBox + myTagsMatchBox = new MFXIconComboBox(this, GUIDesignComboBoxNCol, this, MID_GNE_TAG_SELECTED, GUIDesignComboBox); + // set current tag type without notifying + setCurrentTagType(myTagType, onlyDrawables, false); + // set current tag without notifying + setCurrentTag(tag, false); + // TagSelector is always shown + show(); +} + + +GNEFrameModuls::TagSelector::~TagSelector() { + // clear myACTemplates and myTagsMatchBox + for (const auto &ACTemplate : myACTemplates) { + delete ACTemplate; + } + myACTemplates.clear(); +} + + +void +GNEFrameModuls::TagSelector::showTagSelector() { + show(); +} + + +void +GNEFrameModuls::TagSelector::hideTagSelector() { + hide(); +} + + +GNEAttributeCarrier* +GNEFrameModuls::TagSelector::getCurrentTemplateAC() const { + return myCurrentTemplateAC; +} + + +void +GNEFrameModuls::TagSelector::setCurrentTagType(GNETagProperties::TagType tagType, const bool onlyDrawables, const bool notifyFrameParent) { + // set new tagType + myTagType = tagType; + // change TagSelector text + switch (myTagType) { case GNETagProperties::TagType::NETWORKELEMENT: setText("network elements"); break; @@ -127,21 +172,12 @@ GNEFrameModuls::TagSelector::TagSelector(GNEFrame* frameParent, GNETagProperties break; case GNETagProperties::TagType::PERSONPLAN: setText("Person plans"); - // person plan type has four sub-groups - myTagTypes.push_back(TagType("person trips", GNETagProperties::TagType::PERSONTRIP, GUIIcon::PERSONTRIP_FROMTO)); - myTagTypes.push_back(TagType("walks", GNETagProperties::TagType::WALK, GUIIcon::WALK_FROMTO)); - myTagTypes.push_back(TagType("rides", GNETagProperties::TagType::RIDE, GUIIcon::RIDE_FROMTO)); - myTagTypes.push_back(TagType("stops", GNETagProperties::TagType::STOPPERSON, GUIIcon::STOPELEMENT)); break; case GNETagProperties::TagType::CONTAINER: setText("Container"); break; case GNETagProperties::TagType::CONTAINERPLAN: setText("Container plans"); - // container plan type has four sub-groups - myTagTypes.push_back(TagType("transport", GNETagProperties::TagType::TRANSPORT, GUIIcon::TRANSHIP_FROMTO)); - myTagTypes.push_back(TagType("tranship", GNETagProperties::TagType::TRANSHIP, GUIIcon::TRANSHIP_FROMTO)); - myTagTypes.push_back(TagType("stops", GNETagProperties::TagType::STOPCONTAINER, GUIIcon::STOPELEMENT)); break; case GNETagProperties::TagType::PERSONTRIP: setText("Person trips"); @@ -158,152 +194,70 @@ GNEFrameModuls::TagSelector::TagSelector(GNEFrame* frameParent, GNETagProperties default: throw ProcessError("invalid tag property"); } - // Create FXComboBox - myTagTypesMatchBox = new MFXIconComboBox(this, GUIDesignComboBoxNCol, this, MID_GNE_TAGTYPE_SELECTED, GUIDesignComboBox); - // Create FXComboBox - myTagsMatchBox = new MFXIconComboBox(this, GUIDesignComboBoxNCol, this, MID_GNE_TAG_SELECTED, GUIDesignComboBox); - // Fill comboBox depending of myTagTypes - if (myTagTypes.size() > 0) { - // fill myTypeMatchBox with list of tags - for (const auto& tagType : myTagTypes) { - myTagTypesMatchBox->appendIconItem(tagType.tag.c_str(), GUIIconSubSys::getIcon(tagType.icon)); - } - // Set visible items - myTagTypesMatchBox->setNumVisible((int)myTagTypesMatchBox->getNumItems()); - // fill myTagPropertiesString with personTrips (the first Tag Type) - myTagPropertiesString = GNEAttributeCarrier::getAllowedTagPropertiesByCategory(type, onlyDrawables); - } else { - myTagTypesMatchBox->hide(); - // fill myTagPropertiesString - myTagPropertiesString = GNEAttributeCarrier::getAllowedTagPropertiesByCategory(type, onlyDrawables); - } - // fill myTypeMatchBox with list of tags - for (const auto& tagIt : myTagPropertiesString) { - myTagsMatchBox->appendIconItem(tagIt.second.c_str(), GUIIconSubSys::getIcon(tagIt.first.getGUIIcon()), tagIt.first.getBackGroundColor()); - } + // clear myACTemplates and myTagsMatchBox + for (const auto &ACTemplate : myACTemplates) { + delete ACTemplate; + } + myACTemplates.clear(); + myTagsMatchBox->clearItems(); + // get tag properties + const auto tagProperties = GNEAttributeCarrier::getAllowedTagPropertiesByCategory(myTagType, onlyDrawables); + // fill myACTemplates and myTagsMatchBox + for (const auto &tagProperty : tagProperties) { + myACTemplates.push_back(new ACTemplate(myFrameParent->getViewNet()->getNet(), tagProperty.first)); + myTagsMatchBox->appendIconItem(tagProperty.first.getTagStr().c_str(), GUIIconSubSys::getIcon(tagProperty.first.getGUIIcon()), tagProperty.first.getBackGroundColor()); + } + // set color of myTypeMatchBox to black (valid) + myTagsMatchBox->setTextColor(FXRGB(0, 0, 0)); // Set visible items myTagsMatchBox->setNumVisible((int)myTagsMatchBox->getNumItems()); - // TagSelector is always shown - show(); -} - - -GNEFrameModuls::TagSelector::~TagSelector() {} - - -void -GNEFrameModuls::TagSelector::showTagSelector() { - show(); -} - - -void -GNEFrameModuls::TagSelector::hideTagSelector() { - hide(); -} - - -const GNETagProperties& -GNEFrameModuls::TagSelector::getCurrentTagProperties() const { - return myCurrentTagProperties; -} - - -void -GNEFrameModuls::TagSelector::setCurrentTagType(GNETagProperties::TagType tagType) { - // set empty tag properties - myCurrentTagProperties = GNETagProperties(); - // make sure that tag is in myTypeMatchBox - for (int i = 0; i < (int)myTagsMatchBox->getNumItems(); i++) { - if (myTagsMatchBox->getItem(i).text() == toString(tagType)) { - myTagsMatchBox->setCurrentItem(i); - // fill myTagPropertiesString with personTrips (the first Tag Type) - myTagPropertiesString = GNEAttributeCarrier::getAllowedTagPropertiesByCategory(tagType, true); - // clear myTagsMatchBox - myTagsMatchBox->clearItems(); - // fill myTypeMatchBox with list of tags - for (const auto& tagIt : myTagPropertiesString) { - myTagsMatchBox->appendIconItem(tagIt.second.c_str(), GUIIconSubSys::getIcon(tagIt.first.getGUIIcon()), tagIt.first.getBackGroundColor()); - } - // Set visible items - myTagsMatchBox->setNumVisible((int)myTagsMatchBox->getNumItems()); - } - } + // set first myACTemplate as edited AC + myCurrentTemplateAC = myACTemplates.front()->getAC(); // call tag selected function - myFrameParent->tagSelected(); + if (notifyFrameParent) { + myFrameParent->tagSelected(); + } } void -GNEFrameModuls::TagSelector::setCurrentTag(SumoXMLTag newTag) { - // set empty tag properties - myCurrentTagProperties = GNETagProperties(); - // make sure that tag is in myTypeMatchBox - for (int i = 0; i < (int)myTagsMatchBox->getNumItems(); i++) { - if (myTagsMatchBox->getItem(i).text() == toString(newTag)) { +GNEFrameModuls::TagSelector::setCurrentTag(SumoXMLTag newTag, const bool notifyFrameParent) { + // first reset myCurrentTemplateAC + myCurrentTemplateAC = nullptr; + // iterate over all myTagsMatchBox + for (int i = 0; i < myACTemplates.size(); i++) { + if (myACTemplates.at(i)->getAC() && (myACTemplates.at(i)->getAC()->getTagProperty().getTag() == newTag)) { + // set current template and currentItem + myCurrentTemplateAC = myACTemplates.at(i)->getAC(); myTagsMatchBox->setCurrentItem(i); - // Set new current type - myCurrentTagProperties = GNEAttributeCarrier::getTagProperties(newTag); + // set color of myTypeMatchBox to black (valid) + myTagsMatchBox->setTextColor(FXRGB(0, 0, 0)); } } // call tag selected function - myFrameParent->tagSelected(); + if (notifyFrameParent) { + myFrameParent->tagSelected(); + } } void -GNEFrameModuls::TagSelector::refreshTagProperties() { - // simply call onCmdSelectItem (to avoid duplicated code) - onCmdSelectTag(0, 0, 0); -} - - -long GNEFrameModuls::TagSelector::onCmdSelectTagType(FXObject*, FXSelector, void*) { - // Check if value of myTypeMatchBox correspond of an allowed additional tags - for (const auto& tagType : myTagTypes) { - if (tagType.tag == myTagTypesMatchBox->getText().text()) { - // set color of myTagTypesMatchBox to black (valid) - myTagTypesMatchBox->setTextColor(FXRGB(0, 0, 0)); - // fill myTagPropertiesString with personTrips (the first Tag Type) - myTagPropertiesString = GNEAttributeCarrier::getAllowedTagPropertiesByCategory(tagType.tagType, true); - // show and clear myTagsMatchBox - myTagsMatchBox->show(); - myTagsMatchBox->clearItems(); - // fill myTypeMatchBox with list of tags - for (const auto& tagIt : myTagPropertiesString) { - myTagsMatchBox->appendIconItem(tagIt.second.c_str(), GUIIconSubSys::getIcon(tagIt.first.getGUIIcon()), tagIt.first.getBackGroundColor()); - } - // Set visible items - myTagsMatchBox->setNumVisible((int)myTagsMatchBox->getNumItems()); - // Write Warning in console if we're in testing mode - WRITE_DEBUG(("Selected item '" + myTagsMatchBox->getText() + "' in TagTypeSelector").text()); - // call onCmdSelectTag - return onCmdSelectTag(nullptr, 0, nullptr); - } - } - // if TagType isn't valid, hide myTagsMatchBox - myTagsMatchBox->hide(); - // if additional name isn't correct, set SUMO_TAG_NOTHING as current type - myCurrentTagProperties = myInvalidTagProperty; +GNEFrameModuls::TagSelector::refreshTagSelector() { // call tag selected function myFrameParent->tagSelected(); - // set color of myTagTypesMatchBox to red (invalid) - myTagTypesMatchBox->setTextColor(FXRGB(255, 0, 0)); - // Write Warning in console if we're in testing mode - WRITE_DEBUG("Selected invalid item in TagTypeSelector"); - return 1; } long GNEFrameModuls::TagSelector::onCmdSelectTag(FXObject*, FXSelector, void*) { - // Check if value of myTypeMatchBox correspond of an allowed additional tags - for (const auto& tagProperty : myTagPropertiesString) { - if (tagProperty.second == myTagsMatchBox->getText().text()) { + // iterate over all myTagsMatchBox + for (int i = 0; i < myACTemplates.size(); i++) { + if (myACTemplates.at(i)->getAC() && myACTemplates.at(i)->getAC()->getTagProperty().getTagStr() == myTagsMatchBox->getText().text()) { + // set templateAC and currentItem + myCurrentTemplateAC = myACTemplates.at(i)->getAC(); + myTagsMatchBox->setCurrentItem(i); // set color of myTypeMatchBox to black (valid) myTagsMatchBox->setTextColor(FXRGB(0, 0, 0)); - // Set new current type - myCurrentTagProperties = tagProperty.first; // call tag selected function myFrameParent->tagSelected(); // Write Warning in console if we're in testing mode @@ -311,24 +265,38 @@ GNEFrameModuls::TagSelector::onCmdSelectTag(FXObject*, FXSelector, void*) { return 1; } } - // if additional name isn't correct, set SUMO_TAG_NOTHING as current type - myCurrentTagProperties = myInvalidTagProperty; - // call tag selected function - myFrameParent->tagSelected(); + // reset templateAC + myCurrentTemplateAC = nullptr; // set color of myTypeMatchBox to red (invalid) myTagsMatchBox->setTextColor(FXRGB(255, 0, 0)); // Write Warning in console if we're in testing mode WRITE_DEBUG("Selected invalid item in TagSelector"); + // call tag selected function + myFrameParent->tagSelected(); return 1; } -GNEFrameModuls::TagSelector::TagType::TagType(std::string _tag, GNETagProperties::TagType _tagType, GUIIcon _icon) : - tag(_tag), - tagType(_tagType), - icon(_icon) { +GNEFrameModuls::TagSelector::ACTemplate::ACTemplate(GNENet* net, const GNETagProperties tagProperty) : + tag(tagProperty.getTagStr()), + icon(tagProperty.getGUIIcon()), + myAC(nullptr) { + // create attribute carrier depending of + switch (tagProperty.getTag()) { + // additional elements + case SUMO_TAG_BUS_STOP: + case SUMO_TAG_TRAIN_STOP: + myAC = new GNEBusStop(tagProperty.getTag(), net); + break; + default: + break; + } } + GNEFrameModuls::TagSelector::ACTemplate::~ACTemplate() { + delete myAC; + } + // --------------------------------------------------------------------------- // GNEFrameModuls::DemandElementSelector - methods // --------------------------------------------------------------------------- diff --git a/src/netedit/frames/GNEFrameModuls.h b/src/netedit/frames/GNEFrameModuls.h index 06e8f64d8395..c638405391d8 100644 --- a/src/netedit/frames/GNEFrameModuls.h +++ b/src/netedit/frames/GNEFrameModuls.h @@ -50,7 +50,7 @@ class GNEFrameModuls { public: /// @brief constructor - TagSelector(GNEFrame* frameParent, GNETagProperties::TagType type, bool onlyDrawables = true); + TagSelector(GNEFrame* frameParent, GNETagProperties::TagType type, SumoXMLTag tag, bool onlyDrawables = true); /// @brief destructor ~TagSelector(); @@ -61,23 +61,20 @@ class GNEFrameModuls { /// @brief hide item selector void hideTagSelector(); - /// @brief get current type tag - const GNETagProperties& getCurrentTagProperties() const; + /// @brief get current templateAC + GNEAttributeCarrier *getCurrentTemplateAC() const; /// @brief set current type manually - void setCurrentTagType(GNETagProperties::TagType tagType); + void setCurrentTagType(GNETagProperties::TagType tagType, const bool onlyDrawables, const bool notifyFrameParent = true); /// @brief set current type manually - void setCurrentTag(SumoXMLTag newTag); + void setCurrentTag(SumoXMLTag newTag, const bool notifyFrameParent = true); - /// @brief due myCurrentTagProperties is a Reference, we need to refresh it when frameParent is show - void refreshTagProperties(); + /// @brief refresh tagSelector (used when frameParent is show) + void refreshTagSelector(); /// @name FOX-callbacks /// @{ - /// @brief Called when the user select an group in ComboBox - long onCmdSelectTagType(FXObject*, FXSelector, void*); - /// @brief Called when the user select an elementin ComboBox long onCmdSelectTag(FXObject*, FXSelector, void*); /// @} @@ -87,40 +84,45 @@ class GNEFrameModuls { FOX_CONSTRUCTOR(TagSelector) private: - struct TagType { + class ACTemplate { + + public: /// @brief constructor - TagType(std::string _tag, GNETagProperties::TagType _tagType, GUIIcon _icon); + ACTemplate(GNENet* net, const GNETagProperties tagProperty); + + /// @brief destructor + ~ACTemplate(); + + /// @brief editedAC + GNEAttributeCarrier *getAC() { + return myAC; + }; // @brief tag in string format const std::string tag; - /// @brief tag type - const GNETagProperties::TagType tagType; - /// @brief icon const GUIIcon icon; + + private: + /// @brief editedAC + GNEAttributeCarrier *myAC; }; /// @brief pointer to Frame Parent GNEFrame* myFrameParent; - /// @brief comboBox with tag type - MFXIconComboBox* myTagTypesMatchBox; + /// @brief current tagType + GNETagProperties::TagType myTagType; - /// @brief comboBox with the list of tags + /// @brief comboBox with the tags MFXIconComboBox* myTagsMatchBox; - /// @brief current tag properties - GNETagProperties myCurrentTagProperties; - - /// @brief list of tags types that will be shown in Match Box - std::vector myTagTypes; - - /// @brief list of tags that will be shown in Match Box - std::vector > myTagPropertiesString; + /// @brief current templateAC; + GNEAttributeCarrier *myCurrentTemplateAC; - /// @brief dummy tag properties used if user select an invalid tag - GNETagProperties myInvalidTagProperty; + /// @brief list with ACTemplates + std::vector myACTemplates; }; // =========================================================================== diff --git a/src/netedit/frames/demand/GNEContainerFrame.cpp b/src/netedit/frames/demand/GNEContainerFrame.cpp index 9251bc907c0f..04ab758bc5ed 100644 --- a/src/netedit/frames/demand/GNEContainerFrame.cpp +++ b/src/netedit/frames/demand/GNEContainerFrame.cpp @@ -42,7 +42,7 @@ GNEContainerFrame::GNEContainerFrame(FXHorizontalFrame* horizontalFrameParent, G myContainerBaseObject(new CommonXMLStructure::SumoBaseObject(nullptr)) { // create tag Selector modul for containers - myContainerTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINER); + myContainerTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINER, SUMO_TAG_CONTAINER); // create container types selector modul myPTypeSelector = new GNEFrameModuls::DemandElementSelector(this, SUMO_TAG_PTYPE); @@ -51,7 +51,7 @@ GNEContainerFrame::GNEContainerFrame(FXHorizontalFrame* horizontalFrameParent, G myContainerAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); // create tag Selector modul for container plans - myContainerPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINERPLAN); + myContainerPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINERPLAN, GNE_TAG_TRANSPORT_EDGE); // create container plan attributes myContainerPlanAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -64,9 +64,6 @@ GNEContainerFrame::GNEContainerFrame(FXHorizontalFrame* horizontalFrameParent, G // limit path creator to pedestrians myPathCreator->setVClass(SVC_PEDESTRIAN); - - // set Container as default vehicle - myContainerTagSelector->setCurrentTag(SUMO_TAG_CONTAINER); } @@ -77,12 +74,13 @@ GNEContainerFrame::~GNEContainerFrame() { void GNEContainerFrame::show() { - // refresh item selector - myContainerTagSelector->refreshTagProperties(); + // refresh tag selector + myContainerTagSelector->refreshTagSelector(); myPTypeSelector->refreshDemandElementSelector(); - myContainerPlanTagSelector->refreshTagProperties(); + myContainerPlanTagSelector->refreshTagSelector(); // update VClass of myPathCreator - if (myContainerPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myContainerPlanTagSelector->getCurrentTemplateAC() && + myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isTransportPlan()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); @@ -110,10 +108,9 @@ GNEContainerFrame::addContainer(const GNEViewNetHelper::ObjectsUnderCursor& obje return false; } // obtain tags (only for improve code legibility) - SumoXMLTag containerTag = myContainerTagSelector->getCurrentTagProperties().getTag(); SumoXMLTag clickedACTag = objectsUnderCursor.getAttributeCarrierFront()->getTagProperty().getTag(); // first check that current selected container is valid - if (containerTag == SUMO_TAG_NOTHING) { + if (myContainerTagSelector->getCurrentTemplateAC() == nullptr) { myViewNet->setStatusBarText("Current selected container isn't valid."); return false; } @@ -123,7 +120,7 @@ GNEContainerFrame::addContainer(const GNEViewNetHelper::ObjectsUnderCursor& obje return false; } // finally check that container plan selected is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC() == false) { myViewNet->setStatusBarText("Current selected container plan isn't valid."); return false; } @@ -152,33 +149,33 @@ GNEContainerFrame::getPathCreator() const { void GNEContainerFrame::tagSelected() { // first check if container is valid - if (myContainerTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myContainerTagSelector->getCurrentTemplateAC()) { // show PType selector and container plan selector myPTypeSelector->showDemandElementSelector(); // check if current container type selected is valid if (myPTypeSelector->getCurrentDemandElement()) { // show container attributes depending of myContainerPlanTagSelector - if (myContainerPlanTagSelector->getCurrentTagProperties().isStopContainer()) { - myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTagProperties(), {SUMO_ATTR_DEPARTPOS}); + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopContainer()) { + myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTemplateAC()->getTagProperty(), {SUMO_ATTR_DEPARTPOS}); } else { - myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTagProperties(), {}); + myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); } // show container plan tag selector myContainerPlanTagSelector->showTagSelector(); // now check if container plan selected is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_NOTHING) { // update VClass of myPathCreator depending if container is a ride - if (myContainerPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); } // show container plan attributes - myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTagProperties(), {}); + myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show Netedit attributes modul - myNeteditAttributes->showNeteditAttributesModul(myContainerPlanTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty()); // show edge path creator modul - myPathCreator->showPathCreatorModul(myContainerPlanTagSelector->getCurrentTagProperties().getTag(), false, false); + myPathCreator->showPathCreatorModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } else { // hide modules myContainerPlanAttributes->hideAttributesCreatorModul(); @@ -209,27 +206,27 @@ void GNEContainerFrame::demandElementSelected() { if (myPTypeSelector->getCurrentDemandElement()) { // show container attributes depending of myContainerPlanTagSelector - if (myContainerPlanTagSelector->getCurrentTagProperties().isStopContainer()) { - myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTagProperties(), {SUMO_ATTR_DEPARTPOS}); + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopContainer()) { + myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTemplateAC()->getTagProperty(), {SUMO_ATTR_DEPARTPOS}); } else { - myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTagProperties(), {}); + myContainerAttributes->showAttributesCreatorModul(myContainerTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); } // show container plan tag selector myContainerPlanTagSelector->showTagSelector(); // now check if container plan selected is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_NOTHING) { // update VClass of myPathCreator depending if container is a ride - if (myContainerPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); } // show container plan attributes - myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTagProperties(), {}); + myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show Netedit attributes modul - myNeteditAttributes->showNeteditAttributesModul(myContainerPlanTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty()); // show edge path creator modul - myPathCreator->showPathCreatorModul(myContainerPlanTagSelector->getCurrentTagProperties().getTag(), false, false); + myPathCreator->showPathCreatorModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } else { // hide modules myContainerPlanAttributes->hideAttributesCreatorModul(); @@ -253,7 +250,7 @@ GNEContainerFrame::createPath() { if (!myContainerAttributes->areValuesValid()) { myViewNet->setStatusBarText("Invalid container parameters."); } else if (!myContainerPlanAttributes->areValuesValid()) { - myViewNet->setStatusBarText("Invalid " + myContainerPlanTagSelector->getCurrentTagProperties().getTagStr() + " parameters."); + myViewNet->setStatusBarText("Invalid " + myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " parameters."); } else { /* // begin undo-redo operation @@ -288,7 +285,7 @@ GNEContainerFrame::createPath() { GNEDemandElement* GNEContainerFrame::buildContainer() { // obtain container tag (only for improve code legibility) - SumoXMLTag containerTag = myContainerTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag containerTag = myContainerTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // Declare map to keep attributes from myContainerAttributes myContainerAttributes->getAttributesAndValues(myContainerBaseObject, false); // Check if ID has to be generated diff --git a/src/netedit/frames/demand/GNEContainerPlanFrame.cpp b/src/netedit/frames/demand/GNEContainerPlanFrame.cpp index bc23e9a78eed..0a65480f111a 100644 --- a/src/netedit/frames/demand/GNEContainerPlanFrame.cpp +++ b/src/netedit/frames/demand/GNEContainerPlanFrame.cpp @@ -42,7 +42,7 @@ GNEContainerPlanFrame::GNEContainerPlanFrame(FXHorizontalFrame* horizontalFrameP myContainerSelector = new GNEFrameModuls::DemandElementSelector(this, {GNETagProperties::TagType::CONTAINER}); // Create tag selector for container plan - myContainerPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINERPLAN); + myContainerPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::CONTAINERPLAN, GNE_TAG_TRANSPORT_EDGE); // Create container parameters myContainerPlanAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -52,9 +52,6 @@ GNEContainerPlanFrame::GNEContainerPlanFrame(FXHorizontalFrame* horizontalFrameP // Create HierarchicalElementTree modul myContainerHierarchy = new GNEFrameModuls::HierarchicalElementTree(this); - - // set ContainerPlan tag type in tag selector - myContainerPlanTagSelector->setCurrentTagType(GNETagProperties::TagType::CONTAINERPLAN); } @@ -70,8 +67,8 @@ GNEContainerPlanFrame::show() { if ((containers.size() > 0) || (containerFlows.size() > 0)) { // show container selector myContainerSelector->showDemandElementSelector(); - // refresh container plan tag selector - myContainerPlanTagSelector->refreshTagProperties(); + // refresh tag selector + myContainerPlanTagSelector->refreshTagSelector(); // set first container as demand element (this will call demandElementSelected() function) if (containers.size() > 0) { myContainerSelector->setDemandElement(*containers.begin()); @@ -110,12 +107,12 @@ GNEContainerPlanFrame::addContainerPlanElement(const GNEViewNetHelper::ObjectsUn return false; } // finally check that container plan selected is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC() == nullptr) { myViewNet->setStatusBarText("Current selected container plan isn't valid."); return false; } // Obtain current container plan tag (only for improve code legibility) - SumoXMLTag containerPlanTag = myContainerPlanTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag containerPlanTag = myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // declare flags for requirements const bool requireContainerStop = ((containerPlanTag == GNE_TAG_TRANSPORT_CONTAINERSTOP) || (containerPlanTag == GNE_TAG_TRANSHIP_CONTAINERSTOP) || (containerPlanTag == GNE_TAG_STOPCONTAINER_CONTAINERSTOP)); @@ -144,11 +141,11 @@ GNEContainerPlanFrame::getPathCreator() const { void GNEContainerPlanFrame::tagSelected() { // first check if container is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()) { // Obtain current container plan tag (only for improve code legibility) - SumoXMLTag containerPlanTag = myContainerPlanTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag containerPlanTag = myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // show container attributes - myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTagProperties(), {}); + myContainerPlanAttributes->showAttributesCreatorModul(myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // get previous container plan GNEEdge* previousEdge = myContainerSelector->getContainerPlanPreviousEdge(); // set path creator mode depending if previousEdge exist @@ -179,7 +176,7 @@ GNEContainerPlanFrame::demandElementSelected() { // show container plan tag selector myContainerPlanTagSelector->showTagSelector(); // now check if container plan selected is valid - if (myContainerPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_NOTHING) { // call tag selected tagSelected(); } else { @@ -201,11 +198,11 @@ void GNEContainerPlanFrame::createPath() { // first check that all attributes are valid if (!myContainerPlanAttributes->areValuesValid()) { - myViewNet->setStatusBarText("Invalid " + myContainerPlanTagSelector->getCurrentTagProperties().getTagStr() + " parameters."); + myViewNet->setStatusBarText("Invalid " + myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " parameters."); } else { // check if container plan can be created if (myRouteHandler.buildContainerPlan( - myContainerPlanTagSelector->getCurrentTagProperties().getTag(), + myContainerPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), myContainerSelector->getCurrentDemandElement(), myContainerPlanAttributes, myPathCreator)) { diff --git a/src/netedit/frames/demand/GNEPersonFrame.cpp b/src/netedit/frames/demand/GNEPersonFrame.cpp index e600abfa7be9..c765c7c30d8e 100644 --- a/src/netedit/frames/demand/GNEPersonFrame.cpp +++ b/src/netedit/frames/demand/GNEPersonFrame.cpp @@ -42,7 +42,7 @@ GNEPersonFrame::GNEPersonFrame(FXHorizontalFrame* horizontalFrameParent, GNEView myPersonBaseObject(new CommonXMLStructure::SumoBaseObject(nullptr)) { // create tag Selector modul for persons - myPersonTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSON); + myPersonTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSON, SUMO_TAG_PERSON); // create person types selector modul myPTypeSelector = new GNEFrameModuls::DemandElementSelector(this, SUMO_TAG_PTYPE); @@ -51,7 +51,7 @@ GNEPersonFrame::GNEPersonFrame(FXHorizontalFrame* horizontalFrameParent, GNEView myPersonAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); // create tag Selector modul for person plans - myPersonPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSONPLAN); + myPersonPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSONPLAN, GNE_TAG_PERSONTRIP_EDGE); // create person plan attributes myPersonPlanAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -64,11 +64,6 @@ GNEPersonFrame::GNEPersonFrame(FXHorizontalFrame* horizontalFrameParent, GNEView // limit path creator to pedestrians myPathCreator->setVClass(SVC_PEDESTRIAN); - - // set Person as default vehicle - myPersonTagSelector->setCurrentTag(SUMO_TAG_PERSON); - myPersonPlanTagSelector->setCurrentTag(GNE_TAG_PERSONTRIP_EDGE); - myPersonPlanTagSelector->onCmdSelectTagType(0, 0, 0); } @@ -79,12 +74,13 @@ GNEPersonFrame::~GNEPersonFrame() { void GNEPersonFrame::show() { - // refresh item selector - myPersonTagSelector->refreshTagProperties(); + // refresh tag selector + myPersonTagSelector->refreshTagSelector(); myPTypeSelector->refreshDemandElementSelector(); - myPersonPlanTagSelector->refreshTagProperties(); + myPersonPlanTagSelector->refreshTagSelector(); // update VClass of myPathCreator - if (myPersonPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myPersonPlanTagSelector->getCurrentTemplateAC() && + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); @@ -112,7 +108,7 @@ GNEPersonFrame::addPerson(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnd return false; } // obtain tags (only for improve code legibility) - SumoXMLTag personTag = myPersonTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag personTag = myPersonTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); SumoXMLTag clickedACTag = objectsUnderCursor.getAttributeCarrierFront()->getTagProperty().getTag(); // first check that current selected person is valid if (personTag == SUMO_TAG_NOTHING) { @@ -125,7 +121,7 @@ GNEPersonFrame::addPerson(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnd return false; } // finally check that person plan selected is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == SUMO_TAG_NOTHING) { myViewNet->setStatusBarText("Current selected person plan isn't valid."); return false; } @@ -133,21 +129,21 @@ GNEPersonFrame::addPerson(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnd if (clickedACTag == SUMO_TAG_LANE) { const bool result = myPathCreator->addEdge(objectsUnderCursor.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed()); // if we're creating a stop, create it immediately - if (result && myPersonPlanTagSelector->getCurrentTagProperties().isStopPerson()) { + if (result && myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopPerson()) { createPath(); } return result; } else if (clickedACTag == SUMO_TAG_BUS_STOP) { const bool result = myPathCreator->addStoppingPlace(objectsUnderCursor.getAdditionalFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed()); // if we're creating a stop, create it immediately - if (result && myPersonPlanTagSelector->getCurrentTagProperties().isStopPerson()) { + if (result && myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopPerson()) { createPath(); } return result; } else if (clickedACTag == SUMO_TAG_ROUTE) { const bool result = myPathCreator->addRoute(objectsUnderCursor.getDemandElementFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed()); // if we're creating a walk route, create it immediately - if (result && (myPersonPlanTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_WALK_ROUTE)) { + if (result && (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE)) { createPath(); myPathCreator->removeRoute(); } @@ -170,38 +166,38 @@ GNEPersonFrame::getPathCreator() const { void GNEPersonFrame::tagSelected() { // first check if person is valid - if (myPersonTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myPersonTagSelector->getCurrentTemplateAC()) { // show PType selector and person plan selector myPTypeSelector->showDemandElementSelector(); // check if current person type selected is valid if (myPTypeSelector->getCurrentDemandElement()) { // show person attributes depending of myPersonPlanTagSelector - if (myPersonPlanTagSelector->getCurrentTagProperties().isStopPerson()) { - myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTagProperties(), {SUMO_ATTR_DEPARTPOS}); + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopPerson()) { + myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTemplateAC()->getTagProperty(), {SUMO_ATTR_DEPARTPOS}); } else { - myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTagProperties(), {}); + myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); } // show person plan tag selector myPersonPlanTagSelector->showTagSelector(); // now check if person plan selected is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_NOTHING) { // show person plan attributes - myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTagProperties(), {}); + myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show Netedit attributes modul - myNeteditAttributes->showNeteditAttributesModul(myPersonPlanTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty()); // show path creator depending of tag - if (myPersonPlanTagSelector->getCurrentTagProperties().isStopPerson() || - (myPersonPlanTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_WALK_ROUTE)) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopPerson() || + (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE)) { myPathCreator->hidePathCreatorModul(); } else { // update VClass of myPathCreator depending if person is a ride - if (myPersonPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); } // show edge path creator modul - myPathCreator->showPathCreatorModul(myPersonPlanTagSelector->getCurrentTagProperties().getTag(), false, false); + myPathCreator->showPathCreatorModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } } else { // hide modules @@ -233,27 +229,27 @@ void GNEPersonFrame::demandElementSelected() { if (myPTypeSelector->getCurrentDemandElement()) { // show person attributes depending of myPersonPlanTagSelector - if (myPersonPlanTagSelector->getCurrentTagProperties().isStopPerson()) { - myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTagProperties(), {SUMO_ATTR_DEPARTPOS}); + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isStopPerson()) { + myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTemplateAC()->getTagProperty(), {SUMO_ATTR_DEPARTPOS}); } else { - myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTagProperties(), {}); + myPersonAttributes->showAttributesCreatorModul(myPersonTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); } // show person plan tag selector myPersonPlanTagSelector->showTagSelector(); // now check if person plan selected is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_NOTHING) { // update VClass of myPathCreator depending if person is a ride - if (myPersonPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); } // show person plan attributes - myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTagProperties(), {}); + myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show Netedit attributes modul - myNeteditAttributes->showNeteditAttributesModul(myPersonPlanTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty()); // show edge path creator modul - myPathCreator->showPathCreatorModul(myPersonPlanTagSelector->getCurrentTagProperties().getTag(), false, false); + myPathCreator->showPathCreatorModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } else { // hide modules myPersonPlanAttributes->hideAttributesCreatorModul(); @@ -277,15 +273,17 @@ GNEPersonFrame::createPath() { if (!myPersonAttributes->areValuesValid()) { myViewNet->setStatusBarText("Invalid person parameters."); } else if (!myPersonPlanAttributes->areValuesValid()) { - myViewNet->setStatusBarText("Invalid " + myPersonPlanTagSelector->getCurrentTagProperties().getTagStr() + " parameters."); + myViewNet->setStatusBarText("Invalid " + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " parameters."); } else { // begin undo-redo operation - myViewNet->getUndoList()->begin(myPersonTagSelector->getCurrentTagProperties().getGUIIcon(), "create " + myPersonTagSelector->getCurrentTagProperties().getTagStr() + " and " + myPersonPlanTagSelector->getCurrentTagProperties().getTagStr()); + myViewNet->getUndoList()->begin(myPersonTagSelector->getCurrentTemplateAC()->getTagProperty().getGUIIcon(), "create " + + myPersonTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " and " + + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr()); // create person GNEDemandElement* person = buildPerson(); // check if person and person plan can be created if (myRouteHandler.buildPersonPlan( - myPersonPlanTagSelector->getCurrentTagProperties().getTag(), + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), person, myPersonPlanAttributes, myPathCreator, true)) { // end undo-redo operation myViewNet->getUndoList()->end(); @@ -314,7 +312,7 @@ GNEPersonFrame::buildPerson() { // first person base object myPersonBaseObject->clear(); // obtain person tag (only for improve code legibility) - SumoXMLTag personTag = myPersonTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag personTag = myPersonTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // set tag myPersonBaseObject->setTag(personTag); // get attribute ad values diff --git a/src/netedit/frames/demand/GNEPersonPlanFrame.cpp b/src/netedit/frames/demand/GNEPersonPlanFrame.cpp index 0aaf2e06b687..e76a713f45df 100644 --- a/src/netedit/frames/demand/GNEPersonPlanFrame.cpp +++ b/src/netedit/frames/demand/GNEPersonPlanFrame.cpp @@ -42,7 +42,7 @@ GNEPersonPlanFrame::GNEPersonPlanFrame(FXHorizontalFrame* horizontalFrameParent, myPersonSelector = new GNEFrameModuls::DemandElementSelector(this, {GNETagProperties::TagType::PERSON}); // Create tag selector for person plan - myPersonPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSONPLAN); + myPersonPlanTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::PERSONPLAN, GNE_TAG_PERSONTRIP_EDGE); // Create person parameters myPersonPlanAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -52,10 +52,6 @@ GNEPersonPlanFrame::GNEPersonPlanFrame(FXHorizontalFrame* horizontalFrameParent, // Create HierarchicalElementTree modul myPersonHierarchy = new GNEFrameModuls::HierarchicalElementTree(this); - - // set PersonPlan tag type in tag selector - myPersonPlanTagSelector->setCurrentTagType(GNETagProperties::TagType::PERSONTRIP); - myPersonPlanTagSelector->onCmdSelectTagType(0, 0, 0); } @@ -71,8 +67,8 @@ GNEPersonPlanFrame::show() { if ((persons.size() > 0) || (personFlows.size() > 0)) { // show person selector myPersonSelector->showDemandElementSelector(); - // refresh person plan tag selector - myPersonPlanTagSelector->refreshTagProperties(); + // refresh tag selector + myPersonPlanTagSelector->refreshTagSelector(); // set first person as demand element (this will call demandElementSelected() function) if (persons.size() > 0) { myPersonSelector->setDemandElement(*persons.begin()); @@ -111,12 +107,12 @@ GNEPersonPlanFrame::addPersonPlanElement(const GNEViewNetHelper::ObjectsUnderCur return false; } // finally check that person plan selected is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC() == nullptr) { myViewNet->setStatusBarText("Current selected person plan isn't valid."); return false; } // Obtain current person plan tag (only for improve code legibility) - SumoXMLTag personPlanTag = myPersonPlanTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag personPlanTag = myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // declare flags for requirements const bool requireBusStop = ((personPlanTag == GNE_TAG_PERSONTRIP_BUSSTOP) || (personPlanTag == GNE_TAG_WALK_BUSSTOP) || (personPlanTag == GNE_TAG_RIDE_BUSSTOP) || (personPlanTag == GNE_TAG_STOPPERSON_BUSSTOP)); @@ -153,19 +149,19 @@ GNEPersonPlanFrame::getPathCreator() const { void GNEPersonPlanFrame::tagSelected() { // first check if person is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()) { // Obtain current person plan tag (only for improve code legibility) - SumoXMLTag personPlanTag = myPersonPlanTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag personPlanTag = myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); // show person attributes - myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTagProperties(), {}); + myPersonPlanAttributes->showAttributesCreatorModul(myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // get previous person plan GNEEdge* previousEdge = myPersonSelector->getPersonPlanPreviousEdge(); // show path creator depending of tag - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_WALK_ROUTE) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { myPathCreator->hidePathCreatorModul(); } else { // update VClass of myPathCreator depending if person is a ride - if (myPersonPlanTagSelector->getCurrentTagProperties().isRide()) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().isRide()) { myPathCreator->setVClass(SVC_PASSENGER); } else { myPathCreator->setVClass(SVC_PEDESTRIAN); @@ -199,7 +195,7 @@ GNEPersonPlanFrame::demandElementSelected() { // show person plan tag selector myPersonPlanTagSelector->showTagSelector(); // now check if person plan selected is valid - if (myPersonPlanTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myPersonPlanTagSelector->getCurrentTemplateAC()) { // call tag selected tagSelected(); } else { @@ -221,11 +217,11 @@ void GNEPersonPlanFrame::createPath() { // first check that all attributes are valid if (!myPersonPlanAttributes->areValuesValid()) { - myViewNet->setStatusBarText("Invalid " + myPersonPlanTagSelector->getCurrentTagProperties().getTagStr() + " parameters."); + myViewNet->setStatusBarText("Invalid " + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " parameters."); } else { // check if person plan can be created if (myRouteHandler.buildPersonPlan( - myPersonPlanTagSelector->getCurrentTagProperties().getTag(), + myPersonPlanTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), myPersonSelector->getCurrentDemandElement(), myPersonPlanAttributes, myPathCreator, false)) { // refresh HierarchicalElementTree diff --git a/src/netedit/frames/demand/GNEStopFrame.cpp b/src/netedit/frames/demand/GNEStopFrame.cpp index 2f9da91e5230..8dd70aea6e41 100644 --- a/src/netedit/frames/demand/GNEStopFrame.cpp +++ b/src/netedit/frames/demand/GNEStopFrame.cpp @@ -64,7 +64,7 @@ GNEStopFrame::HelpCreation::updateHelpCreation() { // create information label std::ostringstream information; // set text depending of selected Stop type - switch (myStopFrameParent->myStopTagSelector->getCurrentTagProperties().getTag()) { + switch (myStopFrameParent->myStopTagSelector->getCurrentTemplateAC()->getTagProperty().getTag()) { case SUMO_TAG_STOP_BUSSTOP: information << "- Click over a bus stop\n" @@ -113,7 +113,7 @@ GNEStopFrame::GNEStopFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* myStopParentSelector = new GNEFrameModuls::DemandElementSelector(this, {GNETagProperties::TagType::PERSON, GNETagProperties::TagType::VEHICLE, GNETagProperties::TagType::ROUTE}); // Create item Selector modul for Stops - myStopTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::STOP); + myStopTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::STOP, SUMO_TAG_STOP); // Create Stop parameters myStopAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -150,8 +150,8 @@ GNEStopFrame::show() { myStopTagSelector->showTagSelector(); // refresh vType selector myStopParentSelector->refreshDemandElementSelector(); - // refresh item selector - myStopTagSelector->refreshTagProperties(); + // refresh tag selector + myStopTagSelector->refreshTagSelector(); } else { // hide moduls (except help creation) myStopParentSelector->hideDemandElementSelector(); @@ -187,7 +187,7 @@ GNEStopFrame::addStop(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCu return false; } // create stop base object - getStopParameter(myStopTagSelector->getCurrentTagProperties().getTag(), + getStopParameter(myStopTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), objectsUnderCursor.getLaneFront(), objectsUnderCursor.getAdditionalFront()); if (myStopParentBaseObject->getTag() != SUMO_TAG_NOTHING) { myRouteHandler.buildStop(myStopParentBaseObject->getSumoBaseObjectChildren().front(), @@ -398,10 +398,10 @@ GNEStopFrame::getStopParameter(const SumoXMLTag stopTag, const GNELane* lane, co void GNEStopFrame::tagSelected() { - if (myStopTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myStopTagSelector->getCurrentTemplateAC()) { // show Stop type selector modul - myStopAttributes->showAttributesCreatorModul(myStopTagSelector->getCurrentTagProperties(), {}); - myNeteditAttributes->showNeteditAttributesModul(myStopTagSelector->getCurrentTagProperties()); + myStopAttributes->showAttributesCreatorModul(myStopTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); + myNeteditAttributes->showNeteditAttributesModul(myStopTagSelector->getCurrentTemplateAC()->getTagProperty()); myHelpCreation->showHelpCreation(); } else { // hide all moduls if stop parent isn't valid @@ -417,10 +417,10 @@ GNEStopFrame::demandElementSelected() { // show or hidde moduls depending if current selected stop parent is valid if (myStopParentSelector->getCurrentDemandElement()) { myStopTagSelector->showTagSelector(); - if (myStopTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myStopTagSelector->getCurrentTemplateAC()) { // show moduls - myStopAttributes->showAttributesCreatorModul(myStopTagSelector->getCurrentTagProperties(), {}); - myNeteditAttributes->showNeteditAttributesModul(myStopTagSelector->getCurrentTagProperties()); + myStopAttributes->showAttributesCreatorModul(myStopTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); + myNeteditAttributes->showNeteditAttributesModul(myStopTagSelector->getCurrentTemplateAC()->getTagProperty()); myHelpCreation->showHelpCreation(); } else { myStopAttributes->hideAttributesCreatorModul(); diff --git a/src/netedit/frames/demand/GNEVehicleFrame.cpp b/src/netedit/frames/demand/GNEVehicleFrame.cpp index be259d127641..798342914e12 100644 --- a/src/netedit/frames/demand/GNEVehicleFrame.cpp +++ b/src/netedit/frames/demand/GNEVehicleFrame.cpp @@ -65,7 +65,7 @@ GNEVehicleFrame::HelpCreation::updateHelpCreation() { // create information label std::ostringstream information; // set text depending of selected vehicle type - switch (myVehicleFrameParent->myVehicleTagSelector->getCurrentTagProperties().getTag()) { + switch (myVehicleFrameParent->myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag()) { case SUMO_TAG_VEHICLE: information << "- Click over a route to\n" @@ -103,7 +103,7 @@ GNEVehicleFrame::GNEVehicleFrame(FXHorizontalFrame* horizontalFrameParent, GNEVi myVehicleBaseObject(new CommonXMLStructure::SumoBaseObject(nullptr)) { // Create item Selector modul for vehicles - myVehicleTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::VEHICLE); + myVehicleTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::VEHICLE, SUMO_TAG_VEHICLE); // Create vehicle type selector myVTypeSelector = new GNEFrameModuls::DemandElementSelector(this, SUMO_TAG_VTYPE); @@ -116,9 +116,6 @@ GNEVehicleFrame::GNEVehicleFrame(FXHorizontalFrame* horizontalFrameParent, GNEVi // Create Help Creation Modul myHelpCreation = new HelpCreation(this); - - // set Vehicle as default vehicle - myVehicleTagSelector->setCurrentTag(SUMO_TAG_VEHICLE); } @@ -129,8 +126,8 @@ GNEVehicleFrame::~GNEVehicleFrame() { void GNEVehicleFrame::show() { - // refresh item selector - myVehicleTagSelector->refreshTagProperties(); + // refresh tag selector + myVehicleTagSelector->refreshTagSelector(); // show frame GNEFrame::show(); } @@ -152,7 +149,7 @@ GNEVehicleFrame::addVehicle(const GNEViewNetHelper::ObjectsUnderCursor& objectsU // begin cleaning vehicle base object myVehicleBaseObject->clear(); // obtain tag (only for improve code legibility) - SumoXMLTag vehicleTag = myVehicleTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag vehicleTag = myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); const bool addEdge = ((vehicleTag == SUMO_TAG_TRIP) || (vehicleTag == GNE_TAG_VEHICLE_WITHROUTE) || (vehicleTag == SUMO_TAG_FLOW) || (vehicleTag == GNE_TAG_FLOW_WITHROUTE)); // first check that current selected vehicle is valid if (vehicleTag == SUMO_TAG_NOTHING) { @@ -277,13 +274,13 @@ GNEVehicleFrame::getPathCreator() const { void GNEVehicleFrame::tagSelected() { - if (myVehicleTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myVehicleTagSelector->getCurrentTemplateAC()) { // show vehicle type selector modul myVTypeSelector->showDemandElementSelector(); // show path creator modul - if ((myVehicleTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_VEHICLE) && - (myVehicleTagSelector->getCurrentTagProperties().getTag() != GNE_TAG_FLOW_ROUTE)) { - myPathCreator->showPathCreatorModul(myVehicleTagSelector->getCurrentTagProperties().getTag(), false, false); + if ((myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_VEHICLE) && + (myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != GNE_TAG_FLOW_ROUTE)) { + myPathCreator->showPathCreatorModul(myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } } else { // hide all moduls if vehicle isn't valid @@ -298,13 +295,13 @@ void GNEVehicleFrame::demandElementSelected() { if (myVTypeSelector->getCurrentDemandElement()) { // show vehicle attributes modul - myVehicleAttributes->showAttributesCreatorModul(myVehicleTagSelector->getCurrentTagProperties(), {}); + myVehicleAttributes->showAttributesCreatorModul(myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // set current VTypeClass in TripCreator myPathCreator->setVClass(myVTypeSelector->getCurrentDemandElement()->getVClass()); // show path creator modul - if ((myVehicleTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_VEHICLE) && - (myVehicleTagSelector->getCurrentTagProperties().getTag() != GNE_TAG_FLOW_ROUTE)) { - myPathCreator->showPathCreatorModul(myVehicleTagSelector->getCurrentTagProperties().getTag(), false, false); + if ((myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_VEHICLE) && + (myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != GNE_TAG_FLOW_ROUTE)) { + myPathCreator->showPathCreatorModul(myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(), false, false); } // show help creation myHelpCreation->showHelpCreation(); @@ -325,7 +322,7 @@ GNEVehicleFrame::createPath() { // begin cleaning vehicle base object myVehicleBaseObject->clear(); // obtain tag (only for improve code legibility) - SumoXMLTag vehicleTag = myVehicleTagSelector->getCurrentTagProperties().getTag(); + SumoXMLTag vehicleTag = myVehicleTagSelector->getCurrentTemplateAC()->getTagProperty().getTag(); const bool embebbedRoute = ((vehicleTag == GNE_TAG_VEHICLE_WITHROUTE) || (vehicleTag == GNE_TAG_FLOW_WITHROUTE)); // check number of edges if ((myPathCreator->getSelectedEdges().size() > 1) || (myPathCreator->getSelectedEdges().size() > 0 && embebbedRoute)) { diff --git a/src/netedit/frames/network/GNEAdditionalFrame.cpp b/src/netedit/frames/network/GNEAdditionalFrame.cpp index ff491ad7577c..f03445d94608 100644 --- a/src/netedit/frames/network/GNEAdditionalFrame.cpp +++ b/src/netedit/frames/network/GNEAdditionalFrame.cpp @@ -127,10 +127,10 @@ GNEAdditionalFrame::SelectorParentLanes::startConsecutiveLaneSelector(GNELane* l bool GNEAdditionalFrame::SelectorParentLanes::stopConsecutiveLaneSelector() { // obtain tagproperty (only for improve code legibility) - const auto& tagProperties = myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties(); + const auto& tagProperties = myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty(); // abort if there isn't at least two lanes if (mySelectedLanes.size() < 2) { - WRITE_WARNING(myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties().getTagStr() + " requires at least two lanes."); + WRITE_WARNING(myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + " requires at least two lanes."); // abort consecutive lane selector abortConsecutiveLaneSelector(); return false; @@ -824,7 +824,7 @@ GNEAdditionalFrame::E2MultilaneLaneSelector::drawTemporalE2Multilane(const GUIVi bool GNEAdditionalFrame::E2MultilaneLaneSelector::createPath() { // obtain tagproperty (only for improve code legibility) - const auto& tagProperties = myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties(); + const auto& tagProperties = myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty(); // first check that current tag is valid if (tagProperties.getTag() != GNE_TAG_E2DETECTOR_MULTILANE) { return false; @@ -858,7 +858,7 @@ GNEAdditionalFrame::E2MultilaneLaneSelector::createPath() { myAdditionalFrameParent->myBaseAdditional->addDoubleAttribute(SUMO_ATTR_POSITION, myLanePath.front().second); myAdditionalFrameParent->myBaseAdditional->addDoubleAttribute(SUMO_ATTR_ENDPOS, myLanePath.back().second); // parse common attributes - if (!myAdditionalFrameParent->buildAdditionalCommonAttributes(myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties())) { + if (!myAdditionalFrameParent->buildAdditionalCommonAttributes(myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty())) { return false; } // show warning dialogbox and stop check if input parameters are valid @@ -1008,7 +1008,7 @@ GNEAdditionalFrame::GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, myBaseAdditional(nullptr) { // create item Selector modul for additionals - myAdditionalTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::ADDITIONALELEMENT); + myAdditionalTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::ADDITIONALELEMENT, SUMO_TAG_BUS_STOP); // Create additional parameters myAdditionalAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -1030,9 +1030,6 @@ GNEAdditionalFrame::GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, // Create list for E2Multilane lane selector myE2MultilaneLaneSelector = new E2MultilaneLaneSelector(this); - - // set BusStop as default additional - myAdditionalTagSelector->setCurrentTag(SUMO_TAG_BUS_STOP); } @@ -1046,8 +1043,8 @@ GNEAdditionalFrame::~GNEAdditionalFrame() { void GNEAdditionalFrame::show() { - // refresh item selector - myAdditionalTagSelector->refreshTagProperties(); + // refresh tag selector + myAdditionalTagSelector->refreshTagSelector(); // show frame GNEFrame::show(); } @@ -1056,7 +1053,7 @@ GNEAdditionalFrame::show() { bool GNEAdditionalFrame::addAdditional(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor) { // first check that current selected additional is valid - if (myAdditionalTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_NOTHING) { + if (myAdditionalTagSelector->getCurrentTemplateAC() == nullptr) { myViewNet->setStatusBarText("Current selected additional isn't valid."); return false; } @@ -1066,7 +1063,7 @@ GNEAdditionalFrame::addAdditional(const GNEViewNetHelper::ObjectsUnderCursor& ob return false; } // obtain tagproperty (only for improve code legibility) - const auto& tagProperties = myAdditionalTagSelector->getCurrentTagProperties(); + const auto& tagProperties = myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty(); // create base additional if (!createBaseAdditionalObject(tagProperties)) { return false; @@ -1115,31 +1112,31 @@ GNEAdditionalFrame::getE2MultilaneLaneSelector() const { void GNEAdditionalFrame::tagSelected() { - if (myAdditionalTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myAdditionalTagSelector->getCurrentTemplateAC()) { // show additional attributes modul - myAdditionalAttributes->showAttributesCreatorModul(myAdditionalTagSelector->getCurrentTagProperties(), {}); + myAdditionalAttributes->showAttributesCreatorModul(myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show netedit attributes - myNeteditAttributes->showNeteditAttributesModul(myAdditionalTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty()); // Show myAdditionalFrameParent if we're adding an slave element - if (myAdditionalTagSelector->getCurrentTagProperties().isChild()) { - mySelectorAdditionalParent->showSelectorParentModul(myAdditionalTagSelector->getCurrentTagProperties().getParentTags()); + if (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().isChild()) { + mySelectorAdditionalParent->showSelectorParentModul(myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getParentTags()); } else { mySelectorAdditionalParent->hideSelectorParentModul(); } // Show SelectorChildEdges if we're adding an additional that own the attribute SUMO_ATTR_EDGES - if (myAdditionalTagSelector->getCurrentTagProperties().hasAttribute(SUMO_ATTR_EDGES)) { + if (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().hasAttribute(SUMO_ATTR_EDGES)) { mySelectorChildEdges->showSelectorChildEdgesModul(); } else { mySelectorChildEdges->hideSelectorChildEdgesModul(); } // check if we must show E2 multilane lane selector - if (myAdditionalTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_E2DETECTOR_MULTILANE) { + if (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_E2DETECTOR_MULTILANE) { myE2MultilaneLaneSelector->showE2MultilaneLaneSelectorModul(); - } else if (myAdditionalTagSelector->getCurrentTagProperties().hasAttribute(SUMO_ATTR_LANES)) { + } else if (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().hasAttribute(SUMO_ATTR_LANES)) { myE2MultilaneLaneSelector->hideE2MultilaneLaneSelectorModul(); // Show SelectorChildLanes or consecutive lane selector if we're adding an additional that own the attribute SUMO_ATTR_LANES - if (myAdditionalTagSelector->getCurrentTagProperties().isChild() && - (myAdditionalTagSelector->getCurrentTagProperties().getParentTags().front() == SUMO_TAG_LANE)) { + if (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().isChild() && + (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getParentTags().front() == SUMO_TAG_LANE)) { // show selector parent lane and hide selector child lane mySelectorLaneParents->showSelectorParentLanesModul(); mySelectorChildLanes->hideSelectorChildLanesModul(); @@ -1198,7 +1195,7 @@ GNEAdditionalFrame::createBaseAdditionalObject(const GNETagProperties& tagProper } // stop if currently there isn't a valid selected parent if (mySelectorAdditionalParent->getIdSelected().empty()) { - myAdditionalAttributes->showWarningMessage("A " + toString(tagProperty.getParentTags().front()) + " must be selected before insertion of " + myAdditionalTagSelector->getCurrentTagProperties().getTagStr() + "."); + myAdditionalAttributes->showWarningMessage("A " + toString(tagProperty.getParentTags().front()) + " must be selected before insertion of " + myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTagStr() + "."); return false; } else { // create baseAdditional parent @@ -1224,9 +1221,9 @@ GNEAdditionalFrame::createBaseAdditionalObject(const GNETagProperties& tagProper std::string GNEAdditionalFrame::generateID(GNENetworkElement* networkElement) const { // obtain current number of additionals to generate a new index faster - int additionalIndex = (int)myViewNet->getNet()->getAttributeCarriers()->getAdditionals().at(myAdditionalTagSelector->getCurrentTagProperties().getTag()).size(); + int additionalIndex = (int)myViewNet->getNet()->getAttributeCarriers()->getAdditionals().at(myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTag()).size(); // obtain tag Properties (only for improve code legilibility - const auto& tagProperties = myAdditionalTagSelector->getCurrentTagProperties(); + const auto& tagProperties = myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty(); // get attribute carriers const auto& attributeCarriers = myViewNet->getNet()->getAttributeCarriers(); if (networkElement) { @@ -1264,7 +1261,7 @@ GNEAdditionalFrame::buildAdditionalCommonAttributes(const GNETagProperties& tagP } // If additional own the attribute SUMO_ATTR_FILE but was't defined, will defined as .xml if (tagProperties.hasAttribute(SUMO_ATTR_FILE) && myBaseAdditional->getStringAttribute(SUMO_ATTR_FILE).empty()) { - if ((myAdditionalTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_CALIBRATOR) && (myAdditionalTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_REROUTER)) { + if ((myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_CALIBRATOR) && (myAdditionalTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() != SUMO_TAG_REROUTER)) { // SUMO_ATTR_FILE is optional for calibrators and rerouters (fails to load in sumo when given and the file does not exist) myBaseAdditional->addStringAttribute(SUMO_ATTR_FILE, myBaseAdditional->getStringAttribute(SUMO_ATTR_ID) + ".xml"); } diff --git a/src/netedit/frames/network/GNEPolygonFrame.cpp b/src/netedit/frames/network/GNEPolygonFrame.cpp index 03287c83ad2d..1c001bf3ab39 100644 --- a/src/netedit/frames/network/GNEPolygonFrame.cpp +++ b/src/netedit/frames/network/GNEPolygonFrame.cpp @@ -218,7 +218,7 @@ GNEPolygonFrame::GNEPolygonFrame(FXHorizontalFrame* horizontalFrameParent, GNEVi myBaseShape(nullptr) { // create item Selector modul for shapes - myShapeTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::SHAPE); + myShapeTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::SHAPE, SUMO_TAG_POLY); // Create shape parameters myShapeAttributes = new GNEFrameAttributesModuls::AttributesCreator(this); @@ -231,9 +231,6 @@ GNEPolygonFrame::GNEPolygonFrame(FXHorizontalFrame* horizontalFrameParent, GNEVi /// @brief create GEOPOICreator myGEOPOICreator = new GEOPOICreator(this); - - // set polygon as default shape - myShapeTagSelector->setCurrentTag(SUMO_TAG_POLY); } @@ -247,8 +244,8 @@ GNEPolygonFrame::~GNEPolygonFrame() { void GNEPolygonFrame::show() { - // refresh item selector - myShapeTagSelector->refreshTagProperties(); + // refresh tag selector + myShapeTagSelector->refreshTagSelector(); // show frame GNEFrame::show(); } @@ -259,112 +256,113 @@ GNEPolygonFrame::processClick(const Position& clickedPosition, const GNEViewNetH // reset updateTemporalShape updateTemporalShape = false; // check if current selected shape is valid - if (myShapeTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_POI) { - // show warning dialogbox and stop if input parameters are invalid - if (myShapeAttributes->areValuesValid() == false) { - myShapeAttributes->showWarningMessage(); - return false; - } - // create baseShape object - createBaseShapeObject(SUMO_TAG_POI); - // obtain shape attributes and values - myShapeAttributes->getAttributesAndValues(myBaseShape, true); - // obtain netedit attributes and values - myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); - // Check if ID has to be generated - if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { - myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); - } - // add X-Y - myBaseShape->addDoubleAttribute(SUMO_ATTR_X, clickedPosition.x()); - myBaseShape->addDoubleAttribute(SUMO_ATTR_Y, clickedPosition.y()); - // set GEO Position as false (because we have created POI clicking over View - myBaseShape->addBoolAttribute(SUMO_ATTR_GEO, "false"); - // add shape - addShape(); - // refresh shape attributes - myShapeAttributes->refreshRows(); - // shape added, then return true - return true; - } else if (myShapeTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_POIGEO) { - // show warning dialogbox and stop if input parameters are invalid - if (myShapeAttributes->areValuesValid() == false) { - myShapeAttributes->showWarningMessage(); - return false; - } - // create baseShape object - createBaseShapeObject(SUMO_TAG_POI); - // obtain shape attributes and values - myShapeAttributes->getAttributesAndValues(myBaseShape, true); - // obtain netedit attributes and values - myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); - // Check if ID has to be generated - if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { - myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); - } - // convert position to cartesian - Position GEOPos = clickedPosition; - GeoConvHelper::getFinal().cartesian2geo(GEOPos); - // add X-Y in geo format - myBaseShape->addDoubleAttribute(SUMO_ATTR_LON, GEOPos.x()); - myBaseShape->addDoubleAttribute(SUMO_ATTR_LAT, GEOPos.y()); - // set GEO Position as false (because we have created POI clicking over View - myBaseShape->addBoolAttribute(SUMO_ATTR_GEO, "true"); - // add shape - addShape(); - // refresh shape attributes - myShapeAttributes->refreshRows(); - // shape added, then return true - return true; - } else if (myShapeTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_POILANE) { - // abort if lane is nullptr - if (objectsUnderCursor.getLaneFront() == nullptr) { - WRITE_WARNING(toString(GNE_TAG_POILANE) + " can be only placed over lanes"); - return false; - } - // show warning dialogbox and stop if input parameters are invalid - if (myShapeAttributes->areValuesValid() == false) { - myShapeAttributes->showWarningMessage(); - return false; - } - // create baseShape object - createBaseShapeObject(SUMO_TAG_POI); - // obtain shape attributes and values - myShapeAttributes->getAttributesAndValues(myBaseShape, true); - // obtain netedit attributes and values - myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); - // Check if ID has to be generated - if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { - myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); - } - // obtain Lane - myBaseShape->addStringAttribute(SUMO_ATTR_LANE, objectsUnderCursor.getLaneFront()->getID()); - // obtain position over lane - myBaseShape->addDoubleAttribute(SUMO_ATTR_POSITION, objectsUnderCursor.getLaneFront()->getLaneShape().nearest_offset_to_point2D(clickedPosition)); - // add shape - addShape(); - // refresh shape attributes - myShapeAttributes->refreshRows(); - // shape added, then return true - return true; - } else if (myShapeTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_POLY) { - if (myDrawingShape->isDrawing()) { - // add or delete a new point depending of flag "delete last created point" - if (myDrawingShape->getDeleteLastCreatedPoint()) { - myDrawingShape->removeLastPoint(); - } else { - myDrawingShape->addNewPoint(clickedPosition); + if (myShapeTagSelector->getCurrentTemplateAC() != nullptr) { + if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == SUMO_TAG_POI) { + // show warning dialogbox and stop if input parameters are invalid + if (myShapeAttributes->areValuesValid() == false) { + myShapeAttributes->showWarningMessage(); + return false; } - // set temporal shape - updateTemporalShape = true; + // create baseShape object + createBaseShapeObject(SUMO_TAG_POI); + // obtain shape attributes and values + myShapeAttributes->getAttributesAndValues(myBaseShape, true); + // obtain netedit attributes and values + myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); + // Check if ID has to be generated + if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { + myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); + } + // add X-Y + myBaseShape->addDoubleAttribute(SUMO_ATTR_X, clickedPosition.x()); + myBaseShape->addDoubleAttribute(SUMO_ATTR_Y, clickedPosition.y()); + // set GEO Position as false (because we have created POI clicking over View + myBaseShape->addBoolAttribute(SUMO_ATTR_GEO, "false"); + // add shape + addShape(); + // refresh shape attributes + myShapeAttributes->refreshRows(); + // shape added, then return true return true; - } else { - return false; + } else if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_POIGEO) { + // show warning dialogbox and stop if input parameters are invalid + if (myShapeAttributes->areValuesValid() == false) { + myShapeAttributes->showWarningMessage(); + return false; + } + // create baseShape object + createBaseShapeObject(SUMO_TAG_POI); + // obtain shape attributes and values + myShapeAttributes->getAttributesAndValues(myBaseShape, true); + // obtain netedit attributes and values + myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); + // Check if ID has to be generated + if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { + myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); + } + // convert position to cartesian + Position GEOPos = clickedPosition; + GeoConvHelper::getFinal().cartesian2geo(GEOPos); + // add X-Y in geo format + myBaseShape->addDoubleAttribute(SUMO_ATTR_LON, GEOPos.x()); + myBaseShape->addDoubleAttribute(SUMO_ATTR_LAT, GEOPos.y()); + // set GEO Position as false (because we have created POI clicking over View + myBaseShape->addBoolAttribute(SUMO_ATTR_GEO, "true"); + // add shape + addShape(); + // refresh shape attributes + myShapeAttributes->refreshRows(); + // shape added, then return true + return true; + } else if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_POILANE) { + // abort if lane is nullptr + if (objectsUnderCursor.getLaneFront() == nullptr) { + WRITE_WARNING(toString(GNE_TAG_POILANE) + " can be only placed over lanes"); + return false; + } + // show warning dialogbox and stop if input parameters are invalid + if (myShapeAttributes->areValuesValid() == false) { + myShapeAttributes->showWarningMessage(); + return false; + } + // create baseShape object + createBaseShapeObject(SUMO_TAG_POI); + // obtain shape attributes and values + myShapeAttributes->getAttributesAndValues(myBaseShape, true); + // obtain netedit attributes and values + myNeteditAttributes->getNeteditAttributesAndValues(myBaseShape, objectsUnderCursor.getLaneFront()); + // Check if ID has to be generated + if (!myBaseShape->hasStringAttribute(SUMO_ATTR_ID)) { + myBaseShape->addStringAttribute(SUMO_ATTR_ID, myViewNet->getNet()->getAttributeCarriers()->generateShapeID(SUMO_TAG_POI)); + } + // obtain Lane + myBaseShape->addStringAttribute(SUMO_ATTR_LANE, objectsUnderCursor.getLaneFront()->getID()); + // obtain position over lane + myBaseShape->addDoubleAttribute(SUMO_ATTR_POSITION, objectsUnderCursor.getLaneFront()->getLaneShape().nearest_offset_to_point2D(clickedPosition)); + // add shape + addShape(); + // refresh shape attributes + myShapeAttributes->refreshRows(); + // shape added, then return true + return true; + } else if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == SUMO_TAG_POLY) { + if (myDrawingShape->isDrawing()) { + // add or delete a new point depending of flag "delete last created point" + if (myDrawingShape->getDeleteLastCreatedPoint()) { + myDrawingShape->removeLastPoint(); + } else { + myDrawingShape->addNewPoint(clickedPosition); + } + // set temporal shape + updateTemporalShape = true; + return true; + } else { + return false; + } } - } else { - myViewNet->setStatusBarText("Current selected shape isn't valid."); - return false; } + myViewNet->setStatusBarText("Current selected shape isn't valid."); + return false; } @@ -444,19 +442,19 @@ GNEPolygonFrame::shapeDrawed() { void GNEPolygonFrame::tagSelected() { - if (myShapeTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_NOTHING) { + if (myShapeTagSelector->getCurrentTemplateAC()) { // if there are parmeters, show and Recalc groupBox - myShapeAttributes->showAttributesCreatorModul(myShapeTagSelector->getCurrentTagProperties(), {}); + myShapeAttributes->showAttributesCreatorModul(myShapeTagSelector->getCurrentTemplateAC()->getTagProperty(), {}); // show netedit attributes - myNeteditAttributes->showNeteditAttributesModul(myShapeTagSelector->getCurrentTagProperties()); + myNeteditAttributes->showNeteditAttributesModul(myShapeTagSelector->getCurrentTemplateAC()->getTagProperty()); // Check if drawing mode has to be shown - if (myShapeTagSelector->getCurrentTagProperties().getTag() == SUMO_TAG_POLY) { + if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == SUMO_TAG_POLY) { myDrawingShape->showDrawingShape(); } else { myDrawingShape->hideDrawingShape(); } // Check if GEO POI Creator has to be shown - if (myShapeTagSelector->getCurrentTagProperties().getTag() == GNE_TAG_POIGEO) { + if (myShapeTagSelector->getCurrentTemplateAC()->getTagProperty().getTag() == GNE_TAG_POIGEO) { myGEOPOICreator->showGEOPOICreatorModul(); } else { myGEOPOICreator->hideGEOPOICreatorModul();