Skip to content

Commit

Permalink
Merge pull request #1027 from Louis-Pujol/master
Browse files Browse the repository at this point in the history
vedo.show create a new plotter instance when called twice with different offset arguments
  • Loading branch information
marcomusy authored Jan 18, 2024
2 parents 70f4ca3 + 391aef2 commit 2c247bc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ def show(
new : (bool)
if set to `True`, a call to show will instantiate
a new Plotter object (a new window) instead of reusing the first created.
If new is `True`, but the existing plotter was instantiated with a different
argument for `offscreen`, `new` is ignored and a new Plotter is created anyway.
"""
if len(objects) == 0:
objects = None
Expand All @@ -246,6 +248,12 @@ def show(
else:
objects = utils.flatten(objects)

# If a plotter instance is already present, check if the offscreen argument
# is the same as the one requested by the user. If not, create a new
# plotter instance (see https://github.com/marcomusy/vedo/issues/1026)
if vedo.plotter_instance and vedo.plotter_instance.offscreen != offscreen:
new = True

if vedo.plotter_instance and not new: # Plotter exists
plt = vedo.plotter_instance

Expand Down Expand Up @@ -2984,13 +2992,13 @@ def _scan_input_return_acts(self, objs):

elif isinstance(a, vtk.vtkImageData):
scanned_acts.append(vedo.Volume(a).actor)

elif isinstance(a, vedo.RectilinearGrid):
scanned_acts.append(a.actor)

elif isinstance(a, vtk.vtkLight):
self.renderer.AddLight(a)

elif isinstance(a, vedo.visual.LightKit):
a.lightkit.AddLightsToRenderer(self.renderer)

Expand Down

0 comments on commit 2c247bc

Please sign in to comment.