X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Tools.cpp;h=a1f4ef0640583075e4dd4eee980a3049f3309821;hb=9fadaebe6d57d0836c7997ee60eb4cfdb67e2ffb;hp=35b7e36daf38831f164ac9da5d564c292fb20e42;hpb=48b3193b3aa7ad3413effc73276ab77d6226d73f;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 35b7e36da..a1f4ef064 100755 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -265,11 +265,17 @@ CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature) return CompositeFeaturePtr(); // not found } -ResultBodyPtr bodyOwner(const ResultPtr& theSub) +ResultBodyPtr bodyOwner(const ResultPtr& theSub, const bool theRoot) { if (theSub.get()) { ObjectPtr aParent = theSub->document()->parent(theSub); if (aParent.get()) { + if (theRoot) { // try to find parent of parent + ResultPtr aResultParent = std::dynamic_pointer_cast(aParent); + ResultBodyPtr aGrandParent = bodyOwner(aResultParent, true); + if (aGrandParent.get()) + aParent = aGrandParent; + } return std::dynamic_pointer_cast(aParent); } } @@ -598,7 +604,8 @@ void getConcealedResults(const FeaturePtr& theFeature, } } -std::pair getDefaultName(const std::shared_ptr& theResult) +std::pair getDefaultName(const std::shared_ptr& theResult, + const bool theInherited) { typedef std::list< std::pair < std::string, std::list > > ListOfReferences; @@ -619,26 +626,28 @@ std::pair getDefaultName(const std::shared_ptrdata(); ListOfReferences aReferences; - aData->referencesToObjects(aReferences); - // find first result with user-defined name ListOfReferences::const_iterator aFoundRef = aReferences.end(); - for (ListOfReferences::const_iterator aRefIt = aReferences.begin(); - aRefIt != aReferences.end(); ++aRefIt) { - bool isConcealed = aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first); - bool isMainArg = isConcealed && - aSession->validators()->isMainArgument(anOwner->getKind(), aRefIt->first); - if (isConcealed) { - // check the referred object is a Body - // (for example, ExtrusionCut has a sketch as a first attribute which is concealing) - bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 && - aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group()); - if (isBody && (isMainArg || aFoundRef == aReferences.end() || - aData->isPrecedingAttribute(aRefIt->first, aFoundRef->first))) - aFoundRef = aRefIt; - - if (isMainArg) - break; + if (theInherited) { + aData->referencesToObjects(aReferences); + + for (ListOfReferences::const_iterator aRefIt = aReferences.begin(); + aRefIt != aReferences.end(); ++aRefIt) { + bool isConcealed = aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first); + bool isMainArg = isConcealed && + aSession->validators()->isMainArgument(anOwner->getKind(), aRefIt->first); + if (isConcealed) { + // check the referred object is a Body + // (for example, ExtrusionCut has a sketch as a first attribute which is concealing) + bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 && + aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group()); + if (isBody && (isMainArg || aFoundRef == aReferences.end() || + aData->isPrecedingAttribute(aRefIt->first, aFoundRef->first))) + aFoundRef = aRefIt; + + if (isMainArg) + break; + } } } // get the result number in the feature