Commit 49584a7572b4c2642930318f3cc0a4506f767bac

Authored by tatiana
1 parent 86e4d5cd

ENH: Import panel - ordering and selection (still working)

invesalius/gui/import_panel.py
@@ -57,7 +57,7 @@ class TextPanel(wx.Panel): @@ -57,7 +57,7 @@ class TextPanel(wx.Panel):
57 | wx.TR_ROW_LINES 57 | wx.TR_ROW_LINES
58 | wx.TR_COLUMN_LINES 58 | wx.TR_COLUMN_LINES
59 | wx.TR_FULL_ROW_HIGHLIGHT 59 | wx.TR_FULL_ROW_HIGHLIGHT
60 - | wx.TR_FULL_ROW_HIGHLIGHT 60 + | wx.TR_SINGLE
61 ) 61 )
62 62
63 63
@@ -87,7 +87,6 @@ class TextPanel(wx.Panel): @@ -87,7 +87,6 @@ class TextPanel(wx.Panel):
87 tree.SetColumnWidth(9, 100) # Date of birth 87 tree.SetColumnWidth(9, 100) # Date of birth
88 tree.SetColumnWidth(10, 140) # Accession Number 88 tree.SetColumnWidth(10, 140) # Accession Number
89 tree.SetColumnWidth(11, 160) # Referring physician 89 tree.SetColumnWidth(11, 160) # Referring physician
90 -  
91 90
92 self.root = tree.AddRoot("InVesalius Database") 91 self.root = tree.AddRoot("InVesalius Database")
93 self.tree = tree 92 self.tree = tree
@@ -103,6 +102,7 @@ class TextPanel(wx.Panel): @@ -103,6 +102,7 @@ class TextPanel(wx.Panel):
103 dicom.acquisition.time) 102 dicom.acquisition.time)
104 103
105 parent = tree.AppendItem(self.root, title) 104 parent = tree.AppendItem(self.root, title)
  105 +
106 tree.SetItemText(parent, str(dicom.patient.id), 1) 106 tree.SetItemText(parent, str(dicom.patient.id), 1)
107 tree.SetItemText(parent, str(dicom.patient.age), 2) 107 tree.SetItemText(parent, str(dicom.patient.age), 2)
108 tree.SetItemText(parent, str(dicom.patient.gender), 3) 108 tree.SetItemText(parent, str(dicom.patient.gender), 3)
@@ -118,11 +118,11 @@ class TextPanel(wx.Panel): @@ -118,11 +118,11 @@ class TextPanel(wx.Panel):
118 group_list = patient.GetGroups() 118 group_list = patient.GetGroups()
119 for group in group_list: 119 for group in group_list:
120 dicom = group.GetDicomSample() 120 dicom = group.GetDicomSample()
121 - group_title = dicom.acquisition.series_description  
122 121
123 - child = self.tree.AppendItem(parent, group_title) 122 + child = tree.AppendItem(parent, group.title)
  123 + tree.SetItemPyData(child, group)
124 124
125 - tree.SetItemText(child, str(group_title), 0) 125 + tree.SetItemText(child, str(group.title), 0)
126 tree.SetItemText(child, str(dicom.acquisition.protocol_name), 4) 126 tree.SetItemText(child, str(dicom.acquisition.protocol_name), 4)
127 tree.SetItemText(child, str(dicom.acquisition.modality), 5) 127 tree.SetItemText(child, str(dicom.acquisition.modality), 5)
128 tree.SetItemText(child, str(date_time), 6) 128 tree.SetItemText(child, str(date_time), 6)
@@ -134,7 +134,9 @@ class TextPanel(wx.Panel): @@ -134,7 +134,9 @@ class TextPanel(wx.Panel):
134 tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) 134 tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
135 135
136 def OnActivate(self, evt): 136 def OnActivate(self, evt):
137 - print 'OnActivate: %s' % self.tree.GetItemText(evt.GetItem()) 137 + print "OnActivate"
  138 + item = evt.GetItem()
  139 + print self.tree.GetItemPyData(item)
138 140
139 141
140 def OnRightUp(self, evt): 142 def OnRightUp(self, evt):
invesalius/reader/dicom_grouper.py
@@ -61,6 +61,7 @@ class DicomGroup: @@ -61,6 +61,7 @@ class DicomGroup:
61 # dicom.acquisition.series_number, 61 # dicom.acquisition.series_number,
62 # dicom.image.orientation_label, index) 62 # dicom.image.orientation_label, index)
63 self.key = () 63 self.key = ()
  64 + self.title = ""
64 self.slices_dict = {} # slice_position: Dicom.dicom 65 self.slices_dict = {} # slice_position: Dicom.dicom
65 # IDEA (13/10): Represent internally as dictionary, 66 # IDEA (13/10): Represent internally as dictionary,
66 # externally as list 67 # externally as list
@@ -143,8 +144,10 @@ class PatientGroup: @@ -143,8 +144,10 @@ class PatientGroup:
143 # Does this group exist? Best case ;) 144 # Does this group exist? Best case ;)
144 if group_key not in self.groups_dict.keys(): 145 if group_key not in self.groups_dict.keys():
145 group = DicomGroup() 146 group = DicomGroup()
146 - self.ngroups += 1 147 + group.key = group_key
  148 + group.title = dicom.acquisition.series_description
147 group.AddSlice(dicom) 149 group.AddSlice(dicom)
  150 + self.ngroups += 1
148 self.groups_dict[group_key] = group 151 self.groups_dict[group_key] = group
149 # Group exists... Lets try to add slice 152 # Group exists... Lets try to add slice
150 else: 153 else:
@@ -177,7 +180,10 @@ class PatientGroup: @@ -177,7 +180,10 @@ class PatientGroup:
177 self.groups_dict = self.FixProblem1(self.groups_dict) 180 self.groups_dict = self.FixProblem1(self.groups_dict)
178 181
179 def GetGroups(self): 182 def GetGroups(self):
180 - return self.groups_dict.values() 183 + glist = self.groups_dict.values()
  184 + glist = sorted(glist, key = lambda group:group.title,
  185 + reverse=True)
  186 + return glist
181 187
182 def GetDicomSample(self): 188 def GetDicomSample(self):
183 return self.dicom 189 return self.dicom