X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FIO%2FImageReader.cxx;h=fc747eb7348f910d36a04f936a10a9f8ee43fce4;hb=0bb74f9a32de4ce1559973ebf72fda495aa2c587;hp=60b33b67998b0961d7c04b934c87f9a725fca907;hpb=e9143845b476fc8b86c1706fb140ebee770a650b;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index 60b33b6..fc747eb 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -1,8 +1,6 @@ #include "ImageReader.h" #include -#include - #include #include @@ -18,11 +16,21 @@ ExecConfigurationDialog( QWidget* parent ) #ifdef cpPlugins_Interface_QT4 + QStringList filters; + filters + << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)" + << "Any files (*)"; + + std::vector< std::string > names; + this->m_Parameters->GetStringList( names, "FileNames" ); + std::string name = ( names.size( ) > 0 )? names[ 0 ]: "."; + // 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 (*)" ) ); + dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) ); + dialog.setNameFilters( filters ); + dialog.setAcceptMode( QFileDialog::AcceptOpen ); if( dialog.exec( ) ) { QStringList names = dialog.selectedFiles( ); @@ -46,8 +54,7 @@ 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 ); @@ -352,7 +359,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." ); @@ -367,35 +374,34 @@ _RealGD( const TStringList& names ) { reader->Update( ); out->SetITK< I >( reader->GetOutput( ) ); + out->SetName( names[ 0 ] ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); out->SetITK< I >( NULL ); + out->SetName( "" ); } // yrt } 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( names[ 0 ] ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); out->SetITK< I >( NULL ); + out->SetName( "" ); } // yrt }