Line Widget

The line widget can be enabled and disabled by the pyvista.WidgetHelper.add_line_widget() and pyvista.WidgetHelper.clear_line_widgets() methods respectively. Unfortunately, PyVista does not have any helper methods to utilize this widget, so it is necessary to pass a custom callback method.

One particularly fun example is to use the line widget to create a source for the pyvista.DataSetFilters.streamlines() filter. Again note the use of the name argument in add_mesh.

import pyvista as pv
from pyvista import examples
import numpy as np


mesh = examples.download_kitchen()
furniture = examples.download_kitchen(split=True)

arr = np.linalg.norm(mesh['velocity'], axis=1)
clim = [arr.min(), arr.max()]
p = pv.Plotter()
p.add_mesh(furniture, name='furniture', color=True)
p.add_mesh(mesh.outline(), color='black')

def simulate(pointa, pointb):
    streamlines = mesh.streamlines(n_points=10, max_steps=100,
                                   pointa=pointa, pointb=pointb,
    p.add_mesh(streamlines, name='streamlines', line_width=5,
               render_lines_as_tubes=True, clim=clim)

p.add_line_widget(callback=simulate, use_vertices=True)
line widget


[(15.271875542188045, 14.271875516576674, 13.021875516576674),
 (3.50499999942258, 2.50499999942258, 1.25499999942258),
 (0.0, 0.0, 1.0)]

And here is a screen capture of a user interacting with this


Total running time of the script: ( 0 minutes 0.751 seconds)

Gallery generated by Sphinx-Gallery