updateHistory(ModelAPI_Feature::group());
} else { // make feature has not-null data anyway
theFeature->setData(Model_Data::invalidData());
+ theFeature->setDoc(myDoc);
}
}
aWorkshop->displayer()->updateViewer();
aMgr->finishOperation();
} else {
+ bool isPartRemoved = false;
// Delete part with help of PartSet plugin
// TODO: the deleted objects has to be processed by multiselection
QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
ObjectPtr aObj = aObjects.first();
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
if (aFeature.get() && (aFeature->getKind() == PartSetPlugin_Part::ID())) {
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
- aMgr->startOperation(PartSetPlugin_Remove::ID());
- FeaturePtr aFeature = aDoc->addFeature(PartSetPlugin_Remove::ID());
- aFeature->execute();
- aMgr->finishOperation();
- } else
- return false;
- } else
- return false;
+ // Remove feature should be created in the document of the part results
+ ResultPtr aPartResult = aFeature->firstResult();
+ if (aPartResult.get()) {
+ std::shared_ptr<ModelAPI_ResultPart> aPart =
+ std::dynamic_pointer_cast<ModelAPI_ResultPart>(aPartResult);
+ DocumentPtr aPartDoc = aPart->partDoc();
+ if (aPartDoc.get()) {
+ aMgr->startOperation(PartSetPlugin_Remove::ID());
+ FeaturePtr aFeature = aPartDoc->addFeature(PartSetPlugin_Remove::ID());
+ aFeature->execute();
+ aMgr->finishOperation();
+ isPartRemoved = true;
+ }
+ }
+ }
+ }
+ return isPartRemoved;
}
return true;
}
{
std::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
std::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
- std::shared_ptr<ModelAPI_Document> aCurrent;
std::shared_ptr<PartSetPlugin_Part> a;
for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(
aRoot->object(ModelAPI_ResultPart::group(), a));
- if (aPart
- && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()
- == aPManager->activeDocument()) {
+ if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == document()) {
FeaturePtr aFeature = aRoot->feature(aPart);
if (aFeature) {
// do remove