Salome HOME
Key_Delete shortcut for both delete action - 1. workshop, 2. partset module.
[modules/shaper.git] / src / XGUI / XGUI_Selection.cpp
index 7b4bb5ff1601e0c22f1ca481dd0fcc3c9969bd38..30c623181b9341d6ce7193fd00a99c554770ecdd 100644 (file)
@@ -33,6 +33,9 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip)
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  if (aContext.IsNull())
+    return aPresentations;
+
   if (aContext->HasOpenedContext()) {
     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
       ModuleBase_ViewerPrs aPrs;
@@ -112,11 +115,13 @@ QObjectPtrList XGUI_Selection::selectedPresentations() const
   QObjectPtrList aSelectedList;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
-    if (aResult)
-      aSelectedList.append(aResult);
+  if (!aContext.IsNull()) {
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+      Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+      ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
+      if (aResult)
+        aSelectedList.append(aResult);
+    }
   }
   return aSelectedList;
 }
@@ -157,16 +162,27 @@ 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,
-                                  const Handle(AIS_InteractiveContext)& theContext,
-                                  SelectMgr_IndexedMapOfOwner& theOwners)
+                                  SelectMgr_IndexedMapOfOwner& theOwners) const
 {
-    if (theObject.IsNull() || theContext.IsNull())
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  if (theObject.IsNull() || aContext.IsNull())
     return;
 
   TColStd_ListOfInteger aModes;
-  theContext->ActivatedModes(theObject, aModes);
+  aContext->ActivatedModes(theObject, aModes);
 
   TColStd_ListIteratorOfListOfInteger anIt(aModes);
   for (; anIt.More(); anIt.Next()) {