From: rraphael Date: Mon, 30 Nov 2020 17:46:39 +0000 (+0100) Subject: add 'undo' shorcut on Hide Faces panel selection. WARNING The delete feature is stran... X-Git-Tag: V9_7_0a1~13^2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0a39df1fd0b7002d2f2bc39e44c7dffccd267324;p=modules%2Fshaper.git add 'undo' shorcut on Hide Faces panel selection. WARNING The delete feature is strange, may be bugged --- diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index 10819c8f3..67c904d26 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -44,6 +44,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -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 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 { diff --git a/src/XGUI/XGUI_FacesPanel.h b/src/XGUI/XGUI_FacesPanel.h index 7515fd9cb..467f525ba 100644 --- a/src/XGUI/XGUI_FacesPanel.h +++ b/src/XGUI/XGUI_FacesPanel.h @@ -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 myUndoList; ///< indexes of items for undo QMap myItems; ///< selected face items std::set myItemObjects; ///< cached objects of myItems @@ -207,4 +211,4 @@ private: std::set myHiddenGroups; ///< hidden objects }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 5ca15dc33..5bc03f55e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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 +}