From: vsv Date: Tue, 19 Apr 2016 16:12:08 +0000 (+0300) Subject: Issue #1407: Provide selection of feature from result X-Git-Tag: V_2.3.0~179 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c957951b235d347f30e56c543110575f1d1e036;p=modules%2Fshaper.git Issue #1407: Provide selection of feature from result --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 0b149456b..96dbb9cbc 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -88,11 +88,6 @@ void PartSet_MenuMgr::createActions() aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool))); myActions["EDIT_CMD"] = aAction; - - aAction = new QAction(QIcon(), tr("Select parent feature"), this); - aAction->setCheckable(false); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSelectParentFeature())); - myActions["SELECT_PARENT_CMD"] = aAction; } @@ -503,23 +498,6 @@ void PartSet_MenuMgr::onEdit(bool) myModule->editFeature(aFeature); } -void PartSet_MenuMgr::onSelectParentFeature() -{ - QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects(); - if (aObjects.size() != 1) - return; - - SessionPtr aMgr = ModelAPI_Session::get(); - ResultPtr aResult = std::dynamic_pointer_cast( aObjects.first() ); - if( !aResult.get() ) - return; - - FeaturePtr aParentFeature = aResult->document()->feature( aResult ); - QObjectPtrList aSelection; - aSelection.append( aParentFeature ); - myModule->workshop()->selection()->setSelectedObjects( aSelection ); -} - bool PartSet_MenuMgr::eventFilter(QObject* theObj, QEvent* theEvent) { if (theEvent->type() == QEvent::MouseButtonDblClick) { diff --git a/src/PartSet/PartSet_MenuMgr.h b/src/PartSet/PartSet_MenuMgr.h index 738c6569f..c75493a10 100644 --- a/src/PartSet/PartSet_MenuMgr.h +++ b/src/PartSet/PartSet_MenuMgr.h @@ -83,8 +83,6 @@ private slots: /// A slot called on edit of feature void onEdit(bool); - void onSelectParentFeature(); - protected: bool eventFilter(QObject* theObj, QEvent* theEvent); diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 101a18722..295875c6f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -132,6 +132,9 @@ void XGUI_ContextMenuMgr::createActions() aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select results"), this); addAction("SHOW_RESULTS_CMD", aAction); + aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select parent feature"), this); + addAction("SHOW_FEATURE_CMD", aAction); + buildObjBrowserMenu(); buildViewerMenu(); } @@ -282,6 +285,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("CLEAN_HISTORY_CMD")->setEnabled(true); action("SHOW_RESULTS_CMD")->setEnabled(hasFeature); + action("SHOW_FEATURE_CMD")->setEnabled(hasResult); } // Show/Hide command has to be disabled for objects from non active document @@ -414,6 +418,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(mySeparator); aList.append(action("RENAME_CMD")); aList.append(action("COLOR_CMD")); + aList.append(action("SHOW_FEATURE_CMD")); myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList; //------------------------------------- @@ -429,6 +434,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(mySeparator); aList.append(action("RENAME_CMD")); aList.append(action("COLOR_CMD")); + aList.append(action("SHOW_FEATURE_CMD")); myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList; // Group menu myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList; @@ -437,9 +443,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() //------------------------------------- // Feature menu aList.clear(); - aList.append(action("SHOW_RESULTS_CMD")); - aList.append(mySeparator); aList.append(action("RENAME_CMD")); + aList.append(action("SHOW_RESULTS_CMD")); aList.append(action("MOVE_CMD")); aList.append(mySeparator); aList.append(action("CLEAN_HISTORY_CMD")); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index fbdb6379b..fd0fc2d81 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1233,6 +1233,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) setViewerSelectionMode(-1); } else if (theId == "SHOW_RESULTS_CMD") { highlightResults(aObjects); + } else if (theId == "SHOW_FEATURE_CMD") { + highlightFeature(aObjects); } } @@ -1998,3 +2000,25 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) objectBrowser()->blockSignals(aBlocked); } } + +void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) +{ + ResultPtr aResult; + QObjectPtrList aSelList = theObjects; + FeaturePtr aFeature; + foreach(ObjectPtr aObj, theObjects) { + aResult = std::dynamic_pointer_cast(aObj); + if (aResult.get()) { + aFeature = ModelAPI_Feature::feature(aResult); + if (aFeature.get()) { + aSelList.append(aFeature); + } + } + } + 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 ef44340d5..4c894fc81 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -288,6 +288,10 @@ Q_OBJECT /// features found in the given list void highlightResults(const QObjectPtrList& theObjects); + /// Highlights feature objects in Object Browser according to + /// features found in the given list + void highlightFeature(const QObjectPtrList& theObjects); + /// Returns Data Model XML reader which contains information about /// Data structure configuration const Config_DataModelReader* dataModelXMLReader() const { return myDataModelXMLReader; }