QIntList aModes;
module()->activeSelectionModes(aModes);
aDisplayer->activateObjects(aModes, aDisplayed);
+ myOperationMgr->activate();
}
void XGUI_Workshop::deactivateModule()
XGUI_Displayer* aDisplayer = displayer();
QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
aDisplayer->deactivateObjects(aDisplayed, true);
+
+ myOperationMgr->deactivate();
}
//******************************************************
return;
showPropertyPanel();
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
- ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
-
myPropertyPanel->cleanContent();
- aFactory.createWidget(myPropertyPanel->contentWidget());
- QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+ QList<ModuleBase_ModelWidget*> aWidgets;
+ if (!module()->createWidgets(theOperation, aWidgets)) {
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
+ aFactory.createWidget(myPropertyPanel->contentWidget());
+ aWidgets = aFactory.getModelWidgets();
+ }
// check compatibility of feature and widgets
FeaturePtr aFeature = aFOperation->feature();
QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
- connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)),
- myOperationMgr, SLOT(onKeyReleased(QKeyEvent*)));
+ connect(myPropertyPanel, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
+ myOperationMgr, SLOT(onKeyReleased(QObject*, QKeyEvent*)));
- connect(myPropertyPanel, SIGNAL(enterClicked()),
- myOperationMgr, SLOT(onProcessEnter()));
+ connect(myPropertyPanel, SIGNAL(enterClicked(QObject*)),
+ myOperationMgr, SLOT(onProcessEnter(QObject*)));
}
//******************************************************
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
if (!abortAllOperations())
return;
- // It is necessary to clear selection in order to avoid selection changed event during
- // deletion and negative consequences connected with processing of already deleted items
- mySelector->clearSelection();
// check whether the object can be deleted. There should not be parts which are not loaded
if (!XGUI_Tools::canRemoveOrRename(desktop(), anObjects))
return;
// 3. delete objects
std::set<FeaturePtr> anIgnoredFeatures;
- if (deleteFeatures(anObjects, anIgnoredFeatures, desktop(), true)) {
- operationMgr()->commitOperation();
- }
- else {
- operationMgr()->abortOperation(operationMgr()->currentOperation());
+ std::set<FeaturePtr> aDirectRefFeatures, aIndirectRefFeatures;
+ findReferences(anObjects, aDirectRefFeatures, aIndirectRefFeatures);
+
+ bool doDeleteReferences = true;
+ if (isDeleteFeatureWithReferences(anObjects, aDirectRefFeatures, aIndirectRefFeatures,
+ desktop(), doDeleteReferences)) {
+ // It is necessary to clear selection in order to avoid selection changed event during
+ // deletion and negative consequences connected with processing of already deleted items
+ mySelector->clearSelection();
+ if (deleteFeaturesInternal(anObjects, aDirectRefFeatures, aIndirectRefFeatures,
+ anIgnoredFeatures, doDeleteReferences))
+ operationMgr()->commitOperation();
+ else
+ operationMgr()->abortOperation(operationMgr()->currentOperation());
}
}
return;
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
-
- // 1. find all referenced features
- QList<ObjectPtr> anUnusedObjects;
- std::set<FeaturePtr> aDirectRefFeatures;
+ QObjectPtrList aFeatures;
foreach (ObjectPtr anObject, anObjects) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
// for parameter result, use the corresponded reature to be removed
if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
aFeature = ModelAPI_Feature::feature(anObject);
}
+ aFeatures.append(aFeature);
+ }
+
+ // 1. find all referenced features
+ QList<ObjectPtr> anUnusedObjects;
+ std::set<FeaturePtr> aDirectRefFeatures;
+ //foreach (ObjectPtr anObject, anObjects) {
+ foreach (ObjectPtr anObject, aFeatures) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ // for parameter result, use the corresponded reature to be removed
+ //if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
+ // aFeature = ModelAPI_Feature::feature(anObject);
+ //}
if (aFeature.get()) {
std::set<FeaturePtr> alreadyProcessed;
aDirectRefFeatures.clear();
- XGUI_Tools::refsDirectToFeatureInAllDocuments(aFeature, aFeature, anObjects,
+ XGUI_Tools::refsDirectToFeatureInAllDocuments(aFeature, aFeature, aFeatures,
aDirectRefFeatures, alreadyProcessed);
if (aDirectRefFeatures.empty() && !anUnusedObjects.contains(aFeature))
anUnusedObjects.append(aFeature);
}
//**************************************************************
-bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList,
- const std::set<FeaturePtr>& theIgnoredFeatures,
- QWidget* theParent,
- const bool theAskAboutDeleteReferences)
+void XGUI_Workshop::findReferences(const QObjectPtrList& theList,
+ std::set<FeaturePtr>& aDirectRefFeatures,
+ std::set<FeaturePtr>& aIndirectRefFeatures)
{
-#ifdef DEBUG_DELETE
- QStringList aDInfo;
- QObjectPtrList::const_iterator aDIt = theList.begin(), aDLast = theList.end();
- for (; aDIt != aDLast; ++aDIt) {
- aDInfo.append(ModuleBase_Tools::objectInfo((*aDIt)));
- }
- QString anInfoStr = aDInfo.join(", ");
- qDebug(QString("deleteFeatures: %1, %2").arg(theList.size()).arg(anInfoStr).toStdString().c_str());
-#endif
-
- // 1. find all referenced features
- std::set<FeaturePtr> aDirectRefFeatures, aIndirectRefFeatures;
foreach (ObjectPtr aDeletedObj, theList) {
std::set<FeaturePtr> alreadyProcessed;
XGUI_Tools::refsToFeatureInAllDocuments(aDeletedObj, aDeletedObj, theList, aDirectRefFeatures,
std::inserter(aDifference, aDifference.begin()));
aIndirectRefFeatures = aDifference;
}
+}
- bool doDeleteReferences = true;
+bool XGUI_Workshop::isDeleteFeatureWithReferences(const QObjectPtrList& theList,
+ const std::set<FeaturePtr>& aDirectRefFeatures,
+ const std::set<FeaturePtr>& aIndirectRefFeatures,
+ QWidget* theParent,
+ bool& doDeleteReferences)
+{
+ doDeleteReferences = true;
- // 2. warn about the references remove, break the delete operation if the user chose it
- if (theAskAboutDeleteReferences && !aDirectRefFeatures.empty()) {
+ if (!aDirectRefFeatures.empty()) {
QStringList aDirectRefNames;
foreach (const FeaturePtr& aFeature, aDirectRefFeatures)
aDirectRefNames.append(aFeature->name().c_str());
doDeleteReferences = false;
}
}
+ return true;
+}
- // 3. remove referenced features
+bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theFeatures,
+ const std::set<FeaturePtr>& theIgnoredFeatures)
+{
+ std::set<FeaturePtr> aDirectRefFeatures, aIndirectRefFeatures;
+ findReferences(theFeatures, aDirectRefFeatures, aIndirectRefFeatures);
+ return deleteFeaturesInternal(theFeatures, aDirectRefFeatures, aIndirectRefFeatures,
+ theIgnoredFeatures);
+}
+
+bool XGUI_Workshop::deleteFeaturesInternal(const QObjectPtrList& theList,
+ const std::set<FeaturePtr>& aDirectRefFeatures,
+ const std::set<FeaturePtr>& aIndirectRefFeatures,
+ const std::set<FeaturePtr>& theIgnoredFeatures,
+ const bool doDeleteReferences)
+{
if (doDeleteReferences) {
std::set<FeaturePtr> aFeaturesToDelete = aDirectRefFeatures;
aFeaturesToDelete.insert(aIndirectRefFeatures.begin(), aIndirectRefFeatures.end());
}
QString anActionId = "DELETE_CMD";
- removeFeatures(theList, theIgnoredFeatures, anActionId);
+ return removeFeatures(theList, theIgnoredFeatures, anActionId);
}
//**************************************************************