From: vsv Date: Thu, 7 Apr 2016 08:16:53 +0000 (+0300) Subject: Issue #1126: Highlight results by feature X-Git-Tag: V_2.3.0~277 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0476591a9c87c4569b627a9a0cc4f40f6c096d8;p=modules%2Fshaper.git Issue #1126: Highlight results by feature --- 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 000000000..00f1cd136 Binary files /dev/null and b/src/XGUI/pictures/find_result.png differ