From: nds Date: Fri, 18 Dec 2015 08:35:01 +0000 (+0300) Subject: #1141 Part is not deleted X-Git-Tag: V_2.1.0~143 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9c0fc0d0d7cf50049ccd42f090cab48eb51e082b;p=modules%2Fshaper.git #1141 Part is not deleted It was decided to perform Delete of Parts on the XGUI level. In the previous realization the RemoveFeature was used for this. However, as the result of not loaded Parts do not exists and this feature are simple, it was decided with Mikhail, that this feature(Part) will be removed in the same way as other features. Later, it is possible, the RemoveFeature will be deleted from the application tool bar. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index f919207fa..ba4ba6680 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -322,10 +322,10 @@ bool PartSet_Module::canRedo() const bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const { bool aValid = true; - if (theActionId == "DELETE_CMD" || theActionId == "MOVE_CMD") { + if (theActionId == "MOVE_CMD") { FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); if (aFeature) { - // part features are removed in the PartSet module only. + // part features can not be moved in the history. if (aFeature->getKind() == PartSetPlugin_Part::ID()) aValid = false; } @@ -557,6 +557,8 @@ ModuleBase_ModelWidget* PartSet_Module::activeWidget() const bool PartSet_Module::deleteObjects() { + bool isProcessed = false; + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Workshop* aWorkshop = aConnector->workshop(); XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); @@ -567,6 +569,7 @@ bool PartSet_Module::deleteObjects() bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation), isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation); if (isSketchOp || isNestedOp) { + isProcessed = true; // 2. find selected presentations // selected objects should be collected before the current operation abort because // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue @@ -615,41 +618,7 @@ bool PartSet_Module::deleteObjects() // 5. stop operation anOpMgr->commitOperation(); } - 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(); - if (aObjects.size() == 1) { - ObjectPtr aObj = aObjects.first(); - FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); - if (aFeature.get() && (aFeature->getKind() == PartSetPlugin_Part::ID())) { - // Remove feature should be created in the document of the part results - ResultPtr aPartResult = aFeature->firstResult(); - if (aPartResult.get()) { - std::shared_ptr aPart = - std::dynamic_pointer_cast(aPartResult); - DocumentPtr aPartDoc = aPart->partDoc(); - if (aPartDoc.get()) { - ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction - (PartSetPlugin_Remove::ID().c_str(), this); - if (!anOpMgr->canStartOperation(anOpAction->id())) - return true; // the objects are processed but can not be deleted - - anOpMgr->startOperation(anOpAction); - - FeaturePtr aFeature = aPartDoc->addFeature(PartSetPlugin_Remove::ID()); - aFeature->execute(); - - anOpMgr->commitOperation(); - isPartRemoved = true; - } - } - } - } - return isPartRemoved; - } - return true; + return isProcessed; } void PartSet_Module::onFeatureTriggered() diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 54e200ba5..b00dcf471 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1354,9 +1354,6 @@ bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList, if (!anObjectGroups.contains(aGroupName.c_str())) continue; - if (!myModule->canApplyAction(aObj, anActionId)) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { /*// TODO: to learn the workshop to delegate the Part object deletion to the PartSet module