Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / XGUI / XGUI_Selection.cpp
index a4ca2212d0923951d50cc95fd5ff483dc3d4dad8..23b11c9fbeeb83e81414bc31e2b1a1c2cef6a3e7 100644 (file)
 
 #include <AIS_InteractiveContext.hxx>
 
+#include <SelectMgr_Selection.hxx>
+#include <SelectBasics_SensitiveEntity.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
 #include <set>
 
 XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
@@ -152,3 +156,44 @@ void XGUI_Selection::selectedShapes(NCollection_List<TopoDS_Shape>& theList,
     }
   }
 }
+
+//**************************************************************
+void XGUI_Selection::selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const
+{
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    theSelectedOwners.Add(aContext->SelectedOwner());
+  }
+}
+
+//**************************************************************
+void XGUI_Selection::entityOwners(const Handle(AIS_InteractiveObject)& theObject,
+                                  SelectMgr_IndexedMapOfOwner& theOwners) const
+{
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  if (theObject.IsNull() || aContext.IsNull())
+    return;
+
+  TColStd_ListOfInteger aModes;
+  aContext->ActivatedModes(theObject, aModes);
+
+  TColStd_ListIteratorOfListOfInteger anIt(aModes);
+  for (; anIt.More(); anIt.Next()) {
+    int aMode = anIt.Value();
+    if (!theObject->HasSelection(aMode))
+      continue;
+
+    Handle(SelectMgr_Selection) aSelection = theObject->Selection(aMode);
+    for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
+      Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive();
+      if (anEntity.IsNull())
+        continue;
+      Handle(SelectMgr_EntityOwner) anOwner =
+        Handle(SelectMgr_EntityOwner)::DownCast(anEntity->OwnerId());
+      if (!anOwner.IsNull())
+        theOwners.Add(anOwner);
+    }
+  }
+}