vedo icon indicating copy to clipboard operation
vedo copied to clipboard

Behavior of `vedo.show` when called twice with different arguments

Open Louis-Pujol opened this issue 1 year ago • 1 comments

Hi @marcomusy

When running this script :

import vedo
mesh = vedo.Mesh(vedo.dataurl+"spider.ply")
vedo.show(mesh.c('b'), offscreen=True)
vedo.show(mesh.c('r'), offscreen=False)

I expected the second call to show() to create a new plotter with offscreen=False. But it seemed that the parameter offscreen kept to its previous value. Looking at the code, I spotted that the behavior I wanted was reachable adding new=True to the second call to show, as by default, show reuse the previous plotter instance.

I would find it more natural to have new automatically set to True if I ask explicitly a different behavior than the actualvedo.plotter_instance. My suggestion would be to add something like

if vedo.plotter_instance and vedo.plotter_instance.offscreen != offscreen:
    new = True

at the beginning of the function vedo.plotter.show(). I add this on my local fork and it worked as I expected for my example.

What to you think about adding these lines to vedo ? Maybe other arguments (interactive, ... ?) should be treated the same way ?

I you think it's a good idea, I can open a PR to integrate it.

Louis-Pujol avatar Jan 18 '24 11:01 Louis-Pujol

Hi Louis, thanks, that makes sense to me! Please go on with a PR. I would not do the same for interactive though as that is something one may want change for the same window/plotter.

marcomusy avatar Jan 18 '24 12:01 marcomusy