Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / LightApp / LightApp_VTKSelector.cxx
index 3556c08123ee997fd3384aa3f41b5fc2b992c05b..019a959ec0e5900ed6833eb814a921f3dd8eb4cc 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "LightApp_VTKSelector.h"
 #include "LightApp_DataOwner.h"
 
@@ -47,7 +48,7 @@
   Constructor.
 */
 LightApp_SVTKDataOwner::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
-                                                                 SUIT_Desktop* theDesktop )
+                                                                  SUIT_Desktop* theDesktop )
 : LightApp_DataOwner( theIO ),
 myDesktop( theDesktop )
 {
@@ -113,7 +114,8 @@ LightApp_SVTKDataOwner
 {
   if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){
     using namespace SVTK;
-    return Find<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(IO()));
+    VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
+    return Find<SALOME_Actor>(aCopy.GetActors(),TIsSameIObject<SALOME_Actor>(IO()));
   }
 
   return NULL;
@@ -136,7 +138,7 @@ LightApp_SVTKDataOwner::~LightApp_SVTKDataOwner()
 */
 LightApp_VTKSelector
 ::LightApp_VTKSelector( SVTK_ViewModelBase* viewer, 
-                       SUIT_SelectionMgr* mgr ): 
+                        SUIT_SelectionMgr* mgr ): 
   SUIT_Selector( mgr, viewer ),
   myViewer( viewer )
 {
@@ -187,17 +189,17 @@ LightApp_VTKSelector
   if(myViewer){
     if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){
       if(SVTK_ViewManager* aViewMgr = dynamic_cast<SVTK_ViewManager*>(aViewManager)){
-       if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
-         if(SVTK_Selector* aSelector = aView->GetSelector()){
-           const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
-           SALOME_ListIteratorOfListIO anIter(aListIO);
-           for(; anIter.More(); anIter.Next()){
-             Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-             if(anIO->hasEntry())
-               aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));
-           }
-         }
-       }
+        if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
+          if(SVTK_Selector* aSelector = aView->GetSelector()){
+            const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+            SALOME_ListIteratorOfListIO anIter(aListIO);
+            for(; anIter.More(); anIter.Next()){
+              Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+              if(anIO->hasEntry())
+                aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));
+            }
+          }
+        }
       }
     }
   }
@@ -213,45 +215,45 @@ LightApp_VTKSelector
   if(myViewer){
     if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
       if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
-       if(SVTK_Selector* aSelector = aView->GetSelector()){
-         SALOME_ListIO anAppendList;
-         const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
-         SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
-         for(; anIter != theList.end(); ++anIter){
-           const SUIT_DataOwner* aDataOwner = (*anIter).get();
-           if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
-             aSelector->SetSelectionMode(anOwner->GetMode());
-             Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
+        if(SVTK_Selector* aSelector = aView->GetSelector()){
+          SALOME_ListIO anAppendList;
+          const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
+          SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
+          for(; anIter != theList.end(); ++anIter){
+            const SUIT_DataOwner* aDataOwner = (*anIter).get();
+            if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
+              aSelector->SetSelectionMode(anOwner->GetMode());
+              Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
 
-             aSelector->AddIObject(anIO);
+              aSelector->AddIObject(anIO);
 
-             anAppendList.Append(anIO);
-             aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
-           }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
-             Handle(SALOME_InteractiveObject) anIO = 
-               new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
-             aSelector->AddIObject(anIO);
-             anAppendList.Append(anIO);
-           }
-         }
-         // To remove IOs, which is not selected.
-         QMap< QString, Handle( SALOME_InteractiveObject )> toRemove;
-         SALOME_ListIteratorOfListIO anIt( aStoredList );
-         for( ; anIt.More(); anIt.Next() )
-           if( !anIt.Value().IsNull() )
-             toRemove[ anIt.Value()->getEntry() ] = anIt.Value();
+              anAppendList.Append(anIO);
+              aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
+            }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
+              Handle(SALOME_InteractiveObject) anIO = 
+                new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
+              aSelector->AddIObject(anIO);
+              anAppendList.Append(anIO);
+            }
+          }
+          // To remove IOs, which is not selected.
+          QMap< QString, Handle( SALOME_InteractiveObject )> toRemove;
+          SALOME_ListIteratorOfListIO anIt( aStoredList );
+          for( ; anIt.More(); anIt.Next() )
+            if( !anIt.Value().IsNull() )
+              toRemove[ anIt.Value()->getEntry() ] = anIt.Value();
 
-         anIt = SALOME_ListIteratorOfListIO(anAppendList);
-         for( ; anIt.More(); anIt.Next() )
-           toRemove.remove( anIt.Value()->getEntry() );
+          anIt = SALOME_ListIteratorOfListIO(anAppendList);
+          for( ; anIt.More(); anIt.Next() )
+            toRemove.remove( anIt.Value()->getEntry() );
 
-         QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
-                                                                            REnd = toRemove.end();
-         for( ; RIt!=REnd; RIt++ )
-           aSelector->RemoveIObject( RIt.value() );
-         
-         aView->onSelectionChanged();
-       }
+          QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
+                                                                             REnd = toRemove.end();
+          for( ; RIt!=REnd; RIt++ )
+            aSelector->RemoveIObject( RIt.value() );
+          
+          aView->onSelectionChanged();
+        }
       }
     }
   }