X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOWxTreeView.cpp;h=03c5b0d3d3dab15af21147d39eab9ca01d53d01d;hb=b0843014c5482f70050fab8036c6780172e3b6c9;hp=2fced885b158ecc2844ab93c8bb70ebe10625778;hpb=381f766db11094bd9b96f9e948527cbec24f680a;p=creaImageIO.git diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index 2fced88..03c5b0d 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -5,26 +5,10 @@ #include #include -const std::string empty_string(""); - //===================================================================== namespace creaImageIO { - //===================================================================== - /// Data stored by the list items - struct ItemData - { - ItemData() : node(0), id(-1), attr(&empty_string) {} - // The corresponding Node - tree::Node* node; - // The id ? - int id; - // The pointer on the current attribute string to sort on - const std::string* attr; - // Was the item previously selected ? - // Useful for reselecting the item after sort - bool selected; - }; + //===================================================================== } //===================================================================== @@ -263,6 +247,9 @@ namespace creaImageIO { GimmickDebugMessage(1,"WxTreeView::~WxTreeView" <& WxTreeView::GetSelected(int level) { + std::vector& sel = mLevelList[0].Selected; // if (GetSelectedUpToDate(level)) int l = level - 1; // the selection of upper level - std::vector& sel(mLevelList[l].Selected); - sel.clear(); + if(mLevelList.size() == level -1) + sel = mLevelList.back().Selected; + else + sel= mLevelList[l].Selected; + if (sel.size() > 0) + { + sel.clear(); + } if (level == 1) { sel.push_back(GetTreeHandler()->GetTree().GetTree()); @@ -341,15 +335,17 @@ namespace creaImageIO //===================================================================== ///Removes selected nodes on last selected level // NOT SPECIFIC - void WxTreeView::RemoveSelected() + void WxTreeView::RemoveSelected(std::string &i_save) { - unsigned int tempLevel = mLastLevel; + bool erase=false; + + unsigned int tempLevel = mLastLevel; mLastLevel+=1; const std::vector& sel=GetSelected(mLastLevel+1); // if no selection, no remove action. if(sel.size() != 0) { - bool erase=false; + std::stringstream out; std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName(); out<<"Delete "; @@ -385,9 +381,9 @@ namespace creaImageIO { needRefresh=true; } - tree::Node* n= (tree::Node*)(*i); + //tree::Node* n = new (tree::Node*)(*i); GetTreeHandler()->LoadChildren((*i),4); - GetGimmickView()->AddIgnoreFile(n); + GetGimmickView()->AddIgnoreFile(*i); GetTreeHandler()->Remove(*i); } @@ -411,6 +407,17 @@ namespace creaImageIO mLastLevel = tempLevel; } + if (erase && mLastLevel == 1 && i_save == "0") + { + + RemoveAlertDlg *dial = new RemoveAlertDlg(this, crea::std2wx("Remove files"), wxSize(370,100)); + //dial->ShowModal(); + if (dial->ShowModal() == wxID_OK) + { + i_save = dial->isChecked() == false? "0" : "1"; + } + + } } @@ -492,13 +499,13 @@ namespace creaImageIO wxLIST_MASK_FORMAT ); - ItemData* data = new ItemData; + ItemData* data = new ItemData(); data->node = *j; data->id = _id; - + item.SetId(_id); item.SetData(data); - + _id++; GetCtrl(l)->InsertItem(item); @@ -539,13 +546,15 @@ namespace creaImageIO } else { - + if (val.size()==0) val = "?"; } - if (val.size()==0) val = "?"; + if (val.size()==0) val = "X"; item.SetText( crea::std2wx(val)); item.SetColumn(k); - GetCtrl(l)->SetItem(item); - } + + GetCtrl(l)->SetItem(item); + } + item.Clear(); } } @@ -618,7 +627,8 @@ namespace creaImageIO GetGimmickView()->ClearSelection(); } // Select all images if the selection is at series level - if (level==mLevelList.size()-2) SelectAll(level+1); + if (level==mLevelList.size()-2) + SelectAll(level+1); // Validate selected images if the selection is at image level if (level==(mLevelList.size()-1)) //&&mProcess) { @@ -656,7 +666,7 @@ namespace creaImageIO mIgnoreSelectedChanged = true;// mProcess=false; } GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE - | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT); + | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT); } } @@ -1040,8 +1050,8 @@ namespace creaImageIO if(event.GetKeyCode() == WXK_DELETE) { wxBusyCursor busy; - - RemoveSelected(); + std::string temp = "0"; + RemoveSelected(temp); GetGimmickView()->ClearSelection(); } @@ -1084,114 +1094,6 @@ namespace creaImageIO } //================================================================ - void WxTreeView::SetColor(int l, int item) - { - int colorId=12; - GetCtrl(l)->SetItemTextColour(item, wxColourDatabase().Find - (crea::std2wx(mColorPalette[colorId]))); - GetCtrl(l)->SetItemState(item,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED); /* - int colorId=0; - //Setting the color according to the parent - if(l==0) - { - item.SetBackgroundColour - (wxColourDatabase().Find - (crea::std2wx(mColorPalette[colorId]))); - mColorMap.insert - (NodeColorPair - (*j,wxColourDatabase().Find - (crea::std2wx(mColorPalette[colorId])))); - if(colorId<64) - { - colorId++; - } - else - { - colorId=0; - } - } - else if(l!=mLevelList.size()-1) - { - item.SetBackgroundColour(mColorMap[*i]); - mColorMap.insert(NodeColorPair(*j,mColorMap[*i])); - } - else - { - item.SetBackgroundColour(mColorMap[*i]); - }*/ - } - //================================================================ - void WxTreeView::CreateColorPalette() - { - GimmickDebugMessage(6,"WxTreeView::CreateColorPalette"); - mColorPalette.push_back("WHITE"); - mColorPalette.push_back("LIGHT GREY"); - mColorPalette.push_back("AQUAMARINE"); - mColorPalette.push_back("MEDIUM FOREST GREEN"); - mColorPalette.push_back("INDIAN RED"); - mColorPalette.push_back("KHAKI"); - mColorPalette.push_back("ORANGE"); - mColorPalette.push_back("LIGHT BLUE"); - mColorPalette.push_back("LIGHT STEEL BLUE"); - mColorPalette.push_back("PINK"); - mColorPalette.push_back("PLUM"); - mColorPalette.push_back("PURPLE"); - mColorPalette.push_back("RED"); - mColorPalette.push_back("SEA GREEN"); - mColorPalette.push_back("SIENNA"); - mColorPalette.push_back("SKY BLUE"); - mColorPalette.push_back("SLATE BLUE"); - mColorPalette.push_back("SPRING GREEN"); - mColorPalette.push_back("TAN"); - mColorPalette.push_back("THISTLE"); - mColorPalette.push_back("TURQUOISE"); - mColorPalette.push_back("VIOLET"); - mColorPalette.push_back("VIOLET RED"); - mColorPalette.push_back("WHEAT"); - mColorPalette.push_back("YELLOW"); - mColorPalette.push_back("YELLOW GREEN"); - mColorPalette.push_back("BLUE"); - mColorPalette.push_back("BLUE VIOLET"); - mColorPalette.push_back("BROWN"); - mColorPalette.push_back("CADET BLUE"); - mColorPalette.push_back("CORAL"); - mColorPalette.push_back("CORNFLOWER BLUE"); - mColorPalette.push_back("CYAN"); - mColorPalette.push_back("DARK GREY"); - mColorPalette.push_back("DARK GREEN"); - mColorPalette.push_back("DARK OLIVE GREEN"); - mColorPalette.push_back("DARK ORCHID"); - mColorPalette.push_back("DARK SLATE BLUE"); - mColorPalette.push_back("DARK SLATE GREY"); - mColorPalette.push_back("DARK TURQUOISE"); - mColorPalette.push_back("FIREBRICK"); - mColorPalette.push_back("FOREST GREEN"); - mColorPalette.push_back("GOLD"); - mColorPalette.push_back("GOLDENROD"); - mColorPalette.push_back("GREY"); - mColorPalette.push_back("GREEN"); - mColorPalette.push_back("GREEN YELLOW"); - mColorPalette.push_back("LIME GREEN"); - mColorPalette.push_back("MAGENTA"); - mColorPalette.push_back("MAROON"); - mColorPalette.push_back("MEDIUM AQUAMARINE"); - mColorPalette.push_back("MEDIUM BLUE"); - mColorPalette.push_back("MEDIUM GOLDENROD"); - mColorPalette.push_back("MEDIUM ORCHID"); - mColorPalette.push_back("MEDIUM SEA GREEN"); - mColorPalette.push_back("MEDIUM SLATE BLUE"); - mColorPalette.push_back("MEDIUM SPRING GREEN"); - mColorPalette.push_back("MEDIUM TURQUOISE"); - mColorPalette.push_back("MEDIUM VIOLET RED"); - mColorPalette.push_back("MIDNIGHT BLUE"); - mColorPalette.push_back("NAVY"); - mColorPalette.push_back("ORANGE RED"); - mColorPalette.push_back("ORCHID, PALE GREEN"); - mColorPalette.push_back("STEEL BLUE"); - mColorPalette.push_back("BLACK"); - - - } //================================================================ void WxTreeView::GetAttributes(std::vector& areShown, std::vector& notShown, int level) @@ -1281,6 +1183,47 @@ namespace creaImageIO return !found; } + //================================================================ + //================================================================ + + RemoveAlertDlg::RemoveAlertDlg(wxWindow *parent, + wxString title, + const wxSize& size) + : wxDialog( parent, + wxID_ANY, + title, + wxDefaultPosition, + size, + wxDEFAULT_DIALOG_STYLE) + { + wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + + //std::string out("To reload deleted patient, you should synchronize your database before."); // JPR + //wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY,crea::std2wx(out),wxDefaultPosition, wxSize(500,20)); + wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY, + _T("To reload deleted patient, you should synchronize your database before."), + wxDefaultPosition, wxSize(500,20)); + mcheck = new wxCheckBox(this, 5478, _T("Do not display this warning again!")); + Connect( mcheck->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &RemoveAlertDlg::onCheck ); + wxSizer* buttonsSizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL); + + topsizer->Add(text); + topsizer->Add(mcheck,0,wxGROW); + topsizer->Add(buttonsSizer,0,wxGROW); + SetSizer(topsizer, true); + mSave = false; + Layout(); + } + RemoveAlertDlg::~RemoveAlertDlg(){}; + bool RemoveAlertDlg::isChecked() + { + return mSave; + } + void RemoveAlertDlg::onCheck(wxCommandEvent &Event) + { + mSave = mcheck->IsChecked(); + } + //================================================================ //================================================================