Commit 29071f5b728901c0617c14fb8b1e74c8df378d21

Authored by tatiana
1 parent 434b1eda

ENH: Showing in notebook measures loaded from inv3

Showing 1 changed file with 33 additions and 0 deletions   Show diff stats
invesalius/gui/data_notebook.py
... ... @@ -36,6 +36,16 @@ import utils as ul
36 36  
37 37 BTN_NEW, BTN_REMOVE, BTN_DUPLICATE = [wx.NewId() for i in xrange(3)]
38 38  
  39 +TYPE = {const.LINEAR: _(u"Linear"),
  40 + const.ANGULAR: _(u"Angular"),
  41 + }
  42 +
  43 +LOCATION = {const.SURFACE: _(u"3D"),
  44 + const.AXIAL: _(u"Axial"),
  45 + const.CORONAL: _(u"Coronal"),
  46 + const.SAGITAL: _(u"Sagittal")
  47 + }
  48 +
39 49 # Panel that initializes notebook and related tabs
40 50 class NotebookPanel(wx.Panel):
41 51 def __init__(self, parent):
... ... @@ -924,6 +934,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
924 934 ps.Publisher().subscribe(self.OnCloseProject, 'Close project data')
925 935 ps.Publisher().subscribe(self.OnShowSingle, 'Show single measurement')
926 936 ps.Publisher().subscribe(self.OnShowMultiple, 'Show multiple measurements')
  937 + ps.Publisher().subscribe(self.OnLoadData, 'Load measurement dict')
927 938  
928 939 def __bind_events_wx(self):
929 940 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
... ... @@ -1063,6 +1074,27 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
1063 1074 ps.Publisher().sendMessage('Show measurement',
1064 1075 (index, visibility))
1065 1076  
  1077 + def OnLoadData(self, pubsub_evt):
  1078 + items_dict = pubsub_evt.data
  1079 + for i in items_dict:
  1080 + m = items_dict[i]
  1081 + image = self.CreateColourBitmap(m.colour)
  1082 + image_index = self.imagelist.Add(image)
  1083 +
  1084 + index_list = self._list_index.keys()
  1085 + self._list_index[m.index] = image_index
  1086 +
  1087 + colour = [255*i for i in m.colour]
  1088 + type = TYPE[m.type]
  1089 + location = LOCATION[m.location]
  1090 + if m.type == const.LINEAR:
  1091 + value = "%.2f mm" % m.value
  1092 + else:
  1093 + value = "%.2f˚" % m.value
  1094 + self.InsertNewItem(m.index, m.name, colour, type, location, value)
  1095 +
  1096 +
  1097 +
1066 1098 def AddItem_(self, pubsub_evt):
1067 1099 index = pubsub_evt.data[0]
1068 1100 name = pubsub_evt.data[1]
... ... @@ -1088,6 +1120,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
1088 1120  
1089 1121 def InsertNewItem(self, index=0, label="Measurement 1", colour=None,
1090 1122 type_="LINEAR", location="SURFACE", value="0 mm"):
  1123 + print index, label, colour, type_, location, value
1091 1124 self.InsertStringItem(index, "")
1092 1125 self.SetStringItem(index, 1, label,
1093 1126 imageId = self._list_index[index])
... ...