pyvista.Plotter.add_box_widget

pyvista.Plotter.add_box_widget#

Plotter.add_box_widget(
callback,
bounds=None,
factor=1.25,
rotation_enabled: bool = True,
color=None,
use_planes: bool = False,
outline_translation: bool = True,
pass_widget: bool = False,
interaction_event: pyvista.InteractionEventType = 'end',
)[ソース]#

ボックスウィジェットをシーンに追加します.

これは,コールバック関数なしでは使用できません.単一の引数を取る呼び出し可能関数,このウィジェットからのPolyDataボックス出力を渡して,そのボックスでタスクを実行することができます.

パラメータ:
callbackcallable()

ボックスが更新されるたびに呼び出されるメソッドです.これには2つのオプションがあります:1つの引数, PolyData ボックス (デフォルト) を取るか, use_planes=True の場合, vtkPlanes オブジェクトとしてプレーンコレクションの1つの引数を取ります.

boundstuple(float)

ウィジェットが配置されるバウンディングボックスの長さ6のタプル.

factorfloat, optional

配置時に境界を拡張するための膨張係数.

rotation_enabledbool, optional

False の場合,ボックスウィジェットは回転できず,直交軸に厳密に直交します.

colorColorLike, optional

文字列,RGB配列,または16進数の色文字列のいずれかです.デフォルトは pyvista.plotting.global_theme.font.color です.

use_planesbool, optional

コールバックに渡される引数をボックスを構成する平面に変更します.

outline_translationbool, optional

False の場合,ボックスウィジェットは変換できず,与えられた境界に厳密に配置されます.

pass_widgetbool, optional

True の場合,ウィジェットはコールバックの最後の引数として渡されます.

interaction_eventInteractionEventType, optional

コールバックのトリガーに使用するVTKインタラクションイベントです.文字列 'start', 'end', `` always'`` または vtk.vtkCommand.EventIds を受け付けます.

バージョン 0.38.0 で変更: 文字列または vtk.vtkCommand.EventIds のいずれかを受け付けるようになりました.

戻り値:
vtk.vtkBoxWidget

ボックスウィジェット

球体のサイズ変更と再配置に使用されるインタラクティブなボックスを表示します.

>>> import pyvista as pv
>>> import numpy as np
>>> plotter = pv.Plotter()
>>> def simulate(widget):
...     bounds = widget.bounds
...     new_center = np.array(
...         [
...             (bounds[0] + bounds[1]) / 2,
...             (bounds[2] + bounds[3]) / 2,
...             (bounds[4] + bounds[5]) / 2,
...         ]
...     )
...     new_radius = (
...         min(
...             (bounds[1] - bounds[0]) / 2,
...             (bounds[3] - bounds[2]) / 2,
...             (bounds[5] - bounds[4]) / 2,
...         )
...         - 0.3
...     )
...     sphere = pv.Sphere(new_radius, new_center)
...     _ = plotter.add_mesh(sphere, name='Sphere')
>>> _ = plotter.add_box_widget(callback=simulate)
>>> plotter.show()
../../../_images/pyvista-Plotter-add_box_widget-1_00_00.png