Salome HOME
compilation errors (on Mandrake) fixed.
[modules/gui.git] / src / SalomeApp / SalomeApp_SelectionMgr.cxx
index 4394a254f25ce453a9e476025d4418f9e958305c..683d5327b971110246ec4c0a2c80e520f5399cf6 100644 (file)
@@ -36,85 +36,30 @@ SalomeApp_Application* SalomeApp_SelectionMgr::application() const
   get all selected objects from selection manager
 
 */
-void SalomeApp_SelectionMgr::selectedObjects( SALOME_ListIO& lst ) const
+void SalomeApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType ) const
 {
-  lst.Clear();
-
-  if ( !application() )
-    return;
-
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
-  if ( !appStudy )
-    return;
-
-  _PTR(Study) aStudy ( appStudy->studyDS() );
-  if ( !aStudy )
-    return;
+  theList.Clear();
 
   SUIT_DataOwnerPtrList aList;
-  selected( aList );
-
-  QValueList< QString > anEntryList;
-  Handle(SALOME_InteractiveObject) anIO;
+  selected( aList, theType );
 
   for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
   {
     const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*itr).operator->() );
-
-    if ( owner && dynamic_cast<const SalomeApp_DataSubOwner*>( owner ) ) 
-    { //get only subowners, insert into lst unique subowners (subowners with different entries)
-      if ( !anEntryList.contains( owner->entry() ) )
-      {        
-       anEntryList.append( owner->entry() );
-
-       //construct SALOME_InteractiveObject with predefined entry
-       _PTR(SObject) anObj ( aStudy->FindObjectID( owner->entry().latin1() ) );
-       if ( anObj )
-       {
-         _PTR(SComponent) aFC (anObj->GetFatherComponent());
-         if ( aFC )
-         {
-           anIO = new SALOME_InteractiveObject( anObj->GetID().c_str(), aFC->ComponentDataType().c_str(), anObj->Name().c_str() );
-           if ( anIO ) lst.Append( anIO );
-         }
-       }
-      }
-    }
-    else if ( owner )
-    { //get not subowners data owners
-      _PTR(SObject) anObj ( aStudy->FindObjectID( owner->entry().latin1() ) );
-      if ( anObj )
-      {
-        _PTR(SComponent) aFC (anObj->GetFatherComponent());
-        if ( aFC )
-        {
-          anIO = new SALOME_InteractiveObject( anObj->GetID().c_str(), aFC->ComponentDataType().c_str(), anObj->Name().c_str() );
-         if ( anIO ) lst.Append( anIO );
-        }
-      }
-    }
+    if( owner )
+      theList.Append( owner->IO() );
   }
 }
 
 void SalomeApp_SelectionMgr::setSelectedObjects( const SALOME_ListIO& lst, const bool append )
 {
-  if ( !application() )
-    return;
-
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
-  if ( !appStudy )
-    return;
-
-  _PTR(Study) aStudy ( appStudy->studyDS() );
-  if ( !aStudy )
-    return;
-
   SUIT_DataOwnerPtrList owners;
   for ( SALOME_ListIteratorOfListIO it( lst ); it.More(); it.Next() )
   {
     if ( it.Value()->hasEntry() )
-      owners.append( new SalomeApp_DataOwner( it.Value()->getEntry() ) );
+      owners.append( new SalomeApp_DataOwner( it.Value() ) );
   }
+
   setSelected( owners, append );
 }