]> Creatis software - cpPlugins.git/commitdiff
NOT YET STABLE... just to tired to continue today
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 23 Oct 2015 22:57:30 +0000 (17:57 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 23 Oct 2015 22:57:30 +0000 (17:57 -0500)
lib/cpPlugins/Interface/BaseMPRWindow.cxx
lib/cpPlugins/Interface/BaseMPRWindow.h
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Interface/ParametersQtDialog.h
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx

index 5f64d36a34c90e58b24ef983964997846398cf26..4cf552c356248086f525fdb9330b4fc3561ab40f 100644 (file)
@@ -287,7 +287,6 @@ ExecuteFilter(
         return;
 
       std::string err = filter->Update( );
-      std::cout << "ERR: " << err << std::endl;
       if( err == "" )
       {
         this->m_Images[ "Segmentation" ] =
index 3395d21c25c6963cffe40c7d994092e3adc5c926..94c5341d48b9b9ce7871876bbec758cd1132cc49 100644 (file)
@@ -4,6 +4,8 @@
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Config.h>
 
+#error ACA VOY
+
 #ifdef cpPlugins_Interface_QT4
 
 #include <map>
@@ -52,8 +54,6 @@ namespace cpPlugins
       typedef TMPRObjects::TKeyCommand         TKeyCommand;
       typedef TMPRObjects::TVoidCommand        TVoidCommand;
 
-      typedef std::map< std::string, TImage::Pointer >          TImages;
-      typedef std::map< std::string, TMesh::Pointer >           TMeshes;
       typedef std::set< std::string >           TOrderedStringContainer;
       typedef std::map< std::string, std::set< std::string > > TFilters;
 
@@ -67,43 +67,47 @@ namespace cpPlugins
         );
 
       inline void Block( )
-        {
-          QApplication::setOverrideCursor( Qt::WaitCursor );
-          this->setEnabled( false );
-        }
+      {
+        QApplication::setOverrideCursor( Qt::WaitCursor );
+        this->setEnabled( false );
+      }
       inline void Unblock( )
-        {
-          QApplication::restoreOverrideCursor( );
-          this->setEnabled( true );
-        }
+      {
+        QApplication::restoreOverrideCursor( );
+        this->setEnabled( true );
+      }
 
       bool LoadPlugins( const std::string& fname );
       void LoadPlugins( );
-      std::string LoadImage( );
-      std::string LoadDicomSeries( );
-      std::string LoadMesh( );
-
-      void ExecuteFilter(
-        const std::string& name,
-        const std::string& input_id,
-        const std::string& output_id
-        );
 
-      TProcessObject::Pointer CreateFilter( const std::string& name )
+      // Data IO
+      std::string ReadImage( TImage::Pointer& image );
+      std::string ReadDicomSeries( TImage::Pointer& image );
+      std::string ReadMesh( TMesh::Pointer& mesh );
+
+      std::string WriteImage( TImage* image );
+      std::string WriteMesh( TMesh* mesh );
+
+      /* TODO
+         void ExecuteFilter(
+         const std::string& name,
+         const std::string& input_id,
+         const std::string& output_id
+         );
+      */
+
+      // Filter acces
+      bool CreateFilter(
+        TProcessObject::Pointer& filter, const std::string& name
+        )
       {
         return( this->m_Interface.CreateProcessObject( name ) );
       }
 
-      void AddImage( const std::string& name, TImage* image );
-      TImage* GetImage( std::string& name ) const
-      {
-        TImages::const_iterator i = this->m_Images.find( name );
-        if( i != this->m_Images.end( ) )
-          return( i->second );
-        else
-          return( NULL );
-      }
-
+      
+      // Somme visualization accessors
+      bool ShowImage( TImage* image, bool is_primal = true );
+      bool ShowMesh( TMesh* mesh );
       double GetWindow( ) const
       {
         return( this->m_MPRObjects->GetWindow( ) );
@@ -113,7 +117,9 @@ namespace cpPlugins
         return( this->m_MPRObjects->GetLevel( ) );
       }
 
-      void ClearAll( );
+      /* TODO
+         void ClearAll( );
+      */
 
     protected:
       void _UpdatePlugins( );
@@ -136,9 +142,6 @@ namespace cpPlugins
       TProcessObject::Pointer m_MeshWriter;
       TProcessObject::Pointer m_DicomSeriesReader;
       TFilters m_Filters;
-
-      TImages m_Images;
-      TMeshes m_Meshes;
     };
 
   } // ecapseman
