]> Creatis software - creaImageIO.git/commitdiff
new Output format and structure for Gimmick. Based on creaImageIO Output document...
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 12 May 2010 14:00:10 +0000 (14:00 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 12 May 2010 14:00:10 +0000 (14:00 +0000)
     - choice of output size (2D, 3D) and format
     - sorting of files based on XML Model (for future dicom sup 118)
     - associated informations with selected files

36 files changed:
CMakeLists.txt
appli/TestWxGimmickReaderDialog/main.cxx
src/CMakeLists.txt
src/creaImageIOAbstractImageReader.h
src/creaImageIODicomImageReader2.cpp
src/creaImageIODicomImageReader2.h
src/creaImageIOGimmick.cpp
src/creaImageIOGimmick.h
src/creaImageIOGimmickView.cpp
src/creaImageIOGimmickView.h
src/creaImageIOImageReader.cpp
src/creaImageIOImageReader.h
src/creaImageIOMultiThreadImageReader.cpp
src/creaImageIOMultiThreadImageReader.h
src/creaImageIOSQLiteTreeHandler.cpp
src/creaImageIOSQLiteTreeHandler.h
src/creaImageIOSettings.cpp
src/creaImageIOSettings.h
src/creaImageIOTree.h
src/creaImageIOTreeDescriptor.cpp
src/creaImageIOTreeDescriptor.h
src/creaImageIOTreeHandler.h
src/creaImageIOTreeHandlerImageAdder.cpp
src/creaImageIOTreeHandlerImageAdder.h
src/creaImageIOTreeLevelDescriptor.cpp
src/creaImageIOTreeLevelDescriptor.h
src/creaImageIOUltrasonixImageReader.cpp
src/creaImageIOUltrasonixImageReader.h
src/creaImageIOVtkImageReader.cpp
src/creaImageIOVtkImageReader.h
src/creaImageIOWxExportDlg.h
src/creaImageIOWxGimmickPanel.h
src/creaImageIOWxGimmickReaderDialog.h
src/creaImageIOWxGimmickView.cpp
src/creaImageIOWxGimmickView.h
src/creaImageIOWxTreeView.cpp

index 49b10194416fa5e6ac92e5f99790b9804b06f4ea..0432a40930a23958fa814907d36f44d5f9ce9f94 100644 (file)
@@ -33,10 +33,19 @@ SET(USE_GDCM_VTK ON)
 SET(USE_VTK ON)
 SET(USE_ITK OFF)
 SET(USE_BOOST ON)
-SET(USE_WXWIDGETS ON)
-
-OPTION(USE_GDCM "use gdcm" ON)
-OPTION(USE_GDCM2 "use gdcm2" OFF)
+OPTION(USE_WXWIDGETS "Use WxWidgets GUI" ON)
+OPTION(USE_QT4 "USE WxWidgets GUI"       OFF)
+OPTION(USE_XERCES "USE Xerces if you want to use an beta version of outputModel" OFF)
+
+IF(USE_QT4)
+       IF(USE_WXWIDGETS)
+                MESSAGE(STATUS "CANNOT USE QT WXWIDGETS IN SAME TIME")
+       ENDIF(USE_WXWIDGETS)
+ENDIF(USE_QT4)
+                
+                
+OPTION(USE_GDCM ON)
+OPTION(USE_GDCM2 OFF)
  MESSAGE(STATUS "GDCM LIB ....= ${GDCM_LIBRARIES}")
 IF(USE_GDCM2)
        OPTION(USE_GDCM_ANOM "use gdcm2 anonymizer tool" OFF)
index 33157d9cf427f055cbbe9ee6ee1edacc2753939c..797f46ed9920b28796376add7c74be1bb2c104af 100644 (file)
@@ -6,7 +6,7 @@
 #include <creaVtkBasicSlicer.h>
 
 
-//
+
 //#pragma comment(lib, "creaImageIO.lib")
 //#pragma comment(lib, "DelayImp.lib")
 //
@@ -49,7 +49,6 @@ bool myApp::OnInit( )
    int output_dim = _3D;
 
    int threads = 1;
-
  
    creaImageIO::WxGimmickReaderDialog w(
                     0,
@@ -87,6 +86,18 @@ bool myApp::OnInit( )
        std::vector<vtkImageData*> images;
           w.GetSelectedImages(images,3);
 
+       
+
+
+
+          std::vector<creaImageIO::OutStrGimmick> out;
+               std::vector<std::string> attr;
+               //attr.push_back("ALL");
+               attr.push_back("D0008_1070");
+               w.getSelected(out, attr,true,"");
+
+
+
 // images[1]->UpdateInformation();
        /*   vtkMetaImageReader *r= vtkMetaImageReader::New();
                   r->SetFileName("c:\\toto.mhd");
@@ -137,5 +148,3 @@ bool myApp::OnInit( )
    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
    return false;
 }
-
-
index b4696dd0df00c0a035f98bb7e19edd1829214ba3..1cff20311d1d3ccea0d62bd26a989cba51bbaa98 100644 (file)
@@ -79,6 +79,18 @@ FILE(GLOB SOURCES_CREAIMAGEIO_WX
          )
 endif()
 
+
+IF(USE_XERCES)
+FILE(GLOB SOURCES_CREAIMAGEIO_OUTPUT
+         creaImageIOOutputModel.cpp
+         creaImageIOOutputModelParser.cpp
+         )
+SOURCE_GROUP("Source Files\\Output" FILES ${SOURCES_CREAIMAGEIO_OUTPUT})        
+ENDIF(USE_XERCES)
+
+
+
+
 # Header Files   
 FILE(GLOB HEADER_CREAIMAGEIO creaImageIOImagePointerHolder.h)
 FILE(GLOB SOURCES_CREAIMAGEIO_PACS PACS/*.cpp)
@@ -113,9 +125,16 @@ if( BUILD_CREA_PACS)
                ${HEADER_CREAIMAGEIO_PACS}
                )
 else (BUILD_CREA_PACS)
+IF(USE_XERCES)
        SET (SRCS
                ${PRIMITIVE_SRCS}
+               ${SOURCES_CREAIMAGEIO_OUTPUT}
                )
+ELSE(USE_XERCES)
+       SET (SRCS
+               ${PRIMITIVE_SRCS}
+               )
+ENDIF(USE_XERCES)
 endif (BUILD_CREA_PACS)
 
 OPTION(${LIBRARY_NAME}_BUILD_SHARED 
@@ -129,7 +148,18 @@ crea_DEFINE(CREAIMAGEIO_EXPORT_SYMBOLS)
 
 ADD_LIBRARY(${LIBRARY_NAME} ${CREAIMAGEIO_BUILD_SHARED} ${SRCS})
 
+IF(USE_QT4)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} 
+      ${QT_LIBRARIES})
+ENDIF(USE_QT4)
 
+IF(USE_WXWIDGETS)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} 
+      ${WXWIDGETS_LIBRARIES})
+ENDIF(USE_WXWIDGETS)
+
+
+IF (NOT USE_XERCES)
 TARGET_LINK_LIBRARIES(${LIBRARY_NAME} 
   ${crea_LIBRARIES}
   ${creaBruker_LIBRARIES}
@@ -138,7 +168,19 @@ TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
   ${GDCM_LIBRARIES}
   ${BOOST_LIBRARIES}
   sqlite3)
-
+ELSE(NOT USE_XERCES)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} 
+  ${crea_LIBRARIES}
+  ${creaBruker_LIBRARIES}
+  ${WXWIDGETS_LIBRARIES}
+  ${VTK_LIBRARIES}
+  ${GDCM_LIBRARIES}
+  ${BOOST_LIBRARIES}
+  ${XERCES_LIBRARIES}
+  sqlite3)  
+ENDIF(NOT USE_XERCES)
+  
+  
 #----------------------------------------------------------------------------
 # INSTALLS LIBRARY
 FILE(GLOB HEADERS "*.h" "*.txx")
index 3957f3a7d652456127bcbf461fea6d38cc9f8a7e..91a807f2cc27043d13d185d339e116e4f7531b1b 100644 (file)
@@ -40,6 +40,8 @@ namespace creaImageIO
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr) {}
 
+       /// Another function to read attributes for a file
+       virtual void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr){}
   protected:
 
     /// Set the reader's name
index 7361034b5e50c032797e7b7dbf4a9bf880eb5249..713655ba46ea1fda179f5681b4b2e0b9bcb98dbe 100644 (file)
@@ -67,8 +67,7 @@ namespace creaImageIO
     v.push_back("dcm");
     v.push_back("");
   }
-  //=====================================================================
-  
   //========================================================================
   std::string irclean(const std::string& str)
   {
@@ -91,7 +90,30 @@ namespace creaImageIO
     return str;
   }
   //========================================================================
+  //=====================================================================
+  
+
+       void DicomImageReader::getAttributes(const std::string filename, 
+               std::map <std::string , std::string> &infos,std::vector<std::string> i_attr)
+       {
+               gdcm::Reader reader;
+               reader.SetFileName( filename.c_str() );
+               if (reader.Read())
+               {
+                       std::vector<std::string>::iterator it = i_attr.begin();
+                       for(;it != i_attr.end(); it++)
+                       {
+                               unsigned short el;
+                               unsigned short gr;
+                               sscanf((*it).c_str(),"D%04hx_%04hx",&gr,&el);
+                               if ( ( gr!=0 ) && ( el!=0 ) )
+                               {
+                                       infos[(*it)] =  ( GetStringValueFromTag(reader.GetFile().GetDataSet().GetDataElement(gdcm::Tag(gr,el))) );
+                               }
+                       }
+               }
+               
+       }
   //=====================================================================
   void DicomImageReader::ReadAttributes(const std::string& filename, 
                      std::map<std::string,std::string>& attr)
index 08b01f3a8ca925d8504f60eca270c75f073be2ac..0cd90567f235ca9e9e8091df4aacf7a049911390 100644 (file)
@@ -39,6 +39,8 @@ namespace creaImageIO
        void ReadAttributes2(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
+       /// Another function to read attributes for a file
+       void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
   private:
          const std::string GetStringValueFromTag( const gdcm::DataElement& ds);
          vtkGDCMImageReader *mReader;
index 5edb4edf78c10bea8be01ef81b41de915b8ab733..fcc38e076481bec00e4ecc3bc0f9144c49543e5c 100644 (file)
@@ -1,9 +1,9 @@
 
 #include <creaImageIOGimmick.h>
-
 #include <creaImageIOSystem.h>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
+
 //#include "io.h"
 #ifndef PATH_MAX // If not defined yet : do it 
 #  define PATH_MAX 2048
@@ -424,6 +424,34 @@ path+= mLocalDescpName;
   }
   //========================================================================
 
+  //========================================================================
+  // get attributes values from database  for a given file from database 
+  //========================================================================
+   void Gimmick::GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr)
+  {
+          if (i_attr.inside.size() > 0)
+          {
+                  std::map<std::string, std::string> map_attr;
+                  TreeHandler * handler=GetTreeHandler(i_attr.db);
+                  handler->getAllAttributes(filename, map_attr);
+                  if(i_attr.inside.front() == "ALL") // we  take all values
+                  {
+                          std::map<std::string, std::string>::iterator it = map_attr.begin();
+                          for(; it != map_attr.end(); it++)
+                                  i_res[it->first] = it->second;
+                  }
+                  else
+                  {
+                           std::vector<std::string>::iterator it = i_attr.inside.begin();
+                          for(; it != i_attr.inside.end(); it++)
+                                  i_res[(*it)] = map_attr[(*it)];
+                  }
+          }
+          
+
+  }
+
+
   //========================================================================
 
   void Gimmick::UpdateSetting(const std::string& name, const std::string& value)
@@ -488,4 +516,29 @@ path+= mLocalDescpName;
                 addDB(name, it_path->c_str());
         }
   }    
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Fill attributes structure with attributes present in database (inside vector
+// and not present (outside)
+///////////////////////////////////////////////////////////////////////////////
+void Gimmick::fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos)
+{
+       //test if a tag is present in Database descriptor
+       TreeHandler * handler=GetTreeHandler(infos.db);
+       mImageAdder.SetTreeHandler(handler);
+       std::vector<std::string>::const_iterator it = i_attr.begin();
+       for (;it != i_attr.end(); it++)
+       {
+               if( mImageAdder.isAttributeExist((*it)) != "" ) // in DB
+               {
+                       infos.inside.push_back((*it));
+               }
+               else
+               {
+                               infos.outside.push_back((*it)); // Need to scan again the files
+               }
+       }
 }
+
+}
\ No newline at end of file
index 017d153ce92e0f8f6f1705c6f65ea85843ac7501..49dfae4f871b970e8e476ad2b27c21ea8ee0c286 100644 (file)
@@ -8,6 +8,7 @@
 
 
 
+
 #ifdef _DEBUG
 #include <crtdbg.h>
 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
@@ -69,6 +70,22 @@ namespace creaImageIO
 
   //=======================================================================
   /// Central controler of the gimmick application
+
+
+
+       /// the selected attributes by end-user
+       typedef struct
+       {
+               // name of database to get attributes
+               std::string db;
+               // attributes available in this databse
+               std::vector<std::string> inside;
+               // attributes not available in this databse
+               std::vector<std::string> outside;
+               //
+               bool mult;
+       }OutputAttr;
+
   class CREAIMAGEIO_EXPORT Gimmick
   {
   public:
@@ -181,14 +198,16 @@ namespace creaImageIO
          const std::vector<std::string>& params, 
          std::vector<std::string>& results);
   
-    /// 
+       /// get Values for given attributes
+       void GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr);
+    
     const std::string& GetHomeDirectory();
     const std::string& GetUserSettingsDirectory();
     void CreateUserSettingsDirectory();
     const std::string& GetLocalDatabasePath();
        
-
-
+       /// Decide if attributes are available through database
+       void fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos);
     //=============================================
   private:
        SQLiteTreeHandler* mLocalDatabase;
index 3132aa69f583d1608780875df2a3a7324df840f4..2b7c85b1883a8a8e4a5f4c1cafc903c92eab60ec 100644 (file)
 
 #if defined(USE_GDCM2)
 #include <vtkGDCMImageReader.h>
+#include "gdcmSystem.h"
+#include "gdcmCryptographicMessageSyntax.h"
+#include "gdcmUIDGenerator.h"
+#include "gdcmAnonymizer.h"
+#include "gdcmGlobal.h"
 #endif
 
 
@@ -213,10 +218,30 @@ namespace creaImageIO
        }
        else
        {
-               boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent((*sel).GetAttribute("D0028_0010"),
-                                                                       (*sel).GetAttribute("D0028_0011"),
-                                                                       (*sel).GetAttribute("D0028_0012"), 
-                                                                       ""));
+               std::string extentx = (*sel).GetAttribute("D0028_0010");
+               std::string extenty = (*sel).GetAttribute("D0028_0011");
+               std::string extentz = (*sel).GetAttribute("D0028_0012");
+               std::string extentt = (*sel).GetAttribute("D0028_0010");
+               if( extentx == "" && extenty == "" && extentz == "")
+               {
+                       // we try to create a vtkImageData just to get dim informations
+                       // Long method need to improve it!
+                       std::string name = (*sel).GetAttribute("FullFileName");
+                       if (name != "")
+                       {
+                               int dim[3];
+                               char c[5];
+                               mReader.GetImage(name)->GetDimensions(dim);
+                               sprintf(c,"%d", dim[0]);
+                               extentx = c;
+                               sprintf(c,"%d", dim[1]);
+                               extenty = c;
+                               sprintf(c,"%d", dim[2]);
+                               extentz = c;
+                       }
+               }
+
+               boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent(extentx, extenty, extentz,extentt));
        if(mImageExtent==0)
        {
                mImageExtent=ie;
@@ -286,6 +311,7 @@ namespace creaImageIO
   //======================================================================
   void GimmickView::modifyValidationSignal(bool ivalid)
   {
+
          mValidationSignal(ivalid);
   }
 
@@ -371,7 +397,11 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
 
                        double spc[3];
                        first->GetSpacing(spc);
-                       spc[2]=OrderTheFileNameVector(im);      
+
+                       // OrderTheFileNameVector is not here anymore.
+                       // Try orderFilesWithZSpacing from OutputModel FCY
+                       // spc[2]=OrderTheFileNameVector(im);   
+                       spc[2] =1;
 
                        out->SetSpacing(spc);
 
@@ -393,63 +423,286 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
 }
   //======================================================================
 
-#if defined(USE_GDCM)
-       double GimmickView::OrderTheFileNameVector(std::vector<std::string> &im)
-{
-       double spacing=1;
-       typedef std::vector<GDCM_NAME_SPACE::File* > FileList;
-       FileList fileVector;
-       //GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
-       GDCM_NAME_SPACE::SerieHelper *sh = GDCM_NAME_SPACE::SerieHelper::New();
-       std::vector<std::string> lstAux;
-       std::vector<std::string>::iterator it;
-       for (it=im.begin(); it!=im.end(); ++it)
+
+
+       //////////////////////////////////////////////////////////
+       // Test if the image is a multiple or single frame. 
+       // For the moment only with the creation of vtkImageDta.
+       // TO DO with image size and dim!!!
+       //////////////////////////////////////////////////////////
+       bool GimmickView::isSingle(const std::string i_file)
        {
-               ///\TODO liberer les GDCM_NAME_SPACE::File a la fin!  // JPR
-               GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
-               f->SetFileName(*it);
-               f->Load();
-               if (f->IsReadable())
+               bool bres = true;
+               vtkImageData* first = mReader.GetImage( i_file);
+               int dim[3];
+               first->GetDimensions(dim);
+               if (dim[3] > 1)
                {
-                       fileVector.push_back(f);
-               } else {
-                       lstAux.push_back(*it);
+                       bres = false;
                }
-       } // for
-                       
+               else
+               {
+               }
+               return bres;
+       }
+
+       //////////////////////////////////////////////////////////
+       // get Attributes values for a file
+       //////////////////////////////////////////////////////////
        
-       if ((fileVector.size()>1) && (sh->IsCoherent( &fileVector )))
+       void GimmickView::getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr)
        {
-                       sh->OrderFileList(&fileVector);
-                       spacing= sh->GetZSpacing();
-                       im.clear();
-                       int i;
-                       for (i=0; i<fileVector.size(); i++)
-                       {
-                               im.push_back( (fileVector[i])->GetFileName() );
-                       }
-                       for (i=0; i<lstAux.size(); i++)
+               if(i_attr.inside.size() >0)
+               {
+                       mGimmick->GetAttributes(i_file,o_infos,i_attr);
+               }
+               if(i_attr.outside.size()>0)
+               {
+                       mReader.getAttributes(i_file,o_infos, i_attr.outside);
+               }
+       }
+
+       //////////////////////////////////////////////////////////
+       // create an output structure with n entries = n output
+       //////////////////////////////////////////////////////////
+       void GimmickView::readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr)
+       {
+               std::vector<std::string>::iterator it;
+               for (it=im.begin(); it!=im.end(); ++it)
+               {
+                       OutStrGimmick out;
+                       out.img = vtkImageData::New();
+                       out.img->ShallowCopy(mReader.GetImage(*it));
+                       if(i_attr.mult)
+                               getAttributes((*it),out.infos,i_attr);
+                       o_output.push_back(out);
+               }
+               // If we want only one output information structure, we set it outside the loop
+               if(!i_attr.mult)
+               {
+                       getAttributes(im.front(), o_output.front().infos,i_attr);
+               }
+               
+       }
+
+       //////////////////////////////////////////////////////////
+       // create an output structure with n entries = 1 output
+       //////////////////////////////////////////////////////////
+       void GimmickView::readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, double i_zspc)
+       {
+               OutStrGimmick out;
+               vtkImageData* first = mReader.GetImage( im.front());
+               out.img  = vtkImageData::New();
+               out.img->SetScalarType(first->GetScalarType());
+               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+               int ext[6];
+               first->GetWholeExtent(ext);  // send also 0,0 in Z 
+               if(ext[5] == 0)
+               {
+                       ext[5] = im.size()-1;
+               }
+               else
+               {
+                       ext[5] = ext[5] * im.size()-1; // to deal with multiframes 
+               }
+               out.img->SetExtent(ext);
+               int dim[3];
+               first->GetDimensions(dim);
+               out.img->SetDimensions(dim[0], dim[1], im.size() );
+               out.img->AllocateScalars();
+               out.img->Update();
+               unsigned long imsize = dim[0] * dim[1];
+               imsize = imsize * dim[2] ;  // deal with multiframes here
+               // differents formats char , short, etc...
+               // differents components 1..3  ex. jpg ->RGB 3
+               imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+               // Order the file name vector already did with the OutputModel!!!
+               //!!!!out.img->SetSpacing(i_zspc);
+               int slice = 0;
+               std::vector<std::string>::iterator it;
+               for (it=im.begin(); it!=im.end(); ++it) 
+               {
+                       vtkImageData* cur = mReader.GetImage( (*it) );
+                       memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
+                       slice++;
+               }       
+               getAttributes(im.front(),out.infos, i_attr);
+               o_output.push_back(out);
+       }
+
+
+       // TO DO  NO VERY SURE : NEED TO BE TESTED
+       //////////////////////////////////////////////////////////
+       // create an output structure with n entries (T size) = T output (n size)
+       //////////////////////////////////////////////////////////
+       void GimmickView::readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, double i_zspc)
+       {
+               vtkImageData* first = mReader.GetImage( im.front());
+               int dim[3];
+               first->GetDimensions(dim);
+               // differents formats char , short, etc...
+               // differents components 1..3  ex. jpg ->RGB 3
+               unsigned long imsize = dim[0] * dim[1];
+               imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+
+               // Order the file name vector already did with the OutputModel!!!
+               std::vector<std::string>::iterator it;
+               std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
+
+               for (it=im.begin(); it!=im.end(); ++it, it_out += dim[2])
+               {
+                       vtkImageData* cur = mReader.GetImage( (*it) );
+                       for (int slice= 0 ; slice <dim[2]; slice++)
                        {
-                               im.push_back( lstAux[i] );
+                               OutStrGimmick out;
+                               out.img = vtkImageData::New();
+                               out.img->SetScalarType(first->GetScalarType());
+
+                               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+                               int ext[6];
+                               first->GetWholeExtent(ext);  // send also 0,0 in Z 
+                               ext[5] = 0;
+                               out.img->SetExtent(ext);
+
+                               out.img->SetDimensions(dim[0], dim[1], 1 );
+                               out.img->AllocateScalars();
+                               out.img->Update();
+                               memcpy(out.img->GetScalarPointer(0,0,0), cur->GetScalarPointer(0,0,slice), imsize);
+                               o_output.push_back(out);
                        }
-       }else {
-               std::sort( im.begin(), im.end() );
+                       if(i_attr.mult)
+                               getAttributes((*it),(*it_out).infos,i_attr);
+               }
+               if(!i_attr.mult)
+               {
+                       getAttributes(im.front(), o_output.front().infos,i_attr);
+               }
+
        }
+
+               //////////////////////////////////////////////////////////
+       // create an output structure with n entries (T size) = T + n output
+       //////////////////////////////////////////////////////////
+       void GimmickView::readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr)
+       {
+               std::vector<std::string>::iterator it;
+               std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
+               vtkImageData* first = mReader.GetImage( im.front());
+               int dim[3];
+               first->GetDimensions(dim);
                        
-   return spacing;
-}
+               for (int slice= 0 ; slice <dim[2]; slice++)
+               {
+                       OutStrGimmick out;
+                       out.img = vtkImageData::New();
+                       out.img->SetScalarType(first->GetScalarType());
+                       out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+                       
+                       int ext[6];
+                       first->GetWholeExtent(ext);  // send also 0,0 in Z 
+                       ext[5] = 0;
+                       out.img->SetExtent(ext);
+                       
+                       out.img->SetDimensions(dim[0], dim[1], im.size() );
+                       out.img->AllocateScalars();
+                       out.img->Update();
+                       unsigned long imsize = dim[0] * dim[1];
+                       imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+                       int index = 0;
+       
+                       for (it=im.begin(); it!=im.end(); ++it, index ++)
+                       {
+                               vtkImageData* cur = mReader.GetImage( (*it) );
+                               memcpy(out.img->GetScalarPointer(0,0,index), cur->GetScalarPointer(0,0,slice), imsize);
+                               o_output.push_back(out);
+                       }
+               }
+               if(!i_attr.mult) // No sense to take informations in all images
+               {
+                       getAttributes(im.front(), o_output.front().infos,i_attr);
+               }
 
+       }
 
-#endif
 
-#if defined(USE_GDCM2)
-       // TO DO
-       double GimmickView::OrderTheFileNameVector(std::vector<std::string> &im)
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Global function to read Images and create wished output (informations, multiple, type and size of output...)
+// In function of type (file, vector) and size, the correct readImages function is selected
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       void GimmickView::readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, int i_dim, double i_zspc)
        {
-               return 1;
+               int size = im.size();
+               if ( size == 0)
+               {
+                       return;
+               }
+               else if (size == 1)
+               {
+                       // Simplest case
+                       // Only one image : give it
+                       // But take in count multiframe possibility
+                       if ( isSingle(im.front()) || i_dim != 1)
+                       {
+                                readImages1(o_output,im, i_attr);
+                       }
+                       else
+                       {
+                               readImages2(o_output,im, i_attr,i_zspc);
+                       }
+                       
+               }
+               else
+               {
+                       // multiple or single frame
+                       if ( isSingle(im.front()) )
+                       {
+                               //we deal with 2D images
+                               if(i_dim == 1)
+                               {
+                                       // 2D to 3D
+                                       readImages3(o_output,im, i_attr,i_zspc);
+                               }
+                               else
+                               {
+                                       readImages1(o_output,im, i_attr);
+                               }
+                       }
+                       else
+                       {
+                               // we deal with multiple frames n x (2D x T)
+                               // Differents outputs are avaialable
+                               if(i_dim == 1)
+                               {
+                                       // put all in one output
+                                       readImages3(o_output,im, i_attr,i_zspc);
+
+                               }
+                               else if( i_dim == 2)
+                               {
+                                       // put in a vector of n x T (2D)
+                                       readImages2(o_output,im, i_attr,i_zspc);
+                               }
+                               else if( i_dim == 3)
+                               {
+                                       // put in a vector of n (2D x T)
+                                       // No transformations.
+                                       readImages1(o_output,im, i_attr);
+                               }
+                               else
+                               {
+                                       // put in a vector of T (2D x n)
+                                       readImages4(o_output,im, i_attr);
+                               }
+                       }
+               }
        }
-#endif
-//======================================================================
+
+
 
 
 void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
@@ -591,53 +844,106 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
     mValidationSignal.connect(callback);
   }      
   
-} // EO namespace creaImageIO
 
-//////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
 //void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
+//{
+//
+//     gdcm::FileMetaInformation::SetSourceApplicationEntityTitle( "gdcmanon" );
+//    gdcm::Global& g = gdcm::Global::GetInstance();
+//     //if( !resourcespath )
+// //   {
+//     //      const char *xmlpathenv = getenv("GDCM_RESOURCES_PATH");
+//     //      if( xmlpathenv )
+//     //        {
+//     //        // Make sure to look for XML dict in user explicitly specified dir first:
+//     //        xmlpath = xmlpathenv;
+//     //        resourcespath = 1;
+//     //        }
+// //   }
+// // if( resourcespath )
+// //   {
+// //   // xmlpath is set either by the cmd line option or the env var
+// //   if( !g.Prepend( xmlpath.c_str() ) )
+// //     {
+// //     std::cerr << "Specified Resources Path is not valid: " << xmlpath << std::endl;
+// //     return 1;
+// //     }
+// //   }
+//  // All set, then load the XML files:
+//  if( !g.LoadResourcesFiles() )
+//  {
+//    return ;
+//  }
+//  const gdcm::Defs &defs = g.GetDefs(); (void)defs;
+//  if( !rootuid )
+//    {
+//    // only read the env var if no explicit cmd line option
+//    // maybe there is an env var defined... let's check
+//    const char *rootuid_env = getenv("GDCM_ROOT_UID");
+//    if( rootuid_env )
+//      {
+//      rootuid = 1;
+//      root = rootuid_env;
+//      }
+//    }
+//  if( rootuid )
+//    {
+//    // root is set either by the cmd line option or the env var
+//    if( !gdcm::UIDGenerator::IsValid( root.c_str() ) )
+//      {
+//      std::cerr << "specified Root UID is not valid: " << root << std::endl;
+//      return 1;
+//      }
+//    gdcm::UIDGenerator::SetRoot( root.c_str() );
+//    }
+//
+//     if(type == 0)
 //     {
-               //if(type == 0)
-               //{
-               //   // Get private key/certificate
-        //    gdcm::CryptographicMessageSyntax cms;
-               //if( !dumb_mode )
-  //  {
-  //  if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
-  //    {
-  //    return 1;
-  //    }
-  //  cms.SetCipherType( ciphertype );
-  //  }
-
-  //// Setup gdcm::Anonymizer
-  //gdcm::Anonymizer anon;
-  //if( !dumb_mode )
-  //  anon.SetCryptographicMessageSyntax( &cms );
-
-  //if( dumb_mode )
-  //  {
-  //  for(unsigned int i = 0; i < nfiles; ++i)
-  //    {
-  //    const char *in  = filenames[i].c_str();
-  //    const char *out = outfilenames[i].c_str();
-  //    if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
-  //      {
-  //      //std::cerr << "Could not anonymize: " << in << std::endl;
-  //      return 1;
-  //      }
-  //    }
-  //  }
-  //else
-  //  {
-  //  for(unsigned int i = 0; i < nfiles; ++i)
-  //    {
-  //    const char *in  = filenames[i].c_str();
-  //    const char *out = outfilenames[i].c_str();
-  //    if( !AnonymizeOneFile(anon, in, out) )
-  //      {
-  //      //std::cerr << "Could not anonymize: " << in << std::endl;
-  //      return 1;
-  //      }
-  //    }
-  //  }
-//     }
\ No newline at end of file
+//                // Get private key/certificate
+//          gdcm::CryptographicMessageSyntax cms;
+//             if( !dumb_mode )
+//             {
+//                     if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
+//                     {
+//                             return 1;
+//                     }
+//                     cms.SetCipherType( ciphertype );
+//             }
+//
+//     // Setup gdcm::Anonymizer
+//     gdcm::Anonymizer anon;
+//             if( !dumb_mode )
+//             anon.SetCryptographicMessageSyntax( &cms );
+//
+//             if( dumb_mode )
+//             {
+//                     for(unsigned int i = 0; i < nfiles; ++i)
+//             {
+//             const char *in  = filenames[i].c_str();
+//             const char *out = outfilenames[i].c_str();
+//             if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
+//        {
+//                     //std::cerr << "Could not anonymize: " << in << std::endl;
+//                     return 1;
+//             }
+//      }
+//    }
+//  //else
+//  //  {
+//  //  for(unsigned int i = 0; i < nfiles; ++i)
+//  //    {
+//  //    const char *in  = filenames[i].c_str();
+//  //    const char *out = outfilenames[i].c_str();
+//  //    if( !AnonymizeOneFile(anon, in, out) )
+//  //      {
+//  //      //std::cerr << "Could not anonymize: " << in << std::endl;
+//  //      return 1;
+//  //      }
+//  //    }
+//  //  }
+//     }
+//}
+//
+} // EO namespace creaImageIO
\ No newline at end of file
index beb7bf25f16717e6b423efd773acc4016eebef12..7a0e839340e3a9c0a5b97b30b5e1604982aa9214 100644 (file)
 
 namespace creaImageIO
 {
+
+       typedef struct 
+       { 
+               vtkImageData *img;
+               std::map<std::string, std::string> infos;
+       }OutStrGimmick;
+
+
        /**
        * \ingroup View
        */
@@ -95,8 +103,8 @@ namespace creaImageIO
          { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
       
          /// Anonymize or de-anonymize data
-         void Anonymize(std::vector<std::string> i_filenames, int type);
-         
+         virtual void Anonymize(std::vector<std::string> i_filenames, int type)
+         { GimmickError("INTERNAL ERROR : Anonymize not implemented"); }
 
          /// Display all Dicom Tags
          virtual void DumpTags(const std::string filename)
@@ -175,9 +183,29 @@ namespace creaImageIO
 
        void modifyValidationSignal(bool ivalid);
 
+       
+       void readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, int i_dim, double i_zspc);
+                       bool isSingle(const std::string i_file);
     private:
 
-       double OrderTheFileNameVector(std::vector<std::string> &im);
+
+       typedef void (*readXD)(std::vector<OutStrGimmick>&,  std::vector<std::string>, OutputAttr, double);
+
+       void getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr);
+
+       virtual void readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, double i_zspc);
+
+       virtual void readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr, double i_zspc);
+
+       virtual void readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr);
+
+       virtual void readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
+                        OutputAttr i_attr);
+
 
       /// Controller which manages the interaction with the model
       boost::shared_ptr< Gimmick> mGimmick;
