Public Member Functions | Private Member Functions | Private Attributes

creaImageIO::WxDumpPanel Class Reference
[Top level graphical user interfaces]

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

#include <creaImageIOWxDumpPanel.h>

List of all members.

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Display all dicom tags from a given DICOM file.

Definition at line 19 of file creaImageIOWxDumpPanel.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 25 of file creaImageIOWxDumpPanel.cpp.

References DUMP_SAVE_ID.

{
        // 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(); 

creaImageIO::WxDumpPanel::~WxDumpPanel (  ) 

Destructor.

Definition at line 40 of file creaImageIOWxDumpPanel.cpp.


Member Function Documentation

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

Definition at line 160 of file creaImageIOWxDumpPanel.cpp.

        {
                
                  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;

void creaImageIO::WxDumpPanel::Print (  )  [private]

Display in a control Text all dicom tags.

Display in a control Text all dicom tags

Definition at line 45 of file creaImageIOWxDumpPanel.cpp.

        {
           std::stringstream os;
           std::string result = "";
           if ( !filename.empty()) // ====== Deal with a single file ======
           {

#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);
                   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 line;
                   while(std::getline(os, line))
                   {
                          result +=clean(line.c_str());
                          result += "\n";
                   }
                   

#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::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));                

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 192 of file creaImageIOWxDumpPanel.cpp.

        {
        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();
                }


Member Data Documentation

wxDialog* creaImageIO::WxDumpPanel::dialog [private]

Parent DialogBox.

Definition at line 40 of file creaImageIOWxDumpPanel.h.

wxTextCtrl* creaImageIO::WxDumpPanel::DumpText [private]

ControlText to display tags.

Definition at line 46 of file creaImageIOWxDumpPanel.h.

std::string creaImageIO::WxDumpPanel::filename [private]

Dicom file to display.

Definition at line 49 of file creaImageIOWxDumpPanel.h.

wxImageList* creaImageIO::WxDumpPanel::mIcon [private]

Icons list.

Definition at line 43 of file creaImageIOWxDumpPanel.h.


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