]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxDumpPanel.cpp
std:string vs std::string
[creaImageIO.git] / src / creaImageIOWxDumpPanel.cpp
index 843db487dd5a3485e7cbe02576e1e6c765e6d5a5..d1cac29bef901b4f54c68f73c68b70d30ef678d6 100644 (file)
@@ -1,6 +1,7 @@
 #include <creaImageIOWxDumpPanel.h>
 #include <creaImageIOSystem.h>
 #include <creaImageIOGimmick.h>
+#include <boost/algorithm/string.hpp>
 #if defined(USE_GDCM)
 #include <gdcmGlobal.h>
 #include <gdcmDictSet.h>
@@ -8,6 +9,16 @@
 #include "gdcmDocument.h"
 #include "gdcmFileHelper.h"
 #endif
+
+#if defined(USE_GDCM2)
+#include "gdcmGlobal.h"
+#include "gdcmFile.h"
+#include "gdcmDictPrinter.h"
+#include "gdcmPrinter.h"
+#include "gdcmReader.h"
+#include "gdcmSmartPointer.h"
+#include "gdcmSequenceOfItems.h"
+#endif
 #include "icons/save.xpm"
 
 namespace creaImageIO
@@ -36,9 +47,12 @@ namespace creaImageIO
        void WxDumpPanel::Print()
        {
           std::stringstream os;
+          std::string result = "";
           if ( !filename.empty()) // ====== Deal with a single file ======
           {
-       /*         GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+
+#if defined(USE_GDCM)
+                  GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
                   f->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);
                   f->SetFileName( filename );
                   f->SetMaxSizeLoadEntry(0xffff);
@@ -47,22 +61,100 @@ namespace creaImageIO
                      f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ |GDCM_NAME_SPACE::LD_NOSHADOW); 
                   fh->SetPrintLevel( 0 );
                   fh->Print(os);
-                  std::string result;
+                
                   std::string line;
                   while(std::getline(os, line))
                   {
                          result +=clean(line.c_str());
                          result += "\n";
                   }
-                  DumpText->SetValue(crea::std2wx(result));
-               
-                  std::string pixelType =f->GetPixelType();
-                       int nX,nY,nZ,nT,sPP,planarConfig;
-    
-      nX=f->GetXSize();
-      nY=f->GetYSize();
-      nZ=f->GetZSize();
-      nT=f->GetTSize();*/
+                  
+
+#endif
+#if defined(USE_GDCM2)
+                 gdcm::Reader reader;
+                 reader.SetFileName( filename.c_str() );
+                 if (reader.Read())
+                 {
+                         gdcm::Printer printer;
+                         printer.SetFile ( reader.GetFile() );
+                         printer.SetColor( 0 );
+                         printer.Print( os );
+                         result = os.str();
+                 }
+
+
+
+       //const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
+ // // (5400,0100) SQ (Sequence with undefined length #=1)     # u/l, 1 WaveformSequence
+       // gdcm::Tag twsq(0x5400,0x0100);
+       // bool btest = ds.FindDataElement( twsq) ;
+       //const gdcm::DataElement &wsq = ds.GetDataElement( twsq );
+       // gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = wsq.GetValueAsSQ();
+       // int num = sqi->GetNumberOfItems();
+ // 
+ // const gdcm::Item & item = sqi->GetItem(1); // Item start at #1
+ // const gdcm::DataSet& nestedds = item.GetNestedDataSet();
+
+ // // (5400,1004) US 16                                       #   2, 1 WaveformBitsAllocated
+ // gdcm::Tag twba(0x5400,0x1004);
+ // if( !nestedds.FindDataElement( twba ) )
+ //   {
+ // 
+ //   }
+ // const gdcm::DataElement &wba= nestedds.GetDataElement( twba );
+
+ // //std::cout << wba << std::endl;
+ // //  (5400,1006) CS [SS]                                     #   2, 1 WaveformSampleInterpretation
+ // // (5400,1010) OW 00ba\0030\ff76\ff8b\00a2\ffd3\ffae\ff50\0062\00c4\011e\00c2\00ba... # 57600, 1 WaveformData
+ // gdcm::Tag twd(0x5400,0x1010);
+ // if( !nestedds.FindDataElement( twd ) )
+ //   {
+
+ //   }
+ // const gdcm::DataElement &wd = nestedds.GetDataElement( twd );
+ // const gdcm::ByteValue *bv = wd.GetByteValue();
+ // size_t len = bv->GetLength();
+ // int16_t *p = (int16_t*)bv;
+       // 
+ // size_t npts = len / 2;
+ // //npts = 10; // DEBUG !
+ // for(size_t i = 0; i < npts; ++i )
+ //   {
+ //   float x;
+ //   x = (float)p[i];
+ //   }
+ //// 
+       //// gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = wsq.GetValueAsSQ();
+       ////if( !sqi || !sqi->GetNumberOfItems() )
+ ////   {
+ ////   
+ ////   }
+
+ //// const gdcm::Item & item = sqi->GetItem(1); // Item start at #1
+ //// const gdcm::DataSet& nestedds = item.GetNestedDataSet();
+
+ //// // (5400,1004) US 16                                       #   2, 1 WaveformBitsAllocated
+ //// gdcm::Tag twba(0x5400,0x1004);
+ //// if( !nestedds.FindDataElement( twba ) )
+ ////   {
+ ////   return 0;
+ ////   }
+ //// const gdcm::DataElement &wba= nestedds.GetDataElement( twba );
+
+
+
+       //        gdcm::DataElement data = reader.GetFile().GetDataSet().GetDataElement(gdcm::Tag(0x5400,0x0100));
+       //        std::string seq_old_begin = "(fffe,e000) na (Item with undefined length)";
+       //        std::string seq_new_begin = "<SEQ>";
+       //        boost::algorithm::replace_all(result, seq_old_begin, seq_new_begin);
+       //        std::string seq_old_end = "(fffe,e00d)";
+       //        std::string seq_new_end = "<\\SEQ>";
+       //        boost::algorithm::replace_all(result, seq_old_end, seq_new_end);
+                 //seq_old_end = "(fffe,e0dd)";                  boost::algorithm::replace_all(result, seq_old_end, "\n");
+#endif
+                 DumpText->SetValue(crea::std2wx(result));                
+
                }
        }
 
@@ -74,7 +166,7 @@ namespace creaImageIO
                           {
                                   std::string tag;
                                   std::string line;
-                                  std:string signification;
+                                  std::string signification;
                                   std::string value;
                                   std::string resultat;