X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FMPR3DWidget.cxx;h=718078f854f8c751880414887a8b409d7eb3a599;hb=73a0f5c554b34a173cdccf23f3493b5435c4f86b;hp=3d5d50882ce915c98eb9b9c3b3c02af980f3fa39;hpb=3393941bf8f26babc7b592db434b40c1b747a687;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/MPR3DWidget.cxx b/lib/cpExtensions/QT/MPR3DWidget.cxx index 3d5d508..718078f 100644 --- a/lib/cpExtensions/QT/MPR3DWidget.cxx +++ b/lib/cpExtensions/QT/MPR3DWidget.cxx @@ -3,12 +3,11 @@ #ifdef cpExtensions_QT4 #include -#include -#include +#include #include -#include #include +#include #include // ------------------------------------------------------------------------- @@ -17,40 +16,51 @@ MPR3DWidget( QWidget* parent, Qt::WindowFlags f ) : Superclass( parent, f ), m_ImageName( "" ) { - this->m_Actors = - vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( ); } // ------------------------------------------------------------------------- cpExtensions::QT::MPR3DWidget:: ~MPR3DWidget( ) { + for( auto a = this->m_Actors.begin( ); a != this->m_Actors.end( ); ++a ) + delete *a; + this->m_Actors.clear( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::MPR3DWidget:: +Clear( ) +{ + this->RemoveViewProps( ); + this->m_ImageName = ""; } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: SetImage( vtkImageData* image, const std::string& name ) { + if( name == "" ) + return; if( this->m_ImageName != "" ) + this->Clear( ); + this->m_ImageName = name; + + for( unsigned int o = 0; o < 3; ++o ) { - // TODO: Clear visualization + this->m_WLActors[ o ] = vtkSmartPointer< TWLActor >::New( ); + this->m_WLActors[ o ]->SetImage( image ); + this->m_WLActors[ o ]->SetOrientation( o ); - } // fi + this->m_OLActors[ o ] = vtkSmartPointer< TOLActor >::New( ); + this->m_OLActors[ o ]->SetBounds( + o, image->GetBounds( )[ o << 1 ], image->GetBounds( ) + ); - this->m_Actors->SetImage( image ); - this->m_ImageName = name; + this->AddViewProp( this->m_WLActors[ o ], this->m_ImageName ); + this->AddAuxViewProp( this->m_OLActors[ o ], this->m_ImageName ); + this->ResetCamera( ); - vtkSmartPointer< vtkPropCollection > props = - vtkSmartPointer< vtkPropCollection >::New( ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 0 ) ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 1 ) ); - props->AddItem( this->m_Actors->GetWindowLevelImageActor( 2 ) ); - this->AddViewProps( props, name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 0 ), name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 1 ), name ); - this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 2 ), name ); - this->ResetCamera( ); - this->Render( ); + } // rof } // ------------------------------------------------------------------------- @@ -61,84 +71,73 @@ Add( vtkDataSet* data, const std::string& name ) auto pdata = dynamic_cast< vtkPolyData* >( data ); if( image != NULL ) { - if( this->m_ImageName != "" ) - { - } - else - this->SetImage( image, name ); + /* TODO + if( this->m_ImageName != "" ) + { + } + else + this->SetImage( image, name ); + */ } else if( pdata != NULL ) { - this->AddViewProp( this->m_Actors->AddMesh( pdata ), name ); + TActor* actor = new TActor( ); + actor->SetMesh( pdata ); + this->m_Actors.push_back( actor ); + this->AddViewProp( actor->GetActor( ), name ); this->Render( ); if( this->m_ImageName == "" ) this->ResetCamera( ); } // fi - - /* TODO - return; - - auto image = dynamic_cast< vtkImageData* >( data ); - auto pdata = dynamic_cast< vtkPolyData* >( data ); - if( image != NULL ) - { - this->m_Actors->AddLUTImage( image ); - vtkSmartPointer< vtkPropCollection > coll = - vtkSmartPointer< vtkPropCollection >::New( ); - coll->AddItem( this->m_Actors->GetLUTImageActor( 0 ) ); - coll->AddItem( this->m_Actors->GetLUTImageActor( 1 ) ); - coll->AddItem( this->m_Actors->GetLUTImageActor( 2 ) ); - this->AddViewProps( coll, name ); - this->Render( ); - } - else if( pdata != NULL ) - { - - } // fi - */ } // ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetSliceNumber( int orientation, int slice ) -{ - this->m_Actors->SetSliceNumber( orientation, slice ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetSlicesNumbers( int x, int y, int z ) -{ - this->m_Actors->SetSliceNumber( 0, x ); - this->m_Actors->SetSliceNumber( 1, y ); - this->m_Actors->SetSliceNumber( 2, z ); - this->Render( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetScalarRange( double r[ 2 ] ) +cpExtensions::QT::MPR3DWidget:: +TWLActor* cpExtensions::QT::MPR3DWidget:: +GetImageActor( int o ) { + return( this->m_WLActors[ o % 3 ] ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::MPR3DWidget:: -SetWindowLevel( double wl[ 2 ] ) +const cpExtensions::QT::MPR3DWidget:: +TWLActor* cpExtensions::QT::MPR3DWidget:: +GetImageActor( int o ) const { + return( this->m_WLActors[ o % 3 ] ); } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: -SetImageOpacity( double o ) +SetSliceNumber( int orientation, int slice ) { + int o = orientation % 3; + this->m_WLActors[ o ]->SetSliceNumber( slice ); + this->m_OLActors[ o ]->SetBounds( + o, + this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ], + this->m_WLActors[ o ]->GetImage( )->GetBounds( ) + ); + this->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: -SetImageInterpolation( unsigned char i ) +SetSlicesNumbers( int x, int y, int z ) { + int s[] = { x, y, z }; + for( int o = 0; o < 3; ++o ) + { + this->m_WLActors[ o ]->SetSliceNumber( s[ o ] ); + this->m_OLActors[ o ]->SetBounds( + o, + this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ], + this->m_WLActors[ o ]->GetImage( )->GetBounds( ) + ); + + } // rof + this->Render( ); } #endif // cpExtensions_QT4