Commit 0241ef01314b7743874c1ae7ed68a03e1bf254fd
1 parent
d0658e0b
Exists in
master
and in
68 other branches
ENH: Adding the measures in MeasuresList
Showing
2 changed files
with
25 additions
and
11 deletions
Show diff stats
invesalius/data/viewer_volume.py
invesalius/gui/data_notebook.py
| ... | ... | @@ -48,9 +48,11 @@ class NotebookPanel(wx.Panel): |
| 48 | 48 | if sys.platform != 'win32': |
| 49 | 49 | book.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
| 50 | 50 | |
| 51 | + self.measures_list = MeasuresListCtrlPanel(book) | |
| 52 | + | |
| 51 | 53 | book.AddPage(MaskPage(book), _("Masks")) |
| 52 | 54 | book.AddPage(SurfacePage(book), _("Surfaces")) |
| 53 | - book.AddPage(MeasuresListCtrlPanel(book), _("Measures")) | |
| 55 | + book.AddPage(self.measures_list, _("Measures")) | |
| 54 | 56 | book.AddPage(AnnotationsListCtrlPanel(book), _("Annotations")) |
| 55 | 57 | |
| 56 | 58 | book.SetSelection(0) |
| ... | ... | @@ -60,9 +62,22 @@ class NotebookPanel(wx.Panel): |
| 60 | 62 | self.SetSizer(sizer) |
| 61 | 63 | |
| 62 | 64 | book.Refresh() |
| 65 | + | |
| 66 | + self.__bind_events() | |
| 63 | 67 | |
| 64 | 68 | # TODO: insert icons bellow notebook |
| 65 | 69 | |
| 70 | + def __bind_events(self): | |
| 71 | + ps.Publisher().subscribe(self._add_measure, | |
| 72 | + "Add measure to list") | |
| 73 | + | |
| 74 | + def _add_measure(self, pubsub_evt): | |
| 75 | + type = pubsub_evt.data[0] | |
| 76 | + value = pubsub_evt.data[1] | |
| 77 | + | |
| 78 | + self.measures_list.AddMeasure(type, value) | |
| 79 | + | |
| 80 | + | |
| 66 | 81 | |
| 67 | 82 | class MaskPage(wx.Panel): |
| 68 | 83 | """ |
| ... | ... | @@ -751,9 +766,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 751 | 766 | self.__init_columns() |
| 752 | 767 | self.__init_image_list() |
| 753 | 768 | self.__init_evt() |
| 754 | - | |
| 755 | - # just testing | |
| 756 | - self.Populate() | |
| 769 | + | |
| 770 | + self._last_measure = 0 | |
| 757 | 771 | |
| 758 | 772 | def __init_evt(self): |
| 759 | 773 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
| ... | ... | @@ -807,13 +821,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 807 | 821 | self.InsertStringItem(index, "") |
| 808 | 822 | self.SetStringItem(index, 1, type_, imageId = self.img_colour) |
| 809 | 823 | self.SetStringItem(index, 2, value) |
| 810 | - | |
| 811 | - def Populate(self): | |
| 812 | - dict = ((0, "30000 mm", "/ 3D"), | |
| 813 | - (1, "20o", "o 2D"), | |
| 814 | - (2, "500 mm", "/ 2D")) | |
| 815 | - for data in dict: | |
| 816 | - self.InsertNewItem(data[0], data[1], data[2]) | |
| 824 | + | |
| 825 | + def AddMeasure(self, type_, value, colour=None): | |
| 826 | + self.InsertNewItem(self._last_measure, type_, value, colour) | |
| 827 | + self._last_measure += 1 | |
| 828 | + | |
| 817 | 829 | |
| 818 | 830 | |
| 819 | 831 | class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ... | ... |