Path: blob/main/src/netedit/frames/GNEAttributesEditor.cpp
193674 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEAttributesEditor.cpp14/// @author Pablo Alvarez Lopez15/// @date Feb 202516///17// pack of all GNEAttributesEditorTypes18/****************************************************************************/1920#include "GNEAttributesEditor.h"2122#include <netedit/elements/GNEAttributeCarrier.h>23#include <netedit/GNETagProperties.h>2425// ===========================================================================26// method definitions27// ===========================================================================2829GNEAttributesEditor::GNEAttributesEditor(GNEFrame* frameParent, GNEAttributesEditorType::EditorType editorType) {30myBasicAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Internal attributes"), editorType, GNEAttributesEditorType::AttributeType::BASIC);31myExtendedAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Extended attributes"), editorType, GNEAttributesEditorType::AttributeType::EXTENDED);32myFlowAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Flow attributes"), editorType, GNEAttributesEditorType::AttributeType::FLOW);33myGeoAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Geo attributes"), editorType, GNEAttributesEditorType::AttributeType::GEO);34myParametersAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Parameters"), editorType, GNEAttributesEditorType::AttributeType::PARAMETERS);35myNeteditAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Netedit attributes"), editorType, GNEAttributesEditorType::AttributeType::NETEDIT);36}373839void40GNEAttributesEditor::showAttributesEditor(GNEAttributeCarrier* AC, const bool primaryAttributeEditor) {41myBasicAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);42myExtendedAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);43myFlowAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);44myGeoAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);45myParametersAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);46myNeteditAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);47}484950void51GNEAttributesEditor::showAttributesEditor(const std::unordered_set<GNEAttributeCarrier*>& ACs, const bool primaryAttributeEditor) {52myBasicAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);53myExtendedAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);54myFlowAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);55myGeoAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);56myParametersAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);57myNeteditAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);58}596061void62GNEAttributesEditor::hideAttributesEditor() {63myBasicAttributesEditor->hideAttributesEditor();64myExtendedAttributesEditor->hideAttributesEditor();65myFlowAttributesEditor->hideAttributesEditor();66myGeoAttributesEditor->hideAttributesEditor();67myParametersAttributesEditor->hideAttributesEditor();68myNeteditAttributesEditor->hideAttributesEditor();69}707172void73GNEAttributesEditor::refreshAttributesEditor() {74myBasicAttributesEditor->refreshAttributesEditor();75myExtendedAttributesEditor->refreshAttributesEditor();76myFlowAttributesEditor->refreshAttributesEditor();77myGeoAttributesEditor->refreshAttributesEditor();78myParametersAttributesEditor->refreshAttributesEditor();79myNeteditAttributesEditor->refreshAttributesEditor();80}818283void84GNEAttributesEditor::disableAttributesEditor() {85myBasicAttributesEditor->disableAttributesEditor();86myExtendedAttributesEditor->disableAttributesEditor();87myFlowAttributesEditor->disableAttributesEditor();88myGeoAttributesEditor->disableAttributesEditor();89myParametersAttributesEditor->disableAttributesEditor();90myNeteditAttributesEditor->disableAttributesEditor();91}929394GNEAttributesEditorType*95GNEAttributesEditor::getNeteditAttributesEditor() const {96return myNeteditAttributesEditor;97}9899100bool101GNEAttributesEditor::checkAttributes(const bool showWarning) {102if (!myBasicAttributesEditor->checkAttributes(showWarning)) {103return false;104} else if (!myExtendedAttributesEditor->checkAttributes(showWarning)) {105return false;106} else if (!myFlowAttributesEditor->checkAttributes(showWarning)) {107return false;108} else if (!myGeoAttributesEditor->checkAttributes(showWarning)) {109return false;110} else if (!myParametersAttributesEditor->checkAttributes(showWarning)) {111return false;112} else if (!myNeteditAttributesEditor->checkAttributes(showWarning)) {113return false;114} else {115return true;116}117}118119120SumoXMLAttr121GNEAttributesEditor::fillSumoBaseObject(CommonXMLStructure::SumoBaseObject* baseObject) const {122// check if edited AC is a vehicle (needed to avoid empty attributes in SUMOVehicleParser123bool useSUMOVehicleparser = false;124if (myBasicAttributesEditor->getEditedAttributeCarriers().size() > 0) {125if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isVehicle()) {126useSUMOVehicleparser = true;127} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isPerson()) {128useSUMOVehicleparser = true;129} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isContainer()) {130useSUMOVehicleparser = true;131}132}133SumoXMLAttr fillResult = SUMO_ATTR_DEFAULT;134fillResult = myBasicAttributesEditor->fillSumoBaseObject(baseObject, !useSUMOVehicleparser);135if (fillResult != SUMO_ATTR_NOTHING) {136return fillResult;137}138fillResult = myExtendedAttributesEditor->fillSumoBaseObject(baseObject, true);139if (fillResult != SUMO_ATTR_NOTHING) {140return fillResult;141}142fillResult = myFlowAttributesEditor->fillSumoBaseObject(baseObject, true);143if (fillResult != SUMO_ATTR_NOTHING) {144return fillResult;145}146fillResult = myGeoAttributesEditor->fillSumoBaseObject(baseObject, true);147if (fillResult != SUMO_ATTR_NOTHING) {148return fillResult;149}150fillResult = myParametersAttributesEditor->fillSumoBaseObject(baseObject, true);151if (fillResult != SUMO_ATTR_NOTHING) {152return fillResult;153}154fillResult = myNeteditAttributesEditor->fillSumoBaseObject(baseObject, true);155if (fillResult != SUMO_ATTR_NOTHING) {156return fillResult;157}158return fillResult;159}160161162bool163GNEAttributesEditor::isReparenting() const {164return myNeteditAttributesEditor->isReparenting();165}166167168bool169GNEAttributesEditor::checkNewParent(const GNEAttributeCarrier* AC) const {170return myNeteditAttributesEditor->checkNewParent(AC);171}172173174void175GNEAttributesEditor::setNewParent(const GNEAttributeCarrier* AC) {176myNeteditAttributesEditor->setNewParent(AC);177}178179180void181GNEAttributesEditor::abortReparenting() {182myNeteditAttributesEditor->abortReparenting();183}184185/****************************************************************************/186187188