index 80d73a265f5499e0d8445ca868f471f6455ed6cd..5a669832393aa1cf8321e1d8fc576244383ebabb 100644 (file)
@@ -230,30 +230,30 @@ syncParameters( )
 
 
 
-    /* TODO
-       enum Type
-       {
-       Index,
-       Point,
-       StringList,
-       BoolList,
-       IntList,
-       UintList,
-       IndexList,
-       PointList,
-       Choices,
-       NoType
-       };
-    */
+/* TODO
+   enum Type
+   {
+   Index,
+   Point,
+   StringList,
+   BoolList,
+   IntList,
+   UintList,
+   IndexList,
+   PointList,
+   Choices,
+   NoType
+   };
+*/
 /*
-bool cpPlugins::Interface::
-ParametersQtDialog(
+  bool cpPlugins::Interface::
+  ParametersQtDialog(
   Parameters* parameters, const std::string& title, QWidget* parent
   )
-{
+  {
   // Create dialog with a simple layout
   QDialog* dlg = new QDialog( parent );
-  dlg->setWindowFlags( Qt::FramelessWindowHint ); 
+  dlg->setWindowFlags( Qt::FramelessWindowHint );
   dlg->setWindowFlags( Qt::WindowTitleHint );
   QGridLayout* gridLayout = new QGridLayout( dlg );
   QVBoxLayout* verticalLayout = new QVBoxLayout( );
@@ -269,172 +269,172 @@ ParametersQtDialog(
   std::vector< std::string >::const_iterator nIt = names.begin( );
   for( ; nIt != names.end( ); ++nIt )
   {
-    Parameters::Type pt = this->m_Parameters->GetType( *nIt );
+  Parameters::Type pt = this->m_Parameters->GetType( *nIt );
 
-    QWidget* w_input = NULL;
-    if( pt == Parameters::String )
-    {
-      QLineEdit* v_string = new QLineEdit( dlg );
-      v_string->setText( "Enter some text!!!" );
-      w_input = v_string;
-    }
-    else if( pt == Parameters::Bool )
-    {
-      QCheckBox* v_bool = new QCheckBox( dlg );
-      v_bool->setText( "[ON/OFF]" );
-      v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
-      w_input = v_bool;
-    }
-    else if( pt == Parameters::Uint )
-    {
-      QSpinBox* v_uint = new QSpinBox( dlg );
-      v_uint->setMinimum( 0 );
-      v_uint->setMaximum( std::numeric_limits< int >::max( ) );
-      v_uint->setValue( this->m_Parameters->GetUint( *nIt ) );
-      w_input = v_uint;
-    }
-    else if( pt == Parameters::Int )
-    {
-      QSpinBox* v_int = new QSpinBox( dlg );
-      v_int->setMinimum( -std::numeric_limits< int >::max( ) );
-      v_int->setMaximum(  std::numeric_limits< int >::max( ) );
-      v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
-      w_input = v_int;
-    }
-    else if( pt == Parameters::Real )
-    {
-      QDoubleSpinBox* v_double = new QDoubleSpinBox( dlg );
-      v_double->setDecimals( 3 );
-      v_double->setMinimum( -std::numeric_limits< double >::max( ) );
-      v_double->setMaximum(  std::numeric_limits< double >::max( ) );
-      v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
-      w_input = v_double;
-    }
-    else if(
-      pt == Parameters::StringList ||
-      pt == Parameters::IntList ||
-      pt == Parameters::UintList ||
-      pt == Parameters::RealList
-      )
-    {
-      cpPlugins::Interface::ParametersListWidget* l_double =
-        new cpPlugins::Interface::ParametersListWidget( *nIt, dlg );
-      w_input = l_double;
+  QWidget* w_input = NULL;
+  if( pt == Parameters::String )
+  {
+  QLineEdit* v_string = new QLineEdit( dlg );
+  v_string->setText( "Enter some text!!!" );
+  w_input = v_string;
+  }
+  else if( pt == Parameters::Bool )
+  {
+  QCheckBox* v_bool = new QCheckBox( dlg );
+  v_bool->setText( "[ON/OFF]" );
+  v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
+  w_input = v_bool;
+  }
+  else if( pt == Parameters::Uint )
+  {
+  QSpinBox* v_uint = new QSpinBox( dlg );
+  v_uint->setMinimum( 0 );
+  v_uint->setMaximum( std::numeric_limits< int >::max( ) );
+  v_uint->setValue( this->m_Parameters->GetUint( *nIt ) );
+  w_input = v_uint;
+  }
+  else if( pt == Parameters::Int )
+  {
+  QSpinBox* v_int = new QSpinBox( dlg );
+  v_int->setMinimum( -std::numeric_limits< int >::max( ) );
+  v_int->setMaximum(  std::numeric_limits< int >::max( ) );
+  v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
+  w_input = v_int;
+  }
+  else if( pt == Parameters::Real )
+  {
+  QDoubleSpinBox* v_double = new QDoubleSpinBox( dlg );
+  v_double->setDecimals( 3 );
+  v_double->setMinimum( -std::numeric_limits< double >::max( ) );
+  v_double->setMaximum(  std::numeric_limits< double >::max( ) );
+  v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
+  w_input = v_double;
+  }
+  else if(
+  pt == Parameters::StringList ||
+  pt == Parameters::IntList ||
+  pt == Parameters::UintList ||
+  pt == Parameters::RealList
+  )
+  {
+  cpPlugins::Interface::ParametersListWidget* l_double =
+  new cpPlugins::Interface::ParametersListWidget( *nIt, dlg );
+  w_input = l_double;
 
-    } // fi
+  } // fi
 
     // Ok, a representation was created
     if( w_input != NULL )
     {
-      w_input->setObjectName( QString( nIt->c_str( ) ) );
+    w_input->setObjectName( QString( nIt->c_str( ) ) );
 
-      QHBoxLayout* horizontalLayout = new QHBoxLayout( );
-      QLabel* label = new QLabel( dlg );
-      label->setText( QString( nIt->c_str( ) ) );
-      horizontalLayout->addWidget( label );
-      horizontalLayout->addWidget( w_input );
-      verticalLayout->addLayout( horizontalLayout );
+    QHBoxLayout* horizontalLayout = new QHBoxLayout( );
+    QLabel* label = new QLabel( dlg );
+    label->setText( QString( nIt->c_str( ) ) );
+    horizontalLayout->addWidget( label );
+    horizontalLayout->addWidget( w_input );
+    verticalLayout->addLayout( horizontalLayout );
 
     } // fi
 
-  } // rof
+    } // rof
 
-  // Add buttons
-  QDialogButtonBox* bb = new QDialogButtonBox(
+    // Add buttons
+    QDialogButtonBox* bb = new QDialogButtonBox(
     QDialogButtonBox::Ok | QDialogButtonBox::Cancel
     );
-  QObject::connect( bb, SIGNAL( accepted( ) ), dlg, SLOT( accept( ) ) );
-  QObject::connect( bb, SIGNAL( rejected( ) ), dlg, SLOT( reject( ) ) );
-  verticalLayout->addWidget( bb );
-  gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
-
-  // Execute
-  QMetaObject::connectSlotsByName( dlg );
-  if( !( dlg->exec( ) ) )
+    QObject::connect( bb, SIGNAL( accepted( ) ), dlg, SLOT( accept( ) ) );
+    QObject::connect( bb, SIGNAL( rejected( ) ), dlg, SLOT( reject( ) ) );
+    verticalLayout->addWidget( bb );
+    gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
+
+    // Execute
+    QMetaObject::connectSlotsByName( dlg );
+    if( !( dlg->exec( ) ) )
     return( false );
 
-  // Get values back
-  nIt = names.begin( );
-  for( ; nIt != names.end( ); ++nIt )
-  {
+    // Get values back
+    nIt = names.begin( );
+    for( ; nIt != names.end( ); ++nIt )
+    {
     Parameters::Type pt = this->m_Parameters->GetType( *nIt );
     if( pt == Parameters::String )
     {
-      QLineEdit* v_string = dlg->findChild< QLineEdit* >( nIt->c_str( ) );
-      if( v_string != NULL )
-        this->m_Parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
+    QLineEdit* v_string = dlg->findChild< QLineEdit* >( nIt->c_str( ) );
+    if( v_string != NULL )
+    this->m_Parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
     }
     else if( pt == Parameters::Bool )
     {
-      QCheckBox* v_bool = dlg->findChild< QCheckBox* >( nIt->c_str( ) );
-      if( v_bool != NULL )
-        this->m_Parameters->SetBool( *nIt, v_bool->isChecked( ) );
+    QCheckBox* v_bool = dlg->findChild< QCheckBox* >( nIt->c_str( ) );
+    if( v_bool != NULL )
+    this->m_Parameters->SetBool( *nIt, v_bool->isChecked( ) );
     }
     else if( pt == Parameters::Uint )
     {
-      QSpinBox* v_uint = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
-      if( v_uint != NULL )
-        this->m_Parameters->SetUint( *nIt, v_uint->value( ) );
+    QSpinBox* v_uint = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
+    if( v_uint != NULL )
+    this->m_Parameters->SetUint( *nIt, v_uint->value( ) );
     }
     else if( pt == Parameters::Int )
     {
-      QSpinBox* v_int = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
-      if( v_int != NULL )
-        this->m_Parameters->SetInt( *nIt, v_int->value( ) );
+    QSpinBox* v_int = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
+    if( v_int != NULL )
+    this->m_Parameters->SetInt( *nIt, v_int->value( ) );
     }
     else if( pt == Parameters::Real )
     {
-      QDoubleSpinBox* v_double =
-        dlg->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
-      if( v_double != NULL )
-        this->m_Parameters->SetReal( *nIt, v_double->value( ) );
+    QDoubleSpinBox* v_double =
+    dlg->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
+    if( v_double != NULL )
+    this->m_Parameters->SetReal( *nIt, v_double->value( ) );
     }
     else if(
-      pt == Parameters::StringList ||
-      pt == Parameters::IntList ||
-      pt == Parameters::UintList ||
-      pt == Parameters::RealList
-      )
+    pt == Parameters::StringList ||
+    pt == Parameters::IntList ||
+    pt == Parameters::UintList ||
+    pt == Parameters::RealList
+    )
     {
-      cpPlugins::Interface::ParametersListWidget* l_double =
-        dlg->findChild< cpPlugins::Interface::ParametersListWidget* >(
-          nIt->c_str( )
-          );
-      if( l_double != NULL )
-      {
-        if( pt == Parameters::StringList )
-        {
-          std::vector< std::string > values = l_double->GetStringValues( );
-          for( int r = 0; r < values.size( ); ++r )
-            this->m_Parameters->AddToStringList( *nIt, values[ r ] );
-        }
-        else if( pt == Parameters::IntList )
-        {
-          std::vector< int > values = l_double->GetIntValues( );
-          for( int r = 0; r < values.size( ); ++r )
-            this->m_Parameters->AddToIntList( *nIt, values[ r ] );
-        }
-        else if( pt == Parameters::UintList )
-        {
-          std::vector< unsigned int > values = l_double->GetUintValues( );
-          for( int r = 0; r < values.size( ); ++r )
-            this->m_Parameters->AddToUintList( *nIt, values[ r ] );
-        }
-        else if( pt == Parameters::RealList )
-        {
-          std::vector< double > values = l_double->GetDoubleValues( );
-          for( int r = 0; r < values.size( ); ++r )
-            this->m_Parameters->AddToRealList( *nIt, values[ r ] );
-
-        } // fi
+    cpPlugins::Interface::ParametersListWidget* l_double =
+    dlg->findChild< cpPlugins::Interface::ParametersListWidget* >(
+    nIt->c_str( )
+    );
+    if( l_double != NULL )
+    {
+    if( pt == Parameters::StringList )
+    {
+    std::vector< std::string > values = l_double->GetStringValues( );
+    for( int r = 0; r < values.size( ); ++r )
+    this->m_Parameters->AddToStringList( *nIt, values[ r ] );
+    }
+    else if( pt == Parameters::IntList )
+    {
+    std::vector< int > values = l_double->GetIntValues( );
+    for( int r = 0; r < values.size( ); ++r )
+    this->m_Parameters->AddToIntList( *nIt, values[ r ] );
+    }
+    else if( pt == Parameters::UintList )
+    {
+    std::vector< unsigned int > values = l_double->GetUintValues( );
+    for( int r = 0; r < values.size( ); ++r )
+    this->m_Parameters->AddToUintList( *nIt, values[ r ] );
+    }
+    else if( pt == Parameters::RealList )
+    {
+    std::vector< double > values = l_double->GetDoubleValues( );
+    for( int r = 0; r < values.size( ); ++r )
+    this->m_Parameters->AddToRealList( *nIt, values[ r ] );
 
-      } // fi
+    } // fi
 
     } // fi
 
-  } // rof
-  return( true );
-}
+    } // fi
+
+    } // rof
+    return( true );
+    }
 */
 
 #endif // cpPlugins_Interface_QT4
