+#include <creaImageIOWxDumpPanel.h>
+#include <creaImageIOSystem.h>
+#include <creaImageIOGimmick.h>
+#include <gdcmGlobal.h>
+#include <gdcmDictSet.h>
+#include "gdcmFile.h"
+#include "gdcmDocument.h"
+#include "gdcmFileHelper.h"
+#include "icons/save.xpm"
+
+namespace creaImageIO
+{
+ // CTor
+ 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();
+ }
+
+ // DTor
+ WxDumpPanel::~WxDumpPanel(){}
+
+ ///////////////////////////////////////////////////
+ /// Display in a control Text all dicom tags
+ ///////////////////////////////////////////////////
+ void WxDumpPanel::Print()
+ {
+ std::stringstream os;
+ if ( !filename.empty()) // ====== Deal with a single file ======
+ {
+ 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);
+ fh->SetPrintLevel( 0 );
+ fh->Print(os);
+ std::string result;
+ std::string line;
+ while(std::getline(os, line))
+ {
+ result +=line;
+ result += "\n";
+ }
+ DumpText->SetValue(crea::std2wx(result));
+
+ }
+ }
+
+///////////////////////////////////////////////////
+/// wxEvent to save Dicom Tags in a text file //
+///////////////////////////////////////////////////
+ void WxDumpPanel::SaveInfos(wxCommandEvent& event)
+ {
+ wxFileDialog* FD = new wxFileDialog( 0,_T("Select file"), _T(""), _T(""),
+ crea::std2wx("*.txt"), wxOPEN, wxDefaultPosition);
+ if (FD->ShowModal()==wxID_OK)
+ {
+ wxBusyCursor busy;
+ std::ofstream ofs(crea::wx2std(FD->GetPath()).c_str());
+ ofs.clear();
+ ofs << crea::wx2std(DumpText->GetValue());;
+ ofs.close();
+ }
+ Close();
+ }
+
+
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+BEGIN_EVENT_TABLE(WxDumpPanel, wxDialog)
+ EVT_TOOL(DUMP_SAVE_ID, SaveInfos)
+END_EVENT_TABLE()
+}
\ No newline at end of file