creaImageIO_lib
creaImageIO::WxDumpPanel Class Reference

Display all dicom tags from a given DICOM file. More...

#include <creaImageIOWxDumpPanel.h>

Inheritance diagram for creaImageIO::WxDumpPanel:
Collaboration diagram for creaImageIO::WxDumpPanel:

Public Member Functions

 WxDumpPanel (wxWindow *parent, std::string i_filename)
 Constructor. More...
 
 ~WxDumpPanel ()
 Destructor. More...
 

Private Member Functions

const std::string clean (const std::string &i_line)
 
void Print ()
 Display in a control Text all dicom tags. More...
 
void SaveInfos (wxCommandEvent &event)
 wxEvent to save Dicom Tags in a text file More...
 

Private Attributes

wxDialog * dialog
 Parent DialogBox. More...
 
wxImageList * mIcon
 Icons list. More...
 
wxTextCtrl * DumpText
 ControlText to display tags. More...
 
std::string filename
 Dicom file to display. More...
 

Detailed Description

Display all dicom tags from a given DICOM file.

Definition at line 47 of file creaImageIOWxDumpPanel.h.

Constructor & Destructor Documentation

creaImageIO::WxDumpPanel::WxDumpPanel ( wxWindow *  parent,
std::string  i_filename 
)

Constructor.

Definition at line 55 of file creaImageIOWxDumpPanel.cpp.

References DUMP_SAVE_ID, DumpText, mIcon, and Print().

56  : wxDialog(parent, -1,_T("DICOM TAGS"), wxDefaultPosition, wxSize(550,580)), filename(i_filename)
57  {
58  int size = 16;
59  mIcon = new wxImageList(size,size,true);
60  mIcon->Add(wxBitmap(wxBitmap(wxIcon(save_xpm)).ConvertToImage().Rescale(size, size)));
61  wxToolBar *mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize);
62  mToolBar->AddTool( DUMP_SAVE_ID,_T("Save"), mIcon->GetBitmap(0), _T("Save Dicom Tags in text file"));
63  mToolBar->Realize();
64  DumpText = new wxTextCtrl( this, wxID_ANY,_T(""), wxPoint(5,30), wxSize(520,510), wxTE_READONLY| wxMac | wxTE_MULTILINE | wxTE_RICH );
65  Layout();
66  Print();
67  }

Here is the call graph for this function:

creaImageIO::WxDumpPanel::~WxDumpPanel ( )

Destructor.

Definition at line 70 of file creaImageIOWxDumpPanel.cpp.

70 {}

Member Function Documentation

const std::string creaImageIO::WxDumpPanel::clean ( const std::string &  i_line)
private

Definition at line 190 of file creaImageIOWxDumpPanel.cpp.

Referenced by Print().

191  {
192 
193  if (i_line.substr(4,1) == "|")
194  {
195  std::string tag;
196  std::string line;
197  std::string signification;
198  std::string value;
199  std::string resultat;
200 
201  tag = "(" + i_line.substr(0,9) + ")";
202  line = i_line.substr(14,i_line.size()-10);
203  int pos1 = (int)line.find_first_of("[");
204  int pos2 = (int)line.find_first_of("]");
205  signification = line.substr(pos1+1, pos2-pos1-1);
206  line = line.substr(pos2+1);
207  pos1 = (int)line.find_first_of("[");
208  pos2 = (int)line.find_first_of("]");
209  value = line.substr(pos1+1, pos2-pos1-1);
210  resultat = tag + " " + signification + ": " +value;
211  return resultat;
212  }
213  else
214  {
215  return i_line;
216  }
217  }

Here is the caller graph for this function:

void creaImageIO::WxDumpPanel::Print ( )
private

Display in a control Text all dicom tags.

Display in a control Text all dicom tags

Definition at line 75 of file creaImageIOWxDumpPanel.cpp.

References clean(), DumpText, and filename.

Referenced by WxDumpPanel().

