]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1407: Provide selection of feature from result
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 19 Apr 2016 16:12:08 +0000 (19:12 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 19 Apr 2016 16:12:08 +0000 (19:12 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_MenuMgr.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 0b149456b023ff458e5b80da0135fdaea1a35f6d..96dbb9cbcdcc5dfd99b9b00d0cd705010a0494c2 100644 (file)
@@ -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<ModelAPI_Result>( 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) {
index 738c6569f7ef8d571de66dc15b5369ae46949c2f..c75493a1010cdab197141b5adf181dafb8bd3153 100644 (file)
@@ -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);
 
index 101a18722d4b8f400efebdaa4d76b4f8678337f0..295875c6fc92a0779e92501e1c11f6cab4c617e8 100644 (file)
@@ -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"));
index fbdb6379b393f11fddb917661ea703cfa44ac69f..fd0fc2d81e600fad8906d67e2b7291acb33ea1bf 100755 (executable)
@@ -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<ModelAPI_Result>(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);
+  }
+}
index ef44340d538387a4105f39504676dd404a457865..4c894fc81c088b11826d94df4aaf22e643fbd1d1 100755 (executable)
@@ -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; }