# Box Widget
# ==========

# The box widget can be enabled and disabled by the
# `pyvista.Plotter.add_box_widget()` and
# `pyvista.Plotter.clear_box_widgets()` methods respectively.
# When enabling the box widget, you must provide a custom callback function
# otherwise the box would appear and do nothing - the callback functions are
# what allow us to leverage the widget to perform a task like clipping/cropping.
# Considering that using a box to clip/crop a mesh is one of the most common use
# cases, we have included a helper method that will allow you to add a mesh to a
# scene with a box widget that controls its extent, the
# `pyvista.Plotter.add_mesh_clip_box()` method.
import pyvista as pv
from pyvista import examples

mesh = examples.download_washington_bust()

pl = pv.Plotter()
pl.add_mesh_clip_box(mesh, color='white')
pl.show()

# After interacting with the scene, the clipped mesh is available as:
pl.widgets.box_clipped_meshes

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