76  {
77  std::stringstream os;
78  std::string result = "";
79  if ( !filename.empty()) // ====== Deal with a single file ======
80  {
81 
82 #if defined(USE_GDCM)
83  GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
84  f->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);
85  f->SetFileName( filename );
86  f->SetMaxSizeLoadEntry(0xffff);
87  f->Load();
88  GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
89  f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ |GDCM_NAME_SPACE::LD_NOSHADOW);
90  fh->SetPrintLevel( 0 );
91  fh->Print(os);
92 
93  std::string line;
94  while(std::getline(os, line))
95  {
96  result +=clean(line.c_str());
97  result += "\n";
98  }
99 
100 
101 #endif
102 #if defined(USE_GDCM2)
103  gdcm::Reader reader;
104  reader.SetFileName( filename.c_str() );
105  if (reader.Read())
106  {
107  gdcm::Printer printer;
108  printer.SetFile ( reader.GetFile() );
109  printer.SetColor( 0 );
110  printer.Print( os );
111  result = os.str();
112  }
113 
114 
115 
116  //const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
117  // // (5400,0100) SQ (Sequence with undefined length #=1) # u/l, 1 WaveformSequence
118  // gdcm::Tag twsq(0x5400,0x0100);
119  // bool btest = ds.FindDataElement( twsq) ;
120  //const gdcm::DataElement &wsq = ds.GetDataElement( twsq );
121  // gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = wsq.GetValueAsSQ();
122  // int num = sqi->GetNumberOfItems();
123  //
124  // const gdcm::Item & item = sqi->GetItem(1); // Item start at #1
125  // const gdcm::DataSet& nestedds = item.GetNestedDataSet();
126 
127  // // (5400,1004) US 16 # 2, 1 WaveformBitsAllocated
128  // gdcm::Tag twba(0x5400,0x1004);
129  // if( !nestedds.FindDataElement( twba ) )
130  // {
131  //
132  // }
133  // const gdcm::DataElement &wba= nestedds.GetDataElement( twba );
134 
135  // //std::cout << wba << std::endl;
136  // // (5400,1006) CS [SS] # 2, 1 WaveformSampleInterpretation
137  // // (5400,1010) OW 00ba\0030\ff76\ff8b\00a2\ffd3\ffae\ff50\0062\00c4\011e\00c2\00ba... # 57600, 1 WaveformData
138  // gdcm::Tag twd(0x5400,0x1010);
139  // if( !nestedds.FindDataElement( twd ) )
140  // {
141 
142  // }
143  // const gdcm::DataElement &wd = nestedds.GetDataElement( twd );
144  // const gdcm::ByteValue *bv = wd.GetByteValue();
145  // size_t len = bv->GetLength();
146  // int16_t *p = (int16_t*)bv;
147  //
148  // size_t npts = len / 2;
149  // //npts = 10; // DEBUG !
150  // for(size_t i = 0; i < npts; ++i )
151  // {
152  // float x;
153  // x = (float)p[i];
154  // }
161 
164 
172 
173 
174 
175  // gdcm::DataElement data = reader.GetFile().GetDataSet().GetDataElement(gdcm::Tag(0x5400,0x0100));
176  // std::string seq_old_begin = "(fffe,e000) na (Item with undefined length)";
177  // std::string seq_new_begin = "<SEQ>";
178  // boost::algorithm::replace_all(result, seq_old_begin, seq_new_begin);
179  // std::string seq_old_end = "(fffe,e00d)";
180  // std::string seq_new_end = "<\\SEQ>";
181  // boost::algorithm::replace_all(result, seq_old_end, seq_new_end);
182  //seq_old_end = "(fffe,e0dd)"; boost::algorithm::replace_all(result, seq_old_end, "\n");
183 #endif
184  DumpText->SetValue(crea::std2wx(result));
185 
186  }
187  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::WxDumpPanel::SaveInfos ( wxCommandEvent &  event)
private

wxEvent to save Dicom Tags in a text file

wxEvent to save Dicom Tags in a text file //

Definition at line 222 of file creaImageIOWxDumpPanel.cpp.

References DumpText.

223  {
224  wxFileDialog* FD = new wxFileDialog( 0,_T("Select file"), _T(""), _T(""),
225  crea::std2wx("*.txt"), wxOPEN, wxDefaultPosition);
226  if (FD->ShowModal()==wxID_OK)
227  {
228  wxBusyCursor busy;
229  std::ofstream ofs(crea::wx2std(FD->GetPath()).c_str());
230  ofs.clear();
231  ofs << crea::wx2std(DumpText->GetValue());;
232  ofs.close();
233  }
234  Close();
235  }

Member Data Documentation

wxDialog* creaImageIO::WxDumpPanel::dialog
private

Parent DialogBox.

Definition at line 68 of file creaImageIOWxDumpPanel.h.

wxTextCtrl* creaImageIO::WxDumpPanel::DumpText
private

ControlText to display tags.

Definition at line 74 of file creaImageIOWxDumpPanel.h.

Referenced by Print(), SaveInfos(), and WxDumpPanel().

std::string creaImageIO::WxDumpPanel::filename
private

Dicom file to display.

Definition at line 77 of file creaImageIOWxDumpPanel.h.

Referenced by Print().

wxImageList* creaImageIO::WxDumpPanel::mIcon
private

Icons list.

Definition at line 71 of file creaImageIOWxDumpPanel.h.

Referenced by WxDumpPanel().


The documentation for this class was generated from the following files: