Path: blob/main/src/netedit/frames/GNEAttributesEditor.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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}929394bool95GNEAttributesEditor::checkAttributes(const bool showWarning) {96if (!myBasicAttributesEditor->checkAttributes(showWarning)) {97return false;98} else if (!myExtendedAttributesEditor->checkAttributes(showWarning)) {99return false;100} else if (!myFlowAttributesEditor->checkAttributes(showWarning)) {101return false;102} else if (!myGeoAttributesEditor->checkAttributes(showWarning)) {103return false;104} else if (!myParametersAttributesEditor->checkAttributes(showWarning)) {105return false;106} else if (!myNeteditAttributesEditor->checkAttributes(showWarning)) {107return false;108} else {109return true;110}111}112113114SumoXMLAttr115GNEAttributesEditor::fillSumoBaseObject(CommonXMLStructure::SumoBaseObject* baseObject) const {116// check if edited AC is a vehicle (needed to avoid empty attributes in SUMOVehicleParser117bool useSUMOVehicleparser = false;118if (myBasicAttributesEditor->getEditedAttributeCarriers().size() > 0) {119if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isVehicle()) {120useSUMOVehicleparser = true;121} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isPerson()) {122useSUMOVehicleparser = true;123} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isContainer()) {124useSUMOVehicleparser = true;125}126}127SumoXMLAttr fillResult = SUMO_ATTR_DEFAULT;128fillResult = myBasicAttributesEditor->fillSumoBaseObject(baseObject, !useSUMOVehicleparser);129if (fillResult != SUMO_ATTR_NOTHING) {130return fillResult;131}132fillResult = myExtendedAttributesEditor->fillSumoBaseObject(baseObject, true);133if (fillResult != SUMO_ATTR_NOTHING) {134return fillResult;135}136fillResult = myFlowAttributesEditor->fillSumoBaseObject(baseObject, true);137if (fillResult != SUMO_ATTR_NOTHING) {138return fillResult;139}140fillResult = myGeoAttributesEditor->fillSumoBaseObject(baseObject, true);141if (fillResult != SUMO_ATTR_NOTHING) {142return fillResult;143}144fillResult = myParametersAttributesEditor->fillSumoBaseObject(baseObject, true);145if (fillResult != SUMO_ATTR_NOTHING) {146return fillResult;147}148fillResult = myNeteditAttributesEditor->fillSumoBaseObject(baseObject, true);149if (fillResult != SUMO_ATTR_NOTHING) {150return fillResult;151}152return fillResult;153}154155156bool157GNEAttributesEditor::isReparenting() const {158return myNeteditAttributesEditor->isReparenting();159}160161162bool163GNEAttributesEditor::checkNewParent(const GNEAttributeCarrier* AC) const {164return myNeteditAttributesEditor->checkNewParent(AC);165}166167168void169GNEAttributesEditor::setNewParent(const GNEAttributeCarrier* AC) {170myNeteditAttributesEditor->setNewParent(AC);171}172173174void175GNEAttributesEditor::abortReparenting() {176myNeteditAttributesEditor->abortReparenting();177}178179/****************************************************************************/180181182