#ifdef cpExtensions_QT4
#include <cpExtensions/Interaction/ImageSliceStyle.h>
-#include <cpExtensions/Visualization/ImageOutlineActor.h>
+#include <cpExtensions/Visualization/MeshActor.h>
+#include <cpExtensions/Visualization/OutlineSource.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
+#include <vtkCamera.h>
+#include <vtkImageData.h>
+#include <vtkProperty.h>
#include <vtkRenderer.h>
/* TODO
#include <cpExtensions/Visualization/ImageViewerActors.h>
#include <cpExtensions/Visualization/LUTImageActor.h>
- #include <vtkCamera.h>
#include <vtkImageData.h>
#include <vtkImageProperty.h>
*/
cpExtensions::QT::ImageWidget::
ImageWidget( QWidget* parent, Qt::WindowFlags f )
: Superclass( parent, f ),
- m_ImageName( "" )
+ m_ImageName( "" ),
+ m_OutlineActor( NULL )
{
this->m_Style = vtkSmartPointer< TStyle >::New( );
this->m_Style->SetCurrentRenderer( this->m_Renderer );
cpExtensions::QT::ImageWidget::
~ImageWidget( )
{
+ if( this->m_OutlineActor != NULL )
+ delete this->m_OutlineActor;
}
// -------------------------------------------------------------------------
this->m_WLActor->SetImage( image );
this->m_WLActor->SetOrientation( orientation );
- this->m_OLActor = vtkSmartPointer< TOLActor >::New( );
- this->m_OLActor->SetBounds(
- orientation,
- this->m_WLActor->GetBounds( )[ orientation ],
- this->m_WLActor->GetBounds( )
- );
+ this->m_Outline = vtkSmartPointer< TOutline >::New( );
+ this->m_Outline->SetBounds( image->GetBounds( ) );
+ this->m_Outline->Update( );
+
+ if( this->m_OutlineActor != NULL )
+ delete this->m_OutlineActor;
+ this->m_OutlineActor = new TActor( );
+ this->m_OutlineActor->SetMesh( this->m_Outline->GetOutput( ) );
+
+ double cr = double( 0 );
+ double cg = double( 0 );
+ double cb = double( 0 );
+ switch( this->m_WLActor->GetOrientation( ) )
+ {
+ case 0: cr = double( 1 ); break;
+ case 1: cg = double( 1 ); break;
+ case 2: cb = double( 1 ); break;
+ default: cr = double( 1 ); break;
+ } // hctiws
+ this->m_OutlineActor->GetActor( )->GetProperty( )->SetColor( cr, cg, cb );
this->AddViewProp( this->m_WLActor, this->m_ImageName );
- this->AddAuxViewProp( this->m_OLActor, this->m_ImageName );
+ this->AddAuxViewProp( this->m_OutlineActor->GetActor( ), this->m_ImageName );
this->ResetCamera( );
}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::ImageWidget::
+ResetCamera( )
+{
+ if( this->m_WLActor.GetPointer( ) != NULL )
+ {
+ auto image = this->m_WLActor->GetImage( );
+ if( image != NULL )
+ {
+ double bounds[ 6 ];
+ image->GetBounds( bounds );
+
+ // Compute camera properties
+ double center[ 3 ];
+ center[ 0 ] = ( bounds[ 1 ] + bounds[ 0 ] ) / double( 2 );
+ center[ 1 ] = ( bounds[ 3 ] + bounds[ 2 ] ) / double( 2 );
+ center[ 2 ] = ( bounds[ 5 ] + bounds[ 4 ] ) / double( 2 );
+
+ int ori = this->m_WLActor->GetOrientation( );
+ double pos[ 3 ] = { double( 0 ) };
+ pos[ ori ] = double( 1 );
+ pos[ 0 ] += center[ 0 ];
+ pos[ 1 ] += center[ 1 ];
+ pos[ 2 ] += center[ 2 ];
+
+ double up[ 3 ] = { double( 0 ) };
+ if( ori == 0 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
+ }
+ else if( ori == 1 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
+ }
+ else if( ori == 2 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 1 ] = double( 1 );
+ pos[ 2 ] *= double( -1 );
+
+ } // fi
+
+ // Reconfigure camera and return
+ auto camera = this->m_Renderer->GetActiveCamera( );
+ camera->ParallelProjectionOn( );
+ camera->SetFocalPoint( center );
+ camera->SetPosition( pos );
+ camera->SetViewUp( up );
+ this->m_Renderer->ResetCamera( bounds );
+ }
+ else
+ this->Superclass::ResetCamera( );
+ }
+ else
+ this->Superclass::ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::ImageWidget::
+TWLActor* cpExtensions::QT::ImageWidget::
+GetImageActor( )
+{
+ return( this->m_WLActor );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::QT::ImageWidget::
+TWLActor* cpExtensions::QT::ImageWidget::
+GetImageActor( ) const
+{
+ return( this->m_WLActor );
+}
+
/* TODO
// -------------------------------------------------------------------------
this->Render( );
}
-// -------------------------------------------------------------------------
-void cpExtensions::QT::ImageWidget::
-ResetCamera( )
-{
- if( this->m_ImageViewerActors.GetPointer( ) != NULL )
- {
- auto image = this->m_ImageViewerActors->GetImage( );
- if( image != NULL )
- {
- double bounds[ 6 ];
- image->GetBounds( bounds );
-
- // Compute camera properties
- double center[ 3 ];
- center[ 0 ] = ( bounds[ 1 ] + bounds[ 0 ] ) / double( 2 );
- center[ 1 ] = ( bounds[ 3 ] + bounds[ 2 ] ) / double( 2 );
- center[ 2 ] = ( bounds[ 5 ] + bounds[ 4 ] ) / double( 2 );
-
- int ori = this->m_ImageViewerActors->GetOrientation( );
- double pos[ 3 ] = { double( 0 ) };
- pos[ ori ] = double( 1 );
- pos[ 0 ] += center[ 0 ];
- pos[ 1 ] += center[ 1 ];
- pos[ 2 ] += center[ 2 ];
-
- double up[ 3 ] = { double( 0 ) };
- if( ori == 0 )
- {
- if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
- }
- else if( ori == 1 )
- {
- if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
- }
- else if( ori == 2 )
- {
- if ( this->m_Quadrant == 0 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 1 ] = double( 1 );
- pos[ 2 ] *= double( -1 );
-
- } // fi
-
- // Reconfigure camera and return
- auto camera = this->m_Renderer->GetActiveCamera( );
- camera->SetFocalPoint( center );
- camera->SetPosition( pos );
- camera->SetViewUp( up );
- this->m_Renderer->ResetCamera( bounds );
- }
- else
- this->Superclass::ResetCamera( );
- }
- else
- this->Superclass::ResetCamera( );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::QT::ImageWidget::
GetScalarRange( double r[ 2 ] ) const