Salome HOME
new presentation using DTM
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_OCCSelector.cxx
index 750593296731d62ab2f7d1195845b7254b41a14f..432306627ff08164ce644a83d348cb9dca394d77 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_DataOwner.h"
 #include "HYDROGUI_Module.h"
 
 #include <AIS_ListOfInteractive.hxx>
@@ -53,8 +54,14 @@ void HYDROGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
   for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() )
     if ( !anIt.Value().IsNull() )
     {
-      if ( !isLocalContext )
-        aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
+      if ( !isLocalContext ) {
+        QString anEntry = entry( anIt.Value() );
+        if ( !anEntry.isEmpty() ) {
+          aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
+        } else {
+          aList.append( SUIT_DataOwnerPtr( new HYDROGUI_DataOwner( anIt.Value() ) ) );
+        }
+      }
     }
   // add externally selected objects
   SUIT_DataOwnerPtrList::const_iterator anExtIter;
@@ -74,9 +81,7 @@ void HYDROGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
     return;
   }
 
-  //@MZN LightApp_OCCSelector::setSelection( aList );
   QMap<QString, Handle(AIS_InteractiveObject)> aDisplayed;
-    
   AIS_ListOfInteractive aDispList, aSelList;
   aContext->DisplayedObjects( aDispList );
 
@@ -94,11 +99,16 @@ void HYDROGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
     const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
     if ( owner && aDisplayed.contains( owner->entry() ) )
       aSelList.Append( aDisplayed[owner->entry()] );
-    else
-      mySelectedExternals.append(*itr);
+    else {
+      const HYDROGUI_DataOwner* hydroOwner = dynamic_cast<const HYDROGUI_DataOwner*>( (*itr).operator->() );
+      if ( hydroOwner && !hydroOwner->IO().IsNull() ) {
+        aSelList.Append( hydroOwner->IO() );
+      } else
+        mySelectedExternals.append(*itr);
+    }
   }
-
-  //@MZNmyViewer->unHighlightAll( false );
+  aViewer->unHighlightAll( false );
   aViewer->setObjectsSelected( aSelList );
 }