From 2185cb449f914a47829c9c38dd12a7a02aa0fc8b Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 27 Apr 2022 15:02:56 +0300 Subject: [PATCH] Recover feature in context menu. --- src/FeaturesPlugin/doc/recoverFeature.rst | 3 ++- src/XGUI/XGUI_ContextMenuMgr.cpp | 17 +++++++++++++++++ src/XGUI/XGUI_Workshop.cpp | 11 +++++++++++ src/XGUI/XGUI_Workshop.h | 3 +++ src/XGUI/XGUI_msg_fr.ts | 4 ++++ src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/recover.png | Bin 0 -> 972 bytes 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/XGUI/pictures/recover.png diff --git a/src/FeaturesPlugin/doc/recoverFeature.rst b/src/FeaturesPlugin/doc/recoverFeature.rst index c2cc6d22c..3608b55f7 100644 --- a/src/FeaturesPlugin/doc/recoverFeature.rst +++ b/src/FeaturesPlugin/doc/recoverFeature.rst @@ -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: diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 99e9bc0fb..a40b0c20e 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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(aObject); + std::list > 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")); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index fb55eef8b..7da5f8797 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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) { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 3050590c0..afa94962a 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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 diff --git a/src/XGUI/XGUI_msg_fr.ts b/src/XGUI/XGUI_msg_fr.ts index 42c57b1a6..e21700fbb 100644 --- a/src/XGUI/XGUI_msg_fr.ts +++ b/src/XGUI/XGUI_msg_fr.ts @@ -19,6 +19,10 @@ Move to the end and split Aller à la fin et diviser + + Recover + Récupérer + SHAPER files (*.shaper *.cadbld) Fichiers SHAPER (*.shaper *.cadbld) diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index dd81c3b93..2b81d5e48 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -73,6 +73,7 @@ pictures/insert_folder_before.png pictures/move_out_after.png pictures/move_out_before.png + pictures/recover.png pictures/selection.png pictures/autoapply_start.png pictures/autoapply_stop.png diff --git a/src/XGUI/pictures/recover.png b/src/XGUI/pictures/recover.png new file mode 100644 index 0000000000000000000000000000000000000000..ddcc1b0f6f837371ce287383a3530e47df6e152b GIT binary patch literal 972 zcmV;-12g=IP)!!5gPN4BPa>Y|e zH-pGbwCPGsV+CcoS@cAk8~u~b)G@cxYAa_E8xo0i4W)=U4I7)*G*BKpz{T$QiTi!~ z$74Nxw$Fc`_vih2zxVz~{I~S?-9xL%Kyiu|oh+mB1@TVLF+07$r(;um4v7E3L9U5y zyXv|A$2mk~7%|z480$uah7ig{MBh<-m4yuJlUWF_v)hM5fpBsnC6;yMA8aB=r-i59X3YL04==d6PIDtS`;Opg+k?|Th_KzyX!=U- zjxl6cHKZA>n^ys;#kurd{ep042vJqUML?2W9z51Ev~TSpqyG}2X(zMZ2q6Gt?c;}| zE4UF6(aDUOhW(B!Y<%V*KSdRIZ5QU8JJ}(71Gr*rwsPVJPhc%yk9|$u*3VRG^>bQH zQt*Xmo0{X*@r{`^4R4H&v-|y1I4cTCFsx#W?DgZ0EpU0^<-^j%jLMQ&V9Be0bN?$V z0>PkuX3Ckmd;9iwB=*IX)dvPgxdvd&BujRAa4QO&>}IjHMLOH-u1l~!c|gB+$4*UF zMkcmutJ3q$SM7dpP@Sqv8Br-zEV`KoNQ_6L3WVsiK96a9k~UB7qx!=21siIsABu}z z)v&Qn4oAYOPdZN>1IZ^4`w-LvL=~d)=}M{gB$IYqvP%ZiYD)O7x`c1%?A`N7N^i$U9|ogJ6oB(Te82Qw$I)Bf zfcHV?xi60anR)9l`GYX! zuc0OU&t0$Oll{%K2r