]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1126: Highlight results by feature
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 7 Apr 2016 08:16:53 +0000 (11:16 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 7 Apr 2016 08:17:06 +0000 (11:17 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/find_result.png [new file with mode: 0644]

index 051fa80283b963cc977166e4844b8f26a5c13cae..579be3621db1f647d1b28e799c2b3976803a7292 100644 (file)
@@ -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();
index e55d6406ee87b8e455180942a72d13a77a25b216..88ff0c7705c5bbccbc9badd3f864e64959f4b3a3 100755 (executable)
@@ -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<ResultPtr> aResList;
+  foreach(ObjectPtr aObj, theObjects) {
+    aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    if (aFeature.get()) {
+      aResList = aFeature->results();
+      std::list<std::shared_ptr<ModelAPI_Result> >::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);
+  }
+}
index 187182e6686dc30e3a4f2f2ad3aeafe217d5d520..4cda396f14e7150760cb9d5da6c34ffa1144f4fa 100755 (executable)
@@ -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
index b1c2569a27e5f0bffec2a4af874225743cb12043..8cea2834516542bc5c17d585b3218042fe594a7c 100644 (file)
@@ -57,5 +57,6 @@
      <file>pictures/shell.png</file>
      <file>pictures/wire.png</file>
      <file>pictures/result.png</file>
+     <file>pictures/find_result.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/find_result.png b/src/XGUI/pictures/find_result.png
new file mode 100644 (file)
index 0000000..00f1cd1
Binary files /dev/null and b/src/XGUI/pictures/find_result.png differ