this->m_UI->setupUi( this );
// Configure VTK widgets
- this->m_VTK[ 0 ] = this->m_UI->VTK01;
- this->m_VTK[ 1 ] = this->m_UI->VTK00;
- this->m_VTK[ 2 ] = this->m_UI->VTK10;
- this->m_VTK[ 3 ] = this->m_UI->VTK11;
+ this->m_VTK[ 0 ] = this->m_UI->VTK_X;
+ this->m_VTK[ 1 ] = this->m_UI->VTK_Y;
+ this->m_VTK[ 2 ] = this->m_UI->VTK_Z;
+ this->m_VTK[ 3 ] = this->m_UI->VTK_3D;
for( unsigned int i = 0; i < 4; ++i )
{
void cpExtensions::QT::SimpleMPRWidget::
SetMainImage( vtkImageData* image )
{
+ this->Clear( );
for( unsigned int i = 0; i < 3; ++i )
{
- this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
this->m_2DSlices[ i ]->SetInputData( image, i );
this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
- this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
this->m_3DSlices[ i ]->SetInputData( image, i );
this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
this->m_3DSlices[ i ]->SetStyle(
);
} // rof
+ this->_AssociateSlices( );
+}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetMainActor( vtkImageActor* actor )
+{
+ this->Clear( );
+ vtkImageData* image = NULL;
for( unsigned int i = 0; i < 3; ++i )
{
- for( unsigned int j = 0; j < 3; ++j )
+ this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+ if( i == 0 )
{
- if( i != j )
- this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
- this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
-
- } // rof
+ this->m_2DSlices[ i ]->SetInputActor( actor, i );
+ image = this->m_2DSlices[ i ]->GetInputData( );
+ }
+ else
+ this->m_2DSlices[ i ]->SetInputData( image, i );
+ this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
+ this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
+ SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
- } // rof
- for( unsigned int i = 0; i < 3; ++i )
- {
- this->m_2DSlices[ i ]->GetStyle( )->
- SetCurrentRenderer( this->m_Renderers[ i ] );
- this->m_Renderers[ i ]->ResetCamera( );
- this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+ this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+ this->m_3DSlices[ i ]->SetInputData( image, i );
+ this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
+ this->m_3DSlices[ i ]->SetStyle(
+ dynamic_cast< vtkInteractorStyle* >(
+ this->m_Renderers[ 3 ]->GetRenderWindow( )->
+ GetInteractor( )->GetInteractorStyle( )
+ )
+ );
} // rof
- this->m_Renderers[ 3 ]->ResetCamera( );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ this->_AssociateSlices( );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-AddMesh( vtkPolyData* mesh )
+AddImage( vtkImageData* image )
{
- PolyDataActor a;
- a.Configure( mesh );
- this->m_PolyDatas[ mesh ] = a;
- this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+ std::cerr << "SimpleMPR: adding image" << std::endl;
+ std::exit( 1 );
+}
- bool has_main_image = false;
- for( unsigned int i = 0; i < 3; ++i )
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddImageActor( vtkImageActor* actor )
+{
+ unsigned int i = 0;
+ bool cont = true;
+ while( i < 3 && cont )
{
if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
{
- if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+ if( this->m_2DSlices[ i ]->GetImageActor( ) != NULL )
{
- has_main_image = true;
- this->m_2DSlices[ i ]->AddMesh( mesh );
- this->m_2DSlices[ i ]->Render( );
-
- } // fi
+ // TODO: add image actor
+ }
+ else
+ cont = false;
} // fi
+ i++;
} // rof
- if( !has_main_image )
- this->m_Renderers[ 3 ]->ResetCamera( );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+
+ // Add if no actors were found
+ if( cont )
+ this->SetMainActor( actor );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMesh( vtkPolyData* mesh )
+{
+ std::cerr << "SimpleMPR: adding mesh" << std::endl;
+ std::exit( 1 );
+ /* TODO
+ PolyDataActor a;
+ a.Configure( mesh );
+ this->m_PolyDatas[ mesh ] = a;
+ this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+
+ bool has_main_image = false;
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
+ {
+ if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+ {
+ has_main_image = true;
+ this->m_2DSlices[ i ]->AddMesh( mesh );
+ this->m_2DSlices[ i ]->Render( );
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ if( !has_main_image )
+ this->m_Renderers[ 3 ]->ResetCamera( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+ */
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMeshActor( vtkActor* actor )
+{
+ std::cerr << "SimpleMPR: adding mesh actor" << std::endl;
+ std::exit( 1 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddActor( vtkProp* actor )
+{
+ auto ia = dynamic_cast< vtkImageActor* >( actor );
+ if( ia == NULL )
+ {
+ auto ma = dynamic_cast< vtkActor* >( actor );
+ if( ma != NULL )
+ this->AddMeshActor( ma );
+ }
+ else
+ this->AddImageActor( ia );
}
// -------------------------------------------------------------------------
}
// -------------------------------------------------------------------------
-std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
-cpExtensions::QT::SimpleMPRWidget::
-GetMainImageActors( )
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetRenderWindow( unsigned int i )
{
- std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
- for( unsigned int i = 0; i < 3; ++i )
+ if( i < 4 )
{
- actors.push_back(
- std::pair< vtkImageActor*, vtkRenderer* >(
- this->m_2DSlices[ i ]->GetImageActor( ),
- this->m_Renderers[ i ]
- )
- );
- actors.push_back(
- std::pair< vtkImageActor*, vtkRenderer* >(
- this->m_3DSlices[ i ]->GetImageActor( ),
- this->m_Renderers[ 3 ]
- )
- );
-
- } // rof
- return( actors );
+ if( this->m_Renderers[ i ].GetPointer( ) != NULL )
+ return( this->m_Renderers[ i ]->GetRenderWindow( ) );
+ else
+ return( NULL );
+ }
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
-vtkActor* cpExtensions::QT::SimpleMPRWidget::
-GetActor( vtkPolyData* mesh )
+/* TODO
+ std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+ cpExtensions::QT::SimpleMPRWidget::
+ GetMainImageActors( )
+ {
+ std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ actors.push_back(
+ std::pair< vtkImageActor*, vtkRenderer* >(
+ this->m_2DSlices[ i ]->GetImageActor( ),
+ this->m_Renderers[ i ]
+ )
+ );
+ actors.push_back(
+ std::pair< vtkImageActor*, vtkRenderer* >(
+ this->m_3DSlices[ i ]->GetImageActor( ),
+ this->m_Renderers[ 3 ]
+ )
+ );
+
+ } // rof
+ return( actors );
+ }
+*/
+
+// -------------------------------------------------------------------------
+/* TODO
+ vtkActor* cpExtensions::QT::SimpleMPRWidget::
+ GetActor( vtkPolyData* mesh )
+ {
+ auto i = this->m_PolyDatas.find( mesh );
+ if( i != this->m_PolyDatas.end( ) )
+ return( i->second.Actor.GetPointer( ) );
+ else
+ return( NULL );
+ }
+*/
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+_AssociateSlices( )
{
- auto i = this->m_PolyDatas.find( mesh );
- if( i != this->m_PolyDatas.end( ) )
- return( i->second.Actor.GetPointer( ) );
- else
- return( NULL );
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ for( unsigned int j = 0; j < 3; ++j )
+ {
+ if( i != j )
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
+
+ } // rof
+
+ } // rof
+ for( unsigned int i = 0; i < 3; ++i )
+ {
+ this->m_2DSlices[ i ]->GetStyle( )->
+ SetCurrentRenderer( this->m_Renderers[ i ] );
+ this->m_Renderers[ i ]->ResetCamera( );
+ this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+
+ } // rof
+ this->m_Renderers[ 3 ]->ResetCamera( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
}
// -------------------------------------------------------------------------