1

I am trying to enable/disable interacting with a pyvista.renderer by means of a callback function. This works fine when only one actor is present in the scene. In the example below, pressing 's' activates and deactivates interacting with with the camera using the mouse.

import pyvista as pv
opts = dict({'interactionOn' : True})  # track if renderer active/inactive in a global variable
def toggleInteraction():
    if opts['interactionOn']:
        P.renderer.disable()
        opts.update({'interactionOn' : False})

    else:
        P.renderer.enable()
        opts.update({'interactionOn': True})

sp = pv.Sphere()
P = pv.Plotter()
a1=P.add_mesh(sp,pickable=True,opacity = .5)
P.add_key_event('s', toggleInteraction)
P.show()

However if you add a second actor to the scene. Pressing toggling using 's' changes the look of the second actor. On the second press (re enabling interaction) the actor seems to revert to the fdefault style (it changes from points to solid)

import pyvista as pv
opts = dict({'interactionOn' : True})  # track if renderer active/inactive in a global variable
def toggleInteraction():
    if opts['interactionOn']:
        P.renderer.disable()
        opts.update({'interactionOn' : False})
    else:
        P.renderer.enable()
        opts.update({'interactionOn': True})

sp = pv.Sphere()
P = pv.Plotter()
a1=P.add_mesh(sp,pickable=True,opacity=.5)
sp2 = pv.Sphere(radius=1.5,center=[1,1,1])
a2=P.add_mesh(sp2,style = 'points')
P.add_key_event('s', toggleInteraction)
P.show() # press s twice to see what happens on my machine the second actor changes from points to solid

I am using Python 3.10 on Linux with vtk 9.1.0 with pyvista 0.37. I guess this is a bug, any ideas for a workaround would be appreciated. Harry

Harry Matthews
  • 143
  • 1
  • 10
  • I haven't had a chance yet to take a close look at your question, but it's well asked, contains a complete example, and you have a strong suspicion it's a bug. I'd recommend posting it to [the issue tracker](https://github.com/pyvista/pyvista/issues) as [a bug](https://github.com/pyvista/pyvista/issues/new?assignees=&labels=bug&template=bug-report.yml). – Andras Deak -- Слава Україні Nov 24 '22 at 22:11
  • 1
    Thank you for the suggestion. I have reported this as a bug https://github.com/pyvista/pyvista/issues/3647 – Harry Matthews Nov 25 '22 at 12:14

0 Answers0