TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE);
CompositeFeaturePtr aMain; // main feature that may nest the new current
+ std::set<FeaturePtr> anOwners; // composites that contain theCurrent (with any level of nesting)
if (theCurrent.get()) {
aMain = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theCurrent);
- if (!aMain.get()) {
- // if feature nests into compisite feature, make the composite feature as current
- const std::set<AttributePtr>& aRefsToMe = theCurrent->data()->refsToMe();
- std::set<AttributePtr>::const_iterator aRefToMe = aRefsToMe.begin();
- for(; aRefToMe != aRefsToMe.end(); aRefToMe++) {
- CompositeFeaturePtr aComposite =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*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);
}
}
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;
std::dynamic_pointer_cast<Model_Data>((*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<ModelAPI_CompositeFeature>(aFeature);
if (aComp.get()) {
aReferenced->setDisabled(aComp->isDisabled());
}
}
+ */
}
}
}
// 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<ModelAPI_CompositeFeature>(theFeature);
+ if (aCompos)
+ iterateUpdate(aCompos);
return;
+ }
// do not execute the composite that contains the current
bool isPostponedMain = false;