index 2dc62ed168a2542f9d0ffb035c470621ac89e7c4..365ec9ca1edda5eba97419f97a2983dd0aae6f9b 100644 (file)
@@ -54,14 +54,6 @@ namespace cpPlugins
       std::vector< vtkAbstractWidget* > m_Widgets;
     };
 
-    /* TODO
-       bool cpPlugins_Interface_EXPORT ParametersQtDialog(
-       Parameters* parameters,
-       const std::string& title,
-       QWidget* parent = NULL
-       );
-    */
-
   } // ecapseman
 
 } // ecapseman
index f0d8d52886531aa72bcf80096c28d622a04cb925..a4a123755f80e6afcee30170693bc1770c7e5bb0 100644 (file)
@@ -110,6 +110,7 @@ ExecConfigurationDialog( QWidget* parent )
 
   } // fi
 
+  std::cout << "ok" << std::endl;
   if( !( this->m_ParametersDialog->IsModal( ) ) )
   {
     this->m_ParametersDialog->show( );
@@ -124,8 +125,7 @@ ExecConfigurationDialog( QWidget* parent )
     parent
     );
     if( r )
-    // TODO: !!! this->m_Parameters = parameters;
-    */
+  */
 
 #endif // cpPlugins_Interface_QT4
 
index 99f19b06a460efdd6db258a472898cd40e241000..913190f1f5f73b288650026c4c0d1c5e1e8fa2ca 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef cpPlugins_Interface_QT4
 #include <queue>
 #include <map>
