Skip to content

Commit

Permalink
Duplicated figures with BackgroundPlotter in sphinx (pyvista#548)
Browse files Browse the repository at this point in the history
* Add simple example

* Remove explicit call to BasePlotter.__init__()

* Revert "Remove explicit call to BasePlotter.__init__()"

This reverts commit 29444d9.

* Add QVTKRenderWindowInteractorAdapter

* Fix depth peeling and tests

* Fix testing

* Fix style

* Fix default depth peeling setting

* Use methods inherited from BasePlotter

* Adapt close event

* Use BasePlotter version of add_actor

* Cover more features of BackgroundPlotter

* Use parent version of render

* Enable AlphaBitPlanes

* Use BasePlotter version of render

* TST: Build doc

* Revert "TST: Build doc"

This reverts commit bc38205.

* TST: Build doc

* Add support for drag&drop

* Fix reset_camera

* Revert "TST: Build doc"

This reverts commit dd74ec1.

* Remove bgplot.py

* Trigger CIs
  • Loading branch information
GuillaumeFavelier authored Feb 3, 2020
1 parent 38a8543 commit afb9696
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 141 deletions.
3 changes: 1 addition & 2 deletions pyvista/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from .colors import (color_char_to_word, get_cmap_safe, hex_to_rgb, hexcolors,
string_to_rgb, PARAVIEW_BACKGROUND)
from .export_vtkjs import export_plotter_vtkjs, get_vtkjs_url

from .theme import (DEFAULT_THEME, FONT_KEYS, MAX_N_COLOR_BARS,
parse_color, parse_font_family, rcParams, set_plot_theme)
from .tools import (create_axes_marker, create_axes_orientation_box,
Expand All @@ -12,6 +11,6 @@

from .renderer import CameraPosition, Renderer, scale_point
from .plotting import BasePlotter, Plotter, close_all
from .qt_plotting import BackgroundPlotter, QtInteractor
from .qt_plotting import BackgroundPlotter, QtInteractor, MainWindow, Counter
from .helpers import plot, plot_arrows, plot_compare_four
from .itkplotter import PlotterITK
44 changes: 16 additions & 28 deletions pyvista/plotting/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@ def disable_anti_aliasing(self, *args, **kwargs):
def set_focus(self, *args, **kwargs):
"""Wrap ``Renderer.set_focus``."""
self.renderer.set_focus(*args, **kwargs)
self._render()
self.render()

@wraps(Renderer.set_position)
def set_position(self, *args, **kwargs):
"""Wrap ``Renderer.set_position``."""
self.renderer.set_position(*args, **kwargs)
self._render()
self.render()

@wraps(Renderer.set_viewup)
def set_viewup(self, *args, **kwargs):
"""Wrap ``Renderer.set_viewup``."""
self.renderer.set_viewup(*args, **kwargs)
self._render()
self.render()

@wraps(Renderer.add_axes)
def add_axes(self, *args, **kwargs):
Expand Down Expand Up @@ -392,7 +392,7 @@ def disable_eye_dome_lighting(self, *args, **kwargs):
def reset_camera(self, *args, **kwargs):
"""Wrap ``Renderer.reset_camera``."""
self.renderer.reset_camera(*args, **kwargs)
self._render()
self.render()

@wraps(Renderer.isometric_view)
def isometric_view(self, *args, **kwargs):
Expand Down Expand Up @@ -603,6 +603,10 @@ def image(self):

#### Everything else ####

def render(self):
"""Render the main window."""
if hasattr(self, 'ren_win'):
self.ren_win.Render()

def add_key_event(self, key, callback):
"""Add a function to callback when the given key is pressed.
Expand Down Expand Up @@ -880,15 +884,6 @@ def enable_rubber_band_style(self):
return self.update_style()


def _render(self):
"""Redraw the render window if it exists."""
if hasattr(self, 'ren_win'):
if hasattr(self, 'render_trigger'):
self.render_trigger.emit()
elif not self._first_time:
self.render()


def hide_axes_all(self):
"""Hide the axes orientation widget in all renderers."""
for renderer in self.renderers:
Expand Down Expand Up @@ -940,7 +935,7 @@ def update(self, stime=1, force_redraw=True):
self.iren.Start()
self.iren.DestroyTimer(self.right_timer_id)

self._render()
self.render()
Plotter.last_update_time = curr_time
else:
if force_redraw:
Expand Down Expand Up @@ -2521,7 +2516,7 @@ def update_coordinates(self, points, mesh=None, render=True):
mesh.points = points

if render:
self._render()
self.render()


def _clear_ren_win(self):
Expand Down Expand Up @@ -3218,11 +3213,7 @@ def screenshot(self, filename=None, transparent_background=None,
# Plotter hasn't been rendered or was improperly closed
raise AttributeError('This plotter is closed and unable to save a screenshot.')

if isinstance(self, Plotter):
# TODO: we need a consistent rendering function
self.render()
else:
self._render()
self.render()

# debug: this needs to be called twice for some reason,
img = self.image
Expand Down Expand Up @@ -3376,7 +3367,7 @@ def remove_legend(self):
"""Remove the legend actor."""
if hasattr(self, 'legend'):
self.remove_actor(self.legend, reset_camera=False)
self._render()
self.render()


def generate_orbital_path(self, factor=3., n_points=20, viewup=None, shift=0.0):
Expand Down Expand Up @@ -3465,7 +3456,7 @@ def orbit():
self.set_focus(focus)
self.set_viewup(viewup)
self.renderer.ResetCameraClippingRange()
self._render()
self.render()
if bkg:
time.sleep(step)
if write_frames:
Expand Down Expand Up @@ -3656,8 +3647,9 @@ def on_timer(iren, event_id):
self.iren.AddObserver(vtk.vtkCommand.TimerEvent, on_timer)

if rcParams["depth_peeling"]["enabled"]:
for renderer in self.renderers:
self.enable_depth_peeling()
if self.enable_depth_peeling():
for renderer in self.renderers:
renderer.enable_depth_peeling()

def show(self, title=None, window_size=None, interactive=True,
auto_close=None, interactive_update=False, full_screen=False,
Expand Down Expand Up @@ -3835,7 +3827,3 @@ def plot(self, *args, **kwargs):
"""
logging.warning("`.plot()` is deprecated. Please use `.show()` instead.")
return self.show(*args, **kwargs)

def render(self):
"""Render the main window."""
self.ren_win.Render()
Loading

0 comments on commit afb9696

Please sign in to comment.