-void cpExtensions::Visualization::ImageSliceActors::
-PushActorsInto( vtkRenderWindow* window, bool force_style )
-{
- this->m_Window = window;
- if( window == NULL )
- return;
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
- if( rwi == NULL || renderer == NULL )
- return;
-
- // Update style
- if( this->m_Style.GetPointer( ) != NULL && force_style )
- rwi->SetInteractorStyle( this->m_Style );
-
- // Update actors
- renderer->AddViewProp( this->m_ImageActor );
- renderer->AddViewProp( this->m_BlenderActor );
- if( force_style )
- {
- renderer->AddViewProp( this->m_CursorActor );
- renderer->AddViewProp( this->m_PlaneActor );
- renderer->AddViewProp( this->m_TextActor );
- renderer->AddViewProp( this->m_Axis1Actor );
- renderer->AddViewProp( this->m_Axis2Actor );
-
- } // fi
-
- // Configure camera
- vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera != NULL && force_style )
- {
- // Parallel projections are better when displaying 2D images
- int axis = this->GetAxis( );
- camera->ParallelProjectionOn( );
- camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
- if( axis == 0 )
- {
- camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) );
- }
- else if( axis == 1 )
- {
- camera->SetPosition( double( 0 ), double( -1 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) );
- }
- else // if( axis == 2 )
- {
- camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
- camera->SetViewUp ( double( 0 ), double( -1 ), double( 0 ) );
-
- } // fi
-
- } // fi
- this->ResetCamera( );
- rwi->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-PopActorsFrom( vtkRenderWindow* window )
-{
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
- if( renderer != NULL )
- {
- renderer->RemoveViewProp( this->m_ImageActor );
- renderer->RemoveViewProp( this->m_BlenderActor );
- renderer->RemoveViewProp( this->m_CursorActor );
- renderer->RemoveViewProp( this->m_PlaneActor );
- renderer->RemoveViewProp( this->m_TextActor );
- renderer->RemoveViewProp( this->m_Axis1Actor );
- renderer->RemoveViewProp( this->m_Axis2Actor );
- if( rwi != NULL )
- rwi->Render( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::ImageSliceActors::
-GetNumberOfImages( ) const
-{
- return( this->m_Blender->GetNumberOfInputPorts( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( )
-{
- return( this->m_ImageActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( ) const
-{
- return( this->m_ImageActor );
-}
-
-// -------------------------------------------------------------------------
-vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetBinaryActor( )
-{
- return( this->m_BlenderActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetBinaryActor( ) const
-{
- return( this->m_BlenderActor );
-}
-
-// -------------------------------------------------------------------------
-vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
-GetTextActor( )
-{
- return( this->m_TextActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
-GetTextActor( ) const
-{
- return( this->m_TextActor );
-}
-
-// -------------------------------------------------------------------------
-vtkActor* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneActor( )
-{
- return( this->m_PlaneActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkActor* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneActor( ) const
-{
- return( this->m_PlaneActor );
-}
-
-// -------------------------------------------------------------------------
-vtkPlane* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneFunction( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSlicePlane( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const vtkPlane* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneFunction( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSlicePlane( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInterpolate( bool v )
-{
- if( this->m_Interpolate != v )
- {
- this->m_ImageActor->SetInterpolate( v );
- this->m_BlenderActor->SetInterpolate( v );
- this->m_Interpolate = v;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-InterpolateOn( )
-{
- this->SetInterpolate( true );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-InterpolateOff( )
-{
- this->SetInterpolate( false );
-}
-
-// -------------------------------------------------------------------------
-double* cpExtensions::Visualization::ImageSliceActors::
-GetDisplayBounds( ) const
-{
- if( this->m_ImageActor.GetPointer( ) != NULL )
- return( this->m_ImageActor->GetDisplayBounds( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-GetDisplayBounds( double bounds[ 6 ] ) const
-{
- if( this->m_ImageActor.GetPointer( ) == NULL )
- {
- bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double( 0 );
- bounds[ 1 ] = bounds[ 3 ] = bounds[ 5 ] = double( -1 );
- }
- else
- this->m_ImageActor->GetDisplayBounds( bounds );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-ResetCursor( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- {
- double pos[] =
- {
- this->m_VisibleBounds[ 0 ],
- this->m_VisibleBounds[ 2 ],
- this->m_VisibleBounds[ 4 ]
- };
- this->SetCursor( pos );
- }
- else
- {
- vtkPoints* points = this->m_Cursor->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- points->SetPoint( 2, 0, 0, 0 );
- points->SetPoint( 3, 0, 0, 0 );
- this->m_Cursor->Modified( );
- this->m_CursorMapper->Modified( );
- this->m_CursorActor->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetCursor( double pos[ 3 ] )
-{
- if( this->m_ImageMapper.GetPointer( ) == NULL )
- return;
-
- // Get ordered axes
- int a0 = this->GetAxis( );
- int a1 = ( a0 + 1 ) % 3;
- int a2 = ( a0 + 2 ) % 3;
- int ma0 = a0 << 1;
- int ma1 = a1 << 1;
- int ma2 = a2 << 1;
-
- // Update cross
- double* bounds = this->m_VisibleBounds;
- double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
-
- p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
- p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
- p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
- p0[ a1 ] = bounds[ ma1 ];
- p1[ a1 ] = bounds[ ma1 + 1 ];
- p2[ a2 ] = bounds[ ma2 ];
- p3[ a2 ] = bounds[ ma2 + 1 ];
-
- vtkPoints* points = this->m_Cursor->GetPoints( );
- points->SetPoint( 0, p0 );
- points->SetPoint( 1, p1 );
- points->SetPoint( 2, p2 );
- points->SetPoint( 3, p3 );
- this->m_Cursor->Modified( );
- this->m_CursorMapper->Modified( );
- this->m_CursorActor->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-ResetAxesCursor( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- {
- double pos[] =
- {
- this->m_VisibleBounds[ 0 ],
- this->m_VisibleBounds[ 2 ],
- this->m_VisibleBounds[ 4 ]
- };
- this->SetAxesCursor( pos );
- }
- else
- {
- vtkPoints* points = this->m_Axis1->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- this->m_Axis1->Modified( );
- this->m_Axis1Mapper->Modified( );
- this->m_Axis1Actor->Modified( );
-
- points = this->m_Axis2->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- this->m_Axis2->Modified( );
- this->m_Axis2Mapper->Modified( );
- this->m_Axis2Actor->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetAxesCursor( double pos[ 3 ] )
-{
- if( this->m_ImageMapper.GetPointer( ) == NULL )
- return;
-
- // Get ordered axes
- int a0 = this->GetAxis( );
- int a1 = ( a0 + 1 ) % 3;
- int a2 = ( a0 + 2 ) % 3;
- int ma0 = a0 << 1;
- int ma1 = a1 << 1;
- int ma2 = a2 << 1;
-
- // Update cross
- double* bounds = this->m_VisibleBounds;
- double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
-
- p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
- p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
- p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
- p0[ a1 ] = bounds[ ma1 ];
- p1[ a1 ] = bounds[ ma1 + 1 ];
- p2[ a2 ] = bounds[ ma2 ];
- p3[ a2 ] = bounds[ ma2 + 1 ];
-
- vtkPoints* points1 = this->m_Axis1->GetPoints( );
- points1->SetPoint( 0, p2 );
- points1->SetPoint( 1, p3 );
-
- vtkPoints* points2 = this->m_Axis2->GetPoints( );
- points2->SetPoint( 0, p0 );
- points2->SetPoint( 1, p1 );
-
- this->m_Axis1->Modified( );
- this->m_Axis1Mapper->Modified( );
- this->m_Axis1Actor->Modified( );
-
- this->m_Axis2->Modified( );
- this->m_Axis2Mapper->Modified( );
- this->m_Axis2Actor->Modified( );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMinWindow( ) const
-{
- return( this->m_WLRange[ 0 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMaxWindow( ) const
-{
- return( this->m_WLRange[ 1 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMinLevel( ) const
-{
- return( this->m_WLRange[ 2 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMaxLevel( ) const