+#include <sstream>
 #include <vector>
 
 #include <QDialogButtonBox>
@@ -30,127 +31,132 @@ ExecConfigurationDialog( QWidget* parent )
   itk::GDCMSeriesFileNames::Pointer series =
     itk::GDCMSeriesFileNames::New( );
 
-  typedef std::map< std::string, TStringList > _TSeries;
-  typedef std::map< std::string, _TSeries > _TFilenames;
-  _TSeries found_series;
-  _TFilenames found_filenames;
-
   // Show dialog and check if it was accepted
   QFileDialog dialog( parent );
   dialog.setFileMode( QFileDialog::DirectoryOnly );
   dialog.setDirectory( QFileDialog::tr( "." ) );
-  if( dialog.exec( ) )
+  if( !dialog.exec( ) )
+    return( false );
+
+  // Prepare dialog
+  QDialog* tree_dialog = new QDialog( parent );
+  QTreeWidget* tree_widget = new QTreeWidget( tree_dialog );
+  QList< QTreeWidgetItem* > tree_items;
+  std::map< std::string, std::map< std::string, TStringList > > found_files;
+
+  std::string main_dir_name =
+    dialog.selectedFiles( ).begin( )->toStdString( );
+  std::queue< std::string > q;
+  q.push( main_dir_name );
+  while( !( q.empty( ) ) )
   {
-    std::string dir_name = dialog.selectedFiles( ).begin( )->toStdString( );
-    std::queue< std::string > q;
-    q.push( dir_name );
-    while( !( q.empty( ) ) )
+    std::string dir_name = q.front( );
+    q.pop( );
+
+    // Get DICOM information
+    series->SetUseSeriesDetails( true );
+    series->AddSeriesRestriction( "0008|0021" );
+    series->SetDirectory( dir_name );
+    const TStringList& seriesUID = series->GetSeriesUIDs( );
+    if( seriesUID.size( ) > 0 )
     {
-      dir_name = q.front( );
-      q.pop( );
-
-      // Get DICOM information
-      series->SetUseSeriesDetails( true );
-      series->AddSeriesRestriction( "0008|0021" );
-      series->SetDirectory( dir_name );
-      const TStringList& seriesUID = series->GetSeriesUIDs( );
-      if( seriesUID.size( ) > 0 )
+      QTreeWidgetItem* new_item = new QTreeWidgetItem(
+        ( QTreeWidgetItem* )( NULL ),
+        QStringList( dir_name.c_str( ) )
+        );
+      QTreeWidgetItem* new_leaf = NULL;
+      TStringList::const_iterator sIt = seriesUID.begin( );
+      for( ; sIt != seriesUID.end( ); ++sIt )
       {
-        TStringList::const_iterator sIt = seriesUID.begin( );
-        for( ; sIt != seriesUID.end( ); ++sIt )
+        TStringList filenames = series->GetFileNames( *sIt );
+        if( filenames.size( ) > 0 )
         {
-          TStringList filenames = series->GetFileNames( *sIt );
-          if( filenames.size( ) > 0 )
-          {
-            found_series[ dir_name ].push_back( *sIt );
-            found_filenames[ dir_name ][ *sIt ] = filenames;
-
-          } // fi
-
-        } // rof
-
-      } // fi
-
-      // Update queue
-      QDir dir( dir_name.c_str( ) );
-      QFileInfoList contents = dir.entryInfoList( );
-      QFileInfoList::const_iterator i = contents.begin( );
-      for( ; i != contents.end( ); ++i )
-      {
-        if( i->isDir( ) )
-        {
-          std::string new_dir_name = i->absoluteFilePath( ).toStdString( );
-          if( new_dir_name.size( ) > dir_name.size( ) )
-            q.push( new_dir_name );
+          std::stringstream ss;
+          ss << "(" << filenames.size( ) << "): " << *sIt;
+          new_leaf =
+            new QTreeWidgetItem(
+              new_item, QStringList( ss.str( ).c_str( ) )
+              );
+          new_item->addChild( new_leaf );
+          found_files[ dir_name ][ *sIt ] = filenames;
 
         } // fi
 
       } // rof
 
-    } // elihw
-
-  } // fi
-
-  // Show second dialog
-  if( found_series.size( ) > 0 )
-  {
-    QDialog* tree_dialog = new QDialog( parent );
-
-    QLabel* title = new QLabel( tree_dialog );
-    title->setText( "Choose a DICOM series" );
-    QGridLayout* mainLayout = new QGridLayout( tree_dialog );
-    QVBoxLayout* toolsLayout = new QVBoxLayout( );
-    toolsLayout->addWidget( title );
-    mainLayout->addLayout( toolsLayout, 0, 0, 1, 1 );
-
-    QTreeWidget* tree = new QTreeWidget( tree_dialog );
-    QList< QTreeWidgetItem* > tree_items;
+      if( new_leaf != NULL )
+        tree_items.append( new_item );
+      else
+        delete new_item;
+        
+    } // fi
 