index d6edb7854d55a7fc2ee3a490a5574972860dd158..d93b186c839253fbac7aa11f29e30260c2de2e75 100644 (file)
@@ -164,8 +164,19 @@ namespace creaImageIO
     return i;
   }
   //=====================================================================
-
-
+  // Another function to read attributes for a file
+  void ImageReader::getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+  {
+          if (mLastFilename!=filename)
+      {
+       if (!CanRead(filename)) 
+         { 
+           return;
+         }
+      }
+    mLastReader->getAttributes(filename, infos, i_attr);
+  }
   //=====================================================================
    void ImageReader::ReadAttributes(const std::string& filename, 
                                    std::map<std::string,std::string>& attr)
index ab9fbe70b3bb70b2d02f16ffe1ff4109525fb5af..1bf201c16de8c80e3d2375b1f91be9e6718f0c11 100644 (file)
@@ -37,8 +37,12 @@ namespace creaImageIO
 
     /// Exclude specific readers 
     /// TO DO...
+       /// Another function to read attributes for a file
+       void getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
     
 
+
   protected:
     
     /// Register a reader
index 3ee50de9a2e558912cfe0d8ac0e489e2cc1cd209..8e5c716da4c5bbf03adef473575e7adc224d505e 100644 (file)
@@ -211,6 +211,12 @@ namespace creaImageIO
      }
   }
   //=====================================================================
