From 49584a7572b4c2642930318f3cc0a4506f767bac Mon Sep 17 00:00:00 2001 From: tatiana Date: Thu, 15 Oct 2009 18:28:55 +0000 Subject: [PATCH] ENH: Import panel - ordering and selection (still working) --- invesalius/gui/import_panel.py | 14 ++++++++------ invesalius/reader/dicom_grouper.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/invesalius/gui/import_panel.py b/invesalius/gui/import_panel.py index 1395c9d..16f28c1 100644 --- a/invesalius/gui/import_panel.py +++ b/invesalius/gui/import_panel.py @@ -57,7 +57,7 @@ class TextPanel(wx.Panel): | wx.TR_ROW_LINES | wx.TR_COLUMN_LINES | wx.TR_FULL_ROW_HIGHLIGHT - | wx.TR_FULL_ROW_HIGHLIGHT + | wx.TR_SINGLE ) @@ -87,7 +87,6 @@ class TextPanel(wx.Panel): tree.SetColumnWidth(9, 100) # Date of birth tree.SetColumnWidth(10, 140) # Accession Number tree.SetColumnWidth(11, 160) # Referring physician - self.root = tree.AddRoot("InVesalius Database") self.tree = tree @@ -103,6 +102,7 @@ class TextPanel(wx.Panel): dicom.acquisition.time) parent = tree.AppendItem(self.root, title) + tree.SetItemText(parent, str(dicom.patient.id), 1) tree.SetItemText(parent, str(dicom.patient.age), 2) tree.SetItemText(parent, str(dicom.patient.gender), 3) @@ -118,11 +118,11 @@ class TextPanel(wx.Panel): group_list = patient.GetGroups() for group in group_list: dicom = group.GetDicomSample() - group_title = dicom.acquisition.series_description - child = self.tree.AppendItem(parent, group_title) + child = tree.AppendItem(parent, group.title) + tree.SetItemPyData(child, group) - tree.SetItemText(child, str(group_title), 0) + tree.SetItemText(child, str(group.title), 0) tree.SetItemText(child, str(dicom.acquisition.protocol_name), 4) tree.SetItemText(child, str(dicom.acquisition.modality), 5) tree.SetItemText(child, str(date_time), 6) @@ -134,7 +134,9 @@ class TextPanel(wx.Panel): tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) def OnActivate(self, evt): - print 'OnActivate: %s' % self.tree.GetItemText(evt.GetItem()) + print "OnActivate" + item = evt.GetItem() + print self.tree.GetItemPyData(item) def OnRightUp(self, evt): diff --git a/invesalius/reader/dicom_grouper.py b/invesalius/reader/dicom_grouper.py index f8f2624..ead509c 100644 --- a/invesalius/reader/dicom_grouper.py +++ b/invesalius/reader/dicom_grouper.py @@ -61,6 +61,7 @@ class DicomGroup: # dicom.acquisition.series_number, # dicom.image.orientation_label, index) self.key = () + self.title = "" self.slices_dict = {} # slice_position: Dicom.dicom # IDEA (13/10): Represent internally as dictionary, # externally as list @@ -143,8 +144,10 @@ class PatientGroup: # Does this group exist? Best case ;) if group_key not in self.groups_dict.keys(): group = DicomGroup() - self.ngroups += 1 + group.key = group_key + group.title = dicom.acquisition.series_description group.AddSlice(dicom) + self.ngroups += 1 self.groups_dict[group_key] = group # Group exists... Lets try to add slice else: @@ -177,7 +180,10 @@ class PatientGroup: self.groups_dict = self.FixProblem1(self.groups_dict) def GetGroups(self): - return self.groups_dict.values() + glist = self.groups_dict.values() + glist = sorted(glist, key = lambda group:group.title, + reverse=True) + return glist def GetDicomSample(self): return self.dicom -- libgit2 0.21.2