From fe1414607afe2a01de5e019f908a909a749ddbe6 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 26 Sep 2019 16:45:45 +0300 Subject: [PATCH] Fir for the issue #3020 : Error in console after dump/load python script. Fixed the problem of dump naming name of selected circle center of the other part. --- src/Model/Model_AttributeIntArray.cpp | 4 +- src/Model/Model_AttributeSelection.cpp | 11 +++-- src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/Test/Test3020.py | 42 ++++++++++++++++++++ src/SketchPlugin/SketchPlugin_SketchEntity.h | 2 +- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 src/ModelAPI/Test/Test3020.py diff --git a/src/Model/Model_AttributeIntArray.cpp b/src/Model/Model_AttributeIntArray.cpp index 3ee8a25de..3ee99ee6a 100644 --- a/src/Model/Model_AttributeIntArray.cpp +++ b/src/Model/Model_AttributeIntArray.cpp @@ -39,7 +39,7 @@ int Model_AttributeIntArray::size() myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True; } // checking the validity because attribute (as a field) may be presented, - // but without label: it is undoed + // but without label: it is undone return (myArray.IsNull() || !myArray->IsValid()) ? 0 : myArray->Length(); } @@ -52,7 +52,7 @@ void Model_AttributeIntArray::setSize(const int theSize) } } else { // reset the old array if (theSize) { - if (theSize != myArray->Length()) { // old data is not keept, a new array is created + if (theSize != myArray->Length()) { // old data is not kept, a new array is created Handle(TColStd_HArray1OfInteger) aNewArray = new TColStd_HArray1OfInteger(0, theSize - 1); myArray->ChangeArray(aNewArray); owner()->data()->sendAttributeUpdated(this); diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 41df2868a..e7a974e2e 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -785,14 +785,13 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa if (aCont->groupName() == ModelAPI_ResultPart::group()) { ResultPartPtr aPart = std::dynamic_pointer_cast(aCont); int anIndex; - GeomShapePtr aValue = value(); - if (aValue.get()) - return aPart->data()->name() + "/" + aPart->nameInPart(aValue, anIndex); - else - return aPart->data()->name(); + std::string aResult = aSubSh.get() ? + aPart->data()->name() + "/" + aPart->nameInPart(aSubSh, anIndex) : aPart->data()->name(); + if (aCenterType != NOT_CENTER) + aResult += centersMap()[aCenterType]; + return aResult; } - // whole infinitive construction if (aCont->groupName() == ModelAPI_ResultConstruction::group()) { ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aCont); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 2fe3426ce..1ef43263f 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -253,4 +253,5 @@ ADD_UNIT_TESTS(TestConstants.py Test2873.py Test2901.py Test2903.py + Test3020.py ) diff --git a/src/ModelAPI/Test/Test3020.py b/src/ModelAPI/Test/Test3020.py new file mode 100644 index 000000000..429dd9125 --- /dev/null +++ b/src/ModelAPI/Test/Test3020.py @@ -0,0 +1,42 @@ +# 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 +# + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(25, 20, 10) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 20, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]__cc"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchCircle_2 = Sketch_2.addCircle(25, 20, 5) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_2.center()) +model.end() +# check the sketch_2 projection and the whole sketch is valid after selection of the circle center from another part +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(SketchProjection_1.feature())) +assert(aFactory.validate(Sketch_2.feature())) + +assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index c207dd72b..eb50851fa 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -156,7 +156,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC if (theResult.get() && ModelAPI_Session::get()->isOperation()) { AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); aColorAttr->setSize(3); - // Set the color attribute in order do not use default colors in the perasentation object + // Set the color attribute in order do not use default colors in the presentation object for (int i = 0; i < 3; i++) aColorAttr->setValue(i, aColor[i]); } -- 2.39.2