+  // function to read attributes for a file
+  void MultiThreadImageReader::getAttributes(const std::string filename, 
+         std::map <std::string , std::string> &infos,std::vector<std::string> i_attr)
+  {
+         mReader->getAttributes(filename, infos, i_attr);
+  }
 
   //=====================================================================
   void MultiThreadImageReader::Request( MultiThreadImageReaderUser* user,
index c5a9ef9574081937cf4849933c0eed44409a62da..461d2c31397c2a83d6865ed1c24a134bc0214607 100644 (file)
@@ -105,7 +105,10 @@ namespace creaImageIO
     void OnMultiThreadImageReaderEvent( const std::string& filename,
                                        EventType type,
                                        vtkImageData* image);
-    
+   
+    /// Function to read attributes for a file 
+       void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+
   protected:
          bool mDone;
     int GetMaximalPriorityWithoutLocking();
@@ -140,6 +143,8 @@ namespace creaImageIO
       int& UnloadIndex() { return mUnloadIndex; }
       vtkImageData* GetImage() const { return mImage; }
       void SetImage( vtkImageData* i ) { mImage=i; }
+
+         std::map<std::string, std::string> getAttributes(const std::vector<std::string> i_attr);
     private:
       MultiThreadImageReaderUser* mUser;
       std::string mFilename;
index 627db08f7465afd4321302687a5d527d3affee6d..7a296e65576cbd97fa2d3c0b47b482eab14fd818 100644 (file)
@@ -1,7 +1,6 @@
 #include <creaImageIOSQLiteTreeHandler.h>
 #include <creaImageIOSystem.h>
 #include <creaImageIOGimmick.h>
-#include <creaImageIOTree.h>
 
 #include "CppSQLite3.h"
 
@@ -321,6 +320,7 @@ namespace creaImageIO
            command += "\n)";
            UPDATEDB(command);
            
+               GetTree().CopyAttributeDescriptorList(l);
            
            // Add Attribute 'ID' to Description
            GetTree().GetDescriptor().Add
@@ -500,6 +500,7 @@ namespace creaImageIO
            return false;
  
          }
