I find vtkPropPicker
can not pick a vtkFollower
with 0.8 opacity, but it can pick vtkActor
with 0.8 opacity. My test code is:
import vtkmodules.all as vtk
cylinder1 = vtk.vtkCylinderSource()
cylinder1.SetCenter(0, 0, 0)
cylinder1.Update()
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputData(cylinder1.GetOutput())
actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)
actor1.GetProperty().SetColor(1, 0, 0)
actor1.GetProperty().SetOpacity(0.8)
cylinder2 = vtk.vtkCylinderSource()
cylinder2.SetCenter(2, 0, 0)
cylinder2.Update()
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputData(cylinder2.GetOutput())
actor2 = vtk.vtkFollower()
actor2.SetMapper(mapper2)
actor2.GetProperty().SetColor(0, 1, 0)
actor2.GetProperty().SetOpacity(0.8)
cylinder3 = vtk.vtkCylinderSource()
cylinder3.SetCenter(4, 0, 0)
cylinder3.Update()
mapper3 = vtk.vtkPolyDataMapper()
mapper3.SetInputData(cylinder3.GetOutput())
actor3 = vtk.vtkFollower()
actor3.SetMapper(mapper3)
actor3.GetProperty().SetColor(0, 0, 1)
actor3.GetProperty().SetOpacity(1)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor1)
renderer.AddActor(actor2)
renderer.AddActor(actor3)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
def MouseMoveEvent(iren, evt):
x, y = iren.GetEventPosition()
picker1 = vtk.vtkPropPicker()
picker1.Pick(x, y, 0, renderer)
ac = picker1.GetViewProp()
if ac is None:
print('cannot find actor')
return
acs = [actor1, actor2, actor3]
idx = acs.index(ac)
print('find actor: ', idx+1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.AddObserver('MouseMoveEvent', MouseMoveEvent)
iren.Initialize()
iren.Start()
There are three actors:
id | type | opacity |
---|---|---|
1 | vtkActor | 0.8 |
2 | vtkFollower | 0.8 |
3 | vtkFollower | 1 |
When move the mouse over the window, the application would print cannot find actor
or find actor: 1/2/3
.
When run the code, we can see that the vtkPropPicker
can not pick actor 2
. Is it a bug?
My environment is:
win 10
python 3.9.12
vtk 9.2