Salome HOME
SPlot2d_Viewer connected to Plot2d_ViewManager
[modules/gui.git] / src / SalomeApp / SalomeApp_VTKSelector.cxx
index 3b3a8a30478f454bb1b2d157dcbb7563b501b27d..e67be28b4f178fe339fc1abf2cc7f5f69a1d8562 100644 (file)
@@ -11,7 +11,7 @@
 #include "utilities.h"
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -134,21 +134,21 @@ SalomeApp_VTKSelector
            }
          }
          // To remove IOs, which is not selected.
-         SALOME_ListIO aRemoveList;
-         SALOME_ListIteratorOfListIO anAppendListIter(anAppendList);
-         for(; anAppendListIter.More(); anAppendListIter.Next()){
-           Handle(SALOME_InteractiveObject) anIO = anAppendListIter.Value();
-           SALOME_ListIteratorOfListIO aStoredListIter(aStoredList);
-           for(; aStoredListIter.More(); aStoredListIter.Next()){
-             if(anIO->isSame(aStoredListIter.Value())){
-               aRemoveList.Append(anIO);
-             }
-           }
-         }
-         SALOME_ListIteratorOfListIO aRemoveListIter(aRemoveList);
-         for(; aRemoveListIter.More(); aRemoveListIter.Next()){
-           aSelector->RemoveIObject(aRemoveListIter.Value());
-         }
+         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() );
+
+         QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
+                                                                            REnd = toRemove.end();
+         for( ; RIt!=REnd; RIt++ )
+           aSelector->RemoveIObject( RIt.data() );
+         
          aView->onSelectionChanged();
        }
       }