X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOWxDescriptorPanel.cpp;h=d192534b96c80c305b25d27a3b5d7f78a29c72d3;hb=37692ca5ea7fb8414cb70bcae0ce16e51da57568;hp=f37554b50881cfa3cd40ee0efc97eefd2a2117ea;hpb=62fe686c7ff816464b9b309933030ea88e27338f;p=creaImageIO.git diff --git a/src2/creaImageIOWxDescriptorPanel.cpp b/src2/creaImageIOWxDescriptorPanel.cpp index f37554b..d192534 100644 --- a/src2/creaImageIOWxDescriptorPanel.cpp +++ b/src2/creaImageIOWxDescriptorPanel.cpp @@ -2,14 +2,16 @@ #include #include #include +#include +#include namespace creaImageIO { // CTor -WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) - : wxDialog(parent, -1,_T("Descriptor Creation"), wxDefaultPosition, wxSize(550,550)) + WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent, const std::string path) + : wxDialog(parent, -1,_T("Descriptor Creation"), wxDefaultPosition, wxSize(550,550)) , m_path(path) { @@ -17,7 +19,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) <GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &WxDescriptorPanel::OnDicomAttribute ); wxStaticText * EL=new wxStaticText(this,-1,_T(" DICOM Element: "), wxPoint(140,110)); @@ -50,7 +52,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) wxString choices[3]; - choices[0] = "Unknow Attribute"; + choices[0] = _T("Unknow Attribute"); std::map::iterator it_att =ownatt.begin(); for(int i = 1; it_att != ownatt.end(); it_att++, i++) { @@ -84,7 +86,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) wxButton *Cancel = new wxButton(this, wxID_CANCEL,_T("CANCEL"), wxPoint(250,480) ); // Connect( Cancel->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxCloseEvent) &wxWindow::Close ); - Layout(); + Layout(); CreateDescriptor(0); } @@ -106,12 +108,13 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) std::string name_att; if (AttributeCombo->GetSelection() == 0) { - name_att = "D" + GRCtrl->GetValue() + "_" + ELCtrl->GetValue(); + name_att = "D" + crea::wx2std(GRCtrl->GetValue()) + "_" + crea::wx2std(ELCtrl->GetValue()); } else - { wxString wd = AttributeCombo->GetValue(); - std::string st = crea::wx2std(wd); - name_att = OwnAttribute(st); + { + wxString wd = AttributeCombo->GetValue(); + std::string st = crea::wx2std(wd); + name_att = OwnAttribute(st); } onAddAttribute(crea::wx2std(AttributeCombo->GetValue()), name_att); } @@ -130,7 +133,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } else { - if( !att.empty() ) + if( !att.empty() ) { // Find Name of level if(level.empty()) @@ -147,18 +150,18 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) ResultCtrl->SetInsertionPoint(InsertPt); for (int i = 1; i<=lv;i++) { - ResultCtrl->WriteText(" "); + ResultCtrl->WriteText(_T(" ")); } - ResultCtrl->WriteText("| - "); - ResultCtrl->WriteText(att); + ResultCtrl->WriteText(_T("| - ")); + ResultCtrl->WriteText(crea::std2wx(att)); wxTextAttr ResultAttr(ResultCtrl->GetDefaultStyle()); ResultAttr.SetTextColour(*wxWHITE); ResultCtrl->SetDefaultStyle(ResultAttr); std::string text = " "; - ResultCtrl->WriteText(" " + name_att); + ResultCtrl->WriteText(crea::std2wx(" " + name_att)); ResultAttr.SetTextColour(*wxBLACK); ResultCtrl->SetDefaultStyle(ResultAttr); - ResultCtrl->WriteText("\n"); + ResultCtrl->WriteText(_T("\n")); } InsertPt = ResultCtrl->GetInsertionPoint(); } @@ -185,7 +188,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) ////////////////////////////////////////////////// void WxDescriptorPanel::onAddLevel(const std::string &level) { - if(addLevel(crea::wx2std(level))) + if(addLevel(level)) { wxMessageBox(_T("Level already used"),crea::std2wx(("WARNING")),wxOK,this); return; @@ -195,24 +198,24 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) ResultCtrl->SetInsertionPoint(InsertPt); for (int i = 1; iWriteText(" "); + ResultCtrl->WriteText(_T(" ")); } if(lv>1) - { ResultCtrl->WriteText("| \n"); + { ResultCtrl->WriteText(_T("| \n")); for (int i = 1; iWriteText(" "); + ResultCtrl->WriteText(_T(" ")); } - ResultCtrl->WriteText("|_"); + ResultCtrl->WriteText(_T("|_")); } wxTextAttr ResultAttr(ResultCtrl->GetDefaultStyle()); ResultAttr.SetTextColour(*wxRED); ResultCtrl->SetDefaultStyle(ResultAttr); - ResultCtrl->WriteText(level); + ResultCtrl->WriteText(crea::std2wx(level)); ResultAttr.SetTextColour(*wxBLACK); ResultCtrl->SetDefaultStyle(ResultAttr); - ResultCtrl->WriteText("\n"); + ResultCtrl->WriteText(_T("\n")); InsertPt = ResultCtrl->GetInsertionPoint(); } @@ -302,7 +305,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } else { - level_pos_start += 2; + level_pos_start += 2; } std::string::size_type level_pos_end = tx.find_first_of("\n",level_pos_start); @@ -333,7 +336,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) else { wxString text = ResultCtrl->GetLineText(line); - if ( text.Find("|_") == -1) + if ( text.Find(_T("|_")) == -1) { std::string level = findLevel(); // find GR and EL values to remove @@ -345,7 +348,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) else { RemoveLevel(crea::wx2std(text.AfterFirst('_'))); - lv = text.Find("|")/3; + lv = text.Find(_T("|"))/3; pos_start= ResultCtrl->XYToPosition(0,line-1); ResultCtrl->SetInsertionPointEnd(); pos_end = ResultCtrl->GetInsertionPoint(); @@ -354,10 +357,10 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } } - ////////////////////////////////////////////////////// - // create a descriptor structure // - // @param name : level's name to add // - // @return : boolean result // + ////////////////////////////////////////////// + // create a descriptor structure // + // @param name : level's name to add // + // @return : boolean result // ////////////////////////////////////////////////// void WxDescriptorPanel::CreateDescriptor(int type) { @@ -525,9 +528,9 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } ////////////////////////////////////////////////// - // create a new descriptor // - // @param event : WxEvent // - // @return : - // + // create a new descriptor // + // @param event : WxEvent // + // @return : - // ////////////////////////////////////////////////// void WxDescriptorPanel::OnNew(wxCommandEvent &Event) { @@ -538,9 +541,9 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } ////////////////////////////////////////////////// - // Load a descriptor file // - // @param event : WxEvent // - // @return : - // + // Load a descriptor file // + // @param event : WxEvent // + // @return : - // ////////////////////////////////////////////////// void WxDescriptorPanel::OnLoad(wxCommandEvent &Event) { @@ -553,7 +556,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) std::string wc("*.dscp"); wxFileDialog* FD = new wxFileDialog( 0, _T("Select file"), - _T(""), + crea::std2wx(m_path), _T(""), crea::std2wx(wc), style, @@ -568,7 +571,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) ////////////////////////////////////////////////// // Save a descriptor // // @param event : WxEvent // - // @return : - // + // @return : - // ////////////////////////////////////////////////// void WxDescriptorPanel::OnOK(wxCommandEvent &Event) { @@ -578,8 +581,8 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) ///////////////////////////////////////////////////// // Save a descriptor and apply it (create a new DB// - // @param event : WxEvent // - // @return : - // + // @param event : WxEvent // + // @return : - // ///////////////////////////////////////////////////// void WxDescriptorPanel::OnApply(wxCommandEvent &Event) { @@ -615,9 +618,9 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) } /////////////////////////////////////////////////////// - // Cancel action // + // Cancel action // // @param event : WxEvent // - // @return : - // + // @return : - // /////////////////////////////////////////////////////// void WxDescriptorPanel::OnCancel(wxCommandEvent& event) @@ -626,8 +629,8 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) /////////////////////////////////////////////////////// // create a descriptor file // - // @param - : // - // @return : - // + // @param - : // + // @return : - // /////////////////////////////////////////////////////// void WxDescriptorPanel::createDescriptorFile() { @@ -643,7 +646,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) std::map::iterator it_lv_nb = lvlist.begin(); std::map::iterator it_lv = lvlist.begin(); it_lv_nb++; - for (;it_lv != lvlist.end(); it_lv++, it_lv_nb++) + for (;it_lv != lvlist.end(); it_lv++) { outDscp +=""; outDscp += "\n"; @@ -655,6 +658,7 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) outDscp += it_lv_nb->second.c_str(); outDscp += "s"; outDscp += "\n"; + it_lv_nb++; } std::vector::iterator it_branch = DscpTree[it_lv->second.c_str()].begin(); for(;it_branch != DscpTree[it_lv->second.c_str()].end(); it_branch++) @@ -761,6 +765,10 @@ WxDescriptorPanel::WxDescriptorPanel(wxWindow *parent) onAddAttribute( entry->GetName(),compose, level); } } + else if(descriptors[0].find("#") != -1) + { + // commented line continue to next line + } else // "O" means if user's own tag. { boost::algorithm::replace_all(descriptors[2],"_"," ");