X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FIO%2FImageReader.cxx;h=900940bfcaf97c7a9d0e22149e1a56065d55b700;hb=7e29f3aec097ba1bff1894fed6eb1094276c5b72;hp=d28b129dec2ebfa4bbac4598d9dec6fd39f25453;hpb=e3bf0f6ea82aedbb6d703a7bf54a655d4d53e8d1;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index d28b129..900940b 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -4,59 +4,20 @@ #include #include -#ifdef cpPlugins_Interface_QT4 -#include -#endif // cpPlugins_Interface_QT4 - -// ------------------------------------------------------------------------- -bool cpPlugins::IO::ImageReader:: -ExecConfigurationDialog( QWidget* parent ) -{ - bool r = false; - -#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( name.c_str( ) ) ); - dialog.setNameFilters( filters ); - 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; - - } // fi - -#endif // cpPlugins_Interface_QT4 - - return( r ); -} - // ------------------------------------------------------------------------- cpPlugins::IO::ImageReader:: ImageReader( ) : Superclass( ) { - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsStringList( "FileNames" ); - this->m_Parameters->ConfigureAsBool( "VectorType", false ); + this->m_Parameters->ConfigureAsOpenFileNameList( "FileNames" ); + this->m_Parameters->ConfigureAsBool( "VectorType" ); + this->m_Parameters->SetBool( "VectorType", false ); + this->m_Parameters->SetAcceptedFileExtensions( + "FileNames", + "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)" + ); } // ------------------------------------------------------------------------- @@ -70,8 +31,7 @@ std::string cpPlugins::IO::ImageReader:: _GenerateData( ) { // Get filenames - TStringList names; - this->m_Parameters->GetStringList( names, "FileNames" ); + TStringList names = this->m_Parameters->GetOpenFileNameList( "FileNames" ); std::string r = ""; if( names.size( ) >= 1 ) @@ -104,7 +64,7 @@ _GenerateData( ) r = "ImageReader: Could not CreateImageIO for \"" + names[ 0 ] + "\""; } else - r = "No image files given"; + r = "ImageReader: No image files given"; return( r ); } @@ -357,11 +317,7 @@ template< class I > std::string cpPlugins::IO::ImageReader:: _RealGD( const TStringList& names ) { - cpPlugins::Interface::Image* out = - this->GetOutput< cpPlugins::Interface::Image >( "Output" ); - if( out == NULL ) - return( "ImageReader: No output object properly created." ); - + auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); std::string r = ""; if( names.size( ) == 1 ) { @@ -372,14 +328,12 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - out->SetITK< I >( reader->GetOutput( ) ); - out->SetName( names[ 0 ] ); + out->SetITK( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITK< I >( NULL ); - out->SetName( "" ); + out->SetITK( NULL ); } // yrt } @@ -393,14 +347,12 @@ _RealGD( const TStringList& names ) try { reader->Update( ); - out->SetITK< I >( reader->GetOutput( ) ); - out->SetName( names[ 0 ] ); + out->SetITK( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITK< I >( NULL ); - out->SetName( "" ); + out->SetITK( NULL ); } // yrt }