From 6387f4dc506c5cade63244a67e804cc2228cc4a6 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 8 Oct 2015 14:11:05 +0300 Subject: [PATCH] Made the nesting feature disabled until the nested features are modified/current --- src/Model/Model_Document.cpp | 27 ++++++++++++++------------- src/Model/Model_Objects.cpp | 2 ++ src/Model/Model_Update.cpp | 7 ++++++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index e0ae73e76..c049e739b 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -759,20 +759,16 @@ void Model_Document::setCurrentFeature( TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE); CompositeFeaturePtr aMain; // main feature that may nest the new current + std::set anOwners; // composites that contain theCurrent (with any level of nesting) if (theCurrent.get()) { aMain = std::dynamic_pointer_cast(theCurrent); - if (!aMain.get()) { - // if feature nests into compisite feature, make the composite feature as current - const std::set& aRefsToMe = theCurrent->data()->refsToMe(); - std::set::const_iterator aRefToMe = aRefsToMe.begin(); - for(; aRefToMe != aRefsToMe.end(); aRefToMe++) { - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast((*aRefToMe)->owner()); - if (aComposite.get() && aComposite->isSub(theCurrent)) { - aMain = aComposite; - break; - } + CompositeFeaturePtr anOwner = ModelAPI_Tools::compositeOwner(theCurrent); + while(anOwner.get()) { + if (!aMain.get()) { + aMain = anOwner; } + anOwners.insert(anOwner); + anOwner = ModelAPI_Tools::compositeOwner(anOwner); } } @@ -817,8 +813,13 @@ void Model_Document::setCurrentFeature( if (anIter == theCurrent) aPassed = true; bool aDisabledFlag = !aPassed; - if (aMain.get() && aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled - aDisabledFlag = false; + if (aMain.get()) { + if (aMain->isSub(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; + } + if (anIter->getKind() == "Parameter") {// parameters are always out of the history of features, but not parameters if (theCurrent.get() && theCurrent->getKind() != "Parameter") aDisabledFlag = false; diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 82831c710..9e209eb72 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -754,6 +754,7 @@ void Model_Objects::synchronizeBackRefs() std::dynamic_pointer_cast((*aRefTo)->data()); aRefData->addBackReference(aFeature, aRefsIter->first); // here the Concealed flag is updated // update enable/disable status: the nested status must be equal to the composite + /* MPV: not sub-elements of sketch may be enabled during editition of sketch CompositeFeaturePtr aComp = std::dynamic_pointer_cast(aFeature); if (aComp.get()) { @@ -762,6 +763,7 @@ void Model_Objects::synchronizeBackRefs() aReferenced->setDisabled(aComp->isDisabled()); } } + */ } } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 69b345114..69a10d745 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -274,8 +274,13 @@ void Model_Update::updateFeature(FeaturePtr theFeature) // check all features this feature depended on (recursive call of updateFeature) static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); - if (theFeature->isDisabled()) + if (theFeature->isDisabled()) { + // possibly sub-elements are not disabled? + CompositeFeaturePtr aCompos = std::dynamic_pointer_cast(theFeature); + if (aCompos) + iterateUpdate(aCompos); return; + } // do not execute the composite that contains the current bool isPostponedMain = false; -- 2.39.2