X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FSimpleMPRWidget.cxx;h=b700b4e8d5d250ea558258ad20a55d30f9c47e47;hb=8a5ea31f638e60ee6708667e2dc71bafd0e899ee;hp=ee2196e8ff4bd57ec7f801acae738a694e5479ec;hpb=b445d953049ba15290197549dcd4e31367e3c8a5;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index ee2196e..b700b4e 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -2,54 +2,73 @@ #ifdef cpExtensions_QT4 -#include +#include +#include +#include +#include +#include -#include -#include - -double cpExtensions::QT::SimpleMPRWidget:: -cm_Colors[ 8 ][ 3 ] = -{ - { 1.0, 0.0, 0.0 }, - { 0.0, 1.0, 0.0 }, - { 0.0, 0.0, 1.0 }, - { 0.0, 1.0, 1.0 }, - { 1.0, 0.0, 1.0 }, - { 1.0, 1.0, 0.0 }, - { 1.0, 0.5, 0.0 }, - { 1.0, 0.0, 0.5 } -}; +#include +#include +#include +#include // ------------------------------------------------------------------------- cpExtensions::QT::SimpleMPRWidget:: -SimpleMPRWidget( QWidget* parent ) - : QWidget( parent ), +SimpleMPRWidget( QWidget* parent, Qt::WindowFlags f ) + : Superclass( parent, f ), + Superclass2( ), m_UI( new Ui::SimpleMPRWidget ), - m_MainImage( "" ) + m_MainImageName( "" ) { 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_MPRObjects = vtkSmartPointer< TMPRObjects >::New( ); - this->m_MPRObjects->SetRenderWindows( - this->m_VTK[ 0 ]->GetRenderWindow( ), - this->m_VTK[ 1 ]->GetRenderWindow( ), - this->m_VTK[ 2 ]->GetRenderWindow( ), - this->m_VTK[ 3 ]->GetRenderWindow( ) - ); + // 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 ) ) ); } @@ -62,581 +81,548 @@ cpExtensions::QT::SimpleMPRWidget:: } // ------------------------------------------------------------------------- -unsigned int cpExtensions::QT::SimpleMPRWidget:: -GetNumberOfData( ) const -{ - return( this->m_Data.size( ) ); +void cpExtensions::QT::SimpleMPRWidget:: +Configure( char q1, char q2, char q3, char q4 ) +{ + // 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 ); } // ------------------------------------------------------------------------- bool cpExtensions::QT::SimpleMPRWidget:: -AddData( - vtkImageData* data, const std::string& name, - const std::string& parent - ) +HasImage( ) const { - if( name == "" ) - return( false ); + return( this->m_MainImage.GetPointer( ) != NULL ); +} - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetImage( vtkImageData* image, const std::string& name ) +{ + if( this->m_MainImageName != "" || image == NULL ) { - if( parent != "" ) - { - auto pIt = this->m_Data.find( parent ); - if( pIt == this->m_Data.end( ) ) - return( false ); + // TODO: Clear visualization - } // fi + } // fi + this->m_MainImageName = name; + this->m_MainImage = image; - // Add new data - this->m_Data[ name ].SetImageData( data ); + if( this->m_MainImage != NULL && this->m_MainImageName != "" ) + { + this->m_XImage->SetImage( this->m_MainImage, 0, name ); + this->m_YImage->SetImage( this->m_MainImage, 1, name ); + this->m_ZImage->SetImage( this->m_MainImage, 2, name ); + this->m_3DView->SetImage( this->m_MainImage, name ); - // Set color - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) - { - vtkActor* actor = - dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) ); - if( actor != NULL ) - { - unsigned int idx = this->m_Data.size( ) % 8; - actor->GetProperty( )->SetColor( - Self::cm_Colors[ idx ][ 0 ], - Self::cm_Colors[ idx ][ 1 ], - Self::cm_Colors[ idx ][ 2 ] - ); - - } // fi - - } // fi - - // Add to tree view - // TODO: this->_UpdateTreeItem( name, parent ); - return( true ); - } - else - return( false ); + } // fi } // ------------------------------------------------------------------------- bool cpExtensions::QT::SimpleMPRWidget:: -AddData( vtkPolyData* data, const std::string& name ) +Add( vtkDataSet* data, const std::string& name ) { - if( name == "" ) - return( false ); + bool success = true; + auto image = dynamic_cast< vtkImageData* >( data ); + auto pdata = dynamic_cast< vtkPolyData* >( data ); - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) + if( image != NULL ) { - // Add new data - this->m_Data[ name ].SetPolyData( data ); - - // Set color - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) + if( this->m_MainImageName != "" ) { - vtkActor* actor = - dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) ); - if( actor != NULL ) - { - unsigned int idx = this->m_Data.size( ) % 8; - actor->GetProperty( )->SetColor( - Self::cm_Colors[ idx ][ 0 ], - Self::cm_Colors[ idx ][ 1 ], - Self::cm_Colors[ idx ][ 2 ] - ); - - } // fi - - } // fi - - // Add to tree view - // TODO: this->_UpdateTreeItem( name, parent ); - return( true ); + 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->SetImage( image, name ); } + else if( pdata != NULL ) + this->m_3DView->Add( pdata, name ); else - return( false ); + success = false; + return( success ); } // ------------------------------------------------------------------------- -const std::string& cpExtensions::QT::SimpleMPRWidget:: -GetMainImage( ) const +cpExtensions::QT::SimpleMPRWidget:: +TProps cpExtensions::QT::SimpleMPRWidget:: +GetViewProps( const std::string& name ) const { - return( this->m_MainImage ); +/* + 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 ); +*/ } // ------------------------------------------------------------------------- -bool cpExtensions::QT::SimpleMPRWidget:: -SetMainImage( const std::string& name ) +cpExtensions::QT::SimpleMPRWidget:: +TProps cpExtensions::QT::SimpleMPRWidget:: +GetImageProps( ) const { - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) - { - if( iIt->second.Tag == Data::IMAGE ) - { - this->m_MainImage = name; - return( true ); - } - else - return( false ); - } - else - return( false ); + return( this->GetViewProps( this->m_MainImageName ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -DeleteData( const std::string& name ) +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetXInteractor( ) { - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) - { - this->m_Data.erase( iIt ); - - // Get children - std::vector< std::string > to_erase; - auto tIt = this->m_Tree.begin( ); - for( ; tIt != this->m_Tree.end( ); ++tIt ) - if( tIt->second == name ) - to_erase.push_back( tIt->first ); - - // Delete from tree - tIt = this->m_Tree.find( name ); - if( tIt != this->m_Tree.end( ) ) - this->m_Tree.erase( tIt ); - - // Recursive erase - auto dIt = to_erase.begin( ); - for( ; dIt != to_erase.end( ); ++dIt ) - this->DeleteData( *dIt ); - - // Delete from tree widget - /* TODO - QTreeWidgetItem* item = this->_FindItemInTree( name ); - if( item != NULL ) - this->m_UI->LoadedData->removeItemWidget( item, 0 ); - */ - - // Reset main image, just in case - if( this->m_Data.size( ) == 0 ) - this->m_MainImage = ""; + return( this->m_XImage->GetInteractor( ) ); +} - } // fi +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetXInteractor( ) const +{ + return( this->m_XImage->GetInteractor( ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -DeleteAllData( ) +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetYInteractor( ) { - this->m_MPRObjects->Clear( ); - this->m_Data.clear( ); - this->m_Tree.clear( ); - // TODO: this->m_UI->LoadedData->clear( ); - this->m_MainImage = ""; + return( this->m_YImage->GetInteractor( ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -SetDataColor( - const std::string& name, const double& r, const double& g, const double& b - ) +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetYInteractor( ) const { - /* - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) - return; + return( this->m_YImage->GetInteractor( ) ); +} - if( iIt->second.Tag == Data::IMAGE ) - { - } - else if( iIt->second.Tag == Data::MESH ) - { - } // fi - */ +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetZInteractor( ) +{ + return( this->m_ZImage->GetInteractor( ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -ShowData( const std::string& name ) +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetZInteractor( ) const { - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) - return; + return( this->m_ZImage->GetInteractor( ) ); +} - if( iIt->second.Tag == Data::IMAGE ) - { - if( name == this->m_MainImage ) - this->m_MPRObjects->SetInputImage( iIt->second.Image ); - else - { - unsigned int i = ( this->m_MPRObjects->GetNumberOfImages( ) - 1 ) % 8; - this->m_MPRObjects->AddBinaryImage( - iIt->second.Image, - Self::cm_Colors[ i ][ 0 ], - Self::cm_Colors[ i ][ 1 ], - Self::cm_Colors[ i ][ 2 ] - ); - } - this->m_MPRObjects->Show( ); - } - else if( iIt->second.Tag == Data::MESH ) - { - vtkRenderer* ren = - this->m_VTK[ 3 ]->GetRenderWindow( )-> - GetRenderers( )->GetFirstRenderer( ); - if( ren == NULL ) - return; - ren->AddActor( iIt->second.GetMeshActor( ) ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetWInteractor( ) +{ + return( this->m_3DView->GetInteractor( ) ); +} - } // fi +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: +GetWInteractor( ) const +{ + return( this->m_3DView->GetInteractor( ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -HideData( const std::string& name ) +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetXRenderWindow( ) { + return( this->m_XImage->GetRenderWindow( ) ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget:: -SetWindowLevel( const double& w, const double& l ) +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetXRenderWindow( ) const { - this->m_MPRObjects->SetWindowLevel( w, l ); + return( this->m_XImage->GetRenderWindow( ) ); } // ------------------------------------------------------------------------- -double cpExtensions::QT::SimpleMPRWidget:: -GetWindow( ) const +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetYRenderWindow( ) { - return( this->m_MPRObjects->GetWindow( ) ); + return( this->m_YImage->GetRenderWindow( ) ); } // ------------------------------------------------------------------------- -double cpExtensions::QT::SimpleMPRWidget:: -GetLevel( ) const +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetYRenderWindow( ) const { - return( this->m_MPRObjects->GetLevel( ) ); + return( this->m_YImage->GetRenderWindow( ) ); } // ------------------------------------------------------------------------- -vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: -GetInteractor( unsigned int i ) +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetZRenderWindow( ) { - if( i < 4 ) - { - if( this->m_VTK[ i ] != NULL ) - return( this->m_VTK[ i ]->GetInteractor( ) ); - else - return( NULL ); - } - else - return( NULL ); + return( this->m_ZImage->GetRenderWindow( ) ); } // ------------------------------------------------------------------------- -/* - bool cpExtensions::QT::SimpleMPRWidget:: - ShowImage( - vtkImageData* image, - const std::string& name, - const std::string& parent - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - this->m_Images[ name ] = image; - this->m_Tree[ name ] = parent; - - // Show image and return - this->m_MPRObjects->AddImage( image ); - return( true ); - } +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetZRenderWindow( ) const +{ + return( this->m_ZImage->GetRenderWindow( ) ); +} - // ------------------------------------------------------------------------- - bool cpExtensions::QT::SimpleMPRWidget:: - ShowImage( - vtkImageData* image, - const std::string& name, - const std::string& parent, - const double& r, const double& g, const double& b - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - this->m_Images[ name ] = image; - this->m_Tree[ name ] = parent; - - // Show image and return - this->m_MPRObjects->AddImage( image ); - return( true ); - } +// ------------------------------------------------------------------------- +vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetWRenderWindow( ) +{ + return( this->m_3DView->GetRenderWindow( ) ); +} - // ------------------------------------------------------------------------- - bool cpExtensions::QT::SimpleMPRWidget:: - ShowMesh( - vtkPolyData* mesh, - const std::string& name, - const std::string& parent - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - PolyDataActor* actor = new PolyDataActor( mesh ); - this->m_Meshes[ name ] = actor; - this->m_Tree[ name ] = parent; - - // Show mesh - this->_Add3DActor( actor->Actor ); - return( true ); - } - // ------------------------------------------------------------------------- - bool cpExtensions::QT::SimpleMPRWidget:: - ShowMesh( - vtkPolyData* mesh, - const std::string& name, - const std::string& parent, - const double& r, const double& g, const double& b - ) - { - return false; - } +// ------------------------------------------------------------------------- +const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget:: +GetWRenderWindow( ) const +{ + return( this->m_3DView->GetRenderWindow( ) ); +} - // ------------------------------------------------------------------------- - void cpExtensions::QT::SimpleMPRWidget:: - ClearAll( ) - { - this->m_MPRObjects->ClearAll( ); - this->m_Images.clear( ); - this->m_Meshes.clear( ); - } +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +ResetCameras( ) +{ +/* + this->m_XImage->ResetCamera( ); + this->m_YImage->ResetCamera( ); + this->m_ZImage->ResetCamera( ); + this->m_3DView->ResetCamera( ); +*/ +} + +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +Render( ) +{ +/* + this->m_XImage->Render( ); + this->m_YImage->Render( ); + this->m_ZImage->Render( ); + this->m_3DView->Render( ); */ +} // ------------------------------------------------------------------------- -std::string cpExtensions::QT::SimpleMPRWidget:: -GetSelectedData( ) const +std::set< std::string > cpExtensions::QT::SimpleMPRWidget:: +GetActorsNames( ) const { - /* TODO - QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( ); - if( item != NULL ) - return( item->text( 0 ).toStdString( ) ); - else - */ - return( "" ); + 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 ); } // ------------------------------------------------------------------------- -/* TODO -QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget:: -_FindItemInTree( const std::string& name ) const +bool cpExtensions::QT::SimpleMPRWidget:: +IsWindowLevelImageActor( const std::string& name ) const { - QList< QTreeWidgetItem* > items = - this->m_UI->LoadedData->findItems( - name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive - ); - if( items.size( ) > 0 ) - return( items[ 0 ] ); - else - return( NULL ); + return( this->m_XImage->IsWindowLevelImageActor( name ) ); } // ------------------------------------------------------------------------- -QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget:: -_UpdateTreeItem( const std::string& name, const std::string& parent ) +bool cpExtensions::QT::SimpleMPRWidget:: +IsLUTImageActor( const std::string& name ) const { - // Update tree view - QTreeWidgetItem* new_item = NULL; - if( parent != "" ) - { - QTreeWidgetItem* parent_item = this->_FindItemInTree( parent ); - if( parent_item != NULL ) - { - QTreeWidgetItem* old_item = this->_FindItemInTree( name ); - if( old_item == NULL ) - { - new_item = - new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) ); - parent_item->setExpanded( true ); + return( this->m_XImage->IsLUTImageActor( name ) ); +} - } // fi +// ------------------------------------------------------------------------- +bool cpExtensions::QT::SimpleMPRWidget:: +Is3DActor( const std::string& name ) const +{ + return( + this->m_XImage->Is3DActor( name ) || this->m_3DView->Is3DActor( name ) + ); +} - } // fi - } - else - { - new_item = new QTreeWidgetItem( - ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) ) - ); - this->m_UI->LoadedData->addTopLevelItem( new_item ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +GetScalarRange( const std::string& name, double r[ 2 ] ) const +{ + this->m_XImage->GetScalarRange( name, r ); +} - } // fi - return( new_item ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +GetWindowLevel( const std::string& name, double wl[ 2 ] ) const +{ + this->m_XImage->GetWindowLevel( name, wl ); } -*/ // ------------------------------------------------------------------------- -/* - void cpExtensions::QT::SimpleMPRWidget:: - _Add3DActor( vtkProp3D* prop ) - { - vtkRenderer* ren = - this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( ); - if( ren == NULL ) - return; - ren->AddActor( prop ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); - } -*/ +double cpExtensions::QT::SimpleMPRWidget:: +GetWindow( const std::string& name ) const +{ + return( this->m_XImage->GetWindow( name ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLevel( const std::string& name ) const +{ + return( this->m_XImage->GetLevel( name ) ); +} + +// ------------------------------------------------------------------------- +char cpExtensions::QT::SimpleMPRWidget:: +GetImageInterpolation( const std::string& name ) const +{ + return( this->m_XImage->GetImageInterpolation( name ) ); +} // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_SyncBottom( int a, int b ) +GetColor( const std::string& name, double& r, double& g, double& b ) const { - this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) ); + this->m_XImage->GetColor( name, r, g, b ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetOpacity( const std::string& name ) const +{ + return( this->m_XImage->GetOpacity( name ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetPointSize( const std::string& name ) const +{ + return( this->m_XImage->GetPointSize( name ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLineWidth( const std::string& name ) const +{ + return( this->m_XImage->GetLineWidth( name ) ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::QT::SimpleMPRWidget:: +GetRepresentation( const std::string& name ) const +{ + return( this->m_XImage->GetRepresentation( name ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: -_SyncTop( int a, int b ) +SetScalarRange( const std::string& name, double r[ 2 ] ) { - this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) ); + this->m_XImage->SetScalarRange( name, r ); + this->m_YImage->SetScalarRange( name, r ); + this->m_ZImage->SetScalarRange( name, r ); + this->m_3DView->SetScalarRange( name, r ); } // ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget::PolyDataActor:: -PolyDataActor( ) - : Mesh( NULL ), - Normals( NULL ), - Stripper( NULL ), - Mapper( NULL ), - Actor( NULL ) +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 ); } // ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget::PolyDataActor:: -~PolyDataActor( ) +void cpExtensions::QT::SimpleMPRWidget:: +SetWindowLevel( const std::string& name, double wl[ 2 ] ) { - if( this->Actor != NULL ) this->Actor->Delete( ); - if( this->Mapper != NULL ) this->Mapper->Delete( ); - if( this->Stripper != NULL ) this->Stripper->Delete( ); - if( this->Normals != NULL ) this->Normals->Delete( ); + 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::PolyDataActor:: -Configure( vtkPolyData* pd ) +void cpExtensions::QT::SimpleMPRWidget:: +SetWindowLevel( const std::string& name, double w, double l ) { - if( pd == NULL ) - return; + 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 ); +} - double range[ 2 ]; - pd->GetScalarRange( range ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetWindow( const std::string& name, double w ) +{ + this->m_XImage->SetWindow( name, w ); + this->m_YImage->SetWindow( name, w ); + this->m_ZImage->SetWindow( name, w ); + this->m_3DView->SetWindow( name, w ); +} - this->Normals = vtkPolyDataNormals::New( ); - this->Stripper = vtkStripper::New( ); - this->Mapper = vtkPolyDataMapper::New( ); - this->Actor = vtkQuadricLODActor::New( ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetLevel( const std::string& name, double l ) +{ + this->m_XImage->SetLevel( name, l ); + this->m_YImage->SetLevel( name, l ); + this->m_ZImage->SetLevel( name, l ); + this->m_3DView->SetLevel( name, l ); +} - this->Mesh = pd; - this->Normals->SetInputData( pd ); - this->Normals->SetFeatureAngle( 60.0 ); - this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) ); - this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) ); - this->Mapper->UseLookupTableScalarRangeOff( ); - this->Mapper->SetScalarRange( - range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ] - ); - this->Actor->SetMapper( this->Mapper ); - this->Actor->GetProperty( )->SetPointSize( 10 ); - this->Actor->DeferLODConstructionOff( ); +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetImageInterpolation( const std::string& name, char i ) +{ + this->m_XImage->SetImageInterpolation( name, i ); + this->m_YImage->SetImageInterpolation( name, i ); + this->m_ZImage->SetImageInterpolation( name, i ); + this->m_3DView->SetImageInterpolation( name, i ); } // ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget::Data:: -Data( ) +void cpExtensions::QT::SimpleMPRWidget:: +SetColor( const std::string& name, double r, double g, double b ) { - this->Tag = Data::IMAGE; - this->Image = NULL; + 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 ); } // ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget::Data:: -~Data( ) +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 ); } // ------------------------------------------------------------------------- -cpExtensions::QT::SimpleMPRWidget:: -Data& cpExtensions::QT::SimpleMPRWidget::Data:: -operator=( const Data& data ) +void cpExtensions::QT::SimpleMPRWidget:: +SetPointSize( const std::string& name, double s ) +{ + 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->Tag = data.Tag; - if( this->Tag == Data::IMAGE ) - this->Image = data.Image; - else if( this->Tag == Data::MESH ) - this->Mesh = data.Mesh; - return( *this ); + this->m_XImage->SetLineWidth( name, w ); + this->m_YImage->SetLineWidth( name, w ); + this->m_ZImage->SetLineWidth( name, w ); + this->m_3DView->SetLineWidth( name, w ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget::Data:: -SetImageData( vtkImageData* data ) +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToPoints( const std::string& name ) { - this->Tag = Data::IMAGE; - this->Image = data; + this->m_XImage->SetRepresentationToPoints( name ); + this->m_YImage->SetRepresentationToPoints( name ); + this->m_ZImage->SetRepresentationToPoints( name ); + this->m_3DView->SetRepresentationToPoints( name ); } // ------------------------------------------------------------------------- -void cpExtensions::QT::SimpleMPRWidget::Data:: -SetPolyData( vtkPolyData* data ) +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToSurface( const std::string& name ) { - this->Tag = Data::MESH; - this->Mesh.Configure( data ); + this->m_XImage->SetRepresentationToSurface( name ); + this->m_YImage->SetRepresentationToSurface( name ); + this->m_ZImage->SetRepresentationToSurface( name ); + this->m_3DView->SetRepresentationToSurface( name ); } // ------------------------------------------------------------------------- -vtkImageData* cpExtensions::QT::SimpleMPRWidget::Data:: -GetImage( ) +void cpExtensions::QT::SimpleMPRWidget:: +SetRepresentationToWireframe( const std::string& name ) { - if( this->Tag == Data::IMAGE ) - return( this->Image ); - else - return( NULL ); + this->m_XImage->SetRepresentationToWireframe( name ); + this->m_YImage->SetRepresentationToWireframe( name ); + this->m_ZImage->SetRepresentationToWireframe( name ); + this->m_3DView->SetRepresentationToWireframe( name ); } // ------------------------------------------------------------------------- -vtkPolyData* cpExtensions::QT::SimpleMPRWidget::Data:: -GetMesh( ) +void cpExtensions::QT::SimpleMPRWidget:: +_SyncBottom( int a, int b ) { - if( this->Tag == Data::MESH ) - return( this->Mesh.Mesh ); - else - return( NULL ); + this->m_UI->Bottom->setSizes( this->m_UI->Top->sizes( ) ); } // ------------------------------------------------------------------------- -vtkProp* cpExtensions::QT::SimpleMPRWidget::Data:: -GetMeshActor( ) +void cpExtensions::QT::SimpleMPRWidget:: +_SyncTop( int a, int b ) { - if( this->Tag == Data::MESH ) - return( this->Mesh.Actor ); - else - return( NULL ); + this->m_UI->Top->setSizes( this->m_UI->Bottom->sizes( ) ); } #endif // cpExtensions_QT4