1 #include <creaImageIOWxDumpPanel.h>
2 #include <creaImageIOSystem.h>
3 #include <creaImageIOGimmick.h>
5 #include <gdcmGlobal.h>
6 #include <gdcmDictSet.h>
8 #include "gdcmDocument.h"
9 #include "gdcmFileHelper.h"
11 #include "icons/save.xpm"
16 WxDumpPanel::WxDumpPanel(wxWindow *parent, std::string i_filename)
17 : wxDialog(parent, -1,_T("DICOM TAGS"), wxDefaultPosition, wxSize(550,580)), filename(i_filename)
20 mIcon = new wxImageList(size,size,true);
21 mIcon->Add(wxBitmap(wxBitmap(wxIcon(save_xpm)).ConvertToImage().Rescale(size, size)));
22 wxToolBar *mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize);
23 mToolBar->AddTool( DUMP_SAVE_ID,_T("Save"), mIcon->GetBitmap(0), _T("Save Dicom Tags in text file"));
25 DumpText = new wxTextCtrl( this, wxID_ANY,_T(""), wxPoint(5,30), wxSize(520,510), wxTE_READONLY| wxMac | wxTE_MULTILINE | wxTE_RICH );
31 WxDumpPanel::~WxDumpPanel(){}
33 ///////////////////////////////////////////////////
34 /// Display in a control Text all dicom tags
35 ///////////////////////////////////////////////////
36 void WxDumpPanel::Print()
39 if ( !filename.empty()) // ====== Deal with a single file ======
41 /* GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
42 f->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);
43 f->SetFileName( filename );
44 f->SetMaxSizeLoadEntry(0xffff);
46 GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
47 f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ |GDCM_NAME_SPACE::LD_NOSHADOW);
48 fh->SetPrintLevel( 0 );
52 while(std::getline(os, line))
54 result +=clean(line.c_str());
57 DumpText->SetValue(crea::std2wx(result));
59 std::string pixelType =f->GetPixelType();
60 int nX,nY,nZ,nT,sPP,planarConfig;
70 const std::string WxDumpPanel::clean(const std::string &i_line)
73 if (i_line.substr(4,1) == "|")
77 std:string signification;
81 tag = "(" + i_line.substr(0,9) + ")";
82 line = i_line.substr(14,i_line.size()-10);
83 int pos1 = line.find_first_of("[");
84 int pos2 = line.find_first_of("]");
85 signification = line.substr(pos1+1, pos2-pos1-1);
86 line = line.substr(pos2+1);
87 pos1 = line.find_first_of("[");
88 pos2 = line.find_first_of("]");
89 value = line.substr(pos1+1, pos2-pos1-1);
90 resultat = tag + " " + signification + ": " +value;
99 ///////////////////////////////////////////////////
100 /// wxEvent to save Dicom Tags in a text file //
101 ///////////////////////////////////////////////////
102 void WxDumpPanel::SaveInfos(wxCommandEvent& event)
104 wxFileDialog* FD = new wxFileDialog( 0,_T("Select file"), _T(""), _T(""),
105 crea::std2wx("*.txt"), wxOPEN, wxDefaultPosition);
106 if (FD->ShowModal()==wxID_OK)
109 std::ofstream ofs(crea::wx2std(FD->GetPath()).c_str());
111 ofs << crea::wx2std(DumpText->GetValue());;
117 ////////////////////////////////////////////////////////////
118 ////////////////////////////////////////////////////////////
119 BEGIN_EVENT_TABLE(WxDumpPanel, wxDialog)
120 EVT_TOOL(DUMP_SAVE_ID, WxDumpPanel::SaveInfos)