X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelection.cpp;h=432c6f1c2e7740d37293b040c46aafd89823e727;hb=e8fce5fe73fee1a8ea2929934a7e6f71bd1e3eb5;hp=369fb52a7f78c23a034f2379bea34703c5b4f3c6;hpb=c5a351512e0bf9a981b9dbdc53f4c8d18ac7d68c;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 369fb52a7..432c6f1c2 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// Copyright (C) 2014-2021 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 @@ -604,6 +604,8 @@ bool Model_AttributeSelection::update() aResult = aSelector.restore(aContextShape); bool aWasInvalid = aSelLab.IsAttribute(kINVALID_SELECTION); setInvalidIfFalse(aSelLab, aResult); + if (!aResult) + aWasInvalid = false; TopoDS_Shape aNewShape; if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) @@ -1055,7 +1057,22 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, // collect features from PartSet and the current part SessionPtr aSession = ModelAPI_Session::get(); std::list aFeatures = aSession->moduleDocument()->allFeatures(); - if (aSession->moduleDocument() != owner()->document()) { + if (anOwner->getKind() == "ImportResult") { + // special case: feature "ImportResult" refers to the results from another parts, + // thus, it is necessary to go through the features of these parts too. + std::list aPartSetFeatures = aFeatures; + aFeatures.clear(); + for (std::list::iterator it = aPartSetFeatures.begin(); + it != aPartSetFeatures.end(); ++it) { + aFeatures.push_back(*it); + if ((*it)->firstResult()->groupName() == ModelAPI_ResultPart::group()) { + ResultPartPtr aPart = std::dynamic_pointer_cast((*it)->firstResult()); + std::list aPartFeatures = aPart->partDoc()->allFeatures(); + aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end()); + } + } + } + else if (aSession->moduleDocument() != owner()->document()) { std::list aPartFeatures = owner()->document()->allFeatures(); aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end()); } @@ -2052,24 +2069,28 @@ ResultPtr Model_AttributeSelection::newestContext( //if (aResult->groupName() == ModelAPI_ResultBody::group()) { // try to search newer context by the concealment references // take references to all results: root one, any sub - std::list allRes; + std::list allRes; ResultPtr aCompContext; ResultBodyPtr aCompBody = ModelAPI_Tools::bodyOwner(aResult, true); if (aCompBody.get()) { - ModelAPI_Tools::allSubs(aCompBody, allRes); - allRes.push_back(aCompBody); + std::list allSub; + ModelAPI_Tools::allSubs(aCompBody, allSub); + for(std::list::iterator anIt = allSub.begin(); anIt != allSub.end(); anIt++) + allRes.push_back((*anIt)->data()); + allRes.push_back(aCompBody->data()); aCompContext = aCompBody; } if (allRes.empty()) - allRes.push_back(aResult); + allRes.push_back(aResult->data()); + allRes.push_back(aResult->document()->feature(aResult)->data()); bool aFoundReferernce = false; - for (std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { - ResultPtr aResCont = *aSub; - ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont); + for (std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { + DataPtr aResCont = *aSub; + ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont->owner()); if (aResBody.get() && aResBody->numberOfSubs() > 0 && aResBody != aCompContext) continue; // only lower and higher level subs are counted - const std::set& aRefs = aResCont->data()->refsToMe(); + const std::set& aRefs = aResCont->refsToMe(); std::set::const_iterator aRef = aRefs.begin(); for (; !aFindNewContext && aRef != aRefs.end(); aRef++) { if (!aRef->get() || !(*aRef)->owner().get())