+                GetTree().CopyAttributeDescriptorList(level);
       }
 
        
@@ -804,21 +805,10 @@ GimmickDebugMessage(1,                                    "query : '"                         <<query                                         <<std::endl);
   {
        
     std::string query = "DELETE FROM ";
-   
-
-       query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
-       
+       query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
     query += " WHERE ID='"+ node->GetAttribute("ID") + "';";
-    UPDATEDB(query);
-       GimmickDebugMessage(2,
-                           " Deleting '"
-                               <<node->GetLabel()<<"' with ID '"
-                           <<node->GetAttribute("ID")
-                           <<"' in level "<< GetTree().GetLevelDescriptor(node->GetLevel()).GetName()
-                           <<std::endl);
-
-
+       UPDATEDB(query);
+       
        if(node->GetNumberOfChildren()!=0)
        {
                Node::ChildrenListType::iterator i;
@@ -954,36 +944,135 @@ GimmickDebugMessage(1,                                   "query : '"                         <<query                                         <<std::endl);
     return nb; 
   }
 
-  //===================================================================== 
-  void SQLiteTreeHandler::GetTopLevelNodeId(const std::string& searchParam, const std::string& searchValue, std::string& parent_id) 
+//===================================================================== 
+// get all attributes from database for a given file
+  void SQLiteTreeHandler::getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results)
   {
          int level=GetTree().GetNumberOfLevels()-1;
-         std::string sp=searchParam.c_str();
-         std::string sv=searchValue.c_str();
+         
+         std::string search = i_filename;
+         std::string param = "FullFileName";
+         std::string name;
 
+         std::string id;
+         std::set<std::string> pid;
+         std::vector<AttributeDescriptor> attr;
+         std::vector<AttributeDescriptor>::iterator it_attr;
+         std::vector<std::string> values;
+         std::vector<std::string>::iterator it_val;
+        
+
+
+         
          while(level>1)
          {
-               std::stringstream out;
-               std::stringstream results;
-               out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
-               out<<" WHERE "<<sp<<"='"<<sv<<"'";      
-               CppSQLite3Query q;
-               QUERYDB(out.str(),q);
-               
-               
-               while (!q.eof())
-               {
+                 attr = GetTree().GetAttributeDescriptorList(level,1);
+
+                 name = GetTree().GetLevelDescriptor(level).GetName();
+                 std::vector<std::string> values;
+                 GetUpLevelNodeId(level, param,search,id);
+                 GetAttributes(name, param,search,attr, values);
+                 for(it_attr = attr.begin(), it_val = values.begin(); it_attr != attr.end(); it_attr++, it_val++)
+                 {
+                                       i_results[(*it_attr).GetKey()] = (*it_val).c_str();
+                 }
+                 search = id;
+                 param = "ID";
+                 level --;
+         }
+  }
+
+
+//===================================================================== 
+// get selected attributes from database for a given file
+         void SQLiteTreeHandler::GetAttributes(std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector<std::string> &i_results)
+        {
+                //SELECT t1.ArtistName,CDs.Title FROM Artists t1, CDs WHERE t1.ArtistID=CDs.ArtistID    
+                 std::stringstream out;
+                 std::stringstream results;
+                 out<<"SELECT ";
+                 tree::LevelDescriptor::AttributeDescriptorListType::iterator it = i_attr.begin();
+                 std::string query ="";
+                 for(; it != i_attr.end(); it++)
+                 {
+                         query += (*it).GetKey();
+                         query +=" ,";
+                 }
+                 query = query.substr(0, query.size()-1);
+                 out << query;
+                 out << "FROM "<<name;
+                 out<<" WHERE "<<i_id <<"='"<<i_value<<"'";    
+                 CppSQLite3Query q;
+                 QUERYDB(out.str(),q);
+                 while (!q.eof())
+                 {
                        for (int fld = 0; fld < q.numFields(); fld++)
                        {
-                               results<<q.getStringField(fld);
+                               i_results.push_back(q.getStringField(fld));
                        }
                        q.nextRow();
+                 }
+       }
+
+   void SQLiteTreeHandler::GetUpLevelNodeId(int level, const std::string& searchParam, const std::string& searchValue, std::string& parent_id) 
+   {
+         std::string sp=searchParam.c_str();
+         std::string sv=searchValue.c_str();
+         std::stringstream out;
+         std::stringstream results;
+         out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
+         out<<" WHERE "<<sp<<"='"<<sv<<"'";    
+         CppSQLite3Query q;
+         QUERYDB(out.str(),q);
+         while (!q.eof())
+         {
+               for (int fld = 0; fld < q.numFields(); fld++)
+               {
+                       results<<q.getStringField(fld);
                }
-               level=level-1;
-               sp="ID";
-               sv=results.str();
+               q.nextRow();
+         }
+         parent_id = results.str();
+
+  }
+
+
+  //===================================================================== 
+  void SQLiteTreeHandler::GetTopLevelNodeId(const std::string& searchParam, const std::string& searchValue, std::string& parent_id) 
+  {
+         int level=GetTree().GetNumberOfLevels()-1;
+         std::string sp=searchParam.c_str();
+         std::string sv=searchValue.c_str();
+
+         while(level>1)
+         {
+               GetUpLevelNodeId(level, sp, sv, parent_id);
+               level--;
+               sp = "ID";
+               sv = parent_id;
          }
-         parent_id=sv;
+///*
+//             std::stringstream out;
+//             std::stringstream results;
+//             out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
+//             out<<" WHERE "<<sp<<"='"<<sv<<"'";      
+//             CppSQLite3Query q;
+//             QUERYDB(out.str(),q);
+//             
+//             
+//             while (!q.eof())
+//             {
+//                     for (int fld = 0; fld < q.numFields(); fld++)
+//                     {
+//                             results<<q.getStringField(fld);
+//                     }
+//                     q.nextRow();
+//             }*/
+//             level=level-1;
+//             sp="ID";
+//             sv=results.str();
+//       }
+//       parent_id=sv;
 
   }
 
index 1172298500f114096ee6195b71b0687251853084..e5c001edd0ecd02e2aa760cf42d02a20b6c24362 100644 (file)
@@ -2,6 +2,7 @@
 #define __creaImageIOSQLiteTreeHandler_h_INCLUDED__
 
 #include <creaImageIOTreeHandler.h>
+#include <creaImageIOTree.h>
 
 class CppSQLite3DB;
 
@@ -135,9 +136,15 @@ namespace creaImageIO
                const std::string i_val);
  
     //====================================================================
