X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FSimpleMPRWidget.cxx;h=42dd1cd724d3658dd851b0a577f810365c53e08f;hb=510ac31d52c1ac725baf278243c958e6c564b5b3;hp=fe67abcb5e93d1669956b969186bb1e99b33ad8d;hpb=9a9120ade4a750bfa451a0a2e193c55e43b2749c;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index fe67abc..42dd1cd 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -2,65 +2,73 @@ #ifdef cpExtensions_QT4 -#include -#include -#include +#include +#include +#include +#include +#include -// ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle* -cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle:: -New( ) -{ - return( new _3DInteractorStyle( ) ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle:: -OnKeyPress( ) -{ - vtkRenderWindowInteractor* i = this->Interactor; - std::string key = i->GetKeySym( ); - if( key == "r" || key == "R" ) - { - this->CurrentRenderer->ResetCamera( ); - i->Render( ); - - } // fi -} +#include +#include +#include +#include // ------------------------------------------------------------------------- cpExtensions::QT::SimpleMPRWidget:: -SimpleMPRWidget( QWidget* parent ) - : QWidget( parent ), - m_UI( new Ui::SimpleMPRWidget ) +SimpleMPRWidget( QWidget* parent, Qt::WindowFlags f ) + : Superclass( parent, f ), + Superclass2( ), + m_UI( new Ui::SimpleMPRWidget ), + m_MainImageName( "" ) { this->m_UI->setupUi( this ); - // Configure VTK widgets - 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 ) - { - this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( ); - this->m_VTK[ i ]->GetRenderWindow( )-> - AddRenderer( this->m_Renderers[ i ] ); - - } // rof - vtkSmartPointer< _3DInteractorStyle > style = - vtkSmartPointer< _3DInteractorStyle >::New( ); - this->m_VTK[ 3 ]->GetRenderWindow( )-> - GetInteractor( )->SetInteractorStyle( style ); - style->SetCurrentRenderer( this->m_Renderers[ 3 ] ); + // Prepare default configuration + this->m_UI->Q1->hide( ); + this->m_UI->Q2->hide( ); + this->m_UI->Q3->hide( ); + this->m_UI->Q4->hide( ); + this->m_UI->Q1->close( ); + this->m_UI->Q2->close( ); + this->m_UI->Q3->close( ); + this->m_UI->Q4->close( ); + delete this->m_UI->Q1; + delete this->m_UI->Q2; + delete this->m_UI->Q3; + delete this->m_UI->Q4; + this->m_XImage = new ImageWidget( this ); + this->m_YImage = new ImageWidget( this ); + this->m_ZImage = new ImageWidget( this ); + this->m_3DView = new MPR3DWidget( this ); + this->m_UI->Q1 = this->m_XImage; + this->m_UI->Q2 = this->m_YImage; + this->m_UI->Q3 = this->m_ZImage; + this->m_UI->Q4 = this->m_3DView; + this->Configure( 'y', 'x', 'w', 'z' ); + + // Interaction synchronizer + unsigned long ev1 = vtkCommand::UserEvent + 1; + unsigned long ev2 = vtkCommand::UserEvent + 2; + vtkSmartPointer< cpExtensions::QT::MPRInteractionCommand > cmd = + vtkSmartPointer< cpExtensions::QT::MPRInteractionCommand >::New( ); + cmd->AddWidget( this->m_XImage ); + cmd->AddWidget( this->m_YImage ); + cmd->AddWidget( this->m_ZImage ); + cmd->AddWidget( this->m_3DView ); + this->m_XImage->GetStyle( )->AddObserver( ev1, cmd ); + this->m_YImage->GetStyle( )->AddObserver( ev1, cmd ); + this->m_ZImage->GetStyle( )->AddObserver( ev1, cmd ); + this->m_XImage->GetStyle( )->AddObserver( ev2, cmd ); + this->m_YImage->GetStyle( )->AddObserver( ev2, cmd ); + this->m_ZImage->GetStyle( )->AddObserver( ev2, cmd ); // Connect slots - QObject::connect( - this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ), + this->connect( + this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ), this, SLOT( _SyncBottom( int, int ) ) ); - QObject::connect( - this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ), + this->connect( + this->m_UI->Bottom, SIGNAL( splitterMoved( int, int ) ), this, SLOT( _SyncTop( int, int ) ) ); } @@ -69,332 +77,562 @@ SimpleMPRWidget( QWidget* parent ) cpExtensions::QT::SimpleMPRWidget:: ~SimpleMPRWidget( ) { - this->Clear( ); delete this->m_UI; } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -Clear( ) +Configure( char q1, char q2, char q3, char q4 ) { - for( unsigned int i = 0; i < 4; ++i ) - this->m_Renderers[ i ]->RemoveAllViewProps( ); - for( unsigned int i = 0; i < 3; ++i ) - { - if( this->m_2DSlices[ i ].GetPointer( ) != NULL ) - this->m_2DSlices[ i ]->Clear( ); - if( this->m_3DSlices[ i ].GetPointer( ) != NULL ) - this->m_3DSlices[ i ]->Clear( ); + // Hide all widgets + this->m_UI->Q1->hide( ); + this->m_UI->Q2->hide( ); + this->m_UI->Q3->hide( ); + this->m_UI->Q4->hide( ); + this->m_UI->Q1->close( ); + this->m_UI->Q2->close( ); + this->m_UI->Q3->close( ); + this->m_UI->Q4->close( ); + + // Reorder them + if ( q1 == 'x' ) this->m_UI->Top->addWidget( this->m_XImage ); + else if( q1 == 'y' ) this->m_UI->Top->addWidget( this->m_YImage ); + else if( q1 == 'z' ) this->m_UI->Top->addWidget( this->m_ZImage ); + else if( q1 == 'w' ) this->m_UI->Top->addWidget( this->m_3DView ); + if ( q2 == 'x' ) this->m_UI->Top->addWidget( this->m_XImage ); + else if( q2 == 'y' ) this->m_UI->Top->addWidget( this->m_YImage ); + else if( q2 == 'z' ) this->m_UI->Top->addWidget( this->m_ZImage ); + else if( q2 == 'w' ) this->m_UI->Top->addWidget( this->m_3DView ); + this->m_UI->Top->update( ); + if ( q4 == 'x' ) this->m_UI->Bottom->addWidget( this->m_XImage ); + else if( q4 == 'y' ) this->m_UI->Bottom->addWidget( this->m_YImage ); + else if( q4 == 'z' ) this->m_UI->Bottom->addWidget( this->m_ZImage ); + else if( q4 == 'w' ) this->m_UI->Bottom->addWidget( this->m_3DView ); + if ( q3 == 'x' ) this->m_UI->Bottom->addWidget( this->m_XImage ); + else if( q3 == 'y' ) this->m_UI->Bottom->addWidget( this->m_YImage ); + else if( q3 == 'z' ) this->m_UI->Bottom->addWidget( this->m_ZImage ); + else if( q3 == 'w' ) this->m_UI->Bottom->addWidget( this->m_3DView ); + this->m_UI->Bottom->update( ); + + // Keep track + if ( q1 == 'x' ) this->m_UI->Q1 = this->m_XImage; + else if( q1 == 'y' ) this->m_UI->Q1 = this->m_YImage; + else if( q1 == 'z' ) this->m_UI->Q1 = this->m_ZImage; + else if( q1 == 'w' ) this->m_UI->Q1 = this->m_3DView; + if ( q2 == 'x' ) this->m_UI->Q2 = this->m_XImage; + else if( q2 == 'y' ) this->m_UI->Q2 = this->m_YImage; + else if( q2 == 'z' ) this->m_UI->Q2 = this->m_ZImage; + else if( q2 == 'w' ) this->m_UI->Q2 = this->m_3DView; + if ( q3 == 'x' ) this->m_UI->Q3 = this->m_XImage; + else if( q3 == 'y' ) this->m_UI->Q3 = this->m_YImage; + else if( q3 == 'z' ) this->m_UI->Q3 = this->m_ZImage; + else if( q3 == 'w' ) this->m_UI->Q3 = this->m_3DView; + if ( q4 == 'x' ) this->m_UI->Q4 = this->m_XImage; + else if( q4 == 'y' ) this->m_UI->Q4 = this->m_YImage; + else if( q4 == 'z' ) this->m_UI->Q4 = this->m_ZImage; + else if( q4 == 'w' ) this->m_UI->Q4 = this->m_3DView; + + // Draw all + this->m_UI->Q1->show( ); + this->m_UI->Q2->show( ); + this->m_UI->Q3->show( ); + this->m_UI->Q4->show( ); + dynamic_cast< RendererWidget* >( this->m_UI->Q1 )->SetQuadrant( 1 ); + dynamic_cast< RendererWidget* >( this->m_UI->Q2 )->SetQuadrant( 2 ); + dynamic_cast< RendererWidget* >( this->m_UI->Q3 )->SetQuadrant( 3 ); + dynamic_cast< RendererWidget* >( this->m_UI->Q4 )->SetQuadrant( 4 ); +} - } // rof - this->m_NamedActors.clear( ); +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +HasImage( ) const +{ + return( this->m_MainImage.GetPointer( ) != NULL ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -SetMainImage( vtkImageData* image, const std::string& name ) +SetImage( vtkImageData* image, const std::string& name ) { - this->Clear( ); - for( unsigned int i = 0; i < 3; ++i ) + if( this->m_MainImageName != "" || image == NULL ) { - 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< 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( ) - ) - ); - - this->m_NamedActors[ name ].insert( - this->m_2DSlices[ i ]->GetImageActor( ) - ); - this->m_NamedActors[ name ].insert( - this->m_3DSlices[ i ]->GetImageActor( ) - ); - - } // rof - this->_AssociateSlices( ); + // TODO: Clear visualization + + } // fi + this->m_MainImageName = name; + this->m_MainImage = image; + + if( this->m_MainImage != NULL && this->m_MainImageName != "" ) + { + this->m_XImage->SetImage( this->m_MainImage, name, 0 ); + this->m_YImage->SetImage( this->m_MainImage, name, 1 ); + this->m_ZImage->SetImage( this->m_MainImage, name, 2 ); + this->m_3DView->SetImage( this->m_MainImage, name ); + + } // fi } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -SetMainActor( vtkImageActor* actor, const std::string& name ) +bool cpExtensions::QT::SimpleMPRWidget:: +Add( vtkDataSet* data, const std::string& name ) { - this->Clear( ); - vtkImageData* image = NULL; - for( unsigned int i = 0; i < 3; ++i ) + bool success = true; + auto image = dynamic_cast< vtkImageData* >( data ); + auto pdata = dynamic_cast< vtkPolyData* >( data ); + + if( image != NULL ) { - this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( ); - if( i == 0 ) + if( this->m_MainImageName != "" ) { - this->m_2DSlices[ i ]->SetInputActor( actor, i ); - image = this->m_2DSlices[ i ]->GetInputData( ); + this->m_XImage->Add( image, name ); + this->m_YImage->Add( image, name ); + this->m_ZImage->Add( image, name ); + // TODO: this->m_3DView->Add( image, name ); } 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( ) ); + this->SetImage( image, name ); + } + else if( pdata != NULL ) + this->m_3DView->Add( pdata, name ); + else + success = false; + return( success ); +} + +// ------------------------------------------------------------------------- +cpExtensions::QT::SimpleMPRWidget:: +TProps cpExtensions::QT::SimpleMPRWidget:: +GetViewProps( const std::string& name ) const +{ +/* + auto x = this->m_XImage->GetViewProps( name ); + auto y = this->m_YImage->GetViewProps( name ); + auto z = this->m_ZImage->GetViewProps( name ); + auto w = this->m_3DView->GetViewProps( name ); + + TProps props; + if( x != NULL ) props.insert( x ); + if( y != NULL ) props.insert( y ); + if( z != NULL ) props.insert( z ); + if( w != NULL ) props.insert( w ); + return( props ); +*/ + TProps props; + return( props ); +} + +// ------------------------------------------------------------------------- +cpExtensions::QT::SimpleMPRWidget:: +TProps cpExtensions::QT::SimpleMPRWidget:: +GetImageProps( ) const +{ + return( this->GetViewProps( this->m_MainImageName ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetXInteractor( ) +{ + return( this->m_XImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetXInteractor( ) const +{ + return( this->m_XImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetYInteractor( ) +{ + return( this->m_YImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetYInteractor( ) const +{ + return( this->m_YImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetZInteractor( ) +{ + return( this->m_ZImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetZInteractor( ) const +{ + return( this->m_ZImage->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetWInteractor( ) +{ + return( this->m_3DView->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetWInteractor( ) const +{ + return( this->m_3DView->GetInteractor( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetXRenderWindow( ) +{ + return( this->m_XImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetXRenderWindow( ) const +{ + return( this->m_XImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetYRenderWindow( ) +{ + return( this->m_YImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetYRenderWindow( ) const +{ + return( this->m_YImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetZRenderWindow( ) +{ + return( this->m_ZImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetZRenderWindow( ) const +{ + return( this->m_ZImage->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetWRenderWindow( ) +{ + return( this->m_3DView->GetRenderWindow( ) ); +} + - 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( ) - ) - ); +// ------------------------------------------------------------------------- +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetWRenderWindow( ) const +{ + return( this->m_3DView->GetRenderWindow( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +ResetCameras( ) +{ + this->m_XImage->ResetCamera( ); + this->m_YImage->ResetCamera( ); + this->m_ZImage->ResetCamera( ); + this->m_3DView->ResetCamera( ); +} - this->m_NamedActors[ name ].insert( - this->m_2DSlices[ i ]->GetImageActor( ) - ); - this->m_NamedActors[ name ].insert( - this->m_3DSlices[ i ]->GetImageActor( ) - ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +Render( ) +{ + this->m_XImage->Render( ); + this->m_YImage->Render( ); + this->m_ZImage->Render( ); + this->m_3DView->Render( ); +} + +// ------------------------------------------------------------------------- +std::set< vtkRenderWindowInteractor* > cpExtensions::QT::SimpleMPRWidget:: +GetInteractors( ) const +{ + std::set< vtkRenderWindowInteractor* > ret; + ret.insert( this->m_XImage->GetInteractor( ) ); + ret.insert( this->m_YImage->GetInteractor( ) ); + ret.insert( this->m_ZImage->GetInteractor( ) ); + ret.insert( this->m_3DView->GetInteractor( ) ); + return( ret ); +} + +// ------------------------------------------------------------------------- +std::set< std::string > cpExtensions::QT::SimpleMPRWidget:: +GetActorsNames( ) const +{ + std::set< std::string > names = this->m_XImage->GetActorsNames( ); + std::set< std::string > y = this->m_YImage->GetActorsNames( ); + std::set< std::string > z = this->m_ZImage->GetActorsNames( ); + std::set< std::string > w = this->m_3DView->GetActorsNames( ); + names.insert( y.begin( ), y.end( ) ); + names.insert( z.begin( ), z.end( ) ); + names.insert( w.begin( ), w.end( ) ); + return( names ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +IsWindowLevelImageActor( const std::string& name ) const +{ + return( this->m_XImage->IsWindowLevelImageActor( name ) ); +} + +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +IsLUTImageActor( const std::string& name ) const +{ + return( this->m_XImage->IsLUTImageActor( name ) ); +} - } // rof - this->_AssociateSlices( ); +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +Is3DActor( const std::string& name ) const +{ + return( + this->m_XImage->Is3DActor( name ) || this->m_3DView->Is3DActor( name ) + ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -AddImage( vtkImageData* image, const std::string& name ) +GetScalarRange( const std::string& name, double r[ 2 ] ) const { - std::cerr << "SimpleMPR: adding image" << std::endl; - std::exit( 1 ); + this->m_XImage->GetScalarRange( name, r ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -AddImageActor( vtkImageActor* actor, const std::string& name ) +GetWindowLevel( const std::string& name, double wl[ 2 ] ) const { - unsigned int i = 0; - bool cont = true; - while( i < 3 && cont ) - { - if( this->m_2DSlices[ i ].GetPointer( ) != NULL ) - { - if( this->m_2DSlices[ i ]->GetImageActor( ) != NULL ) - { - // TODO: add image actor - } - else - cont = false; + this->m_XImage->GetWindowLevel( name, wl ); +} - } // fi - i++; +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetWindow( const std::string& name ) const +{ + return( this->m_XImage->GetWindow( name ) ); +} - } // rof +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLevel( const std::string& name ) const +{ + return( this->m_XImage->GetLevel( name ) ); +} - // Add if no actors were found - if( cont ) - this->SetMainActor( actor, name ); +// ------------------------------------------------------------------------- +char cpExtensions::QT::SimpleMPRWidget:: +GetImageInterpolation( const std::string& name ) const +{ + return( this->m_XImage->GetImageInterpolation( name ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -AddMesh( vtkPolyData* mesh, const std::string& name ) +GetColor( const std::string& name, double& r, double& g, double& b ) const { - 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 ); + this->m_XImage->GetColor( name, r, g, b ); +} - 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( ); +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetOpacity( const std::string& name ) const +{ + return( this->m_XImage->GetOpacity( name ) ); +} - } // fi +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetPointSize( const std::string& name ) const +{ + return( this->m_XImage->GetPointSize( name ) ); +} - } // fi +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLineWidth( const std::string& name ) const +{ + return( this->m_XImage->GetLineWidth( name ) ); +} - } // rof - if( !has_main_image ) - this->m_Renderers[ 3 ]->ResetCamera( ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); - */ +// ------------------------------------------------------------------------- +int cpExtensions::QT::SimpleMPRWidget:: +GetRepresentation( const std::string& name ) const +{ + return( this->m_XImage->GetRepresentation( name ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -AddMeshActor( vtkProp3D* actor, const std::string& name ) +SetScalarRange( const std::string& name, double r[ 2 ] ) { - if( actor != NULL ) - { - this->m_Renderers[ 3 ]->AddViewProp( actor ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); - this->m_NamedActors[ name ].insert( actor ); - if( this->m_Renderers[ 3 ]->GetViewProps( )->GetNumberOfItems( ) == 1 ) - { - this->m_Renderers[ 3 ]->ResetCamera( ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); + this->m_XImage->SetScalarRange( name, r ); + this->m_YImage->SetScalarRange( name, r ); + this->m_ZImage->SetScalarRange( name, r ); + this->m_3DView->SetScalarRange( name, r ); +} - } // fi +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetScalarRange( const std::string& name, double min, double max ) +{ + this->m_XImage->SetScalarRange( name, min, max ); + this->m_YImage->SetScalarRange( name, min, max ); + this->m_ZImage->SetScalarRange( name, min, max ); + this->m_3DView->SetScalarRange( name, min, max ); +} - } // fi +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetWindowLevel( const std::string& name, double wl[ 2 ] ) +{ + this->m_XImage->SetWindowLevel( name, wl ); + this->m_YImage->SetWindowLevel( name, wl ); + this->m_ZImage->SetWindowLevel( name, wl ); + this->m_3DView->SetWindowLevel( name, wl ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -AddActor( vtkProp* actor, const std::string& name ) +SetWindowLevel( const std::string& name, double w, double l ) { - auto ia = dynamic_cast< vtkImageActor* >( actor ); - if( ia == NULL ) - { - auto ma = dynamic_cast< vtkProp3D* >( actor ); - if( ma != NULL ) - this->AddMeshActor( ma, name ); - } - else - this->AddImageActor( ia, name ); + this->m_XImage->SetWindowLevel( name, w, l ); + this->m_YImage->SetWindowLevel( name, w, l ); + this->m_ZImage->SetWindowLevel( name, w, l ); + this->m_3DView->SetWindowLevel( name, w, l ); } // ------------------------------------------------------------------------- -const cpExtensions::QT::SimpleMPRWidget:: -TActors& cpExtensions::QT::SimpleMPRWidget:: -GetActors( const std::string& name ) const +void cpExtensions::QT::SimpleMPRWidget:: +SetWindow( const std::string& name, double w ) { - static const TActors empty; - auto i = this->m_NamedActors.find( name ); - if( i != this->m_NamedActors.end( ) ) - return( i->second ); - else - return( empty ); + this->m_XImage->SetWindow( name, w ); + this->m_YImage->SetWindow( name, w ); + this->m_ZImage->SetWindow( name, w ); + this->m_3DView->SetWindow( name, w ); } // ------------------------------------------------------------------------- -vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: -GetInteractor( unsigned int i ) +void cpExtensions::QT::SimpleMPRWidget:: +SetLevel( const std::string& name, double l ) { - if( i < 4 ) - return( this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( ) ); - else - return( NULL ); + this->m_XImage->SetLevel( name, l ); + this->m_YImage->SetLevel( name, l ); + this->m_ZImage->SetLevel( name, l ); + this->m_3DView->SetLevel( name, l ); } // ------------------------------------------------------------------------- -vtkRenderer* cpExtensions::QT::SimpleMPRWidget:: -GetRenderer( unsigned int i ) +void cpExtensions::QT::SimpleMPRWidget:: +SetImageInterpolation( const std::string& name, char i ) { - if( i < 4 ) - return( this->m_Renderers[ i ] ); - else - return( NULL ); + this->m_XImage->SetImageInterpolation( name, i ); + this->m_YImage->SetImageInterpolation( name, i ); + this->m_ZImage->SetImageInterpolation( name, i ); + this->m_3DView->SetImageInterpolation( name, i ); } // ------------------------------------------------------------------------- -vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: -GetRenderWindow( unsigned int i ) +void cpExtensions::QT::SimpleMPRWidget:: +SetColor( const std::string& name, double r, double g, double b ) { - if( i < 4 ) - { - if( this->m_Renderers[ i ].GetPointer( ) != NULL ) - return( this->m_Renderers[ i ]->GetRenderWindow( ) ); - else - return( NULL ); - } - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -/* 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 ); - } -*/ + this->m_XImage->SetColor( name, r, g, b ); + this->m_YImage->SetColor( name, r, g, b ); + this->m_ZImage->SetColor( name, r, g, b ); + this->m_3DView->SetColor( name, r, g, b ); +} // ------------------------------------------------------------------------- -/* 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:: +SetOpacity( const std::string& name, double o ) +{ + this->m_XImage->SetOpacity( name, o ); + this->m_YImage->SetOpacity( name, o ); + this->m_ZImage->SetOpacity( name, o ); + this->m_3DView->SetOpacity( name, o ); +} // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_AssociateSlices( ) +SetPointSize( const std::string& name, double s ) { - 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 ] ); + this->m_XImage->SetPointSize( name, s ); + this->m_YImage->SetPointSize( name, s ); + this->m_ZImage->SetPointSize( name, s ); + this->m_3DView->SetPointSize( name, s ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetLineWidth( const std::string& name, double w ) +{ + this->m_XImage->SetLineWidth( name, w ); + this->m_YImage->SetLineWidth( name, w ); + this->m_ZImage->SetLineWidth( name, w ); + this->m_3DView->SetLineWidth( name, w ); +} - } // rof +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToPoints( const std::string& name ) +{ + this->m_XImage->SetRepresentationToPoints( name ); + this->m_YImage->SetRepresentationToPoints( name ); + this->m_ZImage->SetRepresentationToPoints( name ); + this->m_3DView->SetRepresentationToPoints( name ); +} - } // 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( ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToSurface( const std::string& name ) +{ + this->m_XImage->SetRepresentationToSurface( name ); + this->m_YImage->SetRepresentationToSurface( name ); + this->m_ZImage->SetRepresentationToSurface( name ); + this->m_3DView->SetRepresentationToSurface( name ); +} - } // rof - this->m_Renderers[ 3 ]->ResetCamera( ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToWireframe( const std::string& name ) +{ + this->m_XImage->SetRepresentationToWireframe( name ); + this->m_YImage->SetRepresentationToWireframe( name ); + this->m_ZImage->SetRepresentationToWireframe( name ); + this->m_3DView->SetRepresentationToWireframe( name ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: _SyncBottom( int a, int b ) { - this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) ); + this->m_UI->Bottom->setSizes( this->m_UI->Top->sizes( ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: _SyncTop( int a, int b ) { - this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) ); + this->m_UI->Top->setSizes( this->m_UI->Bottom->sizes( ) ); } #endif // cpExtensions_QT4