]> Creatis software - creaImageIO.git/commitdiff
reindent
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 26 May 2011 09:07:26 +0000 (09:07 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 26 May 2011 09:07:26 +0000 (09:07 +0000)
src/creaImageIOWxAnySimpleDlg.cpp
src/creaImageIOWxAnySimpleDlg.h

index 4e0bf4dd9a2ec15a42f14c72fd86e06306e1f158..593d389f3a574416f1c409c1d08f8e37780757fe 100644 (file)
 
 namespace creaImageIO
 {
-       
-       ///Ctor
+
+   ///Ctor
    WxAnySimpleDlg::WxAnySimpleDlg(wxWindow *parent, 
                                   wxString i_title,  
                                   const std::string i_namedescp , 
                                   const std::string i_namedb)
     : wxDialog(parent, -1,_T("DISPLAY IMAGES"), wxDefaultPosition, wxSize(230,150))
    {
-               namedescp       = i_namedescp; 
-               namedb          = i_namedb;
-
-          if(!i_title.empty())
-          {
-                       this->SetTitle(i_title);  
-          }
-          // Button to select file(s)
-          wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
-          Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile ); 
-
-          // Button to select directory
-          wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
-          Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadDirectory ); 
-
-          // button to select creaImageIO
-          wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
-          Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadGimmick ); 
-
-          /// \TODO  Button to select Bruker directory
-               m_dicom = true;
-       Layout(); 
-       
-       }
+        namedescp    = i_namedescp; 
+        namedb       = i_namedb;
+
+       if(!i_title.empty())
+       {
+            this->SetTitle(i_title);  
+       }
+       // Button to select file(s)
+       wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
+         Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile ); 
+
+       // Button to select directory
+       wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
+       Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadDirectory ); 
+
+       // button to select creaImageIO
+       wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
+       Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadGimmick ); 
+
+       /// \TODO  Button to select Bruker directory
+        m_dicom = true;
+        Layout(); 
+    }
 //////////////////////////////////////////////////////////////////////
 //                                                                  //
 //////////////////////////////////////////////////////////////////////
      
