]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxDumpPanel.cpp
move directory
[creaImageIO.git] / src2 / creaImageIOWxDumpPanel.cpp
index b2231c152d60fae349adb30fc9a2a269b9c5840f..843db487dd5a3485e7cbe02576e1e6c765e6d5a5 100644 (file)
@@ -1,30 +1,32 @@
 #include <creaImageIOWxDumpPanel.h>
 #include <creaImageIOSystem.h>
 #include <creaImageIOGimmick.h>
+#if defined(USE_GDCM)
 #include <gdcmGlobal.h>
 #include <gdcmDictSet.h>
 #include "gdcmFile.h"
 #include "gdcmDocument.h"
 #include "gdcmFileHelper.h"
+#endif
 #include "icons/save.xpm"
 
 namespace creaImageIO
 {
        // CTor
-       WxDumpPanel::WxDumpPanel(wxWindow *parent,  std::string i_filename)
+   WxDumpPanel::WxDumpPanel(wxWindow *parent,  std::string i_filename)
     : wxDialog(parent, -1,_T("DICOM TAGS"), wxDefaultPosition, wxSize(550,580)), filename(i_filename)
    {
-         int size = 16;
-         mIcon = new wxImageList(size,size,true);
-         mIcon->Add(wxBitmap(wxBitmap(wxIcon(save_xpm)).ConvertToImage().Rescale(size, size)));
-      wxToolBar *mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize);
-         mToolBar->AddTool( DUMP_SAVE_ID,_T("Save"), mIcon->GetBitmap(0), _T("Save Dicom Tags in text file"));
-         mToolBar->Realize();
-         DumpText = new wxTextCtrl( this, wxID_ANY,_T(""), wxPoint(5,30), wxSize(520,510), wxTE_READONLY| wxMac | wxTE_MULTILINE | wxTE_RICH );
-         Layout(); 
-         Print();
+       int size = 16;
+       mIcon = new wxImageList(size,size,true);
+       mIcon->Add(wxBitmap(wxBitmap(wxIcon(save_xpm)).ConvertToImage().Rescale(size, size)));
+       wxToolBar *mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize);
+       mToolBar->AddTool( DUMP_SAVE_ID,_T("Save"), mIcon->GetBitmap(0), _T("Save Dicom Tags in text file"));
+       mToolBar->Realize();
+       DumpText = new wxTextCtrl( this, wxID_ANY,_T(""), wxPoint(5,30), wxSize(520,510), wxTE_READONLY| wxMac | wxTE_MULTILINE | wxTE_RICH );
+       Layout(); 
+       Print();
        }
-       
+
        // DTor
        WxDumpPanel::~WxDumpPanel(){}
 
@@ -33,35 +35,73 @@ namespace creaImageIO
        ///////////////////////////////////////////////////
        void WxDumpPanel::Print()
        {
-               std::stringstream os;
-               if ( !filename.empty()) // ====== Deal with a single file ======
+          std::stringstream os;
+          if ( !filename.empty()) // ====== Deal with a single file ======
           {
-                  GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+       /*         GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
                   f->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);
                   f->SetFileName( filename );
                   f->SetMaxSizeLoadEntry(0xffff);
                   f->Load();
                   GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
+                     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 +=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();*/
                }
        }
 
+
+       const std::string WxDumpPanel::clean(const std::string &i_line)
+       {
+               
+                 if (i_line.substr(4,1) == "|")
+                          {
+                                  std::string tag;
+                                  std::string line;
+                                  std:string signification;
+                                  std::string value;
+                                  std::string resultat;
+
+                                  tag = "(" + i_line.substr(0,9) + ")";
+                                  line = i_line.substr(14,i_line.size()-10);
+                                  int pos1 = line.find_first_of("[");
+                                  int pos2 = line.find_first_of("]");
+                                  signification = line.substr(pos1+1, pos2-pos1-1);
+                                  line = line.substr(pos2+1);
+                                   pos1 = line.find_first_of("[");
+                                   pos2 = line.find_first_of("]");
+                                  value = line.substr(pos1+1, pos2-pos1-1);
+                                  resultat = tag + " " + signification + ": " +value;
+                                 return resultat;
+                          }
+                  else
+                  {
+                          return i_line;
+                  }
+       }
+
 ///////////////////////////////////////////////////    
 /// wxEvent to save Dicom Tags in a text file   //
 ///////////////////////////////////////////////////
        void WxDumpPanel::SaveInfos(wxCommandEvent& event)
        {
-               wxFileDialog* FD = new wxFileDialog( 0,_T("Select file"), _T(""), _T(""),
+       wxFileDialog* FD = new wxFileDialog( 0,_T("Select file"), _T(""), _T(""),
                                               crea::std2wx("*.txt"), wxOPEN, wxDefaultPosition);
         if (FD->ShowModal()==wxID_OK)
                {
@@ -74,10 +114,10 @@ namespace creaImageIO
                Close();
        }
 
-
 ////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////
 BEGIN_EVENT_TABLE(WxDumpPanel, wxDialog)
-    EVT_TOOL(DUMP_SAVE_ID, SaveInfos)
+    EVT_TOOL(DUMP_SAVE_ID, WxDumpPanel::SaveInfos)
 END_EVENT_TABLE()
-}
\ No newline at end of file
+}
+