#include #include namespace creaImageIO { #define TreeListCtrlId -1 //================================================================ class WxGimmickFieldsViewItemData : public wxTreeItemData { public: WxGimmickFieldsViewItemData(const std::string& key) : mKey(key) { } const std::string& GetKey() const { return mKey; } private: std::string mKey; }; //================================================================ //================================================================ WxGimmickFieldsView::WxGimmickFieldsView(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxPanel(parent,id,pos,size) { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); style = //wxTR_DEFAULT_STYLE wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS // | wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT //| wxTR_SINGLE // | wxTR_LINES_AT_ROOT ; /* style = style // | wxTR_EDIT_LABELS //Use this style if you wish the user to be able to edit labels in the tree list control. //wxTR_NO_BUTTONS For convenience to document that no buttons are to be drawn. | wxTR_HAS_BUTTONS //Use this style to show + and - buttons to the left of parent items. | wxTR_TWIST_BUTTONS //Use this style to show Mac-style twister buttons to the left of parent items. If both wxTR_HAS_BUTTONS and wxTR_TWIST_BUTTONS are given, twister buttons are generated. //wxTR_NO_LINES Use this style to hide vertical level connectors. | wxTR_FULL_ROW_HIGHLIGHT //Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree list control window. (This flag is ignored under Windows unless you specify wxTR_NO_LINES as well.) | wxTR_LINES_AT_ROOT //Use this style to show lines between root nodes. Only applicable if wxTR_HIDE_ROOT is set and wxTR_NO_LINES is not set. | wxTR_HIDE_ROOT //Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. // wxTR_ROW_LINES // Use this style to draw a contrasting border between displayed rows. // xTR_HAS_VARIABLE_ROW_HEIGHT// Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. & !wxTR_SINGLE // For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. & !wxTR_MULTIPLE // Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. & ! wxTR_EXTENDED // Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.) //wxTR_DEFAULT_STYLE The set of flags that are closest to the defaults for the native control for a particular toolkit. //| wxTR_VIRTUAL //The application provides items text on demand. */ /* | wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS // | wxTR_NO_LINES | wxTR_LINES_AT_ROOT | wxTR_EDIT_LABELS // | wxTR_ROW_LINES | wxTR_FULL_ROW_HIGHLIGHT | wxTR_MULTIPLE | wxTR_EXTENDED */ ; mTreeListCtrl = new wxTreeListCtrl(this, TreeListCtrlId, wxDefaultPosition, wxDefaultSize,style); mTreeListCtrl->AddColumn (_T("Field"),200,wxALIGN_LEFT,-1,true,false); mTreeListCtrl->AddColumn (_T("Value"),400,wxALIGN_LEFT,-1,true,false); mTreeListCtrl->AddColumn (_T("Tag"),100,wxALIGN_LEFT,-1,true,false); mTreeListCtrl->AddColumn (_T("VR"),40,wxALIGN_LEFT,-1,true,false); mTreeListCtrl->SetMainColumn (0); mRootId = mTreeListCtrl->AddRoot( _T("")); mItemId[DicomNode::Database] = mTreeListCtrl->AppendItem( mRootId, _T("Collection")); mItemId[DicomNode::Patient] = mTreeListCtrl->AppendItem( mRootId, _T("Patient")); mItemId[DicomNode::Study] = mTreeListCtrl->AppendItem( mRootId, _T("Study")); mItemId[DicomNode::Series] = mTreeListCtrl->AppendItem( mRootId, _T("Series")); mItemId[DicomNode::Image] = mTreeListCtrl->AppendItem(mRootId, _T("Image")); // CreateImageList(); // CreateButtonsImageList(); // mTreeListCtrl->SetBackgroundColour(*wxWHITE); // mTreeListCtrl->SetSpacingY(0); sizer->Add(mTreeListCtrl,1,wxGROW); SetSizer(sizer); SetAutoLayout(true); Layout(); } //================================================================ //================================================================ WxGimmickFieldsView::~WxGimmickFieldsView() { } //================================================================ //================================================================ void WxGimmickFieldsView::UpdateFields(DicomDatabase* db) { for (int i=DicomNode::Database; iGetDicomNodeTypeDescription(i).GetFieldDescriptionMap().begin(); j != db->GetDicomNodeTypeDescription(i).GetFieldDescriptionMap().end(); j++) { Field::Description& desc = j->second; // Skip DB fields if (desc.GetFlags() & 1) continue; WxGimmickFieldsViewItemData* data = new WxGimmickFieldsViewItemData(desc.GetKey()); wxTreeItemId item = mTreeListCtrl->AppendItem ( mItemId[i], crea::std2wx( desc.GetName() ), 0, 0, data ); // mTreeListCtrl->SetItemFont(item,0,*wxITALIC_FONT); if ( ( desc.GetGroup()!=0 ) || ( desc.GetElement()!=0) ) { std::string groupelem = GDCM_NAME_SPACE::Util::Format("%04x | %04x" , desc.GetGroup() , desc.GetElement()); mTreeListCtrl->SetItemText(item,2,crea::std2wx(groupelem)); } } } /* mTreeListCtrl->SetItemTextColour(mTreeRootId, mSettings.RootColour()); mTreeListCtrl->SetItemBackgroundColour(mTreeRootId, mSettings.RootBgColour()); */ mTreeListCtrl->ExpandAll(mRootId); // mTreeListCtrl->CollapseAll(); } //================================================================ //================================================================ void WxGimmickFieldsView::UpdateValues(DicomNode* node) { // std::cout << "WxGimmickFieldsView::UpdateValues "<GetLabel()<GetFirstChild(mItemId[n->GetType()],cookie); i.IsOk(); i = mTreeListCtrl->GetNextChild(mItemId[n->GetType()],cookie)) { const std::string& key = ((WxGimmickFieldsViewItemData *)(mTreeListCtrl->GetItemData(i)))->GetKey();; wxString v(crea::std2wx(n->GetFieldValueMap()[key])); mTreeListCtrl->SetItemText(i,1,v); } n = n->GetParent(); } while (n != 0); // Reset N/A items (below the node level) for (int t=node->GetType()+1; tGetFirstChild(mItemId[t],cookie); i.IsOk(); i = mTreeListCtrl->GetNextChild(mItemId[t],cookie)) { mTreeListCtrl->SetItemText(i,1,_T("")); } } // } //================================================================ //================================================================ void WxGimmickFieldsView::SetColors( const wxColour& DatabaseColour, const wxColour& DatabaseBgColour, const wxColour& PatientColour, const wxColour& PatientBgColour, const wxColour& StudyColour, const wxColour& StudyBgColour, const wxColour& SeriesColour, const wxColour& SeriesBgColour, const wxColour& ImageColour, const wxColour& ImageBgColour) { mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Database], DatabaseColour); mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Database], DatabaseBgColour); mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Patient], PatientColour); mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Patient], PatientBgColour); mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Study], StudyColour); mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Study], StudyBgColour); mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Series], SeriesColour); mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Series], SeriesBgColour); mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Image], ImageColour); mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Image], ImageBgColour); } //================================================================ }