-        void WxAnySimpleDlg::OnReadFile(wxCommandEvent& event)
-         {
-                 int resultShowModal;
-                 wxFileDialog* fileDlg = new wxFileDialog( 0,  _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
+     void WxAnySimpleDlg::OnReadFile(wxCommandEvent& event)
+      {
+          int resultShowModal;
+          wxFileDialog* fileDlg = new wxFileDialog( 0,  _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
     
-                   resultShowModal = fileDlg->ShowModal();
-                       if ( resultShowModal==wxID_OK )
-                       {
-                               wxArrayString wxArray;
-                               fileDlg->GetPaths(wxArray);
-                               if(wxArray.size() >0)
-                               {
-                                       for( int i = 0; i < wxArray.GetCount(); i++)
-                                       {
-                                               std::string name = crea::wx2std(wxArray[i]);
-                                               // FOR THE MOMENT ONLY short 3D et short 4D
-                                               readImg(name);
-                                       }
-                               
-                               else {
-                                       // TO DO WARNING MESSAGES
-                               }
-                       }
-                 SetReturnCode( resultShowModal );
-//              Close();
-                EndModal( resultShowModal );
-         }
-
-
-           
+          resultShowModal = fileDlg->ShowModal();
+          if ( resultShowModal==wxID_OK )
+          {
+                wxArrayString wxArray;
+                fileDlg->GetPaths(wxArray);
+                if(wxArray.size() >0)
+                {
+                    for( int i = 0; i < wxArray.GetCount(); i++)
+                    {
+                        std::string name = crea::wx2std(wxArray[i]);
+                        // FOR THE MOMENT ONLY short 3D et short 4D
+                        readImg(name);
+                    }
+                } 
+                else {
+                    // TO DO WARNING MESSAGES
+                }
+          }
+          SetReturnCode( resultShowModal );
+//         Close();
+          EndModal( resultShowModal );
+      }
+
+
+        
 void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
 {
-       m_exts = i_exts;
+    m_exts = i_exts;
 }
- //////////////////////////////////////////////////////////////////////
-//                                                                                                                                     //
+ /////////////////////////////////////////////////////////////////////
+//                                                                  //
 //////////////////////////////////////////////////////////////////////
 
-         void WxAnySimpleDlg::OnReadDirectory(wxCommandEvent &event)
-         {
-                 int resultShowModal;
-                 bool bvalid = false;
-            long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
-                wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
-                
-                resultShowModal = dirDlg->ShowModal();
-                if ( resultShowModal==wxID_OK )
-                {  
-                       std::string path = crea::wx2std(dirDlg->GetPath());
-                       typedef boost::filesystem::directory_iterator dir_it;
-                       dir_it itr(path);
-                       dir_it end_itr;
-                       /*if (boost::filesystem::exists(path))
-                       {*/
-                               for(;itr != end_itr; ++itr)
-                               {
-                                          bvalid = m_exts.size() == 0? true : false;
-                                          std::vector<std::string>::iterator it = m_exts.begin();
-                                          std::string ext = itr->filename().substr(itr->filename().find_last_of("."));
-                                          for(; it != m_exts.end(); it++)
-                                          {
-                                                  if(ext == (*it) )
-                                                  {
-                                                          bvalid = true;
-                                                          break;
-                                                  }
-                                          }
-                                       if (!boost::filesystem::is_directory(itr->status()) && bvalid)
-                                       {
-                                               readImg(itr->string().c_str());
-                                       }
-                               }
-                }
-                SetReturnCode( resultShowModal );
-//              Close();
-                EndModal( resultShowModal );
-         }
-
-         //////////////////////////////////////////////////////////////////////
-//                                                                                                                                     //
+      void WxAnySimpleDlg::OnReadDirectory(wxCommandEvent &event)
+      {
+         int resultShowModal;
+         bool bvalid = false;
+         long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
+         wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
+         
+         resultShowModal = dirDlg->ShowModal();
+         if ( resultShowModal==wxID_OK )
+         {  
+            std::string path = crea::wx2std(dirDlg->GetPath());
+            typedef boost::filesystem::directory_iterator dir_it;
+            dir_it itr(path);
+            dir_it end_itr;
+            /*if (boost::filesystem::exists(path))
+            {*/
+                for(;itr != end_itr; ++itr)
+                {
+                       bvalid = m_exts.size() == 0? true : false;
+                       std::vector<std::string>::iterator it = m_exts.begin();
+                       std::string ext = itr->filename().substr(itr->filename().find_last_of("."));
+                       for(; it != m_exts.end(); it++)
+                       {
+                           if(ext == (*it) )
+                           {
+                               bvalid = true;
+                               break;
+                           }
+                       }
+                    if (!boost::filesystem::is_directory(itr->status()) && bvalid)
+                    {
+                        readImg(itr->string().c_str());
+                    }
+                }
+         }
+         SetReturnCode( resultShowModal );
+//         Close();
+         EndModal( resultShowModal );
+      }
+
+      //////////////////////////////////////////////////////////////////////
+//                                                                    //
 //////////////////////////////////////////////////////////////////////
-                   
-         void WxAnySimpleDlg::OnReadGimmick(wxCommandEvent &event)
-         {
-                 // Run Gimmick
-                  WxGimmickReaderDialog dlg(0,-1, 
-                                  namedescp,
-                                  namedb, 
-                                  _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
+            
+      void WxAnySimpleDlg::OnReadGimmick(wxCommandEvent &event)
+      {
+          // Run Gimmick
+           WxGimmickReaderDialog dlg(0,-1, 
+                   namedescp,
+                   namedb, 
+                   _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
                    wxDefaultPosition,
                    wxSize(810,750),
                    GIMMICK_2D_IMAGE_SELECTION,
                    GIMMICK_3D_IMAGE_SELECTION,
                    _3D,
-                                  1);
-                dlg.ShowModal();
-                if (dlg.GetReturnCode() == wxID_OK)
-            {
-                       std::vector<std::string> out;
-                       dlg.stopReading();
-                       dlg.GetSelectedFiles(out);
-                       if(m_dicom)
-                       {
-                               readDicomImg( out);
-                       }
-                       else
-                       {
-                               std::vector<std::string>::iterator ii = out.begin();
-                               for (;ii != out.end();ii++)
-                               {
-                                       readImg( (*ii).c_str() );
-                               }
-                       }
-                       dlg.OnExit();
-                }
-                SetReturnCode( dlg.GetReturnCode() );
-//              Close();
-                EndModal( dlg.GetReturnCode() );
-          }
+                   1);
+         dlg.ShowModal();
+         if (dlg.GetReturnCode() == wxID_OK)
+         {
+            std::vector<std::string> out;
+            dlg.stopReading();
+            dlg.GetSelectedFiles(out);
+            if(m_dicom)
+            {
+                readDicomImg( out);
+            }
+            else
+            {
+                std::vector<std::string>::iterator ii = out.begin();
+                for (;ii != out.end();ii++)
+                {
+                    readImg( (*ii).c_str() );
+                }
+            }
+            dlg.OnExit();
+         }
+         SetReturnCode( dlg.GetReturnCode() );
+//         Close();
+         EndModal( dlg.GetReturnCode() );
+       }
 
 
      
-        wxString WxAnySimpleDlg::getInfoImage()
-       {
-               return infoimage;
-       }
-
-
-         // FCY : just to check but not needed, we hardly suppose that we load only same type and dim of images
-       const std::type_info & WxAnySimpleDlg::getType(const std::string &i_name)
-        {
-                       typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
-                       itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
-                   imageIO->SetFileName(i_name.c_str());
-                       imageIO->ReadImageInformation();
-                       return imageIO->GetComponentTypeInfo();//AsString( imageIO->GetComponentType());
-        }
-
-         const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
-        {
-                       typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
-                       itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
-                   imageIO->SetFileName(i_name.c_str());
-                       imageIO->ReadImageInformation();
-                       return imageIO->GetNumberOfDimensions();
-        }
-
-         void WxAnySimpleDlg::readImg(const std::string &i_name)
-         {
-                 size_t dims = getNumberOfDimensions(i_name);
-                const std::type_info  *type= &getType(i_name);
-                 switch(dims)
-                 {
-                  case 3:
-                           if (getType(i_name) ==  typeid(unsigned char))
-                          {
-                                   typedef itk::Image<unsigned char, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                          }
-                         else if (getType(i_name) ==  typeid(signed char)) 
-                         {
-                                   typedef itk::Image<signed char, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                          else if (getType(i_name) ==  typeid(short))
-                          {
-                                   typedef itk::Image<short, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                          }
-                         else if (getType(i_name) ==  typeid(unsigned short)) 
-                         {
-                                   typedef itk::Image<unsigned short, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(unsigned int)) 
-                         {
-                                   typedef itk::Image<unsigned int, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(signed int)) 
-                         {
-                                   typedef itk::Image<signed int, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(unsigned long)) 
-                         {
-                                   typedef itk::Image<unsigned long, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(signed long)) 
-                         {
-                                   typedef itk::Image<signed long, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(float)) 
-                         {
-                                   typedef itk::Image<float, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(double)) 
-                         {
-                                   typedef itk::Image<double, 3> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                         }
-                         else
-                         {
-                                 //????FCY, so what the type????
-                         }
-                         break;
-                         //assume that we have only one 4D file
-                       case 4:
-                               if (getType(i_name) ==  typeid(unsigned char))
-                           {
-                                   typedef itk::Image<unsigned char, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                           }
-                          else if (getType(i_name) ==  typeid(signed char)) 
-                          {
-                                   typedef itk::Image<signed char, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                          }
-                          else if (getType(i_name) ==  typeid(unsigned short))
-                           {
-                                   typedef itk::Image<unsigned short, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                           }
-                          else if(getType(i_name) == typeid(short))
-                          {
-                                        typedef itk::Image<short, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       try 
-                                       
-                                               reader->Update(); 
-                                       
-                                       catch( itk::ExceptionObject & err ) 
-                                       
-                                               std::cout << "Caught an exception reading" << i_name << ": " << std::endl; 
-                                               std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
-                                               throw err; 
-                                       
-                                       catch(...) 
-                                       
-                                               std::cout << "Error while reading image " << i_name << std::endl; 
-                                               throw; 
-                                       
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                          }
-                          else if (getType(i_name) ==  typeid(unsigned short)) 
-                          {
-                                   typedef itk::Image<unsigned short, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(unsigned int)) 
-                         {
-                                   typedef itk::Image<unsigned int, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(signed int)) 
-                         {
-                                   typedef itk::Image<signed int, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(unsigned long)) 
-                         {
-                                   typedef itk::Image<unsigned long, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(signed long)) 
-                         {
-                                   typedef itk::Image<signed long, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(float)) 
-                         {
-                                   typedef itk::Image<float, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else if (getType(i_name) ==  typeid(double)) 
-                         {
-                                   typedef itk::Image<double, 4> TImage;
-                                       typedef itk::ImageFileReader<TImage> ReaderType; 
-                                       ReaderType::Pointer reader = ReaderType::New(); 
-                                       reader->SetFileName( i_name ); 
-                                       reader->Update(); 
-                                       reader->GetOutput()->Register();
-                                       m_AnyImages.push_back(reader->GetOutput());
-                                       split4Din3Dvtk<TImage>(reader->GetOutput());
-                         }
-                         else
-                         {
-                                 //????FCY, so what the type????
-                         }
-                         break;
-                  }
-                  
-                  // Test to know if we have to add new type
-                 bool btest = false;
-                  if( m_AnyDims.size() != 0)
-                  {
-                          btest = true;
-                  }
-                  else
-                  {
-                          m_AnyDims.push_back(dims);
-                          m_AnyType.push_back(&getType(i_name));
-                  }
-                  if (btest)
-                  {
-                          if(m_AnyDims.front() != dims || m_AnyType.front()->before(getType(i_name)))
-                          {
-                                  m_AnyDims.push_back(dims);
-                                  m_AnyType.push_back(&getType(i_name));
-                          }
-                          else{}
-                  }
-                  else  {}
-         }
-
-
-
-
-         void WxAnySimpleDlg::readDicomImg(const std::vector<std::string> &i_names)
-         {
-                 typedef itk::Image<short,3> TImage;
-                 typedef itk::GDCMImageIO GDCMType;
-                 typedef itk::DICOMSeriesFileNames dicnames;
-                 GDCMType::Pointer gdcmIO = GDCMType::New(); 
-                 dicnames::Pointer generator = dicnames::New();
-
-
-                       typedef itk::ImageSeriesReader<TImage> ReaderType; 
-                   ReaderType::Pointer reader = ReaderType::New(); 
-                       reader->SetImageIO(gdcmIO);
-                       reader->SetFileNames(i_names);
-               //      reader->SetFileName( i_name ); 
-                       try 
-                       
-                               reader->Update(); 
-                       
-                       catch( itk::ExceptionObject & err ) 
-                       
-                       //      std::cout << "Caught an exception reading" << i_name << ": " << std::endl; 
-                               std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
-                               throw err; 
-                       
-                       catch(...) 
-                       
-                               //std::cout << "Error while reading image " << i_name << std::endl; 
-                               throw; 
-                       
-                       //m_Iresults.push_back(reader->GetOutput()); 
+     wxString WxAnySimpleDlg::getInfoImage()
+    {
+        return infoimage;
+    }
+
+
+      // FCY : just to check but not needed, we hardly suppose that we load only same type and dim of images
+    const std::type_info & WxAnySimpleDlg::getType(const std::string &i_name)
+     {
+            typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
+            itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
+            imageIO->SetFileName(i_name.c_str());
+            imageIO->ReadImageInformation();
+            return imageIO->GetComponentTypeInfo();//AsString( imageIO->GetComponentType());
+     }
+
+      const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
+     {
+            typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
+            itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
+            imageIO->SetFileName(i_name.c_str());
+            imageIO->ReadImageInformation();
+            return imageIO->GetNumberOfDimensions();
+     }
+
+      void WxAnySimpleDlg::readImg(const std::string &i_name)
+      {
+          size_t dims = getNumberOfDimensions(i_name);
+          const std::type_info  *type= &getType(i_name);
+          switch(dims)
+          {
+           case 3:
+               if (getType(i_name) ==  typeid(unsigned char))
+               {
+                    typedef itk::Image<unsigned char, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+               }
+              else if (getType(i_name) ==  typeid(signed char)) 
+              {
+                    typedef itk::Image<signed char, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+               else if (getType(i_name) ==  typeid(short))
+               {
+                    typedef itk::Image<short, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+               }
+              else if (getType(i_name) ==  typeid(unsigned short)) 
+              {
+                    typedef itk::Image<unsigned short, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(unsigned int)) 
+              {
+                    typedef itk::Image<unsigned int, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(signed int)) 
+              {
+                    typedef itk::Image<signed int, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(unsigned long)) 
+              {
+                    typedef itk::Image<unsigned long, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(signed long)) 
+              {
+                    typedef itk::Image<signed long, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(float)) 
+              {
+                    typedef itk::Image<float, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(double)) 
+              {
+                    typedef itk::Image<double, 3> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+              }
+              else
+              {
+                  //????FCY, so what the type????
+              }
+              break;
+              //assume that we have only one 4D file
+            case 4:
+                if (getType(i_name) ==  typeid(unsigned char))
+                {
+                    typedef itk::Image<unsigned char, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+                }
+               else if (getType(i_name) ==  typeid(signed char)) 
+               {
+                    typedef itk::Image<signed char, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+               }
+               else    if (getType(i_name) ==  typeid(unsigned short))
+                {
+                    typedef itk::Image<unsigned short, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+                }
+               else if(getType(i_name) == typeid(short))
+               {
+                    typedef itk::Image<short, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    try 
+                    { 
+                        reader->Update(); 
+                    } 
+                    catch( itk::ExceptionObject & err ) 
+                    { 
+                        std::cout << "Caught an exception reading" << i_name << ": " << std::endl; 
+                        std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
+                        throw err; 
+                    } 
+                    catch(...) 
+                    { 
+                        std::cout << "Error while reading image " << i_name << std::endl; 
+                        throw; 
+                    } 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+               }
+               else if (getType(i_name) ==  typeid(unsigned short)) 
+               {
+                    typedef itk::Image<unsigned short, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(unsigned int)) 
+              {
+                    typedef itk::Image<unsigned int, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(signed int)) 
+              {
+                    typedef itk::Image<signed int, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(unsigned long)) 
+              {
+                    typedef itk::Image<unsigned long, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(signed long)) 
+              {
+                    typedef itk::Image<signed long, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(float)) 
+              {
+                    typedef itk::Image<float, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else if (getType(i_name) ==  typeid(double)) 
+              {
+                    typedef itk::Image<double, 4> TImage;
+                    typedef itk::ImageFileReader<TImage> ReaderType; 
+                    ReaderType::Pointer reader = ReaderType::New(); 
+                    reader->SetFileName( i_name ); 
+                    reader->Update(); 
+                    reader->GetOutput()->Register();
+                    m_AnyImages.push_back(reader->GetOutput());
+                    split4Din3Dvtk<TImage>(reader->GetOutput());
+              }
+              else
+              {
+                  //????FCY, so what the type????
+              }
+              break;
+           }
+           
+           // Test to know if we have to add new type
+          bool btest = false;
+           if( m_AnyDims.size() != 0)
+           {
+               btest = true;
+           }
+           else
+           {
+               m_AnyDims.push_back(dims);
+               m_AnyType.push_back(&getType(i_name));
+           }
+           if (btest)
+           {
+               if(m_AnyDims.front() != dims || m_AnyType.front()->before(getType(i_name)))
+               {
+                   m_AnyDims.push_back(dims);
+                   m_AnyType.push_back(&getType(i_name));
+               }
+               else{}
+           }
+           else  {}
+      }
+
+
+
+
+      void WxAnySimpleDlg::readDicomImg(const std::vector<std::string> &i_names)
+      {
+          typedef itk::Image<short,3> TImage;
+          typedef itk::GDCMImageIO GDCMType;
+          typedef itk::DICOMSeriesFileNames dicnames;
+          GDCMType::Pointer gdcmIO = GDCMType::New(); 
+          dicnames::Pointer generator = dicnames::New();
+
+
+            typedef itk::ImageSeriesReader<TImage> ReaderType; 
+            ReaderType::Pointer reader = ReaderType::New(); 
+            reader->SetImageIO(gdcmIO);
+            reader->SetFileNames(i_names);
+        //    reader->SetFileName( i_name ); 
+            try 
+            { 
+                reader->Update(); 
+            } 
+            catch( itk::ExceptionObject & err ) 
+            { 
+            //    std::cout << "Caught an exception reading" << i_name << ": " << std::endl; 
+                std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
+                throw err; 
+            } 
+            catch(...) 
+            { 
+                //std::cout << "Error while reading image " << i_name << std::endl; 
+                throw; 
+            } 
+            //m_Iresults.push_back(reader->GetOutput()); 
     
-         }
-
-
-
-
-         template <typename TImage> 
-         void WxAnySimpleDlg::split3Din3Dvtk(TImage* i_Img)
-         {
-                  typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
-                 typename ConnectorType::Pointer         connector = ConnectorType::New();
-                  connector->SetInput(i_Img);
-                  connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
-                  connector->Update();
-                 vtkImageData *im = vtkImageData::New();
-                 im->ShallowCopy(connector->GetOutput());
-                 im->Update();
-                 m_Vresults.push_back(im);
-         }
-
-
-         template <typename TImage> 
-         void WxAnySimpleDlg::split4Din3Dvtk(TImage* i_Img)
-         {
-                                if(i_Img->GetImageDimension() == 4)
-                                {
-                                        // size of fourth dimension 
-                                        int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
-                                        // Output Type
-                                        typedef itk::Image<unsigned char,3> ImageOutputType;  
-                                        typedef itk::ImageSeriesWriter<TImage, ImageOutputType >  SeriesWriterType;
-                                        typedef itk::MetaImageIO MetaImageType;
-                                        MetaImageType::Pointer metaIO;
-                                        typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
-                       
-                                        // from JPR file to generate output files
-                                        typedef itk::NumericSeriesFileNames NamesGeneratorType;
-                                        NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
-                                        namesGenerator->SetStartIndex(0);
-                                        namesGenerator->SetEndIndex(dsize-1); 
-                                        namesGenerator->SetIncrementIndex(1);
-                                        std::string format = m_dir;
-                                        format += "/image%03d.mhd";
-                                        namesGenerator->SetSeriesFormat( format.c_str() );
-                                       
-                                        const std::vector<std::string> names = namesGenerator->GetFileNames();
-                                        seriesWriter->SetFileNames( names );
-                                        seriesWriter->SetInput(i_Img);
-                                        seriesWriter->SetImageIO(metaIO);
-                                        try
-                                        {
-                                               seriesWriter->Update();
-                                               vtkMetaImageReader *vReader = vtkMetaImageReader::New();
-                                               std::vector<std::string>::const_iterator it = names.begin();
-                                               for( ;it !=  names.end(); ++it)
-                                               {
-                                                       vReader->SetFileName((*it).c_str());
-                                                       vReader->Update();
-                                                       m_Vresults.push_back(vReader->GetOutput());
-                                                       
-                                               }
-                                        }
-                                        catch( itk::ExceptionObject & excp )
-                                        {
-                                               std::cerr << "Exception thrown while writing the series " << std::endl;
-                                               std::cerr << excp << std::endl;
-                                               //return EXIT_FAILURE;
-                                        }
-                                }
-         }
-
-          bool WxAnySimpleDlg::AllSameType()
-          {
-                  if(m_AnyType.size() == 1)
-                  {
-                          return true;
-                  }
-                  else
-                  {
-                          return false;
-                  }
-
-          }
+      }
+
+
+
+
+      template <typename TImage> 
+      void WxAnySimpleDlg::split3Din3Dvtk(TImage* i_Img)
+      {
+          typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
+          typename ConnectorType::Pointer       connector = ConnectorType::New();
+          connector->SetInput(i_Img);
+          connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
+          connector->Update();
+          vtkImageData *im = vtkImageData::New();
+          im->ShallowCopy(connector->GetOutput());
+          im->Update();
+          m_Vresults.push_back(im);
+      }
+
+
+      template <typename TImage> 
+      void WxAnySimpleDlg::split4Din3Dvtk(TImage* i_Img)
+      {
+                 if(i_Img->GetImageDimension() == 4)
+                 {
+                     // size of fourth dimension 
+                     int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
+                     // Output Type
+                     typedef itk::Image<unsigned char,3> ImageOutputType;  
+                     typedef itk::ImageSeriesWriter<TImage, ImageOutputType >  SeriesWriterType;
+                     typedef itk::MetaImageIO MetaImageType;
+                     MetaImageType::Pointer metaIO;
+                     typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
+            
+                     // from JPR file to generate output files
+                     typedef itk::NumericSeriesFileNames NamesGeneratorType;
+                     NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
+                     namesGenerator->SetStartIndex(0);
+                     namesGenerator->SetEndIndex(dsize-1); 
+                     namesGenerator->SetIncrementIndex(1);
+                     std::string format = m_dir;
+                     format += "/image%03d.mhd";
+                     namesGenerator->SetSeriesFormat( format.c_str() );
+                    
+                     const std::vector<std::string> names = namesGenerator->GetFileNames();
+                     seriesWriter->SetFileNames( names );
+                     seriesWriter->SetInput(i_Img);
+                       seriesWriter->SetImageIO(metaIO);
+                     try
+                     {
+                        seriesWriter->Update();
+                        vtkMetaImageReader *vReader = vtkMetaImageReader::New();
+                        std::vector<std::string>::const_iterator it = names.begin();
+                        for( ;it !=  names.end(); ++it)
+                        {
+                            vReader->SetFileName((*it).c_str());
+                            vReader->Update();
+                            m_Vresults.push_back(vReader->GetOutput());
+                            
+                        }
+                     }
+                     catch( itk::ExceptionObject & excp )
+                     {
+                        std::cerr << "Exception thrown while writing the series " << std::endl;
+                        std::cerr << excp << std::endl;
+                        //return EXIT_FAILURE;
+                     }
+                 }
+      }
+
+       bool WxAnySimpleDlg::AllSameType()
+       {
+           if(m_AnyType.size() == 1)
+           {
+               return true;
+           }
+           else
+           {
+               return false;
+           }
+
+       }
 
  }// namespace end
 
index aa829272ec719cab7039d07924f12db28245d96f..eb10d1e2fb0084a259fa7331ec07f1c536c81110 100644 (file)
@@ -9,95 +9,94 @@ namespace creaImageIO
    * \ingroup View
    */
 
-       /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
-//EED  class  __declspec(dllexport) WxAnySimpleDlg : public wxDialog
-       class  CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
-       {
-       public:
-                /// Ctor
-                 WxAnySimpleDlg( wxWindow *parent,  
-                         wxString i_title =_T(""),
-                         const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
-                         const std::string i_namedb   = "Local Database"     
-                         );
-
-                 ~WxAnySimpleDlg(){};
-
-                 void setExts(std::vector<std::string>);
-                 /// Callback to read file(s)
-                 void OnReadFile(wxCommandEvent& event);
-
-                 /// Callback to read directory, no recursive
-                  void OnReadDirectory(wxCommandEvent &event);
-             
-                 /// Callback to select from creaImageIO database
-                  void OnReadGimmick(wxCommandEvent &event);
-
-                  /// return a vtkImageData vector of selected images, if available
-                  std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
-
-                  wxString getInfoImage();
-
-          
-                  void set(bool i_dicom){m_dicom= i_dicom;}
-                  std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
-               
-                  // return the size of readed images
-                  std::vector<const size_t> getDims(){ return m_AnyDims;}
-
-                  // return the type of readed images
-                  std::vector<const std::type_info *> getTypes(){ return m_AnyType;}
-
-                  // get an Image on wanted type
-                  template <typename TImage> 
-             typename TImage::Pointer getImage(boost::any i_AnyImage)
-             {
-                    typedef itk::Image<TImage> ImageOut;
-                    typename ImageOut::Pointer img = ImageOut::New();
-                    img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
-                    return img;
-            }
-
-                // get the images on itk type defined by user
-                 template <typename TImage> 
-                 std::vector<typename TImage::Pointer>  getTemplatedImagesSelected()
-                 {
-                        std::vector<typename TImage::Pointer> imgs;
-                        std::vector<boost::any>::iterator it = m_AnyImages.begin();
-                    for(; it != m_AnyImages.end(); it++)
-                    {
-                                imgs.push_back(boost::any_cast<TImage*> (*it));
-                    }
-                        return imgs;
-             }
-                 bool AllSameType();
-       private:
-
-               
-               std::vector<const size_t> m_AnyDims;
-               std::vector<const std::type_info *> m_AnyType;
-               std::vector<boost::any> m_AnyImages;
-               std::vector<std::string> m_exts;
-               std::string namedescp; 
-               std::string namedb;
-               wxString infoimage;
-               std::string m_dir;
-               template <class TImage> 
-                 void split3Din3Dvtk(TImage* i_Img);
-
-               template <typename TImage> 
-                 void split4Din3Dvtk(TImage* i_Img);
-
-               bool m_dicom;
-               /// interface to read data
-               SimpleView m_view;
-                void readImg(const std::string &i_name);
-                void readDicomImg(const std::vector<std::string> &i_names);
-                std::vector <vtkImageData*> m_Vresults;
-                
-         const size_t getNumberOfDimensions(const std::string &i_name);
-         const std::type_info & getType(const std::string &i_name);
-       };
-
+    /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
+//EED    class  __declspec(dllexport) WxAnySimpleDlg : public wxDialog
+    class  CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
+    {
+    public:
+         /// Ctor
+           WxAnySimpleDlg( wxWindow *parent,  
+               wxString i_title =_T(""),
+               const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
+               const std::string i_namedb   = "Local Database"     
+            );
+
+           ~WxAnySimpleDlg(){};
+
+           void setExts(std::vector<std::string>);
+           /// Callback to read file(s)
+           void OnReadFile(wxCommandEvent& event);
+
+          /// Callback to read directory, no recursive
+           void OnReadDirectory(wxCommandEvent &event);
+          
+          /// Callback to select from creaImageIO database
+           void OnReadGimmick(wxCommandEvent &event);
+
+           /// return a vtkImageData vector of selected images, if available
+           std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
+
+           wxString getInfoImage();
+
+           void set(bool i_dicom){m_dicom= i_dicom;}
+           std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
+        
+           // return the size of readed images
+           //strange compile error // JPR
+           std::vector<const size_t> getDims(){ return m_AnyDims;}
+
+           // return the type of readed images
+           std::vector<const std::type_info *> getTypes(){ return m_AnyType;}
+
+           // get an Image on wanted type
+           template <typename TImage> 
+           typename TImage::Pointer getImage(boost::any i_AnyImage)
+           {
+              typedef itk::Image<TImage> ImageOut;
+              typename ImageOut::Pointer img = ImageOut::New();
+              img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
+              return img;
+           }
+
+         // get the images on itk type defined by user
+          template <typename TImage> 
+          std::vector<typename TImage::Pointer>  getTemplatedImagesSelected()
+          {
+             std::vector<typename TImage::Pointer> imgs;
+             std::vector<boost::any>::iterator it = m_AnyImages.begin();
+             for(; it != m_AnyImages.end(); it++)
+             {
+                 imgs.push_back(boost::any_cast<TImage*> (*it));
+             }
+             return imgs;
+          }
+          bool AllSameType();
+    private:
+
+        // strange compile error with gcc 4.5.1-4 //JPR        
+        std::vector<const size_t> m_AnyDims;
+        std::vector<const std::type_info *> m_AnyType;
+        std::vector<boost::any> m_AnyImages;
+        std::vector<std::string> m_exts;
+        std::string namedescp; 
+        std::string namedb;
+        wxString infoimage;
+        std::string m_dir;
+        template <class TImage> 
+        void split3Din3Dvtk(TImage* i_Img);
+
+        template <typename TImage> 
+        void split4Din3Dvtk(TImage* i_Img);
+
+        bool m_dicom;
+        /// interface to read data
+        SimpleView m_view;
+        void readImg(const std::string &i_name);
+        void readDicomImg(const std::vector<std::string> &i_names);
+        std::vector <vtkImageData*> m_Vresults;
+         
+        const size_t getNumberOfDimensions(const std::string &i_name);
+        const std::type_info & getType(const std::string &i_name);
+    };
 
 }