X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FParametersPlugin%2FParametersPlugin_Parameter.cpp;h=b49507befdee9afa4efdd78ace80d44682e8c243;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=075b5eab4f04a60c79cd0b3653fd7d5d41ed195e;hpb=83f696896f289f92128194a96a0fb667b487e72e;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index 075b5eab4..b49507bef 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: ParametersPlugin_Parameter.cpp -// Created: 23 MArch 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 @@ -61,11 +74,41 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID) void ParametersPlugin_Parameter::updateName() { std::string aName = string(VARIABLE_ID())->value(); - data()->setName(aName); + data()->setName(ModelAPI_Tools::toWString(aName)); ResultParameterPtr aParam = document()->createParameter(data()); - aParam->data()->setName(aName); + std::string anOldName = ModelAPI_Tools::toString(aParam->data()->name()); + aParam->data()->setName(ModelAPI_Tools::toWString(aName)); setResult(aParam); + + + // #2474 : if parameter name now hides/shows the higher level parameter name, + // update the depended expressions + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); + if (aParam->document() != aRootDoc) { + std::list aNames; // collect names in the root document that must be checked + aNames.push_back(aName); + if (anOldName != aName) { + aNames.push_back(anOldName); + } + std::list::iterator aNIter = aNames.begin(); + for (; aNIter != aNames.end(); aNIter++) { + double aValue; + ResultParameterPtr aRootParam; + FeaturePtr aThis = + std::dynamic_pointer_cast(string(VARIABLE_ID())->owner()); + if (ModelAPI_Tools::findVariable(aThis, *aNIter, aValue, aRootParam, aRootDoc)) { + std::set > anAttributes = + aRootParam->data()->refsToMe(); + std::set >::const_iterator anAttributeIt = + anAttributes.cbegin(); + for (; anAttributeIt != anAttributes.cend(); ++anAttributeIt) { + const AttributePtr& anAttribute = *anAttributeIt; + ModelAPI_AttributeEvalMessage::send(anAttribute, NULL); + } + } + } + } } bool ParametersPlugin_Parameter::updateExpression() @@ -83,6 +126,7 @@ bool ParametersPlugin_Parameter::updateExpression() AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); aValueAttribute->setValue(aValue); setResult(aParam); + return true; }