X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FWindowLevelImageActor.cxx;h=c7cbbd43ee53ff8d5e62cf7c0166936aae9f9b2b;hb=aee3cafa7e93f996580777976636ed625dbc43f5;hp=4fe46241f5c9ce88e0d84e78b3a158fece227751;hpb=3393941bf8f26babc7b592db434b40c1b747a687;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/WindowLevelImageActor.cxx b/lib/cpExtensions/Visualization/WindowLevelImageActor.cxx index 4fe4624..c7cbbd4 100644 --- a/lib/cpExtensions/Visualization/WindowLevelImageActor.cxx +++ b/lib/cpExtensions/Visualization/WindowLevelImageActor.cxx @@ -31,31 +31,51 @@ void cpExtensions::Visualization::WindowLevelImageActor:: SetImage( vtkImageData* image ) { this->m_Mapper->SetInputData( image ); - image->GetScalarRange( this->m_Range ); - this->ResetWindowLevel( ); + this->ResetRange( ); this->Modified( ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::WindowLevelImageActor:: -GetLevel( ) +GetLevel( ) const { - return( this->GetProperty( )->GetColorLevel( ) ); + Self* self = const_cast< Self* >( this ); + return( self->GetProperty( )->GetColorLevel( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::WindowLevelImageActor:: -GetWindow( ) +GetWindow( ) const +{ + Self* self = const_cast< Self* >( this ); + return( self->GetProperty( )->GetColorWindow( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +GetWindowLevel( double wl[ 2 ] ) const { - return( this->GetProperty( )->GetColorWindow( ) ); + Self* self = const_cast< Self* >( this ); + wl[ 0 ] = self->GetProperty( )->GetColorWindow( ); + wl[ 1 ] = self->GetProperty( )->GetColorLevel( ); +} + +// ------------------------------------------------------------------------- +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:: SetLevel( double l ) { - double old_l = this->GetProperty( )->GetColorLevel( ); - if( l != old_l && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] ) + double ol = this->GetProperty( )->GetColorLevel( ); + if( l != ol && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] ) { this->GetProperty( )->SetColorLevel( l ); this->Modified( ); @@ -67,9 +87,9 @@ SetLevel( double l ) 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 ) + double mw = this->m_Range[ 1 ] - this->m_Range[ 0 ]; + double ow = this->GetProperty( )->GetColorWindow( ); + if( w != ow && double( 0 ) <= w && w <= mw ) { this->GetProperty( )->SetColorWindow( w ); this->Modified( ); @@ -87,21 +107,24 @@ SetWindowLevel( double w, double l ) // ------------------------------------------------------------------------- void cpExtensions::Visualization::WindowLevelImageActor:: -ResetWindowLevel( ) +SetWindowLevel( double wl[ 2 ] ) { - this->SetWindowLevel( - this->m_Range[ 1 ] - this->m_Range[ 0 ], - ( this->m_Range[ 1 ] + this->m_Range[ 0 ] ) / double( 2 ) - ); + this->SetWindow( wl[ 0 ] ); + this->SetLevel( wl[ 1 ] ); } // ------------------------------------------------------------------------- -void cpExtensions::Visualization::WindowLevelImageActor:: -ConfigureWindowLevel( double min, double max ) +double cpExtensions::Visualization::WindowLevelImageActor:: +GetMinimum( ) const { - this->m_Range[ 0 ] = ( min < max )? min: max; - this->m_Range[ 1 ] = ( min < max )? max: min; - this->ResetWindowLevel( ); + return( this->m_Range[ 0 ] ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::WindowLevelImageActor:: +GetMaximum( ) const +{ + return( this->m_Range[ 0 ] ); } // ------------------------------------------------------------------------- @@ -112,12 +135,60 @@ GetRange( double r[ 2 ] ) const r[ 1 ] = this->m_Range[ 1 ]; } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +ResetRange( ) +{ + this->GetImage( )->GetScalarRange( this->m_Range ); + this->ResetWindowLevel( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +SetMinimum( double a ) +{ + if( this->m_Range[ 0 ] != a ) + { + this->m_Range[ 0 ] = a; + this->ResetWindowLevel( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +SetMaximum( double b ) +{ + if( this->m_Range[ 1 ] != b ) + { + this->m_Range[ 1 ] = b; + this->ResetWindowLevel( ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +SetRange( double a, double b ) +{ + this->SetMinimum( a ); + this->SetMaximum( b ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::WindowLevelImageActor:: +SetRange( double r[ 2 ] ) +{ + this->SetMinimum( r[ 0 ] ); + this->SetMaximum( r[ 1 ] ); +} + // ------------------------------------------------------------------------- cpExtensions::Visualization::WindowLevelImageActor:: WindowLevelImageActor( ) : Superclass( ) { - this->ConfigureWindowLevel( 0, 0 ); + this->m_Range[ 0 ] = this->m_Range[ 1 ] = double( 0 ); } // -------------------------------------------------------------------------