]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/IO/ImageReader.cxx
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Plugins / IO / ImageReader.cxx
index 38739df3807d90b273cea6bad1a9a79b76f7211b..fec094476ad212fc25a3b08bf0c4eca793dc745c 100644 (file)
@@ -6,6 +6,42 @@
 #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( )
@@ -332,25 +368,17 @@ _RealGD( const TStringList& names )
   {
     // Read single image
     typedef itk::ImageFileReader< I > _SR;
-    _SR* reader =
-      dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) );
-    if( reader == NULL )
-    {
-      this->m_RealProcessObject = _SR::New( );
-      reader =
-        dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) );
-
-    } // fi
+    _SR* reader = this->_CreateITK< _SR >( );
     reader->SetFileName( names[ 0 ] );
     try
     {
       reader->Update( );
-      out->SetITKImage< I >( reader->GetOutput( ) );
+      out->SetITK< I >( reader->GetOutput( ) );
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
-      out->SetITKImage< I >( NULL );
+      out->SetITK< I >( NULL );
 
     } // yrt
   }
@@ -362,29 +390,19 @@ _RealGD( const TStringList& names )
       ordered_names.insert( names[ i ] );
 
     typedef itk::ImageSeriesReader< I > _MR;
-    _MR* reader =
-      dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) );
-    if( reader == NULL )
-    {
-      this->m_RealProcessObject = _MR::New( );
-      reader =
-        dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) );
-
-    } // fi
+    _MR* reader = this->_CreateITK< _MR >( );
     std::set< std::string >::const_iterator fnIt = ordered_names.begin( );
     for( ; fnIt != ordered_names.end( ); ++fnIt )
-    {
       reader->AddFileName( *fnIt );
-    }
     try
     {
       reader->Update( );
-      out->SetITKImage< I >( reader->GetOutput( ) );
+      out->SetITK< I >( reader->GetOutput( ) );
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
-      out->SetITKImage< I >( NULL );
+      out->SetITK< I >( NULL );
 
     } // yrt
   }