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( );
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( );
// -------------------------------------------------------------------------
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 ] );
}
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------