From: Frederic Cervenansky Date: Thu, 21 Jan 2010 15:58:00 +0000 (+0000) Subject: For a given file, display all dicom tags. X-Git-Tag: CREATOOLS.2-0-3~64 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=creaImageIO.git;a=commitdiff_plain;h=cb539b100d38f3092d06430575f846c916235db4 For a given file, display all dicom tags. --- diff --git a/src2/CMakeLists.txt b/src2/CMakeLists.txt index 79953c7..b9cf63c 100644 --- a/src2/CMakeLists.txt +++ b/src2/CMakeLists.txt @@ -63,6 +63,7 @@ FILE(GLOB SOURCES_CREAIMAGEIO_WX creaImageIOWxAttributeSelectionPanel.cpp creaImageIOWxPACSConnectionPanel.cpp creaImageIOWxDescriptorPanel.cpp + creaImageIOWxDumpPanel.cpp ) endif() diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 615f1f0..cbe737d 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -66,8 +66,10 @@ namespace creaImageIO mSettings = new Settings(mCurrentDirectory); std::string dbpath = GetLocalDatabasePath(); + // Create or open local database std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/" + mLocalDescpName; + boost::algorithm::replace_all( dpath, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index ed6d31f..47b74ca 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -94,6 +94,10 @@ namespace creaImageIO virtual void CreateEditFieldsDialog(tree::Node* node, std::vector names, std::vector keys) { GimmickError("INTERNAL ERROR : EditFields not implemented"); } + /// Display all Dicom Tags + virtual void DumpTags(const std::string filename) + {GimmickError("INTERNAL ERROR : DumpTags not implemented"); } + ///Copies selected files virtual void SaveAs(const std::vector& filenames) { GimmickError("INTERNAL ERROR : SaveAs not implemented"); } diff --git a/src2/creaImageIOSQLiteTreeHandler.cpp b/src2/creaImageIOSQLiteTreeHandler.cpp index 3531408..e9724c4 100644 --- a/src2/creaImageIOSQLiteTreeHandler.cpp +++ b/src2/creaImageIOSQLiteTreeHandler.cpp @@ -654,6 +654,7 @@ namespace creaImageIO query += " WHERE PARENT_ID='" + node->GetAttribute("ID") + "'"; } +GimmickDebugMessage(1, "query : '" < +#include +#include +#include +#include +#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 diff --git a/src2/creaImageIOWxDumpPanel.h b/src2/creaImageIOWxDumpPanel.h new file mode 100644 index 0000000..891a4d3 --- /dev/null +++ b/src2/creaImageIOWxDumpPanel.h @@ -0,0 +1,62 @@ +#ifndef __creaImageIOWxDumpPanel_h_INCLUDED__ +#define __creaImageIOWxDumpPanel_h_INCLUDED__ + +#ifdef USE_WXWIDGETS +#include +#include + +#define DUMP_SAVE_ID 1800 + + +namespace creaImageIO +{ + /** + * \ingroup GUI + */ + //===================================================================== + //===================================================================== + /// Display all dicom tags from a given DICOM file + class WxDumpPanel : public wxDialog + { + public: + + /// Constructor + WxDumpPanel(wxWindow *parent, std::string i_filename); + + /// Destructor + ~WxDumpPanel(); + + + private : + + /// Display in a control Text all dicom tags + void Print(); + + /// wxEvent to save Dicom Tags in a text file + void SaveInfos(wxCommandEvent& event); + + /// Parent DialogBox + wxDialog* dialog; + + /// Icons list + wxImageList *mIcon; + + /// ControlText to display tags + wxTextCtrl *DumpText; + + /// Dicom file to display + std::string filename; + + DECLARE_EVENT_TABLE() + + }; // class WxEditFieldsPanel + //===================================================================== + + +} // EO namespace creaImageIO + + +#endif // USE_WIDGETS +// EOF +#endif + diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 37c0f19..0d9efc8 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -8,6 +8,7 @@ #include #include #include +#include using namespace crea; // Icons @@ -32,6 +33,10 @@ using namespace crea; #endif +#include +#ifdef _DEBUG +#define new DEBUG_NEW +#endif namespace creaImageIO { @@ -113,11 +118,11 @@ namespace creaImageIO CreateIconList(); // Global sizer - wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + msizer = new wxBoxSizer(wxVERTICAL); // Create the tool bar CreateToolBar(); - sizer->Add( mToolBar, 0, wxGROW, 0); + msizer->Add( mToolBar, 0, wxGROW, 0); // Split part below toolbar into notebook for views and panel // for preview, messages... @@ -139,7 +144,7 @@ namespace creaImageIO // Bottom panel mBottomPanel = new wxPanel(mSplitter,-1); - wxBoxSizer *bottom_sizer = new wxBoxSizer(wxVERTICAL); //HORIZONTAL); + mbottom_sizer = new wxBoxSizer(wxVERTICAL); //HORIZONTAL); // Previewer @@ -151,15 +156,15 @@ namespace creaImageIO mViewer->StartPlayer(); - bottom_sizer->Add(mViewer,1,wxGROW,1); + mbottom_sizer->Add(mViewer,1,wxGROW,1); // mViewer->Show(); mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!")); - bottom_sizer->Add(mText,0,wxGROW,0); + mbottom_sizer->Add(mText,0,wxGROW,0); - mBottomPanel->SetSizer(bottom_sizer); + mBottomPanel->SetSizer(mbottom_sizer); // Splitting int hsize = size.GetHeight(); @@ -171,10 +176,10 @@ namespace creaImageIO mSplitter->SplitHorizontally( mNotebook, mBottomPanel, top_minsize); - sizer->Add( mSplitter, 1, wxGROW, 0); + msizer->Add( mSplitter, 1, wxGROW, 0); mProgressDialog=0; - SetSizer( sizer ); + SetSizer( msizer ); SetAutoLayout(true); Layout(); //mListener=new Listener(); @@ -196,6 +201,7 @@ namespace creaImageIO GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView" <IsAlive()) { mListener->Delete(); } } //====================================================================== @@ -458,6 +464,7 @@ namespace creaImageIO DisplayAddSummary(); } mViewer->StartPlayer(); + delete FD; } @@ -901,7 +908,7 @@ namespace creaImageIO nb->AddPage( pacs, crea::std2wx("Connect to PACS") ); //Third page: CD/DVD Watch - WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused()); + WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this,true);//, mListener->IsPaused()); nb->AddPage( cdWatch, crea::std2wx("CD/DVD") ); //Fourth page: Selection of attributes to show @@ -1011,6 +1018,13 @@ namespace creaImageIO dial->ShowModal(); } + //======================================================================== + void WxGimmickView::DumpTags(std::string i_filename) + { + WxDumpPanel* pan= new WxDumpPanel (this,i_filename); + pan->ShowModal(); + } + //======================================================================== void WxGimmickView::OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val) { diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index d0dfaff..fa7d4d7 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -115,6 +115,8 @@ namespace creaImageIO private: + wxBoxSizer *mbottom_sizer; + wxBoxSizer *msizer; /// Is set to true at the end of constructor /// (in order to lock callbacks from threaded objects or event /// before everything is ok) @@ -197,6 +199,9 @@ namespace creaImageIO ///Edits the fields of a given node void CreateEditFieldsDialog(tree::Node* node, std::vector names, std::vector keys); + + /// Display all Dicom Tags + void DumpTags(const std::string i_filename); /// Progress dialog wxProgressDialog* mProgressDialog; diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index 03c5b0d..9b1f54e 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -4,7 +4,10 @@ #include #include #include - +#include +#ifdef _DEBUG +#define new DEBUG_NEW +#endif //===================================================================== namespace creaImageIO { @@ -106,7 +109,7 @@ namespace creaImageIO // mSplitter = new wxSplitterWindow( this , -1); // Global sizer - wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); + msizer = new wxBoxSizer(wxHORIZONTAL); int ctrl_style = wxLC_REPORT | wxLC_VRULES; int col_style = wxLIST_FORMAT_LEFT; @@ -211,19 +214,22 @@ namespace creaImageIO wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize")); wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy")); wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T("&Edit Fields")); - + wxMenuItem* m4Item=menuItem->Append(wxID_ANY, _T("&Display Dicom Tags")); + mAnonymizingID=m1Item->GetId(); mLocalCopyID=m2Item->GetId(); mEditFieldID=m3Item->GetId(); + mDumpID=m4Item->GetId(); //Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) ); Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) ); Connect( mEditFieldID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnEditField) ); + Connect( mDumpID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnDumpTags) ); #endif // wxUSE_MENUS /// Initialize the first level splitter - sizer->Add( mLevelList[0].wxSplitter ,1, wxGROW ,0); + msizer->Add( mLevelList[0].wxSplitter ,1, wxGROW ,0); // mColumnSelected=1; mLastSelected=0; mLastLevel=0; @@ -234,7 +240,7 @@ namespace creaImageIO //CreateColorPalette(); UpdateLevel(1); - SetSizer( sizer ); + SetSizer( msizer ); SetAutoLayout(true); Layout(); @@ -865,6 +871,29 @@ namespace creaImageIO GetGimmickView()->CreateEditFieldsDialog(node,names,keys); } } + + void WxTreeView::OnDumpTags(wxCommandEvent &event) + { + if(mLastRightSelected!=-1) + { + tree::Node* node=((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node; + tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a; + std::vector names; + std::vector keys; + for (a = GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).begin(); + a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).end(); + ++a) + { + if(a->GetKey()=="FullFileName") + { + GetGimmickView()->DumpTags(node->GetAttribute("FullFileName")); + return; + } + } + } + + } + //================================================================ //================================================================ diff --git a/src2/creaImageIOWxTreeView.h b/src2/creaImageIOWxTreeView.h index 001bf26..49dd62b 100644 --- a/src2/creaImageIOWxTreeView.h +++ b/src2/creaImageIOWxTreeView.h @@ -74,6 +74,9 @@ namespace creaImageIO ///Callback when the user needs to edit a field void OnEditField(wxCommandEvent& event); + + ///Callback when the user needs to display alll dicom tags for a file + void OnDumpTags(wxCommandEvent &event); ///Callback on mouse click void OnMouseClick(wxMouseEvent& event); @@ -97,6 +100,7 @@ namespace creaImageIO /// Called by OnItemSelected and OnItemDeSelected // void ProcessItem private: + wxBoxSizer *msizer; /// The struct holding the data for one level /// Holds the wx control and other data /// such as the vector of attribute keys corresponding to the columns @@ -183,6 +187,7 @@ namespace creaImageIO int mAnonymizingID; int mLocalCopyID; int mEditFieldID; + int mDumpID; // If set to true then OnSelectedChanged returns immediately. // Used to do avoid useless process during multiple selections diff --git a/src2/icons/save.xpm b/src2/icons/save.xpm new file mode 100644 index 0000000..6079335 --- /dev/null +++ b/src2/icons/save.xpm @@ -0,0 +1,130 @@ +/* XPM */ +static const char * save_xpm[] = { +"20 20 107 2", +" c #FFFFFF", +". c #E4E4FB", +"+ c #C2C2F5", +"@ c #ACABEF", +"# c #A2A1EA", +"$ c #9B9AE7", +"% c #9493E4", +"& c #8F8EE0", +"* c #8D8CDE", +"= c #A1A0E3", +"- c #D1D1F1", +"; c #DBDBFF", +"> c #9392F8", +", c #F6F8FB", +"' c #4B58BE", +") c #A4A3D4", +"! c #E2E2FA", +"~ c #BEBDFF", +"{ c #8A89EF", +"] c #EAEEF6", +"^ c #3F52B8", +"/ c #333367", +"( c #C4C4E1", +"_ c #BDBCF2", +": c #8180E6", +"< c #DEE5F0", +"[ c #344DB3", +"} c #7A79DF", +"| c #7E7DBB", +"1 c #A3A2EA", +"2 c #7776DC", +"3 c #D2DBEA", +"4 c #2847AD", +"5 c #7271D7", +"6 c #5857A3", +"7 c #9897E5", +"8 c #6E6DD3", +"9 c #C6D1E5", +"0 c #1C41A7", +"a c #6767CC", +"b c #4D4D9A", +"c c #9291E2", +"d c #6766CC", +"e c #BDCAE1", +"f c #113BA1", +"g c #5C5DC2", +"h c #4A4A94", +"i c #8B8ADF", +"j c #BCBBFF", +"k c #B7B6FF", +"l c #6063C9", +"m c #565EC4", +"n c #5C5DC1", +"o c #5456BA", +"p c #47478F", +"q c #8483DB", +"r c #B4B3FF", +"s c #AEADFF", +"t c #A4A3FC", +"u c #8F8EF4", +"v c #8786EC", +"w c #6C6BD1", +"x c #4C50B2", +"y c #444489", +"z c #8281D9", +"A c #AAA9FF", +"B c #A09FFB", +"C c #9493F5", +"D c #4B5B71", +"E c #526276", +"F c #5B6A7D", +"G c #4C4FB2", +"H c #4449AA", +"I c #494988", +"J c #9898DF", +"K c #A09FFF", +"L c #9190F5", +"M c #000000", +"N c #343C47", +"O c #CED9E9", +"P c #D4DDEC", +"Q c #677485", +"R c #434BAE", +"S c #3C42A3", +"T c #6E6E9E", +"U c #CDCDEF", +"V c #9A99FF", +"W c #68788D", +"X c #D8E0ED", +"Y c #E0E7F1", +"Z c #737F8F", +"` c #3541A3", +" . c #3C42A2", +".. c #353D9C", +"+. c #BBBBD0", +"@. c #C2C1F8", +"#. c #2444AA", +"$. c #213247", +"%. c #ABB4C3", +"&. c #B3BBC6", +"*. c #BCC1CA", +"=. c #C4C8CE", +"-. c #484D56", +";. c #333E9E", +">. c #363D9C", +",. c #8E92C6", +"'. c #6D6C9A", +" ", +" ", +" ", +" . + @ # $ % & * = - ", +" ; > , ' ) ", +" ! ~ { , ] ^ / ( ", +" _ ~ : , ] < [ } | ", +" 1 ~ 2 , ] < 3 4 5 6 ", +" 7 ~ 8 , ] < 3 9 0 a b ", +" c ~ d , ] < 3 9 e f g h ", +" i j k l m ' ^ [ 4 0 f n o p ", +" q r s t u v : } 5 w n o x y ", +" z A B C D D D D E F o G H I ", +" J K L v D M N O P Q R H S T ", +" U V v : D N W X Y Z ` ...+. ", +" @.: #.$.%.&.*.=.-.;.>.,. ", +" ( | 6 b h p y I '.+. ", +" ", +" ", +" "};