-    
+    /// get all attributes from database for a given file
+       void getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results);
+       
+       /// get selected attributes from database for a given file
+       void GetAttributes(std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector<std::string> &i_results);
+       
+       /// get Id for the up level node
+       void GetUpLevelNodeId(int level, const std::string& searchParam, const std::string& searchValue, std::string& parent_id);
 
-    
   protected:
     //======================================================================
     /// Open the database
index 770a80215678d69e318623d8b4c76892dee824f1..d9d0af36baa014e0f8e2055c9e6d42ecbf2eac83 100644 (file)
@@ -40,6 +40,8 @@ namespace creaImageIO
                Keys.push_back(SETTINGS_SYNC_FREQ);
                Keys.push_back(SETTINGS_COPY_PATH);
                Keys.push_back(SETTINGS_REMOVE_PATIENT_DISPLAY);
+               Keys.push_back(SETTINGS_OUTPUT_ASK);
+               Keys.push_back(SETTINGS_OUTPUT_DIM);
                readSettings(Keys, sets);
 
     }
@@ -63,6 +65,8 @@ namespace creaImageIO
        m_SettingsMap[SETTINGS_DICOM_LIBRARY] = "gdcm";
           m_SettingsMap[SETTINGS_COPY_PATH] = m_SettingsFileName.substr(0,m_SettingsFileName.find_last_of('\\')+1)+"Copied files";
           m_SettingsMap[SETTINGS_REMOVE_PATIENT_DISPLAY] = "0";
+          m_SettingsMap[SETTINGS_OUTPUT_ASK] ="true";
+          m_SettingsMap[SETTINGS_OUTPUT_DIM] = "1";
        writeSettingsFile();
    }
 
index 8d13d366ae8348143566079dab4073ec7ce0e687..e6a974473a169332a6a46a0832a2313abc5b4407 100644 (file)
@@ -7,6 +7,8 @@
 #define SETTINGS_DBPATH                                        "<dbpath>"
 #define SETTINGS_COPY_PATH                             "<copy_path>"
 #define SETTINGS_REMOVE_PATIENT_DISPLAY "<remove_patient>"
+#define SETTINGS_OUTPUT_ASK                            "<output_ask>"
+#define SETTINGS_OUTPUT_DIM                            "<output_dim>"
 
 
 namespace creaImageIO
index de5b94a062c84b57a4b42f913e71ff6dcfbf44df..c7b65b4014630e27eb38e524b9171cf9426bfd61 100644 (file)
@@ -55,12 +55,27 @@ namespace creaImageIO
       { return GetDescriptor().GetLevelDescriptor(level); }
 
       /// Returns the AttributeDescriptorList of a given level (const ref)
+         /// type = 0 all attributes
+         /// type = 1 without ID and PATIENT_ID
       const LevelDescriptor::AttributeDescriptorListType& 
-      GetAttributeDescriptorList(int level) const
-      { return GetDescriptor().GetAttributeDescriptorList(level); }
+      GetAttributeDescriptorList(int level, int type = 0) const
+      { return GetDescriptor().GetAttributeDescriptorList(level, type); }
   
       virtual void Print() const;
 
+
+         /// Copy descriptor list without ID tag
+         void CopyAttributeDescriptorList(int level)
+         {
+                 GetDescriptor().CopyAttributeDescriptorList(level);
+         }
+         
+         /// Test if this attribute is available in this tree description
+         const std::string isAttributeExist(const std::string i_attr)
+         {
+                 return mDescriptor.isExist(i_attr);
+         }
+
     private:
       Descriptor mDescriptor;
 
index 852479456716b6cd3e4d1ea266c1499d6b034712..6b176c90af68ec6e746551a166500dcec76774c4 100644 (file)
@@ -272,5 +272,28 @@ namespace creaImageIO
            }
        }
     }
+
+       
+    //==================================================================
+       // test if an attribute is present in DescriptionList
+       // return level's name
+       const std::string Descriptor::isExist(const std::string i_attr)
+       {
+               std::string name = "";
+               LevelDescriptorListType::const_iterator l = GetLevelDescriptorList().begin();
+               for (;     l!= GetLevelDescriptorList().end(); ++l)
+               {
+                       LevelDescriptor::AttributeDescriptorListType::const_iterator a = l->GetAttributeDescriptorList().begin();
+               for(;a!= l->GetAttributeDescriptorList().end(); ++a)
+                       {
+                               if (a->GetKey() == i_attr)
+                               {
+                                       name = l->GetName();
+                                       break;
+                               }
+                       }
+               }
+               return name.c_str();
+       }
   }
 }
