Why vtkImageTracerWidget doesn't work

Why vtkImageTracerWidget doesn’t work?

import vtk
reader=vtk.vtkDICOMImageReader()
reader.SetDirectoryName("DicomData/16")
reader.Update()


view=vtk.vtkImageViewer2()
view.SetInputConnection(reader.GetOutputPort())

interactor = vtk.vtkInteractorStyleImage()
iren=vtk.vtkRenderWindowInteractor()
iren.SetInteractorStyle(interactor)

imageActor = vtk.vtkImageActor()
imageActor.GetMapper().SetInputData(view.GetInput())

view.SetupInteractor(iren)
itw = vtk.vtkImageTracerWidget()
itw.SetCaptureRadius(100)
itw.GetGlyphSource().SetColor(1, 0, 0)
itw.GetGlyphSource().SetScale(3.0)
itw.GetGlyphSource().SetRotationAngle(45.0)
itw.GetGlyphSource().Modified()
itw.ProjectToPlaneOn()
itw.SetViewProp(imageActor)
itw.SetInputData(view.GetInput())
itw.SetInteractor(iren)
itw.PlaceWidget()

itw.SnapToImageOff()
itw.AutoCloseOn()

itw.On()
iren.Start()

Hi,

Try calling InteractionOn() and SetEnabled(1) on itw.

regards,

PC

I’m sorry, but unfortunately it doesn’t work

Hello,

Well, saying “it doesn’t work” is like saying “everywhere” when the doctor asks where the pain is… So, what do you mean by “it doesn’t work”? Can you describe the issue in more detail and/or post an image?

regards,

PC

Hello, I am using QVTKRenderWindow Interface and placing vtkImageViewer2 on QtWidgets In QFrame(), then use vtkImageTracerWidget() for trajectory tracking. The result is that holding down the left mouse button and dragging will call for window width and level adjustment of vtkImageViewer2, rather than displaying the trajectory. May I ask how to solve it?