From: Leonardo Florez-Valencia Date: Sat, 26 Sep 2015 11:12:50 +0000 (+0200) Subject: ... X-Git-Tag: v0.1~360^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ecd4c9efbb1db3f9210699f281694dc7c32ac9de;p=cpPlugins.git ... --- diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 412b9ed..24cfd38 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -47,6 +47,10 @@ ImageMPR::ImageMPR( QWidget* parent ) this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ), this, SLOT( _triggered_actionOpenInputImage( ) ) ); + QObject::connect( + this->m_UI->actionOpenSegmentation, SIGNAL( triggered( ) ), + this, SLOT( _triggered_actionOpenSegmentation( ) ) + ); QObject::connect( this->m_UI->actionOpenInputPolyData, SIGNAL( triggered( ) ), this, SLOT( _triggered_actionOpenInputPolyData( ) ) @@ -227,6 +231,75 @@ _triggered_actionOpenInputImage( ) ); } +// ------------------------------------------------------------------------- +void ImageMPR:: +_triggered_actionOpenSegmentation( ) +{ + // Show dialog and check if it was accepted + QFileDialog dialog( this ); + dialog.setFileMode( QFileDialog::ExistingFiles ); + dialog.setDirectory( tr( "." ) ); + dialog.setNameFilter( + tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" ) + ); + dialog.setDefaultSuffix( tr( "mhd" ) ); + if( !( dialog.exec( ) ) ) + return; + + this->m_InputImage = NULL; + + // Get a reader from plugins + TPluginFilter::Pointer reader = + this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass ); + + // Configure reader + TParameters reader_params = reader->GetDefaultParameters( ); + QStringList q_fnames = dialog.selectedFiles( ); + QStringList::const_iterator qIt = q_fnames.begin( ); + for( ; qIt != q_fnames.end( ); ++qIt ) + reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) ); + reader->SetParameters( reader_params ); + + // Execute and get error message, if any + QApplication::setOverrideCursor( Qt::WaitCursor ); + this->setEnabled( false ); + std::string err = reader->Update( ); + QApplication::restoreOverrideCursor( ); + this->setEnabled( true ); + + // Assign fresh image, if any + if( err == "" ) + { + this->m_InputSegmentation = reader->GetOutput< TPluginImage >( 0 ); + reader->DisconnectOutputs( ); + if( this->m_InputSegmentation.IsNotNull( ) ) + { + vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( ); + if( vtk_id != NULL ) + { + /* + this->m_MPRObjects->SetImage( vtk_id ); + this->m_MPRObjects->ResetCameras( ); + this->m_MPRObjects->RenderAll( ); + */ + } + else + QMessageBox::critical( + this, + tr( "Error message" ), + tr( "Read image does not have a valid VTK converter." ) + ); + + } // fi + } + else + QMessageBox::critical( + this, + tr( "Error reading single image" ), + tr( err.c_str( ) ) + ); +} + // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionOpenInputPolyData( ) diff --git a/appli/ImageMPR/ImageMPR.h b/appli/ImageMPR/ImageMPR.h index ba05de9..1b56805 100644 --- a/appli/ImageMPR/ImageMPR.h +++ b/appli/ImageMPR/ImageMPR.h @@ -55,6 +55,7 @@ protected: private slots: void _triggered_actionOpenPlugins( ); void _triggered_actionOpenInputImage( ); + void _triggered_actionOpenSegmentation( ); void _triggered_actionOpenInputPolyData( ); void _triggered_actionImageToImage( ); void _triggered_actionImageToMesh( ); @@ -75,6 +76,7 @@ private: // Real data TPluginImage::Pointer m_InputImage; + TPluginImage::Pointer m_InputSegmentation; TPluginMesh::Pointer m_InputMesh; // Visualization stuff diff --git a/appli/ImageMPR/ImageMPR.ui b/appli/ImageMPR/ImageMPR.ui index 31ada1d..8e0ee04 100644 --- a/appli/ImageMPR/ImageMPR.ui +++ b/appli/ImageMPR/ImageMPR.ui @@ -101,7 +101,7 @@ 0 0 718 - 25 + 27 @@ -111,6 +111,7 @@ + @@ -169,6 +170,11 @@ dasdasd + + + Open segmentation + +