From c0476591a9c87c4569b627a9a0cc4f40f6c096d8 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 7 Apr 2016 11:16:53 +0300 Subject: [PATCH] Issue #1126: Highlight results by feature --- src/XGUI/XGUI_ContextMenuMgr.cpp | 7 +++++++ src/XGUI/XGUI_Workshop.cpp | 25 +++++++++++++++++++++++++ src/XGUI/XGUI_Workshop.h | 10 +++++++--- src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/find_result.png | Bin 0 -> 593 bytes 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/XGUI/pictures/find_result.png diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 051fa8028..579be3621 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -125,6 +125,9 @@ void XGUI_ContextMenuMgr::createActions() aAction->setChecked(true); + aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select results"), this); + addAction("SHOW_RESULTS_CMD", aAction); + buildObjBrowserMenu(); buildViewerMenu(); } @@ -274,6 +277,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() } if (!hasSubFeature && allActive && (hasFeature|| hasParameter)) action("CLEAN_HISTORY_CMD")->setEnabled(true); + + action("SHOW_RESULTS_CMD")->setEnabled(hasFeature); } // Show/Hide command has to be disabled for objects from non active document @@ -430,6 +435,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("CLEAN_HISTORY_CMD")); aList.append(mySeparator); aList.append(action("RENAME_CMD")); + aList.append(mySeparator); + aList.append(action("SHOW_RESULTS_CMD")); myObjBrowserMenus[ModelAPI_Feature::group()] = aList; aList.clear(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e55d6406e..88ff0c770 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1168,6 +1168,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) setViewerSelectionMode(TopAbs_FACE); } else if (theId == "SELECT_RESULT_CMD") { setViewerSelectionMode(-1); + } else if (theId == "SHOW_RESULTS_CMD") { + highlightResults(aObjects); } } @@ -1991,3 +1993,26 @@ void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc, if (theUpdateViewer) myDisplayer->updateViewer(); } + +void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) +{ + FeaturePtr aFeature; + QObjectPtrList aSelList = theObjects; + std::list aResList; + foreach(ObjectPtr aObj, theObjects) { + aFeature = std::dynamic_pointer_cast(aObj); + if (aFeature.get()) { + aResList = aFeature->results(); + std::list >::const_iterator aIt; + for(aIt = aResList.cbegin(); aIt != aResList.cend(); aIt++) { + aSelList.append(*aIt); + } + } + } + if (aSelList.count() > theObjects.count()) { + // if something was found + bool aBlocked = objectBrowser()->blockSignals(true); + objectBrowser()->setObjectsSelected(aSelList); + objectBrowser()->blockSignals(aBlocked); + } +} diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 187182e66..4cda396f1 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -274,6 +274,13 @@ Q_OBJECT /// \param isToConnect a boolean value whether connect or disconnect void connectToPropertyPanel(const bool isToConnect); + /// Returns defailt selection mode in 3d viewer + int viewerSelectionMode() const { return myViewerSelMode; } + + /// Highlights result objects in Object Browser according to + /// features found in the given list + void highlightResults(const QObjectPtrList& theObjects); + /// A constant string used for "Move to end" command definition /// It is used for specific processing of Undo/Redo for this command. static QString MOVE_TO_END_COMMAND; @@ -359,9 +366,6 @@ signals: /// Activates/deactivates the trihedron in the viewer AIS context void onTrihedronVisibilityChanged(bool theState); - /// Returns defailt selection mode in 3d viewer - int viewerSelectionMode() const { return myViewerSelMode; } - protected: /// Sets the granted operations for the parameter operation. Firstly, it finds the nested features diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index b1c2569a2..8cea28345 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -57,5 +57,6 @@ pictures/shell.png pictures/wire.png pictures/result.png + pictures/find_result.png diff --git a/src/XGUI/pictures/find_result.png b/src/XGUI/pictures/find_result.png new file mode 100644 index 0000000000000000000000000000000000000000..00f1cd136866cb7aa9c9d5c09a089e3239b50050 GIT binary patch literal 593 zcmV-X0Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;(#7eog=Y0m4Z{K~y+TmC#ElL{S(A@H;CdSLXO1MICppkB3`0^1Q z7Ets{jJF|nK>!|M0c=3;Vfi+|Fen@77Zzb3sL3ssR60bbVzWAVYNQbhdCQLhf1xEZ z*D-A2cD_i$tnfEz42rVrP;~N4QRYY3dxiA!n#6)ePmgCh@Zz6a55+2K?RwG&NX)f~ zYttKO7~sGyHUvji!&%G3eAqj)s_J~RYpQ!{N!>obRcrdkU%zg^J!n3JtjG-*KNV^R zCSIs8mYvtVQ8W&qh2QYu>RV_&i6s6rz|5ZmR)QB{=I%W(Yt#vNq-V3oODn4m<<+-& f5fjWBKWM@`UPlYpcPsp200000NkvXXu0mjf!NByH literal 0 HcmV?d00001 -- 2.39.2