From: mpv Date: Thu, 3 Mar 2016 07:41:59 +0000 (+0300) Subject: Fix for the issue #1326 X-Git-Tag: V_2.2.0~20^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9bbebdaff90350f0d412e859b8fccac27823c250;p=modules%2Fshaper.git Fix for the issue #1326 --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 5f18fe56a..c004332cc 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -905,6 +905,17 @@ std::shared_ptr Model_Document::currentFeature(const bool theV return std::shared_ptr(); // null feature means the higher than first } +// recursive function to check if theSub is a child of theMain composite feature +// through all the hierarchy of parents +static bool isSub(const CompositeFeaturePtr theMain, const FeaturePtr theSub) { + CompositeFeaturePtr aParent = ModelAPI_Tools::compositeOwner(theSub); + if (!aParent.get()) + return false; + if (aParent == theMain) + return true; + return isSub(theMain, aParent); +} + void Model_Document::setCurrentFeature( std::shared_ptr theCurrent, const bool theVisible) { @@ -970,7 +981,7 @@ void Model_Document::setCurrentFeature( bool aDisabledFlag = !aPassed; if (aMain.get()) { - if (aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled + if (isSub(aMain, anIter)) // sub-elements of not-disabled feature are not disabled aDisabledFlag = false; else if (anOwners.find(anIter) != anOwners.end()) // disable the higher-level feature is the nested is the current aDisabledFlag = true; diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 57dcd9a78..a5d266d81 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -119,9 +119,13 @@ bool Model_ResultPart::setDisabled(std::shared_ptr theThis, if (!myTrsf.get()) { // disable of base result part DocumentPtr aDoc = Model_ResultPart::partDoc(); if (aDoc.get() && aDoc->isOpened()) { - std::shared_ptr anIntDoc = std::dynamic_pointer_cast(aDoc); // make the current feature the last in any case: to update shapes defore deactivation too - FeaturePtr aLastFeature = anIntDoc->lastFeature(); + int aSize = aDoc->size(ModelAPI_Feature::group()); + FeaturePtr aLastFeature; + if (aSize) + aLastFeature = std::dynamic_pointer_cast(aDoc->object( + ModelAPI_Feature::group(), aSize - 1)); + aDoc->setCurrentFeature(aLastFeature, false); if (theFlag) { // disable, so make all features disabled too // update the shape just before the deactivation: it will be used outside of part