]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Do not delete infinity construction objects out of a history
authorvsv <vsv@opencascade.com>
Fri, 13 Sep 2019 08:54:18 +0000 (11:54 +0300)
committerazv <azv@opencascade.com>
Mon, 23 Sep 2019 09:37:54 +0000 (12:37 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index bb84381bff854b31b2b569f040c32b15f24d80a0..06ebaefa6e65416f6446c1cf7f57f9cc7b581cd6 100644 (file)
@@ -51,7 +51,6 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultConstruction.h>
 
 #include <QMainWindow>
 #include <QAction>
@@ -235,21 +234,6 @@ void PartSet_MenuMgr::updateViewerMenu(const QMap<QString, QAction*>& theStdActi
     theStdActions["SHOW_CMD"]->setEnabled(false);
     theStdActions["HIDE_CMD"]->setEnabled(false);
     theStdActions["HIDEALL_CMD"]->setEnabled(false);
-
-    ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
-    QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
-    ResultConstructionPtr aResult;
-    bool canBeDeleted = true;
-    foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
-      aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aPrs->object());
-      if (aResult.get() != NULL) {
-        FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object());
-        canBeDeleted = !(!(aFeature->isInHistory()) && aResult->isInfinite());
-        if (!canBeDeleted)
-          break;
-      }
-    }
-    theStdActions["DELETE_CMD"]->setEnabled(canBeDeleted);
   }
 }
 
index d2ae91572d3057735f3c238ed11a55214fa0a623..f26973668db730dcc4167cabbf30056a14e60644 100644 (file)
@@ -293,7 +293,6 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
     bool hasCompositeOwner = false;
     bool hasResultInHistory = false;
     bool hasFolder = false;
-    bool canBeDeleted = true;
     ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
                                    hasCompositeOwner, hasResultInHistory, hasFolder);
     //Process Feature
@@ -333,14 +332,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         if( aMgr->activeDocument() == aObject->document() )
         {
           action("RENAME_CMD")->setEnabled(true);
-          if (aObject->groupName() == ModelAPI_ResultConstruction::group()) {
-            ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
-            FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-            canBeDeleted = !(!(aFeature->isInHistory()) && aConstr->isInfinite());
-            action("DELETE_CMD")->setEnabled(canBeDeleted);
-          }
-          else
-            action("DELETE_CMD")->setEnabled(!hasCompositeOwner);
+          action("DELETE_CMD")->setEnabled(!hasCompositeOwner);
           action("CLEAN_HISTORY_CMD")->setEnabled(!hasCompositeOwner &&
                                                   (hasFeature || hasParameter));
         }
@@ -354,15 +346,6 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         action("SHOW_ONLY_CMD")->setEnabled(true);
         action("SHADING_CMD")->setEnabled(true);
         action("WIREFRAME_CMD")->setEnabled(true);
-
-        foreach(ObjectPtr aObj, aObjects) {
-          FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
-          if (!aFeature->isInHistory()) {
-            canBeDeleted = false;
-            break;
-          }
-        }
-        action("DELETE_CMD")->setEnabled(canBeDeleted);
       }
     } // end multi-selection
 
@@ -463,8 +446,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         break;
       }
     if (!hasCompositeOwner && allActive ) {
-      if (hasResult || hasFeature || hasParameter)  // #2924 results can be erased
-        action("DELETE_CMD")->setEnabled(canBeDeleted);
+      if (hasResult || hasFeature || hasParameter) // #2924 results can be erased
+        action("DELETE_CMD")->setEnabled(true);
     }
     if (!hasCompositeOwner && allActive && (hasFeature|| hasParameter))
       action("CLEAN_HISTORY_CMD")->setEnabled(true);
@@ -597,6 +580,10 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
     }
   }
 
+  ModuleBase_IModule* aModule = myWorkshop->module();
+  if (aModule)
+    aModule->updateViewerMenu(myActions);
+
   if (myWorkshop->canChangeProperty("COLOR_CMD"))
     action("COLOR_CMD")->setEnabled(true);
 
@@ -606,9 +593,7 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
   if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD"))
     action("TRANSPARENCY_CMD")->setEnabled(true);
 
-  ModuleBase_IModule* aModule = myWorkshop->module();
-  if (aModule)
-    aModule->updateViewerMenu(myActions);
+  action("DELETE_CMD")->setEnabled(true);
 }
 
 void XGUI_ContextMenuMgr::connectObjectBrowser()
index 3fadef034d0da0cbc8375f406e69b3ee302a49ab..507d13e62d1c1f925e58c331852b41e300f76a11 100644 (file)
@@ -1806,6 +1806,19 @@ void XGUI_Workshop::deleteObjects()
   if (!(hasResult || hasFeature || hasParameter || hasFolder))
     return;
 
+  // Remove from the list non-deletable objects: infinite constuctions which are not in history
+  bool notDelete = true;
+  QObjectPtrList::iterator aIt;
+  for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) {
+    ObjectPtr aObj = (*aIt);
+    ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+    notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite();
+    if (notDelete) {
+      anObjects.removeAll(aObj);
+      aIt--;
+    }
+  }
   // delete objects
   std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
   std::set<FeaturePtr> aFeatures;