1 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
2 #include <cpExtensions/Visualization/ImageSliceMapper.h>
4 #include <vtkImageData.h>
5 #include <vtkImageProperty.h>
7 // -------------------------------------------------------------------------
8 cpExtensions::Visualization::WindowLevelImageActor::
9 Self* cpExtensions::Visualization::WindowLevelImageActor::
12 return( new Self( ) );
15 // -------------------------------------------------------------------------
16 vtkImageData* cpExtensions::Visualization::WindowLevelImageActor::
19 return( this->m_Mapper->GetInput( ) );
22 // -------------------------------------------------------------------------
23 const vtkImageData* cpExtensions::Visualization::WindowLevelImageActor::
26 return( this->m_Mapper->GetInput( ) );
29 // -------------------------------------------------------------------------
30 void cpExtensions::Visualization::WindowLevelImageActor::
31 SetImage( vtkImageData* image )
33 this->m_Mapper->SetInputData( image );
38 // -------------------------------------------------------------------------
39 double cpExtensions::Visualization::WindowLevelImageActor::
42 Self* self = const_cast< Self* >( this );
43 return( self->GetProperty( )->GetColorLevel( ) );
46 // -------------------------------------------------------------------------
47 double cpExtensions::Visualization::WindowLevelImageActor::
50 Self* self = const_cast< Self* >( this );
51 return( self->GetProperty( )->GetColorWindow( ) );
54 // -------------------------------------------------------------------------
55 void cpExtensions::Visualization::WindowLevelImageActor::
56 GetWindowLevel( double wl[ 2 ] ) const
58 Self* self = const_cast< Self* >( this );
59 wl[ 0 ] = self->GetProperty( )->GetColorWindow( );
60 wl[ 1 ] = self->GetProperty( )->GetColorLevel( );
63 // -------------------------------------------------------------------------
64 void cpExtensions::Visualization::WindowLevelImageActor::
68 ( this->m_Range[ 1 ] - this->m_Range[ 0 ] ),
69 ( this->m_Range[ 1 ] + this->m_Range[ 0 ] ) / double( 2 )
73 // -------------------------------------------------------------------------
74 void cpExtensions::Visualization::WindowLevelImageActor::
77 double ol = this->GetProperty( )->GetColorLevel( );
78 if( l != ol && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] )
80 this->GetProperty( )->SetColorLevel( l );
86 // -------------------------------------------------------------------------
87 void cpExtensions::Visualization::WindowLevelImageActor::
90 double mw = this->m_Range[ 1 ] - this->m_Range[ 0 ];
91 double ow = this->GetProperty( )->GetColorWindow( );
92 if( w != ow && double( 0 ) <= w && w <= mw )
94 this->GetProperty( )->SetColorWindow( w );
100 // -------------------------------------------------------------------------
101 void cpExtensions::Visualization::WindowLevelImageActor::
102 SetWindowLevel( double w, double l )
104 this->SetWindow( w );
108 // -------------------------------------------------------------------------
109 void cpExtensions::Visualization::WindowLevelImageActor::
110 SetWindowLevel( double wl[ 2 ] )
112 this->SetWindow( wl[ 0 ] );
113 this->SetLevel( wl[ 1 ] );
116 // -------------------------------------------------------------------------
117 double cpExtensions::Visualization::WindowLevelImageActor::
120 return( this->m_Range[ 0 ] );
123 // -------------------------------------------------------------------------
124 double cpExtensions::Visualization::WindowLevelImageActor::
127 return( this->m_Range[ 0 ] );
130 // -------------------------------------------------------------------------
131 void cpExtensions::Visualization::WindowLevelImageActor::
132 GetRange( double r[ 2 ] ) const
134 r[ 0 ] = this->m_Range[ 0 ];
135 r[ 1 ] = this->m_Range[ 1 ];
138 // -------------------------------------------------------------------------
139 void cpExtensions::Visualization::WindowLevelImageActor::
142 this->GetImage( )->GetScalarRange( this->m_Range );
143 this->ResetWindowLevel( );
146 // -------------------------------------------------------------------------
147 void cpExtensions::Visualization::WindowLevelImageActor::
148 SetMinimum( double a )
150 if( this->m_Range[ 0 ] != a )
152 this->m_Range[ 0 ] = a;
153 this->ResetWindowLevel( );
158 // -------------------------------------------------------------------------
159 void cpExtensions::Visualization::WindowLevelImageActor::
160 SetMaximum( double b )
162 if( this->m_Range[ 1 ] != b )
164 this->m_Range[ 1 ] = b;
165 this->ResetWindowLevel( );
170 // -------------------------------------------------------------------------
171 void cpExtensions::Visualization::WindowLevelImageActor::
172 SetRange( double a, double b )
174 this->SetMinimum( a );
175 this->SetMaximum( b );
178 // -------------------------------------------------------------------------
179 void cpExtensions::Visualization::WindowLevelImageActor::
180 SetRange( double r[ 2 ] )
182 this->SetMinimum( r[ 0 ] );
183 this->SetMaximum( r[ 1 ] );
186 // -------------------------------------------------------------------------
187 cpExtensions::Visualization::WindowLevelImageActor::
188 WindowLevelImageActor( )
191 this->m_Range[ 0 ] = this->m_Range[ 1 ] = double( 0 );
194 // -------------------------------------------------------------------------
195 cpExtensions::Visualization::WindowLevelImageActor::
196 ~WindowLevelImageActor( )