]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
bos #29480 Recover feature in context menu.
authormpv <mpv@opencascade.com>
Wed, 27 Apr 2022 12:02:56 +0000 (15:02 +0300)
committervsr <vsr@opencascade.com>
Thu, 2 Jun 2022 11:52:35 +0000 (14:52 +0300)
src/FeaturesPlugin/doc/recoverFeature.rst
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_msg_fr.ts
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/recover.png [new file with mode: 0644]

index c2cc6d22ce4fbdf76cef85ad33db519af5914a51..3608b55f77b9b445ad57b95b1fcae42a5eedf4e6 100644 (file)
@@ -8,7 +8,8 @@ Recover
 To recover in the active part:
 
 #. select in the Main Menu *Features - > Recover* item or
-#. click |recover.icon| **Recover** button in the toolbar
+#. click |recover.icon| **Recover** button in the toolbar or
+#. click |recover.icon| **Recover** command in the context menu if one feature is selected in the Object Browser
 
 The feature has the following options:
 
index a440c46e141db6177b2f31f86515d1ce551255aa..64c590e661fc64b39e633776b80aac65d9be18ec 100644 (file)
@@ -111,6 +111,10 @@ void XGUI_ContextMenuMgr::createActions()
   addAction("MOVE_SPLIT_CMD", anAction);
 #endif
 
+  anAction = ModuleBase_Tools::createAction(QIcon(":pictures/recover.png"),
+    tr("Recover"), this);
+  addAction("RECOVER_CMD", anAction);
+
   anAction = ModuleBase_Tools::createAction(QIcon(":pictures/clean_history.png"),
                                            tr("Clean history"), aDesktop);
   addAction("CLEAN_HISTORY_CMD", anAction);
@@ -362,6 +366,18 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
           action("MOVE_SPLIT_CMD")->setEnabled(true);
         }
 #endif
+        if (hasFeature && aObject->document() != aMgr->moduleDocument() &&
+            aObject->document() == aMgr->activeDocument())
+        {
+          XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+          if (!anOperationMgr->hasOperation()) {
+            FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+            std::list<std::shared_ptr<ModelAPI_Result> > aResults;
+            ModelAPI_Tools::getConcealedResults(aFeature, aResults);
+            if (!aResults.empty()) // check the feature conceals at least one result
+              action("RECOVER_CMD")->setEnabled(true);
+          }
+        }
 
         if( aMgr->activeDocument() == aObject->document() )
         {
@@ -729,6 +745,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("SHOW_RESULTS_CMD"));
   aList.append(action("MOVE_CMD"));
   aList.append(action("MOVE_SPLIT_CMD"));
+  aList.append(action("RECOVER_CMD"));
   aList.append(mySeparator1);
   aList.append(action("INSERT_FOLDER_CMD"));
   aList.append(action("ADD_TO_FOLDER_BEFORE_CMD"));
index d5b78f0e0f312c0dc52ce5ab72268cf6426abb07..febea937bccd31377007d727e76eb45294ccd7a7 100644 (file)
@@ -1775,6 +1775,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     cleanHistory();
   else if (theId == "MOVE_CMD" || theId == "MOVE_SPLIT_CMD")
     moveObjects(theId == "MOVE_SPLIT_CMD");
+  else if (theId == "RECOVER_CMD")
+    recoverFeature();
   else if (theId == "COLOR_CMD")
     changeColor(anObjects);
   else if (theId == "AUTOCOLOR_CMD")
@@ -2289,6 +2291,15 @@ void XGUI_Workshop::moveObjects(const bool theSplit)
   myViewerProxy->update();
 }
 
+void XGUI_Workshop::recoverFeature()
+{
+  if (!abortAllOperations())
+    return;
+
+  static const QString RECOVER_OP_NAME = "Recover";
+  module()->launchOperation(RECOVER_OP_NAME, false);
+}
+
 //**************************************************************
 bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theObjects)
 {
index 35cca7104b5ae2850aab179ad665058efa12ec51..8b4f0ac362ee478f2caeb1bd2698a1b1a893db5b 100644 (file)
@@ -188,6 +188,9 @@ Q_OBJECT
   /// Move selected features to be after the current feature
   void moveObjects(const bool theSplit);
 
+  /// Start a "Recover" feature on the selected one
+  void recoverFeature();
+
   /// Returns true if the object can be shaded. If the object is a compsolid result, the method
   /// checks subobjects of the result
   /// \return boolean value
index 42c57b1a60fd525389235fcef4e85463413b8447..2e320d15e2cee60c25fb8f756b8b528691075744 100644 (file)
         <source>Show Isos</source>
         <translation>Show Isos</translation>
     </message>
+    <message>
+      <source>Recover</source>
+      <translation>Récupérer</translation>
+    </message>
 </context>
 <context>
     <name>XGUI_DataTree</name>
index dd81c3b936f2788d7268d571a1b24c169b61725b..2b81d5e48f9dfedc886df9855a9fb1bfbe32cfd8 100644 (file)
@@ -73,6 +73,7 @@
      <file>pictures/insert_folder_before.png</file>
      <file>pictures/move_out_after.png</file>
      <file>pictures/move_out_before.png</file>
+     <file>pictures/recover.png</file>
      <file>pictures/selection.png</file>
      <file>pictures/autoapply_start.png</file>
      <file>pictures/autoapply_stop.png</file>
diff --git a/src/XGUI/pictures/recover.png b/src/XGUI/pictures/recover.png
new file mode 100644 (file)
index 0000000..ddcc1b0
Binary files /dev/null and b/src/XGUI/pictures/recover.png differ