index a7e5b94da131cdc6f04676d475ddc02bf64d0c33..39b4180240bb1372739ba601f1f849e2339aea8d 100644 (file)
@@ -40,10 +40,18 @@ namespace creaImageIO
       { return mLevelDescriptorList[level]; }
 
       /// Returns the AttributeDescriptorList of a given level (const ref)
+           /// type = 0 all attributes
+         /// type = 1 without ID and PATIENT_ID
       const LevelDescriptor::AttributeDescriptorListType& 
-      GetAttributeDescriptorList(int level) const
-      { return mLevelDescriptorList[level].GetAttributeDescriptorList(); }
+      GetAttributeDescriptorList(int level, int type = 0) const
+      { return mLevelDescriptorList[level].GetAttributeDescriptorList(type); }
   
+         
+      /// Copy the AttributeDescriptorList without ID tag
+         void CopyAttributeDescriptorList(int level)
+         {
+                 mLevelDescriptorList[level].CopyAttributeDescriptorList();
+         }
 
       /// Adds a LevelDescriptor at the end of the list
       void Add(const LevelDescriptor&);
@@ -67,6 +75,11 @@ namespace creaImageIO
          //Create Attribute Descriptors from a file
        void createDescriptorfromFile(const std::string &i_file);
 
+
+       /// test if an attribute is present in DescriptionList
+       /// return level's name
+       const std::string Descriptor::isExist(const std::string i_attr);
+
     private:
       LevelDescriptorListType mLevelDescriptorList;
       /// Creates the mandatory level 0 descriptor called "Root"
index b84d0f9e64b3cfe85e7944587f449704a9371ece..f603013893f52a3270a88d33ed8c8531804d3fb4 100644 (file)
@@ -147,7 +147,8 @@ namespace creaImageIO
                const std::string i_val){}
  
     //====================================================================
-
+       /// get all attributes for a file
+       virtual void getAllAttributes(std::string i_filename, std::map<std::string, std::string> &i_results) =0;
 
   private:
     /// The handled tree
index f51ef14c816a299a222309a2b04eb3d08101d713..34be57a7478f08136c872d8654400f682e29bbe4 100644 (file)
@@ -234,7 +234,7 @@ namespace creaImageIO
                                    INVALID_FILE_SEPARATOR , 
                                   VALID_FILE_SEPARATOR);
                        i_sc.ReadAttributes(itr->string(),attr);
-                       mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
+               //      mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
                        mTreeHandler->AddBranch(attr);
                        mProgress.IncNumberHandledFiles();
                        std::stringstream removedOn;
@@ -291,7 +291,7 @@ namespace creaImageIO
                        {
                        mProgress.IncNumberHandledFiles();
                        AddFile( itr->string() );
-                       mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
+                       //mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
                        std::stringstream removedOn;
                        removedOn<<time(0);
                        mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
@@ -688,5 +688,10 @@ namespace creaImageIO
          }
   }
 
+  //=======================================================================
+  const std::string TreeHandlerImageAdder::isAttributeExist(const std::string i_attr)
+  {
+         return mTreeHandler->GetTree().isAttributeExist(i_attr);
+  }
+
 }
index 252e78833e295f7345065751b26834a15309af6f..479742252c7dca46cfdad882a06b6bafe2c368f2 100644 (file)
@@ -155,7 +155,9 @@ namespace creaImageIO
        void GetAttributes(const std::vector<std::string>& params, 
          const std::string& filename, 
          std::vector<std::string>& results);
-  
+
+       /// Test if an attribute is referenced for a given treeHandler
+       const std::string isAttributeExist(const std::string i_attr);
   
   
  
index 46eb41a568937d0af9322b673295a2b3d00ccbd7..531b7151ef97228bcb20b45a77dacd4f934a31a1 100644 (file)
@@ -25,7 +25,30 @@ namespace creaImageIO
        }
     }
 
-       
+       // Copy the descriptor List without ID and PATIENT_ID attributes
+       void LevelDescriptor::CopyAttributeDescriptorList() 
+      { 
+                 mAttributeDescriptorListWID = mAttributeDescriptorList; 
+                 for(AttributeDescriptorListType::iterator it = mAttributeDescriptorListWID.begin();
+                         it != mAttributeDescriptorListWID.end(); it++)
+                 {
+                         if((*it).GetKey() == "ID")
+                         {
+                                       mAttributeDescriptorListWID.erase(it);
+                                       break;
+                         }
+                 }
+
+                 for(AttributeDescriptorListType::iterator it = mAttributeDescriptorListWID.begin();
+                         it != mAttributeDescriptorListWID.end(); it++)
+                 {
+                         if((*it).GetKey() == "PARENT_ID")
+                         {
+                                       mAttributeDescriptorListWID.erase(it);
+                                       break;
+                         }
+                 }
+        }
 
   }
 }
index f9470346f62a4dd2bfc65b009a4cc021de528528..be2a3d81ee955897b1278e849d9a501e4fd8ef22 100644 (file)
@@ -36,8 +36,17 @@ namespace creaImageIO
       typedef std::vector<AttributeDescriptor> AttributeDescriptorListType;
  
       /// Returns the list of AttributeDescriptor (const)
-      const AttributeDescriptorListType& GetAttributeDescriptorList() const 
-      { return mAttributeDescriptorList; }
+           /// type = 0 all attributes
+         /// type = 1 without ID and PATIENT_ID
+      const AttributeDescriptorListType& GetAttributeDescriptorList(int type = 0) const 
+      {        if (type == 0)
+                 return mAttributeDescriptorList; 
+               else 
+                       return mAttributeDescriptorListWID;
+         }
+
+         /// Copy the original list of attributes
+         void CopyAttributeDescriptorList();
 
       /// \return The list of attributes with flag IDENTIFIER set
       const std::vector<std::string>& GetIdentifierList() const 
@@ -48,7 +57,10 @@ namespace creaImageIO
 
     private:
       std::string mName;
+         // Attributes List for this level
       AttributeDescriptorListType mAttributeDescriptorList;
+         // Attributes List for this level without ID and PARENT_ID attributes
+         AttributeDescriptorListType mAttributeDescriptorListWID;
       /// The list of attributes with flag IDENTIFIER set
       std::vector<std::string> mIdentifierList;
       /// The list of attributes with flag LABEL set
index 8eb476bbb8605bbaea8eb3a75cc396a1e351a06b..978bb03ec4bd0d89c7134fce65e7c735aac1b485 100644 (file)
@@ -41,10 +41,10 @@ namespace creaImageIO
     fread(header, sizeof(int), HEADER_SIZE, Ultrasonix_file);
     if (ferror(Ultrasonix_file))
        return false;
-    h.type         = header[0];
-    h.frame        = header[1];
-    h.height       = header[2];
-    h.width        = header[3];
+    h.type         = header[1];
+    h.frame        = header[2];
+    h.height       = header[3];
+    h.width        = header[4];
     h.frequency    = header[14];
     h.samplingRate = header[15];
     //free(header);  
@@ -71,20 +71,25 @@ namespace creaImageIO
        fseek(Ultrasonix_file,0,SEEK_END);              // go to end of file
        if (h.type == TYPE_RF)
                size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame) * sizeof(int)) / sizeof(short);
-       else if (h.type == TYPE_B8)
-               size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(char);
+       else if (h.type == 1)//TYPE_B8)
+               size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame+4) *  sizeof(int)) / sizeof(char);
        else if (h.type == TYPE_B32)
                size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(int);
 
        // check if the data size corresponds to the dimensions of the images
        if (size == h.width * h.height * h.frame)
                ok = true;
