Salome HOME
add 'undo' shorcut on Hide Faces panel selection. WARNING The delete feature is stran...
authorrraphael <raphael.raphael@c-s.fr>
Mon, 30 Nov 2020 17:46:39 +0000 (18:46 +0100)
committerrraphael <raphael.raphael@c-s.fr>
Fri, 15 Jan 2021 11:00:49 +0000 (12:00 +0100)
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h
src/XGUI/XGUI_Workshop.cpp

index 10819c8f3e7c1a145c8e3046aec4fa06e50b57f2..67c904d26d9ae82033911f8d8bbce2021321b0cd 100644 (file)
 #include <ModelAPI_Events.h>
 #include <ModelAPI_AttributeSelectionList.h>
 
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationFeature.h>
+#include <XGUI_OperationMgr.h>
+
 #include <QAction>
 #include <QCheckBox>
 #include <QFocusEvent>
@@ -207,8 +211,10 @@ void XGUI_FacesPanel::setActivePanel(const bool theIsActive)
     // the selection is cleared by activating selection control
     myWorkshop->selector()->clearSelection();
   }
-  else
+  else{
     emit deactivated();
+    myUndoList.clear();
+  }
 }
 
 //********************************************************************
@@ -413,6 +419,8 @@ void XGUI_FacesPanel::processSelection()
 
     myItems.insert(myLastItemIndex, aPrs);
     myListView->addItem(aItemName, myLastItemIndex);
+    // add in undo list
+    myUndoList.push_back(myLastItemIndex);
     myLastItemIndex++;
     isModified = true;
   }
@@ -462,7 +470,7 @@ void XGUI_FacesPanel::processSelection()
 bool XGUI_FacesPanel::processDelete()
 {
   //appendFirstSelectionInHistory();
-  QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
+  //QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
 
   std::set<int> aSelectedIds;
   myListView->getSelectedIndices(aSelectedIds);
@@ -604,6 +612,18 @@ void XGUI_FacesPanel::onClosed()
   reset(true);
 }
 
+//********************************************************************
+
+void XGUI_FacesPanel::processUndo()
+{
+ if(!myUndoList.size())
+   return;
+
+ myListView->selectIndices({myUndoList.back()});
+ processDelete();
+ myUndoList.pop_back();
+}
+
 //********************************************************************
 void XGUI_FacesPanel::flushRedisplay() const
 {
index 7515fd9cb41b30b05670d63afac24745b166fabd..467f525ba4cc628640a89f3413fd4f1729211e9a 100644 (file)
@@ -121,6 +121,9 @@ public:
   /// \return whether the delete action is processed
   bool processDelete();
 
+  /// Delete last(s) item(s) added since the recent activation of the faces panel
+  void processUndo();
+
   /// Processing focus in/out for the faces control
   /// \param theObject source object of event
   /// \param theEvent an event
@@ -200,6 +203,7 @@ private:
 
   bool myIsActive; ///< current state about the panel is active
   int myLastItemIndex; ///< last index to be used in the map of items for the next added item
+  std::vector<int> myUndoList; ///< indexes of items for undo
 
   QMap<int, ModuleBase_ViewerPrsPtr> myItems; ///< selected face items
   std::set<ObjectPtr > myItemObjects; ///< cached objects of myItems
@@ -207,4 +211,4 @@ private:
   std::set<ObjectPtr > myHiddenGroups; ///< hidden objects
 };
 
-#endif
\ No newline at end of file
+#endif
index 5ca15dc330cc3de54f38762468c5379594d7e8c6..5bc03f55e400376054edb046022690c7cc4d7941 100644 (file)
@@ -1212,6 +1212,15 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i
     if (anActiveWidget->processAction(theActionType, aParam))
       return;
   }
+  else
+  {
+    XGUI_FacesPanel *  anFacePannel = facesPanel();
+    if(ActionUndo == theActionType && anFacePannel->isActivePanel())
+    {
+      anFacePannel->processUndo();
+      return;
+    }
+  }
   // the viewer update should be blocked in order to avoid the features blinking. For the created
   // feature a results are created, the flush of the created signal caused the viewer redisplay for
   // each created result. After a redisplay signal is flushed. So, the viewer update is blocked
@@ -3258,4 +3267,4 @@ void XGUI_Workshop::changeIsoLines(const QObjectPtrList& theObjects)
     aMgr->finishOperation();
     updateCommandStatus();
   }
-}
\ No newline at end of file
+}