Commit 09dd1451cb4e7a4538b3b0217eeb870da96e24bd
1 parent
4e527a1a
Exists in
master
and in
31 other branches
Fixed crash in Mac and its showing the slices in import panel
Showing
1 changed file
with
7 additions
and
6 deletions
Show diff stats
invesalius/gui/dicom_preview_panel.py
| @@ -666,6 +666,7 @@ class DicomPreviewSlice(wx.Panel): | @@ -666,6 +666,7 @@ class DicomPreviewSlice(wx.Panel): | ||
| 666 | class SingleImagePreview(wx.Panel): | 666 | class SingleImagePreview(wx.Panel): |
| 667 | def __init__(self, parent): | 667 | def __init__(self, parent): |
| 668 | wx.Panel.__init__(self, parent, -1) | 668 | wx.Panel.__init__(self, parent, -1) |
| 669 | + self.actor = None | ||
| 669 | self.__init_gui() | 670 | self.__init_gui() |
| 670 | self.__init_vtk() | 671 | self.__init_vtk() |
| 671 | self.__bind_evt_gui() | 672 | self.__bind_evt_gui() |
| @@ -676,9 +677,6 @@ class SingleImagePreview(wx.Panel): | @@ -676,9 +677,6 @@ class SingleImagePreview(wx.Panel): | ||
| 676 | self.window_level = const.WINDOW_LEVEL[_("Bone")][1] | 677 | self.window_level = const.WINDOW_LEVEL[_("Bone")][1] |
| 677 | 678 | ||
| 678 | def __init_vtk(self): | 679 | def __init_vtk(self): |
| 679 | - actor = vtk.vtkImageActor() | ||
| 680 | - self.actor = actor | ||
| 681 | - | ||
| 682 | text_image_size = vtku.Text() | 680 | text_image_size = vtku.Text() |
| 683 | text_image_size.SetPosition(const.TEXT_POS_LEFT_UP) | 681 | text_image_size.SetPosition(const.TEXT_POS_LEFT_UP) |
| 684 | text_image_size.SetValue("") | 682 | text_image_size.SetValue("") |
| @@ -708,7 +706,6 @@ class SingleImagePreview(wx.Panel): | @@ -708,7 +706,6 @@ class SingleImagePreview(wx.Panel): | ||
| 708 | self.text_acquisition = text_acquisition | 706 | self.text_acquisition = text_acquisition |
| 709 | 707 | ||
| 710 | renderer = vtk.vtkRenderer() | 708 | renderer = vtk.vtkRenderer() |
| 711 | - renderer.AddActor(actor) | ||
| 712 | renderer.AddActor(text_image_size.actor) | 709 | renderer.AddActor(text_image_size.actor) |
| 713 | renderer.AddActor(text_image_location.actor) | 710 | renderer.AddActor(text_image_location.actor) |
| 714 | renderer.AddActor(text_patient.actor) | 711 | renderer.AddActor(text_patient.actor) |
| @@ -816,7 +813,7 @@ class SingleImagePreview(wx.Panel): | @@ -816,7 +813,7 @@ class SingleImagePreview(wx.Panel): | ||
| 816 | value1 = '' | 813 | value1 = '' |
| 817 | else: | 814 | else: |
| 818 | value1 = STR_SPC %(dicom.image.spacing[2]) | 815 | value1 = STR_SPC %(dicom.image.spacing[2]) |
| 819 | - | 816 | + |
| 820 | if dicom.image.orientation_label == 'AXIAL': | 817 | if dicom.image.orientation_label == 'AXIAL': |
| 821 | value2 = STR_LOCAL %(dicom.image.position[2]) | 818 | value2 = STR_LOCAL %(dicom.image.position[2]) |
| 822 | elif dicom.image.orientation_label == 'CORONAL': | 819 | elif dicom.image.orientation_label == 'CORONAL': |
| @@ -838,7 +835,6 @@ class SingleImagePreview(wx.Panel): | @@ -838,7 +835,6 @@ class SingleImagePreview(wx.Panel): | ||
| 838 | value = STR_ACQ % (dicom.acquisition.date, | 835 | value = STR_ACQ % (dicom.acquisition.date, |
| 839 | dicom.acquisition.time) | 836 | dicom.acquisition.time) |
| 840 | self.text_acquisition.SetValue(value) | 837 | self.text_acquisition.SetValue(value) |
| 841 | - | ||
| 842 | 838 | ||
| 843 | rdicom = vtkgdcm.vtkGDCMImageReader() | 839 | rdicom = vtkgdcm.vtkGDCMImageReader() |
| 844 | rdicom.SetFileName(dicom.image.file) | 840 | rdicom.SetFileName(dicom.image.file) |
| @@ -851,6 +847,11 @@ class SingleImagePreview(wx.Panel): | @@ -851,6 +847,11 @@ class SingleImagePreview(wx.Panel): | ||
| 851 | colorer.SetInputConnection(rdicom.GetOutputPort()) | 847 | colorer.SetInputConnection(rdicom.GetOutputPort()) |
| 852 | colorer.SetWindow(float(window_width)) | 848 | colorer.SetWindow(float(window_width)) |
| 853 | colorer.SetLevel(float(window_level)) | 849 | colorer.SetLevel(float(window_level)) |
| 850 | + colorer.Update() | ||
| 851 | + | ||
| 852 | + if self.actor is None: | ||
| 853 | + self.actor = vtk.vtkImageActor() | ||
| 854 | + self.renderer.AddActor(self.actor) | ||
| 854 | 855 | ||
| 855 | # PLOT IMAGE INTO VIEWER | 856 | # PLOT IMAGE INTO VIEWER |
| 856 | self.actor.SetInputData(colorer.GetOutput()) | 857 | self.actor.SetInputData(colorer.GetOutput()) |