// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __fpa__Image__VisualDebugger__hxx__ #define __fpa__Image__VisualDebugger__hxx__ // ------------------------------------------------------------------------- template< class _TFilter > void fpa::Image::VisualDebugger< _TFilter >:: SetVisualization( vtkRenderer* renderer, vtkRenderWindowInteractor* iren ) { #ifdef USE_ivq this->m_Renderer = renderer; this->m_Interactor = iren; this->Modified( ); #endif // USE_ivq } // ------------------------------------------------------------------------- template< class _TFilter > void fpa::Image::VisualDebugger< _TFilter >:: Execute( itk::Object* caller, const itk::EventObject& event ) { this->Execute( const_cast< const itk::Object* >( caller ), event ); } // ------------------------------------------------------------------------- template< class _TFilter > void fpa::Image::VisualDebugger< _TFilter >:: Execute( const itk::Object* caller, const itk::EventObject& event ) { typedef itk::StartEvent _TStart; typedef itk::EndEvent _TEnd; typedef typename _TFilter::TEvent _TEvent; // Check validity const TFilter* filter = dynamic_cast< const TFilter* >( caller ); if( filter == NULL ) return; // Get correct event type const _TEvent* ev_fpa = dynamic_cast< const _TEvent* >( &event ); const _TStart* ev_start = dynamic_cast< const _TStart* >( &event ); const _TEnd* ev_end = dynamic_cast< const _TEnd* >( &event ); if( ev_fpa != NULL ) { if( this->m_Labels.IsNotNull( ) ) { TLabel new_color; if( ev_fpa->IntoQueue ) new_color = this->m_Colors[ this->m_Colors.size( ) - 2 ]; else new_color = this->m_Colors[ ( ev_fpa->FrontId - 1 ) % ( this->m_Colors.size( ) - 2 ) ]; TLabel old_color = this->m_Labels->GetPixel( ev_fpa->Vertex ); if( !( new_color == old_color ) ) { this->m_Labels->SetPixel( ev_fpa->Vertex, new_color ); this->m_VTKLabels->Modified( ); this->Render( ); } // fi } // fi } else if( ev_start != NULL ) { const TImage* image = filter->GetInput( ); this->m_Labels = TLabels::New( ); this->m_Labels-> SetLargestPossibleRegion( image->GetLargestPossibleRegion( ) ); this->m_Labels->SetRequestedRegion( image->GetRequestedRegion( ) ); this->m_Labels->SetBufferedRegion( image->GetBufferedRegion( ) ); this->m_Labels->SetOrigin( image->GetOrigin( ) ); this->m_Labels->SetSpacing( image->GetSpacing( ) ); this->m_Labels->SetDirection( image->GetDirection( ) ); this->m_Labels->Allocate( ); this->m_Labels->FillBuffer( this->m_Colors.back( ) ); #ifdef USE_ivq this->m_VTKLabels = TVTKLabels::New( ); this->m_VTKLabels->SetInput( this->m_Labels ); this->m_VTKLabels->Update( ); this->StartVisualization( ); #endif // USE_ivq } else if( ev_end != NULL ) { this->EndVisualization( ); this->m_Labels = NULL; this->m_VTKLabels = NULL; } // fi } // ------------------------------------------------------------------------- template< class _TFilter > fpa::Image::VisualDebugger< _TFilter >:: VisualDebugger( ) : Superclass( ) { unsigned char colors[ 8 ][ 4 ] = { { 255, 0, 0, 128 }, { 0, 255, 0, 128 }, { 0, 0, 255, 128 }, { 0, 255, 255, 128 }, { 255, 0, 255, 128 }, { 255, 255, 0, 128 }, { 255, 128, 64, 255 }, { 0, 0, 0, 0 } }; for( unsigned int i = 0; i < 8; ++i ) this->m_Colors.push_back( TLabel( colors[ i ] ) ); #ifdef USE_ivq this->m_Renderer = NULL; this->m_Interactor = NULL; #endif // USE_ivq } // ------------------------------------------------------------------------- template< class _TFilter > fpa::Image::VisualDebugger< _TFilter >:: ~VisualDebugger( ) { } #endif // __fpa__Image__VisualDebugger__h__ // eof - $RCSfile$