Commit 09dd1451cb4e7a4538b3b0217eeb870da96e24bd

Authored by Thiago Franco de Moraes
1 parent 4e527a1a

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 666 class SingleImagePreview(wx.Panel):
667 667 def __init__(self, parent):
668 668 wx.Panel.__init__(self, parent, -1)
  669 + self.actor = None
669 670 self.__init_gui()
670 671 self.__init_vtk()
671 672 self.__bind_evt_gui()
... ... @@ -676,9 +677,6 @@ class SingleImagePreview(wx.Panel):
676 677 self.window_level = const.WINDOW_LEVEL[_("Bone")][1]
677 678  
678 679 def __init_vtk(self):
679   - actor = vtk.vtkImageActor()
680   - self.actor = actor
681   -
682 680 text_image_size = vtku.Text()
683 681 text_image_size.SetPosition(const.TEXT_POS_LEFT_UP)
684 682 text_image_size.SetValue("")
... ... @@ -708,7 +706,6 @@ class SingleImagePreview(wx.Panel):
708 706 self.text_acquisition = text_acquisition
709 707  
710 708 renderer = vtk.vtkRenderer()
711   - renderer.AddActor(actor)
712 709 renderer.AddActor(text_image_size.actor)
713 710 renderer.AddActor(text_image_location.actor)
714 711 renderer.AddActor(text_patient.actor)
... ... @@ -816,7 +813,7 @@ class SingleImagePreview(wx.Panel):
816 813 value1 = ''
817 814 else:
818 815 value1 = STR_SPC %(dicom.image.spacing[2])
819   -
  816 +
820 817 if dicom.image.orientation_label == 'AXIAL':
821 818 value2 = STR_LOCAL %(dicom.image.position[2])
822 819 elif dicom.image.orientation_label == 'CORONAL':
... ... @@ -838,7 +835,6 @@ class SingleImagePreview(wx.Panel):
838 835 value = STR_ACQ % (dicom.acquisition.date,
839 836 dicom.acquisition.time)
840 837 self.text_acquisition.SetValue(value)
841   -
842 838  
843 839 rdicom = vtkgdcm.vtkGDCMImageReader()
844 840 rdicom.SetFileName(dicom.image.file)
... ... @@ -851,6 +847,11 @@ class SingleImagePreview(wx.Panel):
851 847 colorer.SetInputConnection(rdicom.GetOutputPort())
852 848 colorer.SetWindow(float(window_width))
853 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 856 # PLOT IMAGE INTO VIEWER
856 857 self.actor.SetInputData(colorer.GetOutput())
... ...