31 #include <wx/splitter.h>
32 #include <wx/gdicmn.h>
33 #include <boost/date_time/gregorian/gregorian.hpp>
53 const std::string& s1(*(data1->
attr));
54 const std::string& s2(*(data2->
attr));
85 const std::string& s1(*(data1->
attr));
86 const std::string& s2(*(data2->
attr));
88 int val1=atoi(s1.c_str());
89 int val2=atoi(s2.c_str());
118 namespace creaImageIO
126 : wxPanel(parent,id),
139 msizer =
new wxBoxSizer(wxHORIZONTAL);
141 int ctrl_style = wxLC_REPORT | wxLC_VRULES;
142 int col_style = wxLIST_FORMAT_LEFT;
156 wxWindow* sparent =
this;
161 level.
wxSplitter =
new wxSplitterWindow( sparent , -1);
168 wxListCtrl* ctrl =
new wxListCtrl(level.
wxSplitter,
180 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
194 if(a->GetName()==
"UNKNOWN")
198 if (title[title.size()-1]!=
's')
206 std::string temp = a->GetKey();
207 if (temp.compare(
"ID") != 0)
210 ctrl->InsertColumn(col,
215 level.
key.push_back(a->GetKey());
227 wxMenuItem* m1=
menu->Append(wxID_ANY, _T(
"&Sort ascending"));
228 wxMenuItem* m2=
menu->Append(wxID_ANY, _T(
"&Sort descending"));
229 wxMenuItem* m3=
menu->Append(wxID_ANY, _T(
"&Filter"));
240 wxMenuItem *subExp1 =
subExportMenu->Append(wxID_ANY, _T(
"&Export to Storage"));
247 wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T(
"&Local Copy"));
248 wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T(
"&Edit Fields"));
249 wxMenuItem* m4Item=menuItem->Append(wxID_ANY, _T(
"&Display Dicom Tags"));
253 wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T(
"&Anonymize"));
268 #endif // wxUSE_MENUS
306 std::vector<tree::Node*>& sel =
mLevelList[0].Selected;
327 item =
GetCtrl(l-1)->GetNextItem(item,
329 wxLIST_STATE_SELECTED);
332 long adr = (long)
GetCtrl(l-1)->GetItemData(item);
396 std::stringstream out;
400 if(sel.size()>1&&levelName.at(levelName.size()-1)!=
's')
409 if (wxMessageBox(crea::std2wx(out.str()),
411 wxYES_NO,this ) == wxYES)
418 bool needRefresh=
false;
419 std::vector<tree::Node*>::const_iterator i;
420 for (i=sel.begin(); i!=sel.end(); ++i)
427 if((*i)->GetParent()->GetNumberOfChildren()<2)
457 if (erase &&
mLastLevel == 1 && i_save ==
"0")
462 if (dial->ShowModal() == wxID_OK)
464 i_save = dial->
isChecked() ==
false?
"0" :
"1";
477 <<
"WxTreeView::UpdateLevel(level "
485 for (i=0; i<level-1; i++)
502 <<
"WxTreeView::RecursiveUpdateLevel(level "
507 const std::vector<tree::Node*>& sel(
GetSelected(level));
515 std::vector<tree::Node*>::const_iterator i;
517 for (i=sel.begin(); i!=sel.end(); ++i)
520 "adding children of '"
529 tree::Node::ChildrenListType::reverse_iterator j;
530 for (j = (*i)->GetChildrenList().rbegin();
531 j!= (*i)->GetChildrenList().rend();
541 item.SetMask(wxLIST_MASK_STATE |
560 for (
int k=0; k<
GetCtrl(l)->GetColumnCount(); ++k)
567 val = (*j)->GetAttribute(
"NumberOfChildren");
570 val = (*j)->GetAttribute(
mLevelList[l].key[k]);
571 if(((*j)->GetAttributeDescriptor(
mLevelList[l].key[k])).isDateEntry())
574 std::string valtmp(val);
577 boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
578 val = to_iso_extended_string(d1);
586 else if(((*j)->GetAttributeDescriptor(
mLevelList[l].key[k])).isTimeEntry())
588 if ((val.size()>6) &&
589 (val !=
"" || val !=
" "))
590 val = val.substr(0,2) +
" : "
591 + val.substr(2,2) +
" : "
596 if (val.size()==0) val =
"?";
598 if (val.size()==0) val =
"X";
599 item.SetText( crea::std2wx(val));
620 <<
" WxTreeView::OnItemDeselected"<<std::endl);
622 wxObject* obj =
event.GetEventObject();
623 unsigned int level = 0;
624 for (level = 0; level<
mLevelList.size(); ++level)
626 if (
GetCtrl(level) == obj )
break;
641 <<
" WxTreeView::OnItemSelected"<<std::endl);
646 " mIgnoreSelectedChanged true: returning"
654 info.m_itemId =
event.m_itemIndex;
657 wxObject* obj =
event.GetEventObject();
658 unsigned int level = 0;
659 for (level = 0; level<
mLevelList.size(); ++level)
661 if (
GetCtrl(level) == obj )
break;
682 if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED)
702 item =
GetCtrl(level)->GetNextItem(item,
707 if(item==(
GetCtrl(level)->GetItemCount()-1))
715 GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE
716 | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
727 clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
728 clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
730 unsigned int level = 0;
731 for (level = 0; level<
mLevelList.size(); ++level)
735 PopupMenu(
menu, clientpt);
745 clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
746 clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
748 unsigned int level = 0;
749 for (level = 0; level<
mLevelList.size(); ++level)
768 "WxTreeView::OnEndLabelEdit"
770 unsigned int level = 0;
771 for (level = 0; level<
mLevelList.size(); ++level)
775 std::string filter = crea::wx2std(wxGetTextFromUser(_T(
"Enter the filter to apply"), _T(
"Filter On Column")));
782 std::vector<long> items;
787 it =
GetCtrl(level)->GetNextItem(it,
792 long adr = (long)
GetCtrl(level)->GetItemData(it);
797 if(att.find(filter)>900)
809 items.push_back(it-del);
813 std::vector<long>::iterator iter;
814 for(iter=items.begin();iter!=items.end();++iter)
816 GetCtrl(level)->DeleteItem(*iter);
826 unsigned int level = 0;
827 for (level = 0; level<
mLevelList.size(); ++level)
849 std::vector<std::string> filesname;
850 std::vector<tree::Node*> nodes;
852 if(nodes.size() != 0)
872 std::stringstream out;
876 if(sel.size()>1&&levelName.at(levelName.size()-1)!=
's')
879 out<<
"s to .creaImageIO?";
885 if (wxMessageBox(crea::std2wx(out.str()),
887 wxYES_NO,this ) == wxYES)
893 std::vector<std::string> s;
913 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
914 std::vector<std::string> names;
915 std::vector<std::string> keys;
922 names.push_back(a->GetName());
923 keys.push_back(a->GetKey());
936 std::vector<std::string> filesname;
937 std::vector<tree::Node*> nodes;
952 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
953 std::vector<std::string> names;
954 std::vector<std::string> keys;
959 if(a->GetKey()==
"FullFileName")
975 "WxTreeView::SortLevel("
985 int n =
GetCtrl(level)->GetItemCount();
986 for (
int i = 0; i < n; i++)
1001 data->
attr = & (*nod).GetAttribute
1005 if (
GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
1013 "WxTreeView::OnSort : "
1014 <<nbselected<<
" selected before sorting"
1046 n =
GetCtrl(level)->GetItemCount();
1048 for (
int i = 0; i < n; i++)
1071 GetCtrl(level)->SetItemState(i,
1072 wxLIST_STATE_SELECTED,
1078 | wxLIST_MASK_FORMAT);
1080 if (
GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
1089 "WxTreeView::SortLevel : "
1090 <<after<<
" selected after sorting"
1101 "WxTreeView::ValidateSelectedImages"
1118 long adr = (long)
GetCtrl(level)->GetItemData(item);
1125 item =
GetCtrl(level)->GetNextItem(item,
1130 item =
GetCtrl(level)->GetNextItem(item,
1133 if ( item == -1 || item==0 )
1137 if(
GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0 )
1140 adr = (long)
GetCtrl(level)->GetItemData(item);
1142 nodes.push_back(nod);
1151 if(event.GetKeyCode() == WXK_DELETE)
1154 std::string temp =
"0";
1167 const std::vector<tree::Node*>& sel=
GetSelected(level+1);
1168 std::vector<tree::Node*>::const_iterator i;
1170 for (i=sel.begin(); i!=sel.end(); ++i)
1172 std::string filename=(*i)->GetAttribute(
"FullFileName");
1173 s.push_back(filename);
1182 std::vector<tree::Node*>::const_iterator i;
1184 for (i=nodes.begin(); i!=nodes.end(); ++i)
1193 std::string filename=(*i)->GetAttribute(
"FullFileName");
1194 s.push_back(filename);
1206 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
1207 for (a =
GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).begin();
1213 areShown.push_back(a->GetName());
1228 int ctrl_style = wxLC_REPORT | wxLC_VRULES;
1229 int col_style = wxLIST_FORMAT_LEFT;
1240 wxWindow* oldWin=
mLevelList[nlevel].wxSplitter->GetWindow1();
1248 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
1249 for (a =
GetTreeHandler()->GetTree().GetAttributeDescriptorList(nlevel+1).begin();
1257 std::string temp = a->GetKey();
1258 if (temp.compare(
"ID") != 0)
1261 crea::std2wx(title),
1265 mLevelList[nlevel].key.push_back(a->GetKey());
1276 std::vector<std::string> ns=
mLevelList[level-1].notShownAtts;
1277 std::vector<std::string>::iterator it;
1279 for(it=ns.begin();it!=ns.end()&&!found;++it)
1281 if(val.compare(*it)==0)
1299 wxDEFAULT_DIALOG_STYLE)
1301 wxBoxSizer *topsizer =
new wxBoxSizer(wxVERTICAL);
1305 wxTextCtrl *text =
new wxTextCtrl(
this, wxID_ANY,
1306 _T(
"To reload deleted patient, you should synchronize your database before."),
1307 wxDefaultPosition, wxSize(650,20));
1308 mcheck =
new wxCheckBox(
this, 5478, _T(
"Do not display this warning again!"));
1310 wxSizer* buttonsSizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
1312 topsizer->Add(text);
1313 topsizer->Add(
mcheck,0,wxGROW);
1314 topsizer->Add(buttonsSizer,0,wxGROW);
1315 SetSizer(topsizer,
true);
1385 EVT_LIST_ITEM_SELECTED(-1,
WxTreeView::OnItemSelected)
1386 EVT_LIST_ITEM_RIGHT_CLICK(-1,
WxTreeView::OnItemMenu)
1387 EVT_LIST_ITEM_DESELECTED(-1,
WxTreeView::OnItemDeSelected)
1393 EVT_LIST_COL_RIGHT_CLICK(-1,
WxTreeView::OnColClick)
1395 EVT_LIST_COL_CLICK(-1,
WxTreeView::OnColClick)