pyvista.plotting.widgets.WidgetHelper.add_box_widget#
- WidgetHelper.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ボックス出力を渡して,そのボックスでタスクを実行することができます.
- パラメータ:
- callback
callable() The method called every time the box is updated. This has two options: Take a single argument, the
PolyDatabox (default) or ifuse_planes=True, then it takes a single argument of the plane collection as a vtkPlanes object.- bounds
tuple(float) ウィジェットが配置されるバウンディングボックスの長さ6のタプル.
- factor
float,optional 配置時に境界を拡張するための膨張係数.
- rotation_enabledbool,
optional Falseの場合,ボックスウィジェットは回転できず,直交軸に厳密に直交します.- color
ColorLike,optional 文字列,RGB配列,または16進数の色文字列のいずれかです.デフォルトは
pyvista.plotting.global_theme.font.colorです.- use_planesbool,
optional コールバックに渡される引数をボックスを構成する平面に変更します.
- outline_translationbool,
optional Falseの場合,ボックスウィジェットは変換できず,与えられた境界に厳密に配置されます.- pass_widgetbool,
optional Trueの場合,ウィジェットはコールバックの最後の引数として渡されます.- interaction_event
InteractionEventType,optional The VTK interaction event to use for triggering the callback. Accepts either the strings
'start','end','always'or a vtkCommand.EventIds.バージョン 0.38.0 で変更: Now accepts either strings or vtkCommand.EventIds.
- callback
- 戻り値:
- 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(radius=new_radius, center=new_center) ... _ = plotter.add_mesh(sphere, name='Sphere') >>> _ = plotter.add_box_widget(callback=simulate) >>> plotter.show()