コード例 #1
0
    def __init__(self, rwi, renderer):
        self.rwi = rwi
        self.renderer = renderer

        istyle = vtk.vtkInteractorStyleTrackballCamera()
        rwi.SetInteractorStyle(istyle)

        # we unbind the existing mousewheel handler so it doesn't
        # interfere
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)

        self.ipws = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut = self.ipws[0].GetLookupTable()
        for ipw in self.ipws:
            ipw.SetInteractor(rwi)
            ipw.SetLookupTable(lut)

        # we only set the picker on the visible IPW, else the
        # invisible IPWs block picking!
        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.005)
        self.ipws[0].SetPicker(self.picker)

        self.outline_source = vtk.vtkOutlineCornerFilter()
        m = vtk.vtkPolyDataMapper()
        m.SetInput(self.outline_source.GetOutput())
        a = vtk.vtkActor()
        a.SetMapper(m)
        a.PickableOff()
        self.outline_actor = a

        self.dv_orientation_widget = DVOrientationWidget(rwi)

        # this can be used by clients to store the current world
        # position
        self.current_world_pos = (0,0,0)
        self.current_index_pos = (0,0,0)
コード例 #2
0
    def __init__(self, rwi, renderer):
        self.rwi = rwi
        self.renderer = renderer

        istyle = vtk.vtkInteractorStyleTrackballCamera()
        rwi.SetInteractorStyle(istyle)

        # we unbind the existing mousewheel handler so it doesn't
        # interfere
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)

        #This is a collection of 1- or 3-component image plane widgets. Each entry corresponds to a single overlay.
        self.ipw_triads = {}
        self.add_overlay(
            0, [0, 0, 0, 0.1]
        )  #Almost-transparent black - for showing the pickable plane stored at id = 0.

        # we only set the picker on the visible IPW, else the
        # invisible IPWs block picking!
        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.005)
        self.ipw_triads[0][0].SetPicker(self.picker)

        self.outline_source = vtk.vtkOutlineCornerFilter()
        m = vtk.vtkPolyDataMapper()
        m.SetInput(self.outline_source.GetOutput())
        a = vtk.vtkActor()
        a.SetMapper(m)
        a.PickableOff()
        self.outline_actor = a

        self.dv_orientation_widget = DVOrientationWidget(rwi)

        # this can be used by clients to store the current world
        # position
        self.current_world_pos = (0, 0, 0)
        self.current_index_pos = (0, 0, 0)
