X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FIO%2FImageReader.cxx;h=e18c98709f58f2654e9b6f431a91b07c94941512;hb=e992c2468610352a34187d9180e2e8f3fd3a6e68;hp=48deb00a14d2f7fa5648465c8a435ec2b5def9a1;hpb=2553991938011b002691361f0ed4ae95a552a686;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index 48deb00..e18c987 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -1,56 +1,66 @@ #include "ImageReader.h" #include -#include - #include #include -#ifdef cpPlugins_Interface_QT4 -#include -#endif // cpPlugins_Interface_QT4 +/* TODO + #ifdef cpPlugins_Interface_QT4 + #include + #endif // cpPlugins_Interface_QT4 -// ------------------------------------------------------------------------- -bool cpPlugins::IO::ImageReader:: -ExecConfigurationDialog( QWidget* parent ) -{ - bool r = false; + // ------------------------------------------------------------------------- + cpPlugins::IO::ImageReader:: + DialogResult cpPlugins::IO::ImageReader:: + ExecConfigurationDialog( QWidget* parent ) + { + DialogResult r = Self::DialogResult_Cancel; -#ifdef cpPlugins_Interface_QT4 + #ifdef cpPlugins_Interface_QT4 - // Show dialog and check if it was accepted - QFileDialog dialog( parent ); - dialog.setFileMode( QFileDialog::ExistingFiles ); - dialog.setDirectory( QFileDialog::tr( "." ) ); - dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) ); - if( dialog.exec( ) ) - { - QStringList names = dialog.selectedFiles( ); - QStringList::const_iterator qIt = names.begin( ); - for( ; qIt != names.end( ); ++qIt ) - this->m_Parameters->AddToStringList( - "FileNames", qIt->toStdString( ) - ); - this->m_Parameters->SetBool( "VectorType", false ); - r = true; + QStringList filters; + filters + << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)" + << "Any files (*)"; - } // fi + TStringList names = this->m_Parameters->GetFileNameList( "FileNames" ); + std::string name = ( names.size( ) > 0 )? names[ 0 ]: "."; -#endif // cpPlugins_Interface_QT4 + // Show dialog and check if it was accepted + QFileDialog dialog( parent ); + dialog.setFileMode( QFileDialog::ExistingFiles ); + dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) ); + dialog.setNameFilters( filters ); + dialog.setAcceptMode( QFileDialog::AcceptOpen ); + if( dialog.exec( ) ) + { + QStringList names = dialog.selectedFiles( ); + QStringList::const_iterator qIt = names.begin( ); + for( ; qIt != names.end( ); ++qIt ) + this->m_Parameters->AddToStringList( + "FileNames", qIt->toStdString( ) + ); + this->m_Parameters->SetBool( "VectorType", false ); + r = Self::DialogResult_NoModal; - return( r ); -} + } // fi + + #endif // cpPlugins_Interface_QT4 + + return( r ); + } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::ImageReader:: ImageReader( ) : Superclass( ) { - this->SetNumberOfOutputs( 1 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); + this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsStringList( "FileNames" ); - this->m_Parameters->ConfigureAsBool( "VectorType", false ); + this->m_Parameters->ConfigureAsFileNameList( "FileNames" ); + this->m_Parameters->ConfigureAsBool( "VectorType" ); + this->m_Parameters->SetBool( "VectorType", false ); } // ------------------------------------------------------------------------- @@ -64,8 +74,7 @@ std::string cpPlugins::IO::ImageReader:: _GenerateData( ) { // Get filenames - TStringList names; - this->m_Parameters->GetStringList( names, "FileNames" ); + TStringList names = this->m_Parameters->GetFileNameList( "FileNames" ); std::string r = ""; if( names.size( ) >= 1 ) @@ -98,7 +107,7 @@ _GenerateData( ) r = "ImageReader: Could not CreateImageIO for \"" + names[ 0 ] + "\""; } else - r = "No image files given"; + r = "ImageReader: No image files given"; return( r ); } @@ -352,7 +361,7 @@ std::string cpPlugins::IO::ImageReader:: _RealGD( const TStringList& names ) { cpPlugins::Interface::Image* out = - this->GetOutput< cpPlugins::Interface::Image >( 0 ); + this->GetOutput< cpPlugins::Interface::Image >( "Output" ); if( out == NULL ) return( "ImageReader: No output object properly created." ); @@ -380,20 +389,15 @@ _RealGD( const TStringList& names ) else if( names.size( ) > 1 ) { // Read image series - std::set< std::string > ordered_names; - for( unsigned int i = 0; i < names.size( ); ++i ) - ordered_names.insert( names[ i ] ); - typedef itk::ImageSeriesReader< I > _MR; _MR* reader = this->_CreateITK< _MR >( ); - std::set< std::string >::const_iterator fnIt = ordered_names.begin( ); - for( ; fnIt != ordered_names.end( ); ++fnIt ) - reader->AddFileName( *fnIt ); + for( unsigned int i = 0; i < names.size( ); ++i ) + reader->AddFileName( names[ i ] ); try { reader->Update( ); out->SetITK< I >( reader->GetOutput( ) ); - out->SetName( *( ordered_names.begin( ) ) ); + out->SetName( names[ 0 ] ); } catch( itk::ExceptionObject& err ) {