Salome HOME
Activation objects redesign.
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
index 38cb1d325055cb3af5b4f1dd50d9b7b3c2fe939c..bece087dc5f4266476d175da5814030859875d1f 100755 (executable)
@@ -150,6 +150,28 @@ void XGUI_SelectionMgr::onViewerSelection()
   emit selectionChanged();
 }
 
+//**************************************************************
+void XGUI_SelectionMgr::deselectPresentation(const Handle(AIS_InteractiveObject) theObject)
+{
+  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+    if (anOwner.IsNull()) // TODO: check why it is possible
+      continue;
+    if (anOwner->Selectable() == theObject && anOwner->IsSelected())
+      aResultOwners.Append(anOwner);
+  }
+  NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
+  Handle(SelectMgr_EntityOwner) anOwner;
+  for (; anOwnersIt.More(); anOwnersIt.Next()) {
+    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+    if (!anOwner.IsNull())
+      aContext->AddOrRemoveSelected(anOwner, false);
+  }
+}
+
 //**************************************************************
 void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace)
 {
@@ -228,10 +250,15 @@ std::list<FeaturePtr> XGUI_SelectionMgr::getSelectedFeatures()
   if (aObjects.isEmpty())
     return aFeatures;
 
+  bool isPart = false;
   foreach(ObjectPtr aObj, aObjects) {
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
-    if (aFeature.get())
-      aFeatures.push_back(aFeature);
+    if (aFeature.get()) {
+      ResultPtr aRes = aFeature->firstResult();
+      isPart = (aRes.get() && (aRes->groupName() == ModelAPI_ResultPart::group()));
+      if (!isPart)
+        aFeatures.push_back(aFeature);
+    }
   }
   return aFeatures;
 }
\ No newline at end of file