From 28f9b7dc84eb4b09e985ad7e43a9f0001a6be928 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 25 May 2016 20:51:42 -0500 Subject: [PATCH] MVC integration at 50% --- appli/PipelineEditor/PipelineEditor.cxx | 112 +++----- lib/cpExtensions/QT/PropertyWidget.cxx | 176 ------------ lib/cpExtensions/QT/PropertyWidget.h | 63 ----- lib/cpExtensions/QT/PropertyWidget.ui | 160 ----------- lib/cpExtensions/QT/SimpleMPRWidget.cxx | 250 +++++++++++++----- lib/cpExtensions/QT/SimpleMPRWidget.h | 25 +- lib/cpExtensions/QT/SimpleMPRWidget.ui | 10 +- .../Visualization/ImageSliceActors.cxx | 15 ++ .../Visualization/ImageSliceActors.h | 1 + lib/cpPipelineEditor/BaseQtMainWindow.cxx | 2 +- lib/cpPlugins/DataObject.cxx | 62 +---- lib/cpPlugins/DataObject.h | 24 +- .../DataObjectVisualizationQtDialog.cxx | 16 ++ lib/cpPlugins/Image.cxx | 15 ++ lib/cpPlugins/Image.h | 2 + lib/cpPlugins/Workspace.cxx | 22 ++ lib/cpPlugins/Workspace.h | 6 + 17 files changed, 334 insertions(+), 627 deletions(-) delete mode 100644 lib/cpExtensions/QT/PropertyWidget.cxx delete mode 100644 lib/cpExtensions/QT/PropertyWidget.h delete mode 100644 lib/cpExtensions/QT/PropertyWidget.ui diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index a4cd75e..f646520 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -3,8 +3,8 @@ #include +#include #include -#include #include #include @@ -84,55 +84,22 @@ _ShowFilterOutput( this->_ExecFilter( filter_name ); // Get output - auto filter = this->m_Workspace.GetFilter( filter_name ); - if( filter != NULL ) + auto output = this->m_Workspace.GetOutput( filter_name, output_name ); + if( output == NULL ) { - auto out = filter->GetOutput( output_name ); - if( out != NULL ) - { - auto id = out->GetVTK< vtkImageData >( ); - auto md = out->GetVTK< vtkPolyData >( ); - if( id != NULL ) - { - this->_Block( ); - this->m_UI->Viewer->Clear( ); - this->m_UI->Viewer->SetMainImage( id ); - auto actors = this->m_UI->Viewer->GetMainImageActors( ); - out->ClearVTKActors( ); - for( auto aIt = actors.begin( ); aIt != actors.end( ); ++aIt ) - out->AddVTKActor( aIt->first, aIt->second ); - this->_UnBlock( ); - } - else if( md != NULL ) - { - this->_Block( ); - this->m_UI->Viewer->AddMesh( md ); - out->AddVTKActor( - this->m_UI->Viewer->GetActor( md ), - this->m_UI->Viewer->GetRenderer( 3 ) - ); - this->_UnBlock( ); - } - else - QMessageBox::critical( - this, - QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( "No known VTK conversion!" ) - ); - } - else - QMessageBox::critical( - this, - QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( "Unknown port name." ) - ); - } - else QMessageBox::critical( this, QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( "Unknown filter." ) + QMessageBox::tr( "Unknown port name." ) ); + return; + + } // fi + + // Create and associate actor + this->_Block( ); + this->m_UI->Viewer->AddActor( output->CreateVTKActor( ) ); + this->_UnBlock( ); } // ------------------------------------------------------------------------- @@ -164,34 +131,35 @@ _PropertiesFilterOutput( const std::string& filter_name, const std::string& output_name ) { - // Get output - auto filter = this->m_Workspace.GetFilter( filter_name ); - if( filter != NULL ) - { - auto output = filter->GetOutputData< vtkPolyData >( output_name ); - if( output != NULL ) - { - auto actor = this->m_UI->Viewer->GetActor( output ); - if( actor != NULL ) - { - cpExtensions::QT::PropertyWidget* wdg = - new cpExtensions::QT::PropertyWidget( NULL ); - wdg->SetProp( actor ); - wdg->SetRenderWindow( - this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( ) - ); - wdg->show( ); - - } // fi - } - else - QMessageBox::critical( - this, - QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( "No known VTK conversion!" ) - ); + /* TODO + auto filter = this->m_Workspace.GetFilter( filter_name ); + if( filter != NULL ) + { + auto output = filter->GetOutputData< vtkPolyData >( output_name ); + if( output != NULL ) + { + auto actor = this->m_UI->Viewer->GetActor( output ); + if( actor != NULL ) + { + cpExtensions::QT::PropertyWidget* wdg = + new cpExtensions::QT::PropertyWidget( NULL ); + wdg->SetProp( actor ); + wdg->SetRenderWindow( + this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( ) + ); + wdg->show( ); - } // fi + } // fi + } + else + QMessageBox::critical( + this, + QMessageBox::tr( "Error showing data" ), + QMessageBox::tr( "No known VTK conversion!" ) + ); + + } // fi + */ } // eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/PropertyWidget.cxx b/lib/cpExtensions/QT/PropertyWidget.cxx deleted file mode 100644 index 3b719ff..0000000 --- a/lib/cpExtensions/QT/PropertyWidget.cxx +++ /dev/null @@ -1,176 +0,0 @@ -#include - -#ifdef cpExtensions_QT4 - -#include -#include -#include -#include -#include -#include - -#include - -// ------------------------------------------------------------------------- -cpExtensions::QT::PropertyWidget:: -PropertyWidget( QWidget* parent ) - : QWidget( parent ), - m_UI( new Ui::PropertyWidget ), - m_Prop( NULL ), - m_Window( NULL ) -{ - this->m_UI->setupUi( this ); - this->connect( - this->m_UI->m_Color, SIGNAL( clicked( ) ), - this, SLOT( _Color( ) ) - ); - this->connect( - this->m_UI->m_Opacity, SIGNAL( valueChanged( int ) ), - this, SLOT( _Opacity( int ) ) - ); - this->connect( - this->m_UI->m_LineWidth, SIGNAL( valueChanged( double ) ), - this, SLOT( _LineWidth( double ) ) - ); - this->connect( - this->m_UI->m_PointSize, SIGNAL( valueChanged( double ) ), - this, SLOT( _PointSize( double ) ) - ); -} - -// ------------------------------------------------------------------------- -cpExtensions::QT::PropertyWidget:: -~PropertyWidget( ) -{ - delete this->m_UI; -} - -// ------------------------------------------------------------------------- -vtkProp* cpExtensions::QT::PropertyWidget:: -GetProp( ) -{ - return( this->m_Prop ); -} - -// ------------------------------------------------------------------------- -vtkRenderWindow* cpExtensions::QT::PropertyWidget:: -GetRenderWindow( ) -{ - return( this->m_Window ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -SetProp( vtkProp* p ) -{ - this->m_Prop = p; - if( this->m_Prop == NULL ) - return; - - auto actor = dynamic_cast< vtkActor* >( this->m_Prop ); - if( actor == NULL ) - return; - - double opacity = actor->GetProperty( )->GetOpacity( ); - double lw = actor->GetProperty( )->GetLineWidth( ); - double ps = actor->GetProperty( )->GetPointSize( ); - opacity *= this->m_UI->m_Opacity->maximum( ); - - this->m_UI->m_Opacity->setValue( opacity ); - this->m_UI->m_LineWidth->setValue( lw ); - this->m_UI->m_PointSize->setValue( ps ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -SetRenderWindow( vtkRenderWindow* w ) -{ - this->m_Window = w; -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -_Color( ) -{ - if( this->m_Prop == NULL ) - return; - - auto actor = dynamic_cast< vtkActor* >( this->m_Prop ); - if( actor == NULL ) - return; - - double rgb[ 3 ]; - actor->GetProperty( )->GetColor( rgb ); - QColor color = - QColorDialog::getColor( - QColor( rgb[ 0 ] * 255, rgb[ 1 ] * 255, rgb[ 2 ] * 255 ), - this, - "Select Color", - QColorDialog::DontUseNativeDialog - ); - if( color.isValid( ) ) - { - rgb[ 0 ] = double( color.red( ) ) / double( 255 ); - rgb[ 1 ] = double( color.green( ) ) / double( 255 ); - rgb[ 2 ] = double( color.blue( ) ) / double( 255 ); - actor->GetMapper( )->ScalarVisibilityOff( ); - actor->GetProperty( )->SetColor( rgb ); - actor->Modified( ); - if( this->m_Window != NULL ) - this->m_Window->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -_Opacity( int o ) -{ - if( this->m_Prop == NULL ) - return; - - auto actor = dynamic_cast< vtkActor* >( this->m_Prop ); - if( actor == NULL ) - return; - double v = double( o ) / double( this->m_UI->m_Opacity->maximum( ) ); - actor->GetProperty( )->SetOpacity( v ); - actor->Modified( ); - if( this->m_Window != NULL ) - this->m_Window->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -_LineWidth( double lw ) -{ - if( this->m_Prop == NULL ) - return; - - auto actor = dynamic_cast< vtkActor* >( this->m_Prop ); - if( actor == NULL ) - return; - actor->GetProperty( )->SetLineWidth( lw ); - actor->Modified( ); - if( this->m_Window != NULL ) - this->m_Window->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::PropertyWidget:: -_PointSize( double ps ) -{ - if( this->m_Prop == NULL ) - return; - - auto actor = dynamic_cast< vtkActor* >( this->m_Prop ); - if( actor == NULL ) - return; - actor->GetProperty( )->SetPointSize( ps ); - actor->Modified( ); - if( this->m_Window != NULL ) - this->m_Window->Render( ); -} - -#endif // cpExtensions_QT4 - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/PropertyWidget.h b/lib/cpExtensions/QT/PropertyWidget.h deleted file mode 100644 index 598ad08..0000000 --- a/lib/cpExtensions/QT/PropertyWidget.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __CPEXTENSIONS__QT__PROPERTYWIDGET__H__ -#define __CPEXTENSIONS__QT__PROPERTYWIDGET__H__ - -#include - -#ifdef cpExtensions_QT4 - -#include - -// ------------------------------------------------------------------------- -class vtkProp; -class vtkRenderWindow; - -namespace Ui -{ - class PropertyWidget; -} - -// ------------------------------------------------------------------------- -namespace cpExtensions -{ - namespace QT - { - /** - */ - class cpExtensions_EXPORT PropertyWidget - : public QWidget - { - Q_OBJECT; - - public: - typedef PropertyWidget Self; - - public: - explicit PropertyWidget( QWidget* parent = 0 ); - virtual ~PropertyWidget( ); - - vtkProp* GetProp( ); - vtkRenderWindow* GetRenderWindow( ); - void SetProp( vtkProp* p ); - void SetRenderWindow( vtkRenderWindow* w ); - - protected slots: - void _Color( ); - void _Opacity( int o ); - void _LineWidth( double lw ); - void _PointSize( double ps ); - - protected: - Ui::PropertyWidget* m_UI; - vtkProp* m_Prop; - vtkRenderWindow* m_Window; - }; - - } // ecapseman - -} // ecapseman - -#endif // cpExtensions_QT4 - -#endif // __CPEXTENSIONS__QT__PROPERTYWIDGET__H__ - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/PropertyWidget.ui b/lib/cpExtensions/QT/PropertyWidget.ui deleted file mode 100644 index 3784ecd..0000000 --- a/lib/cpExtensions/QT/PropertyWidget.ui +++ /dev/null @@ -1,160 +0,0 @@ - - - PropertyWidget - - - - 0 - 0 - 595 - 125 - - - - - 595 - 125 - - - - - 595 - 125 - - - - Form - - - - - - - - Color - - - - - - - - - - - - 54 - 21 - - - - - 54 - 21 - - - - Opacity: - - - - - - - 100 - - - 100 - - - Qt::Horizontal - - - - - - - - - - - - - - 71 - 21 - - - - - 71 - 21 - - - - Line width: - - - - - - - 100.000000000000000 - - - 1.000000000000000 - - - 1.000000000000000 - - - - - - - - - - - - 67 - 21 - - - - - 67 - 21 - - - - Point size: - - - - - - - 100.000000000000000 - - - 1.000000000000000 - - - 1.000000000000000 - - - - - - - - - - - - - - - - diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index ab47c28..f838a2e 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -14,10 +14,10 @@ SimpleMPRWidget( QWidget* parent ) 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 ) { @@ -66,15 +66,16 @@ Clear( ) 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( @@ -85,58 +86,133 @@ SetMainImage( vtkImageData* image ) ); } // 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 ); } // ------------------------------------------------------------------------- @@ -160,39 +236,85 @@ GetRenderer( unsigned int i ) } // ------------------------------------------------------------------------- -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( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.h b/lib/cpExtensions/QT/SimpleMPRWidget.h index d5f3353..8028460 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.h +++ b/lib/cpExtensions/QT/SimpleMPRWidget.h @@ -39,7 +39,7 @@ namespace cpExtensions public: typedef SimpleMPRWidget Self; - typedef cpExtensions::Visualization::ImageSliceActors TActors; + typedef cpExtensions::Visualization::ImageSliceActors TSliceActors; /** */ @@ -96,14 +96,25 @@ namespace cpExtensions // Data management void Clear( ); void SetMainImage( vtkImageData* image ); + void SetMainActor( vtkImageActor* actor ); + void AddImage( vtkImageData* image ); + void AddImageActor( vtkImageActor* actor ); void AddMesh( vtkPolyData* mesh ); + void AddMeshActor( vtkActor* actor ); + void AddActor( vtkProp* actor ); // Visual objects vtkRenderWindowInteractor* GetInteractor( unsigned int i ); vtkRenderer* GetRenderer( unsigned int i ); - std::vector< std::pair< vtkImageActor*, vtkRenderer* > > - GetMainImageActors( ); - vtkActor* GetActor( vtkPolyData* mesh ); + vtkRenderWindow* GetRenderWindow( unsigned int i ); + /* TODO + std::vector< std::pair< vtkImageActor*, vtkRenderer* > > + GetMainImageActors( ); + vtkActor* GetActor( vtkPolyData* mesh ); + */ + + protected: + void _AssociateSlices( ); private slots: void _SyncBottom( int a, int b ); @@ -113,9 +124,9 @@ namespace cpExtensions Ui::SimpleMPRWidget* m_UI; QVTKWidget* m_VTK[ 4 ]; - vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ]; - vtkSmartPointer< TActors > m_2DSlices[ 3 ]; - vtkSmartPointer< TActors > m_3DSlices[ 3 ]; + vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ]; + vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ]; + vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ]; std::map< vtkPolyData*, PolyDataActor > m_PolyDatas; }; diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.ui b/lib/cpExtensions/QT/SimpleMPRWidget.ui index c8246e1..fc1dfa3 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.ui +++ b/lib/cpExtensions/QT/SimpleMPRWidget.ui @@ -35,7 +35,7 @@ Qt::Horizontal - + 200 @@ -43,7 +43,7 @@ - + 200 @@ -62,7 +62,7 @@ Qt::Horizontal - + 200 @@ -70,7 +70,7 @@ - + 200 @@ -87,7 +87,7 @@ QVTKWidget QWidget -
QVTKWidget.h
+
QVTKWidget.h
1
diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 2254ac9..3ac1e5d 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -82,6 +82,21 @@ SetInputData( vtkImageData* data, int orientation ) this->_ConfigureInput( orientation ); } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +SetInputActor( vtkProp* actor, int orientation ) +{ + auto real_actor = dynamic_cast< vtkImageActor* >( actor ); + if( real_actor == NULL ) + return; + auto real_mapper = + dynamic_cast< vtkImageSliceMapper* >( real_actor->GetMapper( ) ); + if( real_mapper == NULL ) + return; + this->m_Mapper = real_mapper; + this->_ConfigureInput( orientation ); +} + // ------------------------------------------------------------------------- vtkImageData* cpExtensions::Visualization::ImageSliceActors:: GetInputData( ) diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index 075c6ec..6aca9db 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -83,6 +83,7 @@ namespace cpExtensions void Clear( ); void SetInputConnection( vtkAlgorithmOutput* aout, int orientation ); void SetInputData( vtkImageData* data, int orientation ); + void SetInputActor( vtkProp* actor, int orientation ); vtkImageData* GetInputData( ); vtkImageActor* GetImageActor( ); diff --git a/lib/cpPipelineEditor/BaseQtMainWindow.cxx b/lib/cpPipelineEditor/BaseQtMainWindow.cxx index 8a9536b..b423294 100644 --- a/lib/cpPipelineEditor/BaseQtMainWindow.cxx +++ b/lib/cpPipelineEditor/BaseQtMainWindow.cxx @@ -14,7 +14,7 @@ bool cpPipelineEditor::BaseQtMainWindow::_TBlocker:: eventFilter( QObject* obj, QEvent* event ) { return( true ); // -> Block all events - /* NOTE: correct implementation: + /* NOTE: this should be the correct implementation: switch( event->type( ) ) { //list event you want to prevent here ... diff --git a/lib/cpPlugins/DataObject.cxx b/lib/cpPlugins/DataObject.cxx index ebfb8b2..9fd054d 100644 --- a/lib/cpPlugins/DataObject.cxx +++ b/lib/cpPlugins/DataObject.cxx @@ -85,66 +85,10 @@ CreateQtDialog( ) } // ------------------------------------------------------------------------- -void cpPlugins::DataObject:: -AddVTKActor( vtkProp* actor, vtkRenderer* renderer ) +vtkProp* cpPlugins::DataObject:: +CreateVTKActor( ) { - if( actor != NULL && renderer != NULL ) - { - TDataView v; - v.Actor = actor; - v.Renderer = renderer; - this->m_Actors.insert( v ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpPlugins::DataObject:: -ClearVTKActors( ) -{ - this->m_Actors.clear( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::DataObject:: -RenderVTKActors( ) -{ - for( auto i = this->m_Actors.begin( ); i != this->m_Actors.end( ); ++i ) - i->Renderer->GetRenderWindow( )->Render( ); -} - -// ------------------------------------------------------------------------- -cpPlugins::DataObject::TDataViews:: -iterator cpPlugins::DataObject:: -BeginVTKActors( ) -{ - return( this->m_Actors.begin( ) ); -} - -// ------------------------------------------------------------------------- -cpPlugins::DataObject::TDataViews:: -iterator cpPlugins::DataObject:: -EndVTKActors( ) -{ - return( this->m_Actors.end( ) ); -} - -// ------------------------------------------------------------------------- -cpPlugins::DataObject::TDataViews:: -const_iterator cpPlugins::DataObject:: -BeginVTKActors( ) const -{ - return( this->m_Actors.begin( ) ); -} - -// ------------------------------------------------------------------------- -cpPlugins::DataObject::TDataViews:: -const_iterator cpPlugins::DataObject:: -EndVTKActors( ) const -{ - return( this->m_Actors.end( ) ); + return( NULL ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObject.h b/lib/cpPlugins/DataObject.h index 9ff55d8..0abc4a4 100644 --- a/lib/cpPlugins/DataObject.h +++ b/lib/cpPlugins/DataObject.h @@ -2,9 +2,9 @@ #define __CPPLUGINS__DATAOBJECT__H__ #include -#include -#include -#include + +// Some forward declarations +class vtkProp; namespace cpPlugins { @@ -28,15 +28,6 @@ namespace cpPlugins itkTypeMacro( DataObject, Object ); cpPlugins_Id_Macro( DataObject, Object ); - struct TDataView - { - vtkSmartPointer< vtkProp > Actor; - vtkSmartPointer< vtkRenderer > Renderer; - bool operator<( const TDataView& b ) const - { return( this->Actor.GetPointer( ) < b.Actor.GetPointer( ) ); } - }; - typedef std::set< TDataView > TDataViews; - public: ProcessObject* GetSource( ); const ProcessObject* GetSource( ) const; @@ -48,13 +39,7 @@ namespace cpPlugins virtual DataObjectVisualizationQtDialog* CreateQtDialog( ); // VTK actors - virtual void AddVTKActor( vtkProp* actor, vtkRenderer* renderer ); - virtual void ClearVTKActors( ); - virtual void RenderVTKActors( ); - TDataViews::iterator BeginVTKActors( ); - TDataViews::iterator EndVTKActors( ); - TDataViews::const_iterator BeginVTKActors( ) const; - TDataViews::const_iterator EndVTKActors( ) const; + virtual vtkProp* CreateVTKActor( ); protected: DataObject( ); @@ -67,7 +52,6 @@ namespace cpPlugins protected: ProcessObject* m_Source; - TDataViews m_Actors; }; } // ecapseman diff --git a/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx b/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx index cd6ca76..7494eed 100644 --- a/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx +++ b/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx @@ -116,6 +116,7 @@ _updateWidgets( ) void cpPlugins::DataObjectVisualizationQtDialog:: _configureForImage( ) { + /* TODO auto image = this->m_DataObject->GetVTK< vtkImageData >( ); auto aIt = this->m_DataObject->BeginVTKActors( ); if( image == NULL || aIt == this->m_DataObject->EndVTKActors( ) ) @@ -204,12 +205,14 @@ _configureForImage( ) op_layout->addWidget( op_label ); op_layout->addWidget( op_sld ); this->m_ToolsLayout->addLayout( op_layout ); +*/ } // ------------------------------------------------------------------------- void cpPlugins::DataObjectVisualizationQtDialog:: _configureForMesh( ) { + /* TODO auto mesh = this->m_DataObject->GetVTK< vtkPolyData >( ); auto aIt = this->m_DataObject->BeginVTKActors( ); if( mesh == NULL || aIt == this->m_DataObject->EndVTKActors( ) ) @@ -305,12 +308,14 @@ _configureForMesh( ) op_layout->addWidget( op_label ); op_layout->addWidget( op_sld ); this->m_ToolsLayout->addLayout( op_layout ); +*/ } // ------------------------------------------------------------------------- void cpPlugins::DataObjectVisualizationQtDialog:: _setWindow( double w ) { + /* TODO if( this->m_DataObject == NULL ) return; auto aIt = this->m_DataObject->BeginVTKActors( ); @@ -326,12 +331,14 @@ _setWindow( double w ) } // rof this->_render( ); +*/ } // ------------------------------------------------------------------------- void cpPlugins::DataObjectVisualizationQtDialog:: _setLevel( double l ) { + /* TODO if( this->m_DataObject == NULL ) return; auto aIt = this->m_DataObject->BeginVTKActors( ); @@ -347,15 +354,18 @@ _setLevel( double l ) } // rof this->_render( ); +*/ } // ------------------------------------------------------------------------- void cpPlugins::DataObjectVisualizationQtDialog:: _render( ) { + /* TODO if( this->m_DataObject == NULL ) return; this->m_DataObject->RenderVTKActors( ); +*/ } // ------------------------------------------------------------------------- @@ -450,6 +460,7 @@ _sldLevel( int v ) void cpPlugins::DataObjectVisualizationQtDialog:: _sldOpacity( int v ) { + /* TODO if( this->m_DataObject == NULL ) return; auto* sld = this->findChild< QSlider* >( "op_sld" ); @@ -479,6 +490,7 @@ _sldOpacity( int v ) } // rof this->_render( ); +*/ } // ------------------------------------------------------------------------- @@ -497,6 +509,7 @@ _boxLineWidth( int v ) void cpPlugins::DataObjectVisualizationQtDialog:: _scalarVisibility( int v ) { + /* TODO if( this->m_DataObject == NULL ) return; auto* btn = this->findChild< QPushButton* >( "color_button" ); @@ -529,12 +542,14 @@ _scalarVisibility( int v ) } // rof this->_render( ); +*/ } // ------------------------------------------------------------------------- void cpPlugins::DataObjectVisualizationQtDialog:: _color( ) { + /* TODO if( this->m_DataObject == NULL ) return; auto* btn = this->findChild< QPushButton* >( "color_button" ); @@ -559,6 +574,7 @@ _color( ) this->_scalarVisibility( 0 ); } // fi +*/ } #endif // cpPlugins_QT4 diff --git a/lib/cpPlugins/Image.cxx b/lib/cpPlugins/Image.cxx index ba3ff29..04d28da 100644 --- a/lib/cpPlugins/Image.cxx +++ b/lib/cpPlugins/Image.cxx @@ -1,5 +1,8 @@ #include +#include +#include + // ------------------------------------------------------------------------- void cpPlugins::Image:: SetITK( itk::LightObject* o ) @@ -25,6 +28,18 @@ SetVTK( vtkObjectBase* o ) std::exit( 1 ); } +// ------------------------------------------------------------------------- +vtkProp* cpPlugins::Image:: +CreateVTKActor( ) +{ + vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( ); + vtkImageActor* actor = vtkImageActor::New( ); + mapper->SetInputData( this->GetVTK< vtkImageData >( ) ); + actor->SetMapper( mapper ); + mapper->Delete( ); + return( actor ); +} + // ------------------------------------------------------------------------- cpPlugins::Image:: Image( ) diff --git a/lib/cpPlugins/Image.h b/lib/cpPlugins/Image.h index 4831ecf..62b9ff1 100644 --- a/lib/cpPlugins/Image.h +++ b/lib/cpPlugins/Image.h @@ -27,6 +27,8 @@ namespace cpPlugins virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE; virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE; + virtual vtkProp* CreateVTKActor( ) ITK_OVERRIDE; + protected: Image( ); virtual ~Image( ); diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index d441c49..4c1fe1d 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -94,6 +94,28 @@ GetFilter( const std::string& name ) const return( f ); } +// ------------------------------------------------------------------------- +cpPlugins::DataObject* cpPlugins::Workspace:: +GetOutput( const std::string& filter, const std::string& output ) +{ + auto f = this->GetFilter( filter ); + if( f != NULL ) + return( f->GetOutput( output ) ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::DataObject* cpPlugins::Workspace:: +GetOutput( const std::string& filter, const std::string& output ) const +{ + auto f = this->GetFilter( filter ); + if( f != NULL ) + return( f->GetOutput( output ) ); + else + return( NULL ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Workspace:: HasFilter( const std::string& name ) const diff --git a/lib/cpPlugins/Workspace.h b/lib/cpPlugins/Workspace.h index d588458..eaa5f11 100644 --- a/lib/cpPlugins/Workspace.h +++ b/lib/cpPlugins/Workspace.h @@ -68,6 +68,12 @@ namespace cpPlugins // Filter management ProcessObject* GetFilter( const std::string& name ); const ProcessObject* GetFilter( const std::string& name ) const; + DataObject* GetOutput( + const std::string& filter, const std::string& output + ); + const DataObject* GetOutput( + const std::string& filter, const std::string& output + ) const; bool HasFilter( const std::string& name ) const; ProcessObject* CreateFilter( const std::string& category, -- 2.47.1