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
| @@ -616,6 +616,8 @@ class Viewer(wx.Panel): | @@ -616,6 +616,8 @@ class Viewer(wx.Panel): | ||
| 616 | else: | 616 | else: |
| 617 | m = self.measures[-1] | 617 | m = self.measures[-1] |
| 618 | m.SetPoint2(x, y, z) | 618 | m.SetPoint2(x, y, z) |
| 619 | + ps.Publisher().sendMessage("Add measure to list", | ||
| 620 | + ("3D", _("%.3f mm3" % m.GetValue()))) | ||
| 619 | self.interactor.Render() | 621 | self.interactor.Render() |
| 620 | 622 | ||
| 621 | 623 |
invesalius/gui/data_notebook.py
| @@ -48,9 +48,11 @@ class NotebookPanel(wx.Panel): | @@ -48,9 +48,11 @@ class NotebookPanel(wx.Panel): | ||
| 48 | if sys.platform != 'win32': | 48 | if sys.platform != 'win32': |
| 49 | book.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | 49 | book.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
| 50 | 50 | ||
| 51 | + self.measures_list = MeasuresListCtrlPanel(book) | ||
| 52 | + | ||
| 51 | book.AddPage(MaskPage(book), _("Masks")) | 53 | book.AddPage(MaskPage(book), _("Masks")) |
| 52 | book.AddPage(SurfacePage(book), _("Surfaces")) | 54 | book.AddPage(SurfacePage(book), _("Surfaces")) |
| 53 | - book.AddPage(MeasuresListCtrlPanel(book), _("Measures")) | 55 | + book.AddPage(self.measures_list, _("Measures")) |
| 54 | book.AddPage(AnnotationsListCtrlPanel(book), _("Annotations")) | 56 | book.AddPage(AnnotationsListCtrlPanel(book), _("Annotations")) |
| 55 | 57 | ||
| 56 | book.SetSelection(0) | 58 | book.SetSelection(0) |
| @@ -60,9 +62,22 @@ class NotebookPanel(wx.Panel): | @@ -60,9 +62,22 @@ class NotebookPanel(wx.Panel): | ||
| 60 | self.SetSizer(sizer) | 62 | self.SetSizer(sizer) |
| 61 | 63 | ||
| 62 | book.Refresh() | 64 | book.Refresh() |
| 65 | + | ||
| 66 | + self.__bind_events() | ||
| 63 | 67 | ||
| 64 | # TODO: insert icons bellow notebook | 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 | class MaskPage(wx.Panel): | 82 | class MaskPage(wx.Panel): |
| 68 | """ | 83 | """ |
| @@ -751,9 +766,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -751,9 +766,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 751 | self.__init_columns() | 766 | self.__init_columns() |
| 752 | self.__init_image_list() | 767 | self.__init_image_list() |
| 753 | self.__init_evt() | 768 | self.__init_evt() |
| 754 | - | ||
| 755 | - # just testing | ||
| 756 | - self.Populate() | 769 | + |
| 770 | + self._last_measure = 0 | ||
| 757 | 771 | ||
| 758 | def __init_evt(self): | 772 | def __init_evt(self): |
| 759 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) | 773 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
| @@ -807,13 +821,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -807,13 +821,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 807 | self.InsertStringItem(index, "") | 821 | self.InsertStringItem(index, "") |
| 808 | self.SetStringItem(index, 1, type_, imageId = self.img_colour) | 822 | self.SetStringItem(index, 1, type_, imageId = self.img_colour) |
| 809 | self.SetStringItem(index, 2, value) | 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 | class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | 831 | class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |