1 #include <creaImageIOWxGimmickFieldsView.h>
8 #define TreeListCtrlId -1
12 //================================================================
13 class WxGimmickFieldsViewItemData : public wxTreeItemData
16 WxGimmickFieldsViewItemData(const std::string& key) :
19 const std::string& GetKey() const { return mKey; }
24 //================================================================
26 //================================================================
27 WxGimmickFieldsView::WxGimmickFieldsView(wxWindow *parent,
32 : wxPanel(parent,id,pos,size)
34 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
36 style = //wxTR_DEFAULT_STYLE
40 | wxTR_FULL_ROW_HIGHLIGHT
42 // | wxTR_LINES_AT_ROOT
47 // | wxTR_EDIT_LABELS //Use this style if you wish the user to be able to edit labels in the tree list control.
48 //wxTR_NO_BUTTONS For convenience to document that no buttons are to be drawn.
49 | wxTR_HAS_BUTTONS //Use this style to show + and - buttons to the left of parent items.
50 | 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.
51 //wxTR_NO_LINES Use this style to hide vertical level connectors.
52 | 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.)
53 | 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.
54 | 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.
55 // wxTR_ROW_LINES // Use this style to draw a contrasting border between displayed rows.
56 // 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.
57 & !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.
58 & !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.
59 & ! wxTR_EXTENDED // Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.)
60 //wxTR_DEFAULT_STYLE The set of flags that are closest to the defaults for the native control for a particular toolkit.
61 //| wxTR_VIRTUAL //The application provides items text on demand.
71 | wxTR_FULL_ROW_HIGHLIGHT
76 mTreeListCtrl = new wxTreeListCtrl(this,
81 mTreeListCtrl->AddColumn (_T("Field"),200,wxALIGN_LEFT,-1,true,false);
82 mTreeListCtrl->AddColumn (_T("Value"),400,wxALIGN_LEFT,-1,true,false);
83 mTreeListCtrl->AddColumn (_T("Tag"),100,wxALIGN_LEFT,-1,true,false);
84 mTreeListCtrl->AddColumn (_T("VR"),40,wxALIGN_LEFT,-1,true,false);
86 mTreeListCtrl->SetMainColumn (0);
88 mRootId = mTreeListCtrl->AddRoot( _T(""));
90 mItemId[DicomNode::Database] = mTreeListCtrl->AppendItem( mRootId,
92 mItemId[DicomNode::Patient] = mTreeListCtrl->AppendItem( mRootId,
94 mItemId[DicomNode::Study] = mTreeListCtrl->AppendItem( mRootId,
96 mItemId[DicomNode::Series] = mTreeListCtrl->AppendItem( mRootId,
98 mItemId[DicomNode::Image] = mTreeListCtrl->AppendItem(mRootId,
102 // CreateImageList();
103 // CreateButtonsImageList();
104 // mTreeListCtrl->SetBackgroundColour(*wxWHITE);
105 // mTreeListCtrl->SetSpacingY(0);
107 sizer->Add(mTreeListCtrl,1,wxGROW);
114 //================================================================
116 //================================================================
117 WxGimmickFieldsView::~WxGimmickFieldsView()
120 //================================================================
123 //================================================================
124 void WxGimmickFieldsView::UpdateFields(DicomDatabase* db)
127 for (int i=DicomNode::Database;
128 i<DicomNode::Image+1;i++)
130 DicomNodeTypeDescription::FieldDescriptionMapType::iterator j;
131 for (j = db->GetDicomNodeTypeDescription(i).GetFieldDescriptionMap().begin();
132 j != db->GetDicomNodeTypeDescription(i).GetFieldDescriptionMap().end();
136 Field::Description& desc = j->second;
138 if (desc.GetFlags() & 1) continue;
140 WxGimmickFieldsViewItemData* data =
141 new WxGimmickFieldsViewItemData(desc.GetKey());
142 wxTreeItemId item = mTreeListCtrl->AppendItem
143 ( mItemId[i], crea::std2wx( desc.GetName() ), 0, 0, data );
144 // mTreeListCtrl->SetItemFont(item,0,*wxITALIC_FONT);
147 if ( ( desc.GetGroup()!=0 ) || ( desc.GetElement()!=0) )
149 std::string groupelem =
150 GDCM_NAME_SPACE::Util::Format("%04x | %04x" ,
153 mTreeListCtrl->SetItemText(item,2,crea::std2wx(groupelem));
159 mTreeListCtrl->SetItemTextColour(mTreeRootId,
160 mSettings.RootColour());
161 mTreeListCtrl->SetItemBackgroundColour(mTreeRootId,
162 mSettings.RootBgColour());
164 mTreeListCtrl->ExpandAll(mRootId);
165 // mTreeListCtrl->CollapseAll();
167 //================================================================
169 //================================================================
170 void WxGimmickFieldsView::UpdateValues(DicomNode* node)
172 // std::cout << "WxGimmickFieldsView::UpdateValues "<<node->GetLabel()<<std::endl;
173 // Fill the values for each level until top of the node hierarchy
177 wxTreeItemIdValue cookie;
179 for (i = mTreeListCtrl->GetFirstChild(mItemId[n->GetType()],cookie);
181 i = mTreeListCtrl->GetNextChild(mItemId[n->GetType()],cookie))
183 const std::string& key =
184 ((WxGimmickFieldsViewItemData *)(mTreeListCtrl->GetItemData(i)))->GetKey();;
185 wxString v(crea::std2wx(n->GetFieldValueMap()[key]));
186 mTreeListCtrl->SetItemText(i,1,v);
192 // Reset N/A items (below the node level)
193 for (int t=node->GetType()+1;
194 t<DicomNode::Image+1;t++)
196 wxTreeItemIdValue cookie;
198 for (i = mTreeListCtrl->GetFirstChild(mItemId[t],cookie);
200 i = mTreeListCtrl->GetNextChild(mItemId[t],cookie))
202 mTreeListCtrl->SetItemText(i,1,_T(""));
208 //================================================================
210 //================================================================
211 void WxGimmickFieldsView::SetColors( const wxColour& DatabaseColour,
212 const wxColour& DatabaseBgColour,
213 const wxColour& PatientColour,
214 const wxColour& PatientBgColour,
215 const wxColour& StudyColour,
216 const wxColour& StudyBgColour,
217 const wxColour& SeriesColour,
218 const wxColour& SeriesBgColour,
219 const wxColour& ImageColour,
220 const wxColour& ImageBgColour)
222 mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Database],
224 mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Database],
226 mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Patient],
228 mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Patient],
230 mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Study],
232 mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Study],
234 mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Series],
236 mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Series],
238 mTreeListCtrl->SetItemTextColour(mItemId[DicomNode::Image],
240 mTreeListCtrl->SetItemBackgroundColour(mItemId[DicomNode::Image],
243 //================================================================