return std::shared_ptr<ModelAPI_Feature>(); // 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<ModelAPI_Feature> theCurrent, const bool theVisible)
{
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;
if (!myTrsf.get()) { // disable of base result part
DocumentPtr aDoc = Model_ResultPart::partDoc();
if (aDoc.get() && aDoc->isOpened()) {
- std::shared_ptr<Model_Document> anIntDoc = std::dynamic_pointer_cast<Model_Document>(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<ModelAPI_Feature>(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