Salome HOME
studyActivated() virtual method has been added
[modules/gui.git] / src / SUIT / SUIT_SelectionMgr.cxx
index 974da5cb0798e58c57787a5cfba1d13566595330..6384d2bd3e83dcdca77777d67b854d7282afca63 100755 (executable)
@@ -8,6 +8,7 @@ myIsSelChangeEnabled( true )
 
 SUIT_SelectionMgr::~SUIT_SelectionMgr()
 {
+  mySelectors.setAutoDelete( true );
 }
 
 void SUIT_SelectionMgr::installSelector( SUIT_Selector* sel )
@@ -47,13 +48,15 @@ void SUIT_SelectionMgr::setEnabled( const bool on, const QString& typ )
   }
 }
 
-void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst ) const
+void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst, const QString& type ) const
 {
   lst.clear();
 
   QMap<const SUIT_DataOwner*, int> map;
   for ( SelectorListIterator it( mySelectors ); it.current(); ++it )
   {
+    if ( !type.isEmpty() && it.current()->type() != type )
+      continue;
     SUIT_DataOwnerPtrList curList;
     it.current()->selected( curList );
     for ( SUIT_DataOwnerPtrList::const_iterator itr = curList.begin(); itr != curList.end(); ++itr )
@@ -106,8 +109,9 @@ void SUIT_SelectionMgr::selectionChanged( SUIT_Selector* sel )
   {
     for ( SUIT_Selector* aSel = mySelectors.first(); aSel; aSel = mySelectors.next() )
     {
-      if ( aSel != sel )
-           aSel->setSelected( newOwners );
+      // Temporary action(to avoid selection of the objects which don't pass the filters):
+      //if ( aSel != sel )
+       aSel->setSelected( newOwners );
     }
   }
   myIsSelChangeEnabled = true;
@@ -203,10 +207,19 @@ bool SUIT_SelectionMgr::hasFilter( SUIT_SelectionFilter* f ) const
   return myFilters.contains( f );
 }
 
-void SUIT_SelectionMgr::installFilter( SUIT_SelectionFilter* f )
+void SUIT_SelectionMgr::installFilter( SUIT_SelectionFilter* f, const bool updateSelection )
 {
   if ( !hasFilter( f ) )
+  {
+    SUIT_DataOwnerPtrList selOwners;
+    if( updateSelection )
+      selected( selOwners );
+      
     myFilters.append( f );
+    
+    if( updateSelection )
+      setSelected( selOwners );
+  }
 }
 
 void SUIT_SelectionMgr::removeFilter( SUIT_SelectionFilter* f )