Skip to content

Latest commit

 

History

History
183 lines (108 loc) · 4.18 KB

ipy_tools.rst

File metadata and controls

183 lines (108 loc) · 4.18 KB

IPython Tools

The IPython tools harness vtki's Qt rendering interface that enables accessible background plotting so that a rendering environment can be updated in real-time from a Jupyter notebook or other IPython environment.

These tools are useable from the top level of vtki on any vtki wrapped dataset. Simply call one of these tools on your object.

Attributes

.. autoautosummary:: vtki.ipy_tools.InteractiveTool
   :attributes:

Methods

.. autoautosummary:: vtki.ipy_tools.InteractiveTool
   :methods:


Orthogonal Slicer

The :class:`vtki.OrthogonalSlicer` tool on an example dataset to create three slices on the cartesian planes and move those slices through the dataset using slider bars directly in a Jupyter notebook:

import vtki
from vtki import examples

dataset = examples.load_hexbeam()

# Use the slicer tool
vtki.OrthogonalSlicer(dataset)
../images/gifs/slicer-tool.gif
.. autoclass:: vtki.OrthogonalSlicer
   :show-inheritance:



Threshold

The :class:`vtki.Threshold` tool is used to interactively threshold a dataset using slider bars for the minimum and maximum range. This tool also has options to invert the threshold using checkboxes all directly in the output of a Jupyter notebook cell:

import vtki
from vtki import examples

dataset = examples.load_uniform()

# Use the slicer tool
vtki.Threshold(dataset)
../images/gifs/threshold-tool.gif
.. autoclass:: vtki.Threshold
   :show-inheritance:



Many Slices Along Axis

The :class:`vtki.ManySlicesAlongAxis` tool is used to create many (n) evenly spaced slices of a dataset along a specified axis. The user selects the number of slices via a slider bar and the axis to slice against via a drop down menu in the Jupyter notebook cell output:

import vtki
from vtki import examples

dataset = examples.load_uniform()

# Use the many slices tool
vtki.ManySlicesAlongAxis(dataset)
../images/gifs/many-slices-tool.gif
.. autoclass:: vtki.ManySlicesAlongAxis
   :show-inheritance:



Isocontour

The :class:`vtki.Isocontour` tool creates a single value isocontour of a dataset along a point scalar array

import vtki
from vtki import examples

dataset = examples.load_uniform()

# Use the contour tool
vtki.Isocontour(dataset)
../images/gifs/isocontour-tool.gif
.. autoclass:: vtki.ManySlicesAlongAxis
   :show-inheritance:


Using the Tools in an Integrated Scene

Each of the tools in this module can be used to either create a scene that can have other datasets added or the tools can be used on an already existing rendering scene. We commonly use the tools to apply a filter on a dataset while viewing it adjacent to other dataset.

The easiest approach is to use a tool to activate a new rendering window like performed in the above examples. This time be sure to assign the tool object so that you can access it's plotting window:

import vtki
from vtki import examples

dataset = examples.load_uniform()

# assign the tool to a variable
thresher = vtki.Threshold(dataset)

Now a rendering environment will appear and the cell will output to IPython tools. Since the tool is captured in the variable thresher for this example, you can access the plotting window and add features or datasets:

# Grab the plotter
p = thresher.plotter

# Label the axes bounds
p.show_grid()

# Add some other datasets
p.add_mesh(dataset.clip())

You can also add as many tools to one rendering environment as you'd like by passing the plotter to the tool upon construction:

# Add a second tool by passing the plotter
slicer = vtki.OrthogonalSlicer(dataset, plotter=p)

And now you have two tools being used in one rendering window!

../images/gifs/integrated-tools.gif