コード例 #3
0
    def __init__(self, rwi, renderer):
        # nnsmit-edit
        self.overlay_active = 0;
        self.overlay_active_voxels = 0;
        self.overlay_active_100band1 = 0;
        self.overlay_active_100band2 = 0;
        self.overlay_active_100band3 = 0;
        self.overlay_active_50band1 = 0;
        self.overlay_active_50band2 = 0;
        self.overlay_active_50band3 = 0;		
		
        # end edit
        self.rwi = rwi
        self.renderer = renderer

        istyle = vtk.vtkInteractorStyleTrackballCamera()
        rwi.SetInteractorStyle(istyle)

        # we unbind the existing mousewheel handler so it doesn't
        # interfere
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)

        self.ipws = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut = self.ipws[0].GetLookupTable()
        for ipw in self.ipws:
            ipw.SetInteractor(rwi)
            ipw.SetLookupTable(lut)

	    # IPWS for overlay
    	self.overlay_ipws = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut = self.overlay_ipws[0].GetLookupTable()
        lut.SetNumberOfTableValues(3)
        lut.SetTableValue(0,0,0,0,0)
        lut.SetTableValue(1,0.5,0,1,1)
        lut.SetTableValue(2,1,0,0,1)
        lut.Build()
        for ipw_overlay in self.overlay_ipws:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)

	
	    # IPWS for voxels selected in scatterplot
    	self.overlay_ipws_voxels = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut = self.overlay_ipws_voxels[0].GetLookupTable()
        lut.SetNumberOfTableValues(3)
        lut.SetTableValue(0,0,0,0,0)
        lut.SetTableValue(1,0.5,0,1,1)
        lut.SetTableValue(2,1,0,0,1)
        lut.Build()
        for ipw_overlay in self.overlay_ipws_voxels:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)	
	
			
			
	    # IPWS for overlay of 100%band in first row
    	self.overlay_ipws_100band1 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut1 = self.overlay_ipws_100band1[0].GetLookupTable()
        lut1.SetNumberOfTableValues(3)
        lut1.SetTableValue(0,0,0,0,0)
        lut1.SetTableValue(1, 1, 1, 0, 1)
        lut1.SetTableValue(2, 1,1,0, 1)
        lut1.Modified()
        lut1.Build()
        for ipw_overlay in self.overlay_ipws_100band1:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut1)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
			
	    # IPWS for overlay of 50%band in first row
    	self.overlay_ipws_50band1 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut1 = self.overlay_ipws_50band1[0].GetLookupTable()
        lut1.SetNumberOfTableValues(3)
        lut1.SetTableValue(0,0,0,0,0)
        lut1.SetTableValue(1, 1, 1, 0, 1)
        lut1.SetTableValue(2, 1,1,0, 1)
        lut1.Modified()
        lut1.Build()
        for ipw_overlay in self.overlay_ipws_50band1:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut1)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
			
			
	    # IPWS for overlay of 100%band in second row
    	self.overlay_ipws_100band2 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        #lut2 = self.overlay_ipws_100band2[0].GetLookupTable()
        #lut2.SetNumberOfTableValues(3)
        #lut2.SetTableValue(0,0,0,0,0)
        #lut2.SetTableValue(1, 0.98,0,0, 0.37)
        #lut2.SetTableValue(2, 0.98,0,0, 0.37)
        #lut2.Modified()
        #lut2.Build()
        for ipw_overlay in self.overlay_ipws_100band2:
            ipw_overlay.SetInteractor(rwi)
            #ipw_overlay.SetLookupTable(lut2)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
			
	    # IPWS for overlay of 100%band in second row
    	self.overlay_ipws_50band2 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        #lut2 = self.overlay_ipws_100band2[0].GetLookupTable()
        #lut2.SetNumberOfTableValues(3)
        #lut2.SetTableValue(0,0,0,0,0)
        #lut2.SetTableValue(1, 0.98,0,0, 0.37)
        #lut2.SetTableValue(2, 0.98,0,0, 0.37)
        #lut2.Modified()
        #lut2.Build()
        for ipw_overlay in self.overlay_ipws_50band2:
            ipw_overlay.SetInteractor(rwi)
            #ipw_overlay.SetLookupTable(lut2)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
			
			
	    # IPWS for overlay of 100%band in third row
    	self.overlay_ipws_100band3 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut3 = self.overlay_ipws_100band3[0].GetLookupTable()
        lut3.SetNumberOfTableValues(3)
        lut3.SetTableValue(0,0,0,0,0)
        lut3.SetTableValue(1,0,0.643,0.941, 0.5)
        lut3.SetTableValue(2,0,0.643,0.941, 0.5)
        lut3.Modified()
        lut3.Build()
        for ipw_overlay in self.overlay_ipws_100band3:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut3)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
			
	    # IPWS for overlay of 50%band in third row
    	self.overlay_ipws_50band3 = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut3 = self.overlay_ipws_50band3[0].GetLookupTable()
        lut3.SetNumberOfTableValues(3)
        lut3.SetTableValue(0,0,0,0,0)
        lut3.SetTableValue(1,0,0.643,0.941, 0.5)
        lut3.SetTableValue(2,0,0.643,0.941, 0.5)
        lut3.Modified()
        lut3.Build()
        for ipw_overlay in self.overlay_ipws_50band3:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut3)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)
	
	
        # now actually connect the sync_overlay observer
        for i,ipw in enumerate(self.ipws):
            ipw.AddObserver('InteractionEvent',lambda vtk_o, vtk_e, i=i: self.observer_sync_overlay(self.ipws,i))
        # end edit

        # we only set the picker on the visible IPW, else the
        # invisible IPWs block picking!
        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.005)
        self.ipws[0].SetPicker(self.picker)

        self.outline_source = vtk.vtkOutlineCornerFilter()
        m = vtk.vtkPolyDataMapper()
        m.SetInput(self.outline_source.GetOutput())
        a = vtk.vtkActor()
        a.SetMapper(m)
        a.PickableOff()
        self.outline_actor = a

        self.dv_orientation_widget = DVOrientationWidget(rwi)

        # this can be used by clients to store the current world
        # position
        self.current_world_pos = (0,0,0)
        self.current_index_pos = (0,0,0)