#include "ImageReader.h"
#include <cpPlugins/Interface/Image.h>
-#include <set>
-
#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
-
-// -------------------------------------------------------------------------
-bool cpPlugins::IO::ImageReader::
-ExecConfigurationDialog( QWidget* parent )
-{
- bool r = false;
-
-#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( ) )
- {
- this->m_Parameters = this->m_DefaultParameters;
- QStringList names = dialog.selectedFiles( );
- QStringList::const_iterator qIt = names.begin( );
- for( ; qIt != names.end( ); ++qIt )
- this->m_Parameters.AddValueToStringList(
- "FileNames", qIt->toStdString( )
- );
- this->m_Parameters.SetValueAsBool( "VectorType", false );
- r = true;
-
- } // fi
-
-#endif // cpPlugins_Interface_QT4
-
- return( r );
-}
-
// -------------------------------------------------------------------------
cpPlugins::IO::ImageReader::
ImageReader( )
: Superclass( )
{
- this->SetNumberOfOutputs( 1 );
- this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
- using namespace cpPlugins::Interface;
- this->m_DefaultParameters.Configure( Parameters::StringList, "FileNames" );
- this->m_DefaultParameters.Configure( Parameters::Bool, "VectorType" );
- this->m_DefaultParameters.SetValueAsBool( "VectorType", false );
- this->m_Parameters = this->m_DefaultParameters;
+ 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)"
+ );
}
// -------------------------------------------------------------------------
_GenerateData( )
{
// Get filenames
- TStringList names;
- this->m_Parameters.GetValueAsStringList( names, "FileNames" );
+ TStringList names = this->m_Parameters->GetOpenFileNameList( "FileNames" );
std::string r = "";
if( names.size( ) >= 1 )
r = "ImageReader: Could not CreateImageIO for \"" + names[ 0 ] + "\"";
}
else
- r = "No image files given";
+ r = "ImageReader: No image files given";
return( r );
}
std::string cpPlugins::IO::ImageReader::
_GD1( const TStringList& names )
{
- if( this->m_Parameters.GetValueAsBool( "VectorType" ) )
+ if( this->m_Parameters->GetBool( "VectorType" ) )
return( this->_RealGD< itk::VectorImage< P, D > >( names ) );
else
return( this->_RealGD< itk::Image< P, D > >( names ) );
std::string cpPlugins::IO::ImageReader::
_RealGD( const TStringList& names )
{
- cpPlugins::Interface::Image* out =
- this->GetOutput< cpPlugins::Interface::Image >( 0 );
+ auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
if( out == NULL )
return( "ImageReader: No output object properly created." );
{
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
}