#include #include #include #include // ------------------------------------------------------------------------- cpExtensions::Visualization::WindowLevelImageActor:: Self* cpExtensions::Visualization::WindowLevelImageActor:: New( ) { return( new Self( ) ); } // ------------------------------------------------------------------------- vtkImageData* cpExtensions::Visualization::WindowLevelImageActor:: GetImage( ) { return( this->m_Mapper->GetInput( ) ); } // ------------------------------------------------------------------------- const vtkImageData* cpExtensions::Visualization::WindowLevelImageActor:: GetImage( ) const { return( this->m_Mapper->GetInput( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: SetImage( vtkImageData* image ) { this->m_Mapper->SetInputData( image ); image->GetScalarRange( this->m_Range ); this->ResetWindowLevel( ); this->Modified( ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::WindowLevelImageActor:: GetLevel( ) { return( this->GetProperty( )->GetColorLevel( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::WindowLevelImageActor:: GetWindow( ) { return( this->GetProperty( )->GetColorWindow( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: SetLevel( double l ) { double old_l = this->GetProperty( )->GetColorLevel( ); if( l != old_l && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] ) { this->GetProperty( )->SetColorLevel( l ); this->Modified( ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: SetWindow( double w ) { double max_w = this->m_Range[ 1 ] - this->m_Range[ 0 ]; double old_w = this->GetProperty( )->GetColorWindow( ); if( w != old_w && double( 0 ) <= w && w <= max_w ) { this->GetProperty( )->SetColorWindow( w ); this->Modified( ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: SetWindowLevel( double w, double l ) { this->SetWindow( w ); this->SetLevel( l ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: ResetWindowLevel( ) { this->SetWindowLevel( this->m_Range[ 1 ] - this->m_Range[ 0 ], ( this->m_Range[ 1 ] + this->m_Range[ 0 ] ) / double( 2 ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: ConfigureWindowLevel( double min, double max ) { this->m_Range[ 0 ] = ( min < max )? min: max; this->m_Range[ 1 ] = ( min < max )? max: min; this->ResetWindowLevel( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: GetRange( double r[ 2 ] ) const { r[ 0 ] = this->m_Range[ 0 ]; r[ 1 ] = this->m_Range[ 1 ]; } // ------------------------------------------------------------------------- cpExtensions::Visualization::WindowLevelImageActor:: WindowLevelImageActor( ) : Superclass( ) { this->ConfigureWindowLevel( 0, 0 ); } // ------------------------------------------------------------------------- cpExtensions::Visualization::WindowLevelImageActor:: ~WindowLevelImageActor( ) { } // eof - $RCSfile$