]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2474 : part parameter has higher priority than partset parameter...
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 8 May 2018 08:45:24 +0000 (11:45 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 8 May 2018 08:45:24 +0000 (11:45 +0300)
src/ParametersPlugin/CMakeLists.txt
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp
src/ParametersPlugin/Test/Test2474.py [new file with mode: 0644]

index a5aae89231b2e3c842adfc1bd6a9ac6a589eb2b1..b37fe03f2778a370784df13e2c76b528cffb3aee 100644 (file)
@@ -118,4 +118,5 @@ ADD_UNIT_TESTS(TestParameterCreation.py
                TestParameterChangeValue.py
                Test1806.py
                Test2392.py
+               Test2474.py
               )
index c485dffde44485fbd085cacdabdfb508d74361f6..d2481ebddbe041f3890e8275fba60522a876ecd9 100644 (file)
@@ -250,10 +250,37 @@ void setParameterName(ResultParameterPtr theResultParameter, const std::string&
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
           ModelAPI_Feature::feature(theResultParameter));
 
+  std::string anOldName = aParameter->name();
   aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true);
   aParameter->data()->setName(theName);
   aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName);
   aParameter->data()->blockSendAttributeUpdated(aWasBlocked);
+
+  // #2474 : if parameter name now hides/shows the higher level parameter name,
+  // update the depended expressions
+  DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+  if (theResultParameter->document() != aRootDoc) {
+    std::list<std::string> aNames; // collect names in the root document that must be checked
+    aNames.push_back(theName);
+    if (anOldName != theName) {
+      aNames.push_back(anOldName);
+    }
+    std::list<std::string>::iterator aNIter = aNames.begin();
+    for (; aNIter != aNames.end(); aNIter++) {
+      double aValue;
+      ResultParameterPtr aRootParam;
+      if (ModelAPI_Tools::findVariable(aParameter, *aNIter, aValue, aRootParam, aRootDoc)) {
+        std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes =
+          aRootParam->data()->refsToMe();
+        std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anAttributeIt =
+          anAttributes.cbegin();
+        for (; anAttributeIt != anAttributes.cend(); ++anAttributeIt) {
+          const AttributePtr& anAttribute = *anAttributeIt;
+          ModelAPI_AttributeEvalMessage::send(anAttribute, NULL);
+        }
+      }
+    }
+  }
 }
 
 void ParametersPlugin_EvalListener::processObjectRenamedEvent(
diff --git a/src/ParametersPlugin/Test/Test2474.py b/src/ParametersPlugin/Test/Test2474.py
new file mode 100644 (file)
index 0000000..bd2b659
--- /dev/null
@@ -0,0 +1,48 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+model.addParameter(partSet, "l", "200")
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(138.3632494179343, 48.5641040948674, -61.63675058206567, 48.5641040948674)
+SketchLine_2 = Sketch_1.addLine(-61.63675058206567, 48.5641040948674, -61.63675058206567, -46.51114810194107)
+SketchLine_3 = Sketch_1.addLine(-61.63675058206567, -46.51114810194107, 138.3632494179343, -46.51114810194107)
+SketchLine_4 = Sketch_1.addLine(138.3632494179343, -46.51114810194107, 138.3632494179343, 48.5641040948674)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "l")
+model.do()
+model.addParameter(Part_1_doc, "l", "300")
+model.end()
+
+# Check that after substitution of module document "l" by part document "l" the value is updated
+aValue = SketchConstraintLength_1.feature().real("ConstraintValue").value()
+assert(aValue == 300)