//=================================================================================
SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp()
{
- Filters::const_iterator anIt = myFilters.begin(),
- aLast = myFilters.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data() )
- delete anIt.data();
+ removeCustomFilters();
}
//=================================================================================
// name : removeCustomFilters
// purpose :
//=================================================================================
-void SMESHGUI_SelectionOp::removeCustomFilters() const
+void SMESHGUI_SelectionOp::removeCustomFilters()
{
- LightApp_SelectionMgr* mgr = selectionMgr();
- if( !mgr )
- return;
-
- Filters::const_iterator anIt = myFilters.begin(),
- aLast = myFilters.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data() )
- mgr->removeFilter( anIt.data() );
+ if (myFilters.count() > 0) {
+ LightApp_SelectionMgr* mgr = selectionMgr();
+ Filters::const_iterator anIt = myFilters.begin(),
+ aLast = myFilters.end();
+ for (; anIt != aLast; anIt++) {
+ if (anIt.data()) {
+ if (mgr) mgr->removeFilter(anIt.data());
+ delete anIt.data();
+ }
+ }
+
+ myFilters.clear();
+ }
}
//=================================================================================
//=================================================================================
void SMESHGUI_SelectionOp::onDeactivateObject( int id )
{
- LightApp_SelectionMgr* mgr = selectionMgr();
- if( mgr && myFilters.contains( id ) && myFilters[ id ] )
- mgr->removeFilter( myFilters[ id ] );
+ removeCustomFilters();
}
//=================================================================================
virtual SUIT_SelectionFilter* createFilter( const int ) const;
//! Remove only filters set by this operation (they are in map myFilters )
- void removeCustomFilters() const;
+ void removeCustomFilters();
//! Return what selection mode is set in VTK viewer
Selection_Mode selectionMode() const;