]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Clean history: correction for parameters.
authornds <nds@opencascade.com>
Wed, 20 Jan 2016 13:24:56 +0000 (16:24 +0300)
committernds <nds@opencascade.com>
Wed, 20 Jan 2016 13:36:37 +0000 (16:36 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index 648abd6cc7ebe1435ce65bf49e46ae7effc68bab..2f831b59fc0b6f6a3c100df2641aba348e6b25f5 100644 (file)
@@ -217,7 +217,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         else if (hasFeature && myWorkshop->canMoveFeature())
           action("MOVE_CMD")->setEnabled(true);
 
-        else if (hasFeature)
+        else if (hasFeature || hasParameter)
           action("CLEAN_HISTORY_CMD")->setEnabled(true);
 
         if( aMgr->activeDocument() == aObject->document() )
@@ -246,7 +246,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
       if (hasFeature || hasParameter)
         action("DELETE_CMD")->setEnabled(true);
     }
-    if (allActive && hasFeature)
+    if (allActive && (hasFeature|| hasParameter))
       action("CLEAN_HISTORY_CMD")->setEnabled(true);
   }
 
@@ -384,6 +384,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
 
   aList.clear();
   aList.append(action("DELETE_CMD"));
+  aList.append(action("CLEAN_HISTORY_CMD"));
   aList.append(mySeparator);
   aList.append(action("RENAME_CMD"));
   myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
index 61d1796be2cc134fe487b0048fe280c19c4127e9..1747b7495e5ae59ac7dd05cf4c998bb9f7e83475 100755 (executable)
 QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
 
 //#define DEBUG_DELETE
+//#define DEBUG_FEATURE_NAME
 
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
     : QObject(),
@@ -597,7 +598,13 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
 
   myModule->propertyPanelDefined(theOperation);
 
+#ifndef DEBUG_FEATURE_NAME
   myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
+#else
+  std::string aFeatureName = aFeature->name();
+  myPropertyPanel->setWindowTitle(QString("%1: %2").arg(theOperation->getDescription()->description())
+                                                  .arg(aFeatureName.c_str()));
+#endif
 
   myErrorMgr->setPropertyPanel(myPropertyPanel);
 }
@@ -1212,29 +1219,35 @@ void XGUI_Workshop::cleanHistory()
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
 
   // 1. find all referenced features
-  std::set<FeaturePtr> anUnusedFeatures;
+  QList<ObjectPtr> anUnusedObjects;
   std::set<FeaturePtr> aDirectRefFeatures;
   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);
+    }
     if (aFeature.get()) {
       std::set<FeaturePtr> alreadyProcessed;
       aDirectRefFeatures.clear();
-      XGUI_Tools::refsDirectToFeatureInAllDocuments(anObject, anObject, anObjects,
+      XGUI_Tools::refsDirectToFeatureInAllDocuments(aFeature, aFeature, anObjects,
                                                     aDirectRefFeatures, alreadyProcessed);
-      if (aDirectRefFeatures.empty() && anUnusedFeatures.find(aFeature) == anUnusedFeatures.end())
-        anUnusedFeatures.insert(aFeature);
+      if (aDirectRefFeatures.empty() && !anUnusedObjects.contains(aFeature))
+        anUnusedObjects.append(aFeature);
     }
   }
 
   // 2. warn about the references remove, break the delete operation if the user chose it
-  if (!anUnusedFeatures.empty()) {
+  if (!anUnusedObjects.empty()) {
     QStringList aNames;
-    foreach (const FeaturePtr& aFeature, anUnusedFeatures)
+    foreach (const ObjectPtr& anObject, anUnusedObjects) {
+      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
       aNames.append(aFeature->name().c_str());
+    }
     QString anUnusedNames = aNames.join(", ");
 
     QString anActionId = "CLEAN_HISTORY_CMD";
-    QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text();
+    QString aDescription = contextMenuMgr()->action(anActionId)->text();
 
     QMessageBox aMessageBox(desktop());
     aMessageBox.setWindowTitle(aDescription);
@@ -1254,7 +1267,7 @@ void XGUI_Workshop::cleanHistory()
     operationMgr()->startOperation(anOpAction);
 
     std::set<FeaturePtr> anIgnoredFeatures;
-    if (removeFeatures(anObjects, anIgnoredFeatures, anActionId)) {
+    if (removeFeatures(anUnusedObjects, anIgnoredFeatures, anActionId)) {
       operationMgr()->commitOperation();
     }
     else {