From: mpv Date: Wed, 24 Jun 2020 14:09:56 +0000 (+0300) Subject: Fix for the issue #19726 : Placement failed because of wrong name in face selection. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b18d4f784e964a968c16a7b0cc1fb58ab27f9d5;p=modules%2Fshaper.git Fix for the issue #19726 : Placement failed because of wrong name in face selection. Call update in history of attribute created for the external part selection. --- diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 193f2d1dd..3ee60386a 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -122,7 +122,7 @@ public: /// Updates the arguments of selection if something was affected by creation /// or reorder of features upper in the history line (issue #1757) /// Returns theRemove true if this attribute must be removed (become deleted) - MODEL_EXPORT virtual void updateInHistory(bool& theRemove); + MODEL_EXPORT virtual void updateInHistory(bool& theRemove) override; // Implementation of the name generator method from the Selector package // This method returns the context name by the label of the sub-selected shape diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 69955315d..ce23976c3 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -2028,6 +2028,8 @@ FeaturePtr Model_Objects::lastFeature() bool Model_Objects::isLater(FeaturePtr theLater, FeaturePtr theCurrent) const { + if (theLater->getKind() == "InternalSelectionInPartFeature") + return true; std::shared_ptr aLaterD = std::static_pointer_cast(theLater->data()); std::shared_ptr aCurrentD = std::static_pointer_cast(theCurrent->data()); if (aLaterD.get() && aLaterD->isValid() && aCurrentD.get() && aCurrentD->isValid()) { diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 044893237..3c52f0986 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -327,7 +327,11 @@ bool Model_ResultPart::updateInPart(const int theIndex) AttributeSelectionListPtr aSelAttr = aDoc->selectionInPartFeature(); AttributeSelectionPtr aThisAttr = aSelAttr->value(theIndex - 1); if (aThisAttr.get()) { - return aThisAttr->update(); + if (aThisAttr->update()) { + bool aRemove = false; + aThisAttr->updateInHistory(aRemove); + return true; // it was updated + } } } return false; // something is wrong diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 4deb924bf..a2bcdfacb 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -1087,8 +1086,8 @@ void Model_Update::updateSelection(const std::setdata()->attributes(ModelAPI_AttributeSelection::typeId()); std::list::iterator aRefsIter = aRefs.begin(); for (; aRefsIter != aRefs.end(); aRefsIter++) { - std::shared_ptr aSel = - std::dynamic_pointer_cast(*aRefsIter); + AttributeSelectionPtr aSel = + std::dynamic_pointer_cast(*aRefsIter); bool aRemove = false; aSel->updateInHistory(aRemove); } @@ -1099,12 +1098,12 @@ void Model_Update::updateSelection(const std::set aSel = std::dynamic_pointer_cast(*aRefsIter); for(int a = aSel->size() - 1; a >= 0; a--) { - std::shared_ptr aSelAttr = - std::dynamic_pointer_cast(aSel->value(a)); + AttributeSelectionPtr aSelAttr = + std::dynamic_pointer_cast(aSel->value(a)); if (aSelAttr.get()) { - bool theRemove = false; - aSelAttr->updateInHistory(theRemove); - if (theRemove) { + bool aRemove = false; + aSelAttr->updateInHistory(aRemove); + if (aRemove) { aRemoveSet.insert(a); } } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 4f04867ec..4ac152b26 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -261,4 +261,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19058.py Test19217.py Test19707.py + Test19726.py ) diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index aba0818d9..fa5b56053 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -123,6 +123,11 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Makes the current local selection becomes all sub-shapes with same base geometry. MODELAPI_EXPORT virtual void combineGeometrical() = 0; + /// Updates the arguments of selection if something was affected by creation + /// or reorder of features upper in the history line. + /// Returns theRemove true if this attribute must be removed (become deleted) + MODELAPI_EXPORT virtual void updateInHistory(bool& theRemove) = 0; + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeSelection(); diff --git a/src/ModelAPI/Test/Test19726.py b/src/ModelAPI/Test/Test19726.py new file mode 100644 index 000000000..f6e82b2ed --- /dev/null +++ b/src/ModelAPI/Test/Test19726.py @@ -0,0 +1,49 @@ +# Copyright (C) 2014-2020 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("XOZ")) +SketchCircle_1 = Sketch_1.addCircle(18.39021699364881, 11.50401662688171, 4.123179523509023) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +model.do() +Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], axis = model.selection("EDGE", "Part_1/([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])"), distance = 20, keepSubResults = True) +aName1 = Translation_1.axisObject().namingName() +model.end() + +# update the extrusion in the part, so, outside the part selection must be moved in history +model.begin() +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 45) +model.do() +aSession = ModelAPI_Session.get() +aSession.setActiveDocument(partSet) +model.end() + +# check that name was changed to the rotation +aName2 = Translation_1.axisObject().namingName() +assert(aName1 != aName2) +assert(len(aName2) > 7) + +assert(model.checkPythonDump())