X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_ValidatorReader.cpp;h=e6b802a59efce057518a2c97b903e1494ca68cc6;hb=97917d3698f5a2f7fc9596e7c755ff8f6751e373;hp=d03dff58d7d6784c5bc572fd25639a5dad93c1bc;hpb=a731f82dccbfdb67cbf8e8d617222a4d3e32018a;p=modules%2Fshaper.git diff --git a/src/Config/Config_ValidatorReader.cpp b/src/Config/Config_ValidatorReader.cpp index d03dff58d..e6b802a59 100644 --- a/src/Config/Config_ValidatorReader.cpp +++ b/src/Config/Config_ValidatorReader.cpp @@ -1,21 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -/* - * Config_ValidatorReader.cpp - * - * Created on: Mar 20, 2015 - * Author: sbh - */ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include #include #include -#include #include #include -#include #include #include @@ -38,15 +46,28 @@ void Config_ValidatorReader::processNode(xmlNodePtr theNode) { if (isNode(theNode, NODE_VALIDATOR, NULL)) { processValidator(theNode); - } else if (isNode(theNode, NODE_SELFILTER, NULL)) { - processSelectionFilter(theNode); } else if (isNode(theNode, NODE_FEATURE, NULL)) { storeAttribute(theNode, _ID); + } else if (isWidgetNode(theNode)) { + storeAttribute(theNode, _ID); + // Store widget name to restore it's id on validator/selector processing + myCurrentWidget = getNodeName(theNode); } //Process SOURCE nodes. Config_XMLReader::processNode(theNode); } +void Config_ValidatorReader::cleanup(xmlNodePtr theNode) +{ + if (isNode(theNode, NODE_FEATURE, NULL)) { + cleanupAttribute(theNode, _ID); + } else if (isWidgetNode(theNode)) { + cleanupAttribute(NODE_XMLPARENT, _ID); + // Cleanup widget name when leave the widget node. + myCurrentWidget = ""; + } +} + bool Config_ValidatorReader::processChildren(xmlNodePtr aNode) { return true; @@ -56,43 +77,19 @@ void Config_ValidatorReader::processValidator(xmlNodePtr theNode) { Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); Events_Loop* aEvLoop = Events_Loop::loop(); - std::shared_ptr + std::shared_ptr aMessage(new Config_ValidatorMessage(aValidatoEvent, this)); std::string aValidatorId; std::list aParameters; getParametersInfo(theNode, aValidatorId, aParameters); aMessage->setValidatorId(aValidatorId); aMessage->setValidatorParameters(aParameters); - //TODO(sbh): update feature/attribute id restoring - // when "cleanup" technique will be available (v. >= 1.1.0) - xmlNodePtr aFeatureOrWdgNode = theNode->parent; - if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { - aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID)); - } else { - aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID)); - aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID)); - } - aEvLoop->send(aMessage); -} - -void Config_ValidatorReader::processSelectionFilter(xmlNodePtr theNode) -{ - Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED); - Events_Loop* aEvLoop = Events_Loop::loop(); - std::shared_ptr aMessage = - std::make_shared(aFilterEvent, this); - std::string aSelectionFilterId; - std::list aParameters; - getParametersInfo(theNode, aSelectionFilterId, aParameters); - aMessage->setSelectionFilterId(aSelectionFilterId); - aMessage->setFilterParameters(aParameters); - - xmlNodePtr aFeatureOrWdgNode = theNode->parent; - if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { - aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID)); - } else { - aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID)); - aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID)); + std::string aFeatureId = restoreAttribute(NODE_FEATURE, _ID); + aMessage->setFeatureId(aFeatureId); + // parent is attribute (widget) + if (!myCurrentWidget.empty()) { + std::string aParentId = restoreAttribute(myCurrentWidget.c_str(), _ID); + aMessage->setAttributeId(aParentId); } aEvLoop->send(aMessage); }