return res;
}
+//******************************************************************
+QString unionOfObjectNames(const QObjectPtrList& theObjects, const QString& theSeparator)
+{
+ QStringList aObjectNames;
+ foreach (ObjectPtr aObj, theObjects) {
+ if (!aObj->data()->isValid())
+ continue;
+ aObjectNames << QString::fromStdString(aObj->data()->name());
+ }
+ return aObjectNames.join(", ");
+}
+
//******************************************************************
bool isModelObject(FeaturePtr theFeature)
{
return isSub;
}
+//**************************************************************
+bool isSubOfComposite(const ObjectPtr& theObject)
+{
+ bool isSub = false;
+ std::set<FeaturePtr> aRefFeatures;
+ refsToFeatureInFeatureDocument(theObject, aRefFeatures);
+ std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
+ aLast = aRefFeatures.end();
+ for (; anIt != aLast && !isSub; anIt++) {
+ isSub = isSubOfComposite(theObject, *anIt);
+ }
+ return isSub;
+}
+
//**************************************************************
void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectPtr& theObject,
+ const QObjectPtrList& theIgnoreList,
std::set<FeaturePtr>& theDirectRefFeatures,
std::set<FeaturePtr>& theIndirectRefFeatures,
std::set<FeaturePtr>& theAlreadyProcessed)
+{
+ refsDirectToFeatureInAllDocuments(theSourceObject, theObject, theIgnoreList, theDirectRefFeatures,
+ theAlreadyProcessed);
+
+ // Run recursion. It is possible recursive dependency, like the following: plane, extrusion uses plane,
+ // axis is built on extrusion. Delete of a plane should check the dependency from the axis also.
+ std::set<FeaturePtr>::const_iterator aFeatureIt = theDirectRefFeatures.begin();
+ for (; aFeatureIt != theDirectRefFeatures.end(); ++aFeatureIt) {
+ std::set<FeaturePtr> aRecursiveRefFeatures;
+ refsToFeatureInAllDocuments(theSourceObject, *aFeatureIt, theIgnoreList,
+ aRecursiveRefFeatures, aRecursiveRefFeatures, theAlreadyProcessed);
+ theIndirectRefFeatures.insert(aRecursiveRefFeatures.begin(), aRecursiveRefFeatures.end());
+ }
+
+}
+
+//**************************************************************
+void refsDirectToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectPtr& theObject,
+ const QObjectPtrList& theIgnoreList,
+ std::set<FeaturePtr>& theDirectRefFeatures,
+ std::set<FeaturePtr>& theAlreadyProcessed)
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (!aFeature.get())
theAlreadyProcessed.insert(aFeature);
// 1. find references in the current document
+
std::set<FeaturePtr> aRefFeatures;
refsToFeatureInFeatureDocument(theObject, aRefFeatures);
std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
aLast = aRefFeatures.end();
for (; anIt != aLast; anIt++) {
- if (!isSubOfComposite(theSourceObject, *anIt))
+ // composite feature should not be deleted when the sub feature is to be deleted
+ if (!isSubOfComposite(theSourceObject, *anIt) && !theIgnoreList.contains(*anIt))
theDirectRefFeatures.insert(*anIt);
}
}
}
}
- if (aHasReferenceToObject && !isSubOfComposite(theSourceObject, aFeature))
+ if (aHasReferenceToObject && !isSubOfComposite(theSourceObject, aFeature) &&
+ !theIgnoreList.contains(aFeature))
theDirectRefFeatures.insert(aFeature);
}
}
}
-
- // Run recursion. It is possible recursive dependency, like the following: plane, extrusion uses plane,
- // axis is built on extrusion. Delete of a plane should check the dependency from the axis also.
- std::set<FeaturePtr>::const_iterator aFeatureIt = theDirectRefFeatures.begin();
- for (; aFeatureIt != theDirectRefFeatures.end(); ++aFeatureIt) {
- std::set<FeaturePtr> aRecursiveRefFeatures;
- refsToFeatureInAllDocuments(theSourceObject, *aFeatureIt,
- aRecursiveRefFeatures, aRecursiveRefFeatures, theAlreadyProcessed);
- theIndirectRefFeatures.insert(aRecursiveRefFeatures.begin(), aRecursiveRefFeatures.end());
- }
}
}