Esempio n. 1
0
    def Execute(self):

        if self.Image == None:
            self.PrintError('Error: no Image.')

        if self.Interactive == 1:
            
            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)                 

            self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetX.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetY.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetZ.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.vmtkRenderer.AddKeyBinding('i','Interact.', self.InteractCallback)

            self.Display()
            while (self.BoxActive == 1):
                self.PaintVOI()
                self.Display()
        else:
            self.PaintVOI()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
Esempio n. 2
0
    def Execute(self):

        if self.Image == None:
            self.PrintError('Error: no Image.')

        self.CroppedImage.DeepCopy(self.Image)

        if self.Interactive == 1:

            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)
            self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetX.SetInteractor(
                self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetY.SetInteractor(
                self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetZ.SetInteractor(
                self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(
                self.vmtkRenderer.RenderWindowInteractor)

            #self.vmtkRenderer.AddKeyBinding('i','Interact.',self.InteractCallback)
            self.InputInfo("Press 'i' to activate interactor")

            self.Display()
            while (self.BoxActive == 1):
                self.ExtractVOI()
                self.Image = self.CroppedImage
                self.Display()
        else:
            self.ExtractVOI()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()

        self.Image = self.CroppedImage
Esempio n. 3
0
    def Execute(self):
        if (self.Image == None) & (self.Display == 1):
            self.PrintError('Error: no Image.')

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self)

        ##self.PrintLog('Ctrl +  left click to add seed.')
        self.Picker = vtk.vtkCellPicker()
        self.Picker.SetTolerance(0.005)

        self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetX.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetX.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetX.SetPicker(self.Picker)
        self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetY.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetY.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetY.SetPicker(self.Picker)
        self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetZ.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetZ.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetZ.SetPicker(self.Picker)

        self.Seeds = vtk.vtkPolyData()
        self.InitializeSeeds()

        self.BuildView()

        self.WidgetsOff()

        if not self.KeepSeeds:
            self.vmtkRenderer.Renderer.RemoveActor(self.SeedActor)

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
Esempio n. 4
0
    def Execute(self):
        if (self.Image == None) & (self.Display == 1):
            self.PrintError('Error: no Image.')

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        ##self.PrintLog('Ctrl +  left click to add seed.')
        self.Picker = vtk.vtkCellPicker()
        self.Picker.SetTolerance(0.005)

        self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetX.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetX.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetX.SetPicker(self.Picker)
        self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetY.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetY.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetY.SetPicker(self.Picker)
        self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
        self.PlaneWidgetZ.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.PlaneWidgetZ.AddObserver("StartInteractionEvent", self.AddSeed)
        self.PlaneWidgetZ.SetPicker(self.Picker)

        self.Seeds = vtk.vtkPolyData()
        self.InitializeSeeds()

        self.BuildView()
        
        self.WidgetsOff()

        if not self.KeepSeeds:
            self.vmtkRenderer.Renderer.RemoveActor(self.SeedActor)

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
Esempio n. 5
0
    def BuildView(self):

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self)

        if (self.ArrayName != ''):
            self.Image.GetPointData().SetActiveScalars(self.ArrayName)
        wholeExtent = self.Image.GetExtent()

        if self.Picker == None:
            self.Picker = vtk.vtkCellPicker()

        if self.PlaneWidgetX == None:
            self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()

        if self.PlaneWidgetY == None:
            self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()

        if self.PlaneWidgetZ == None:
            self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()

        self.Picker.SetTolerance(0.005)

        self.PlaneWidgetX.SetResliceInterpolateToLinear()
        self.PlaneWidgetX.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetX.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetX.SetInputData(self.Image)
        self.PlaneWidgetX.SetPlaneOrientationToXAxes()
        self.PlaneWidgetX.SetSliceIndex(wholeExtent[0])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetX.DisplayTextOn()
        else:
            self.PlaneWidgetX.DisplayTextOff()
        self.PlaneWidgetX.SetPicker(self.Picker)
        self.PlaneWidgetX.KeyPressActivationOff()
        self.PlaneWidgetX.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetX.SetMarginSizeX(0.05)
            self.PlaneWidgetX.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetX.SetMarginSizeX(0.0)
            self.PlaneWidgetX.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetX.SetWindowLevel(self.WindowLevel[0],
                                             self.WindowLevel[1])
        self.PlaneWidgetX.On()

        self.PlaneWidgetY.SetResliceInterpolateToLinear()
        self.PlaneWidgetY.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetY.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetY.SetInputData(self.Image)
        self.PlaneWidgetY.SetPlaneOrientationToYAxes()
        self.PlaneWidgetY.SetSliceIndex(wholeExtent[2])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetY.DisplayTextOn()
        else:
            self.PlaneWidgetY.DisplayTextOff()
        self.PlaneWidgetY.SetPicker(self.Picker)
        self.PlaneWidgetY.KeyPressActivationOff()
        self.PlaneWidgetY.SetLookupTable(self.PlaneWidgetX.GetLookupTable())
        self.PlaneWidgetY.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetY.SetMarginSizeX(0.05)
            self.PlaneWidgetY.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetY.SetMarginSizeX(0.0)
            self.PlaneWidgetY.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetY.SetWindowLevel(self.WindowLevel[0],
                                             self.WindowLevel[1])
        self.PlaneWidgetY.On()

        self.PlaneWidgetZ.SetResliceInterpolateToLinear()
        self.PlaneWidgetZ.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetZ.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetZ.SetInputData(self.Image)
        self.PlaneWidgetZ.SetPlaneOrientationToZAxes()
        self.PlaneWidgetZ.SetSliceIndex(wholeExtent[4])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetZ.DisplayTextOn()
        else:
            self.PlaneWidgetZ.DisplayTextOff()
        self.PlaneWidgetZ.SetPicker(self.Picker)
        self.PlaneWidgetZ.KeyPressActivationOff()
        self.PlaneWidgetZ.SetLookupTable(self.PlaneWidgetX.GetLookupTable())
        self.PlaneWidgetZ.SetInteractor(
            self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetZ.SetMarginSizeX(0.05)
            self.PlaneWidgetZ.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetZ.SetMarginSizeX(0.0)
            self.PlaneWidgetZ.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetZ.SetWindowLevel(self.WindowLevel[0],
                                             self.WindowLevel[1])
        self.PlaneWidgetZ.On()

        if (self.Display == 1):
            self.vmtkRenderer.Render()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
Esempio n. 6
0
    def BuildView(self):

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        if (self.ArrayName != ''):
            self.Image.GetPointData().SetActiveScalars(self.ArrayName)
        wholeExtent = self.Image.GetExtent()

        if self.Picker == None:
            self.Picker = vtk.vtkCellPicker()

        if self.PlaneWidgetX == None:
            self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()

        if self.PlaneWidgetY == None:
            self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()

        if self.PlaneWidgetZ == None:
            self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
            
        self.Picker.SetTolerance(0.005)

        self.PlaneWidgetX.SetResliceInterpolateToLinear()
        self.PlaneWidgetX.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetX.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetX.SetInputData(self.Image)
        self.PlaneWidgetX.SetPlaneOrientationToXAxes()
        self.PlaneWidgetX.SetSliceIndex(wholeExtent[0])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetX.DisplayTextOn()
        else:
            self.PlaneWidgetX.DisplayTextOff()
        self.PlaneWidgetX.SetPicker(self.Picker)
        self.PlaneWidgetX.KeyPressActivationOff()
        self.PlaneWidgetX.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetX.SetMarginSizeX(0.05)
            self.PlaneWidgetX.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetX.SetMarginSizeX(0.0)
            self.PlaneWidgetX.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetX.SetWindowLevel(self.WindowLevel[0],self.WindowLevel[1])
        self.PlaneWidgetX.On()

        self.PlaneWidgetY.SetResliceInterpolateToLinear()
        self.PlaneWidgetY.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetY.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetY.SetInputData(self.Image)
        self.PlaneWidgetY.SetPlaneOrientationToYAxes()
        self.PlaneWidgetY.SetSliceIndex(wholeExtent[2])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetY.DisplayTextOn()
        else:
            self.PlaneWidgetY.DisplayTextOff()
        self.PlaneWidgetY.SetPicker(self.Picker)
        self.PlaneWidgetY.KeyPressActivationOff()
        self.PlaneWidgetY.SetLookupTable(self.PlaneWidgetX.GetLookupTable())
        self.PlaneWidgetY.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetY.SetMarginSizeX(0.05)
            self.PlaneWidgetY.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetY.SetMarginSizeX(0.0)
            self.PlaneWidgetY.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetY.SetWindowLevel(self.WindowLevel[0],self.WindowLevel[1])
        self.PlaneWidgetY.On()

        self.PlaneWidgetZ.SetResliceInterpolateToLinear()
        self.PlaneWidgetZ.SetTextureInterpolate(self.TextureInterpolation)
        self.PlaneWidgetZ.SetUseContinuousCursor(self.ContinuousCursor)
        self.PlaneWidgetZ.SetInputData(self.Image)
        self.PlaneWidgetZ.SetPlaneOrientationToZAxes()
        self.PlaneWidgetZ.SetSliceIndex(wholeExtent[4])
        if self.vmtkRenderer.Annotations:
            self.PlaneWidgetZ.DisplayTextOn()
        else:
            self.PlaneWidgetZ.DisplayTextOff()
        self.PlaneWidgetZ.SetPicker(self.Picker)
        self.PlaneWidgetZ.KeyPressActivationOff()
        self.PlaneWidgetZ.SetLookupTable(self.PlaneWidgetX.GetLookupTable())
        self.PlaneWidgetZ.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        if self.Margins:
            self.PlaneWidgetZ.SetMarginSizeX(0.05)
            self.PlaneWidgetZ.SetMarginSizeY(0.05)
        else:
            self.PlaneWidgetZ.SetMarginSizeX(0.0)
            self.PlaneWidgetZ.SetMarginSizeY(0.0)
        if self.WindowLevel[0] != 0.0:
            self.PlaneWidgetZ.SetWindowLevel(self.WindowLevel[0],self.WindowLevel[1])
        self.PlaneWidgetZ.On()

        if (self.Display == 1):
            self.vmtkRenderer.Render()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()