-               
+
        fclose(Ultrasonix_file);
     }
     return ok;
   }
   //=====================================================================
+  void UltrasonixImageReader::getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+  {
+         //TO DO
+  }
   
   //=====================================================================
   vtkImageData* UltrasonixImageReader::ReadImage(const std::string& filename)
index c0c9c5434ebf1d7996d65641bab8b42e20cf0932..2e33dc0953752f5acea40720d1a0ddad3bbac5c0 100644 (file)
@@ -28,6 +28,9 @@ namespace creaImageIO
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
+        virtual void getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+
   };
   //=====================================================================
 
index 0d3780ac827a22f80dc45bbce6feac23e104e77c..37f116eb2d2c2a4d0e49fd9ddc1dd7f465b73226 100644 (file)
@@ -52,7 +52,10 @@ namespace creaImageIO{
          }*/
   }
   //=====================================================================
-  
+  void VtkImageReader::getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+   {
+   }
   //=====================================================================
   vtkImageData* VtkImageReader::ReadImage(const std::string& filename)
   {
index 44e8f230277c6023ad5bbd6f2cb4e82fdd6c9bd9..ad60149eab6fb66a1e8ab00a1f232f1323812320 100644 (file)
@@ -38,6 +38,8 @@ namespace creaImageIO
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
+       virtual void getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
   private:
     vtkImageReader2* mReader;
     std::string mExtensions;
index 6c5c9cd2404f71a9f9c61260968783b4baa13724..63c6ed450eef9504cae041be9a30cf12f54f6b15 100644 (file)
@@ -38,6 +38,7 @@ namespace creaImageIO{
 
                /// Storage name
                std::string m_name;
+
        };
 }
 #endif // USE_WIDGETS
index ad776ddb2662ade85979b8f2469d80a4110bfd05..0f0c494f5951ddcd4ae558e379a8fd34711d8d9d 100644 (file)
@@ -61,6 +61,8 @@ namespace creaImageIO
        mView->GetSelectedImagesInVector(s, dim); 
     }
 
+  
+
     void OnSelectedImage(bool t);
 
     void AddImagesToDB(std::string dir);
index bac2c140cdb7f467b2676eb6891a9595f437ae0b..975074062580e1b21e438da17b50a779c90a73a0 100644 (file)
@@ -47,6 +47,12 @@ namespace creaImageIO
     void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
     { mView->GetSelectedImagesInVector(s, dim); }
 
+       // get selected files in an Output structure
+       void getSelected(std::vector<OutStrGimmick> &outG,std::vector< std::string> i_attr, bool mult, const std::string outmodel)
+       {
+               mView->getSelectedFiles(outG, i_attr, mult, outmodel);
+       }
+
     void GetSelectedFiles(std::vector<std::string>& s) 
     { mView->GetSelectedFiles(s); }
 
index 91185a56339be44eeed9d790087d31952aa4e5e0..f13c5e01823351ee46f29f898654879d85e07d42 100644 (file)
@@ -10,6 +10,8 @@
 #include <creaImageIOWxDescriptorPanel.h>
 #include <creaImageIOWxDumpPanel.h>
 #include <creaImageIOWxExportDlg.h>
+#include <creaImageIOWxOutputDlg.h>
+#include <creaImageIOOutputModel.h>
 
 using namespace crea;
 // Icons
@@ -298,18 +300,117 @@ namespace creaImageIO
   {
        std::vector<std::string> files;
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
-       ReadImagesNotThreaded(s, files, dim);
+       //ReadImagesNotThreaded(s, files, dim);
+
+
+               std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       //              ReadImagesNotThreadedInfosInVector(db_name,output, files,dim,1);
   }
 
+
+
   //======================================================================
   void WxGimmickView::GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
   {
        std::vector<std::string> files;
+       std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
        ReadImagesNotThreadedInVector(s, files, dim);
   }
+
+
+  /// By default if out_infos is empty, we dont' provide informations, we return only vtkImageData 
+  /// if out_infos has only one entry "all" we provide all database informations
+  void WxGimmickView::getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> i_attr, 
+                                                                         bool mult, const std::string out_model)
+  {
+       // First we select the files
+    std::vector<std::string> files;
+       std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
+       std::string asking;
+       std::string dim;
+       bool bsingle = isSingle(files.front());
+       int i_dim_out;
+       mGimmick->GetSetting(SETTINGS_OUTPUT_ASK, asking);
+       mGimmick->GetSetting(SETTINGS_OUTPUT_DIM, dim);
+
+       if (asking == "true")
+       {
+               // display the output dialog box
+               // get dim
+               int idim;
+               sscanf(dim.c_str(),"%d",&idim);
+               WxOutputDlg *dlg = new WxOutputDlg(this,files, idim -1, bsingle);
+               if (dlg->ShowModal() == wxID_OK)
+               {
+                       dim = dlg->getDim();
+                       mGimmick->UpdateSetting(SETTINGS_OUTPUT_ASK, dlg->getAsking());
+                       mGimmick->UpdateSetting(SETTINGS_OUTPUT_DIM, dim);
+               }
+               else
+               {
+                       return;
+               } 
+       }
+       else
+       {
+       }
+       sscanf(dim.c_str(),"%d",&i_dim_out);
+
+
+       // Next we create the structure for dicom output infos
+       OutputAttr Oattr;
+       Oattr.db = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       if(i_attr.empty())
+       {
+               // We don't send informations!
+       }
+       else if( i_attr.size() == 1 && i_attr.front() == "ALL")
+       {
+               // we send all database
+               Oattr.inside.push_back("ALL");
+       }
+       else if( (i_attr.size() == 1 && i_attr.front() != "ALL") 
+               || (i_attr.size() >1) )
+       {
+               mGimmick->fillVectInfos(i_attr, Oattr);
+       }
+       else
+       {
+               // nothing
+       }
+
+       // Next we create model and sort files
+       std::vector<std::string> sort_files(files);
+       double zspacing = 1;
+       if( !out_model.empty() )
+       {
+       /*      OutputModel mod(out_model);
+               mGimmick->isAttributeExist(db_name, mod);
+               mod.sort(files, sort_files);
+       */}
+
+       if ( sort_files.size() > 1 && ( (bsingle && i_dim_out == 1) || (!bsingle && i_dim_out ==3) ) )
+       {
+               OutputModel *mod = new OutputModel();
+               zspacing = mod->orderFilesWithZspacing(sort_files);
+               delete mod;
+       }
+       // Now we read and create the waiting output (vtkImageData * or OutGimmickData *)
+       readImages(outG, sort_files, Oattr, i_dim_out, zspacing);
+  }
+
+
+
+
   //======================================================================
 
+  //======================================================================
+
+
   //======================================================================
   void WxGimmickView::GetSelectedFiles(std::vector<std::string>& s)
   {
index f676eceb13a905e4b97b4859b054f228d47494a9..63cddad25a342721988633af37b50f96756dcc5f 100644 (file)
@@ -32,6 +32,7 @@ namespace creaImageIO
   public:
     
     typedef int EventType;
+       OutStrGimmick m_out;
     
     /// Ctor
     WxGimmickView(boost::shared_ptr<Gimmick>, 
@@ -48,11 +49,15 @@ namespace creaImageIO
     ///(overloaded from GimmickView)
     void GetSelectedFiles(std::vector<std::string>& s);
     
+        /// Returns the selected files in output structure
+       void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
+
     /// Returns the selected Images so that they comply with the 
     /// given parameter(4D) (overloaded from GimmickView)
     void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
     void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
 
+
     /// Returns the images indicated by the filenames in the vector 
     /// so that they comply with the given parameter(dim)
     //(overloaded from GimmickView) 
index 3b30d4cf9c192e5892aa02028ea80c5fb894091c..01b8ad41764a4e61d31a77145c9bea44997e91a2 100644 (file)
@@ -1145,6 +1145,8 @@ namespace creaImageIO
       }
   }
 
+
+
   //================================================================
   void WxTreeView::GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s)
   {