Commit 618278420364c5a7c6a1acb1ef0ad687097f9f46
1 parent
f6d61f6d
Exists in
master
and in
67 other branches
FIX: Resolve a problem about what the next surface's index is
Showing
4 changed files
with
8 additions
and
24 deletions
Show diff stats
invesalius/control.py
| ... | ... | @@ -248,9 +248,6 @@ class Controller(): |
| 248 | 248 | mask._set_class_index(proj.last_mask_index) |
| 249 | 249 | self.mask_dict_copy = proj.mask_dict.copy() |
| 250 | 250 | |
| 251 | - surface = srf.Surface() | |
| 252 | - surface._set_class_index(proj.last_surface_index) | |
| 253 | - | |
| 254 | 251 | self.LoadProject() |
| 255 | 252 | |
| 256 | 253 | Publisher.sendMessage('Update threshold limits', | ... | ... |
invesalius/data/surface.py
| ... | ... | @@ -315,13 +315,12 @@ class SurfaceManager(): |
| 315 | 315 | # self.actors_dict. |
| 316 | 316 | proj = prj.Project() |
| 317 | 317 | surface = proj.surface_dict[index] |
| 318 | - if surface.is_shown: | |
| 319 | - Publisher.sendMessage('Update surface info in GUI', | |
| 320 | - (index, surface.name, | |
| 321 | - surface.colour, surface.volume, | |
| 322 | - surface.transparency)) | |
| 318 | + Publisher.sendMessage('Update surface info in GUI', | |
| 319 | + (index, surface.name, | |
| 320 | + surface.colour, surface.volume, | |
| 321 | + surface.transparency)) | |
| 323 | 322 | self.last_surface_index = index |
| 324 | - #self.ShowActor(index, True) | |
| 323 | + self.ShowActor(index, True) | |
| 325 | 324 | |
| 326 | 325 | |
| 327 | 326 | def OnLoadSurfaceDict(self, pubsub_evt): | ... | ... |
invesalius/gui/data_notebook.py
| ... | ... | @@ -685,10 +685,9 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 685 | 685 | def __bind_events_wx(self): |
| 686 | 686 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
| 687 | 687 | self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel) |
| 688 | - self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected_) | |
| 688 | + #self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected_) | |
| 689 | 689 | self.Bind(wx.EVT_KEY_UP, self.OnKeyEvent) |
| 690 | 690 | |
| 691 | - | |
| 692 | 691 | def OnKeyEvent(self, event): |
| 693 | 692 | keycode = event.GetKeyCode() |
| 694 | 693 | # Delete key |
| ... | ... | @@ -697,13 +696,11 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 697 | 696 | elif (keycode == wx.WXK_DELETE): |
| 698 | 697 | self.RemoveSurfaces() |
| 699 | 698 | |
| 700 | - | |
| 701 | 699 | def OnHideSurface(self, pubsub_evt): |
| 702 | 700 | surface_dict = pubsub_evt.data |
| 703 | 701 | for key in surface_dict: |
| 704 | 702 | if not surface_dict[key].is_shown: |
| 705 | 703 | self.SetItemImage(key, False) |
| 706 | - | |
| 707 | 704 | |
| 708 | 705 | def RemoveSurfaces(self): |
| 709 | 706 | """ |
| ... | ... | @@ -729,7 +726,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 729 | 726 | else: |
| 730 | 727 | dlg.SurfaceSelectionRequiredForRemoval() |
| 731 | 728 | |
| 732 | - | |
| 733 | 729 | def OnCloseProject(self, pubsub_evt): |
| 734 | 730 | self.DeleteAllItems() |
| 735 | 731 | self.surface_list_index = {} |
| ... | ... | @@ -790,7 +786,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 790 | 786 | |
| 791 | 787 | self.image_gray = Image.open("../icons/object_colour.jpg") |
| 792 | 788 | |
| 793 | - | |
| 794 | 789 | def OnEditLabel(self, evt): |
| 795 | 790 | Publisher.sendMessage('Change surface name', (evt.GetIndex(), evt.GetLabel())) |
| 796 | 791 | evt.Skip() |
| ... | ... | @@ -798,7 +793,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 798 | 793 | def OnItemActivated(self, evt): |
| 799 | 794 | self.ToggleItem(evt.m_itemIndex) |
| 800 | 795 | evt.Skip() |
| 801 | - | |
| 802 | 796 | |
| 803 | 797 | def OnCheckItem(self, index, flag): |
| 804 | 798 | Publisher.sendMessage('Show surface', (index, flag)) |
| ... | ... | @@ -836,8 +830,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 836 | 830 | if index not in self.surface_list_index: |
| 837 | 831 | image = self.CreateColourBitmap(colour) |
| 838 | 832 | image_index = self.imagelist.Add(image) |
| 839 | - | |
| 840 | - | |
| 841 | 833 | |
| 842 | 834 | index_list = self.surface_list_index.keys() |
| 843 | 835 | self.surface_list_index[index] = image_index |
| ... | ... | @@ -847,8 +839,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 847 | 839 | else: |
| 848 | 840 | self.InsertNewItem(index, name, volume, transparency, colour) |
| 849 | 841 | |
| 850 | - | |
| 851 | - | |
| 852 | 842 | def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3", |
| 853 | 843 | transparency="0%%", colour=None): |
| 854 | 844 | self.InsertStringItem(index, "") |
| ... | ... | @@ -865,7 +855,6 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 865 | 855 | self.SetStringItem(index, 2, volume) |
| 866 | 856 | self.SetStringItem(index, 3, transparency) |
| 867 | 857 | self.SetItemImage(index, 1) |
| 868 | - | |
| 869 | 858 | |
| 870 | 859 | def CreateColourBitmap(self, colour): |
| 871 | 860 | """ | ... | ... |
invesalius/project.py
| ... | ... | @@ -303,13 +303,13 @@ class Project(object): |
| 303 | 303 | m = msk.Mask() |
| 304 | 304 | m.OpenPList(filepath) |
| 305 | 305 | self.mask_dict[m.index] = m |
| 306 | - self.surface_dict = {} | |
| 307 | 306 | |
| 308 | 307 | # Opening the surfaces |
| 308 | + self.surface_dict = {} | |
| 309 | 309 | for index in project["surfaces"]: |
| 310 | 310 | filename = project["surfaces"][index] |
| 311 | 311 | filepath = os.path.join(dirpath, filename) |
| 312 | - s = srf.Surface() | |
| 312 | + s = srf.Surface(int(index)) | |
| 313 | 313 | s.OpenPList(filepath) |
| 314 | 314 | self.surface_dict[s.index] = s |
| 315 | 315 | |
| ... | ... | @@ -322,7 +322,6 @@ class Project(object): |
| 322 | 322 | measure.Load(measurements[index]) |
| 323 | 323 | self.measurement_dict[int(index)] = measure |
| 324 | 324 | |
| 325 | - | |
| 326 | 325 | def Compress(folder, filename): |
| 327 | 326 | tmpdir, tmpdir_ = os.path.split(folder) |
| 328 | 327 | current_dir = os.path.abspath(".") | ... | ... |