-    _TSeries::const_iterator fsIt = found_series.begin( );
-    for( ; fsIt != found_series.end( ); ++fsIt )
+      // Update queue
+    QDir dir( dir_name.c_str( ) );
+    QFileInfoList contents = dir.entryInfoList( );
+    QFileInfoList::const_iterator i = contents.begin( );
+    for( ; i != contents.end( ); ++i )
     {
-      QTreeWidgetItem* new_item =
-        new QTreeWidgetItem(
-          ( QTreeWidgetItem* )( NULL ), QStringList( fsIt->first.c_str( ) )
-          );
-      TStringList::const_iterator sId = fsIt->second.begin( );
-      for( ; sId != fsIt->second.end( ); ++sId )
+      if( i->isDir( ) )
       {
-        QTreeWidgetItem* new_leaf =
-          new QTreeWidgetItem( new_item, QStringList( sId->c_str( ) ) );
-        new_item->addChild( new_leaf );
+        std::string new_dir_name = i->absoluteFilePath( ).toStdString( );
+        if( new_dir_name.size( ) > dir_name.size( ) )
+          q.push( new_dir_name );
 
-      } // rof
-      tree_items.append( new_item );
+      } // fi
 
     } // rof
-    tree->insertTopLevelItems( 0, tree_items );
-    toolsLayout->addWidget( tree );
-
-    QDialogButtonBox* bb = new QDialogButtonBox(
-      QDialogButtonBox::Ok | QDialogButtonBox::Cancel
-      );
-    tree_dialog->connect( bb, SIGNAL( accepted( ) ), tree_dialog, SLOT( accept( ) ) );
-    tree_dialog->connect( bb, SIGNAL( rejected( ) ), tree_dialog, SLOT( reject( ) ) );
-    toolsLayout->addWidget( bb );
 
-    if( tree_dialog->exec( ) == 1 )
-    {
-      QTreeWidgetItem* item = tree->currentItem( );
-      QTreeWidgetItem* parent = item->parent( );
-      if( parent != NULL )
-      {
-        std::string serie_dir = parent->text( 0 ).toStdString( );
-        std::string serie_id = item->text( 0 ).toStdString( );
+  } // elihw
 
-        this->m_Parameters->ClearStringList( "FileNames" );
-        const TStringList& filenames = found_filenames[ serie_dir ][ serie_id ];
-        for( unsigned int f = 0; f < filenames.size( ); ++f )
-          this->m_Parameters->AddToStringList( "FileNames", filenames[ f ] );
+  // Show second dialog
+  if( tree_items.size( ) == 0 )
+  {
+    delete tree_widget;
+    delete tree_dialog;
+    return( false );
 
-        r = true;
+  } // fi
 
-      } // fi
+  QLabel* title = new QLabel( tree_dialog );
+  title->setText( "Choose a DICOM series" );
+  QGridLayout* mainLayout = new QGridLayout( tree_dialog );
+  QVBoxLayout* toolsLayout = new QVBoxLayout( );
+  toolsLayout->addWidget( title );
+  mainLayout->addLayout( toolsLayout, 0, 0, 1, 1 );
+
+  tree_widget->insertTopLevelItems( 0, tree_items );
+  toolsLayout->addWidget( tree_widget );
+
+  QDialogButtonBox* bb = new QDialogButtonBox(
+    QDialogButtonBox::Ok | QDialogButtonBox::Cancel
+    );
+  tree_dialog->connect(
+    bb, SIGNAL( accepted( ) ), tree_dialog, SLOT( accept( ) )
+    );
+  tree_dialog->connect(
+    bb, SIGNAL( rejected( ) ), tree_dialog, SLOT( reject( ) )
+    );
+  toolsLayout->addWidget( bb );
+
+  if( tree_dialog->exec( ) == 0 )
+    return( false );
+
+  QTreeWidgetItem* item = tree_widget->currentItem( );
+  if( item != NULL )
+  {
+    QTreeWidgetItem* item_parent = item->parent( );
+    if( item_parent != NULL )
+    {
+      std::string serie_dir = item_parent->text( 0 ).toStdString( );
+      std::string serie_id = item->text( 0 ).toStdString( );
+      serie_id = serie_id.substr( serie_id.find_first_of( " " ) + 1 );
+      this->m_Parameters->ClearStringList( "FileNames" );
+      const TStringList& names = found_files[ serie_dir ][ serie_id ];
+      for( unsigned int f = 0; f < names.size( ); ++f )
+        this->m_Parameters->AddToStringList( "FileNames", names[ f ] );
+
+      r = true;
 
     } // fi