]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Recover feature in context menu.
authormpv <mpv@opencascade.com>
Wed, 27 Apr 2022 12:02:56 +0000 (15:02 +0300)
committermpv <mpv@opencascade.com>
Wed, 27 Apr 2022 12:02:56 +0000 (15:02 +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 99e9bc0fb6dba8d4038cf08a26e957e28e38482a..a40b0c20e3244bd88e8c5f70552a580272963218 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 fb55eef8b1138a116f6ab256bfa5374f037767dc..7da5f879720386c1ee4ced8b00668c9563c649ce 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 3050590c0f7209caabade14539286425008036c7..afa94962a81606e5c8c7cbad6545433a99863d13 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..e21700fbbcb6e154930b9532721b18f6d0ab7a58 100644 (file)
         <source>Move to the end and split</source>
         <translation>Aller à la fin et diviser</translation>
     </message>
+    <message>
+      <source>Recover</source>
+      <translation>Récupérer</translation>
+    </message>
     <message>
         <source>SHAPER files (*.shaper *.cadbld)</source>
         <translation>Fichiers SHAPER (*.shaper *.cadbld)</translation>
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