]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1306: Find Feature by history from result and shape
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 6 Apr 2016 14:27:35 +0000 (17:27 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 6 Apr 2016 14:27:48 +0000 (17:27 +0300)
src/XGUI/XGUI_SelectionMgr.cpp

index 11e2e76fc4190ce292a8b5ca4fe37a1e49407681..fd7729f03ce74f14c2e4e84de0a5e27a19f1d457 100644 (file)
@@ -120,25 +120,26 @@ void XGUI_SelectionMgr::onObjectBrowserSelection()
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
+  SessionPtr aMgr = ModelAPI_Session::get();
+  DocumentPtr anActiveDocument = aMgr->activeDocument();
   QObjectPtrList aFeatures;
+  ResultPtr aResult;
+  FeaturePtr aFeature;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull()) {
     QList<ModuleBase_ViewerPrs> aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer);
     foreach(ModuleBase_ViewerPrs aPrs, aPresentations) {
-      if (aPrs.object().get())
+      if (aPrs.object().get()) {
         aFeatures.append(aPrs.object());
-    }
-  }
-  // Add features by selected results
-  QObjectPtrList aTmpList = aFeatures;
-  ResultPtr aResult;
-  FeaturePtr aFeature;
-  foreach(ObjectPtr aObj, aTmpList) {
-    aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-    if (aResult.get()) {
-      aFeature = ModelAPI_Feature::feature(aResult);
-      if (aFeature.get() && (!aFeatures.contains(aFeature)))
-        aFeatures.append(aFeature);
+        if (aPrs.shape().get()) {
+          aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
+          if (aResult.get()) {
+            aFeature = anActiveDocument->producedByFeature(aResult, aPrs.shape());
+            if (aFeature.get() && (!aFeatures.contains(aFeature)))
+              aFeatures.append(aFeature);
+          }
+        }
+      }
     }
   }
   bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);