Salome HOME
Better management of errors.
[modules/shaper.git] / src / XGUI / XGUI_Selection.cpp
index 6718012dbaa5b01475fc70a70b761ce7c76599d2..5af4ea4c3f4739988c0d331433bb58b6507f1b20 100644 (file)
@@ -80,7 +80,7 @@ Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrsPt
 void XGUI_Selection::getSelectedInViewer(QList<ModuleBase_ViewerPrsPtr>& thePresentations) const
 {
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (!aContext.IsNull() && aContext->HasOpenedContext()) {
+  if (!aContext.IsNull()) {
     QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
       ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
@@ -123,7 +123,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs,
                                       const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
   thePrs->setOwner(theOwner);
-
+  Handle(SelectMgr_SelectableObject) aSelectable = theOwner->Selectable();
   Handle(AIS_InteractiveObject) anIO =
                            Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
   thePrs->setInteractive(anIO);
@@ -242,33 +242,15 @@ QList<ModuleBase_ViewerPrsPtr> XGUI_Selection::getHighlighted() const
       fillPresentation(aPrs, anOwner);
       aPresentations.push_back(aPrs);
     }
-    else { // TODO: check why the entity owner is null here, case is selection point on a line
-      Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
-      ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
-      aPrs->setInteractive(anIO);
-
-      ObjectPtr aResult = aDisplayer->getObject(anIO);
-      // we should not check the appearance of this feature because there can be some selected
-      // shapes for one feature
-      aPrs->setObject(aResult);
-      if (aContext->HasOpenedContext()) {
-        TopoDS_Shape aShape = aContext->DetectedShape();
-        if (!aShape.IsNull()) {
-          std::shared_ptr<GeomAPI_Shape> aGeomShape =
-            std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
-          aGeomShape->setImpl(new TopoDS_Shape(aShape));
-          aPrs->setShape(aGeomShape);
-        }
-      }
-      aPresentations.push_back(aPrs);
-    }
   }
   return aPresentations;
 }
 
 QObjectPtrList XGUI_Selection::selectedObjects() const
 {
-  return myWorkshop->objectBrowser()->selectedObjects();
+  if (myWorkshop->objectBrowser())
+    return myWorkshop->objectBrowser()->selectedObjects();
+  return QObjectPtrList();
 }
 
 void XGUI_Selection::setSelectedObjects( const QObjectPtrList& theObjects ) const