magicclass.ext.vtk package

Submodules

magicclass.ext.vtk.components module

class magicclass.ext.vtk.components.Arrow(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Arrows(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Box(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.CSpline(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Circle(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Cone(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Cube(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Cylinder(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Disc(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Earth(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Ellipsoid(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.KSpline(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Mesh(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Points

property backface_color: magicclass.ext.vtk.components._V
property backface_culling: magicclass.ext.vtk.components._V
property frontface_culling: magicclass.ext.vtk.components._V
property lines_as_tubes: magicclass.ext.vtk.components._V
property linewidth: magicclass.ext.vtk.components._V
property representation: magicclass.ext.vtk.const.Representation

Representation mode of mesh.

One of "points", "wireframe", "surface".

class magicclass.ext.vtk.components.Path(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Points(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.VtkComponent

property color: magicclass.ext.vtk.components._V
property occlusion: magicclass.ext.vtk.components._V
property point_size: magicclass.ext.vtk.components._V
property pos: magicclass.ext.vtk.components._V
property scale: magicclass.ext.vtk.components._V
property spherical: magicclass.ext.vtk.components._V
class magicclass.ext.vtk.components.Ribbon(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Sphere(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Spheres(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Spline(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Spring(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Text(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.Tube(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: magicclass.ext.vtk.components.Mesh

class magicclass.ext.vtk.components.VtkComponent(*args, _parent: Optional[vedo.plotter.Plotter] = None, **kwargs)[source]

Bases: object

property visible: magicclass.ext.vtk.components._V
class magicclass.ext.vtk.components.VtkProperty(vedo_fname: str | None = None, vtk_fname: str | None = None, converter: type | None = None, doc: str | None = None, **kwargs)[source]

Bases: property, Generic[magicclass.ext.vtk.components._L, magicclass.ext.vtk.components._V]

magicclass.ext.vtk.components.get_object_type(name: str) type[magicclass.ext.vtk.components.VtkComponent][source]

magicclass.ext.vtk.const module

class magicclass.ext.vtk.const.AxesMode(value)[source]

Bases: enum.Enum

An enumeration.

box = 9
cartesian = 2
cartesian_pos = 3
circle = 10
corner = 6
cube = 5
grid = 11
none = 0
polar = 12
ruler = 7
ruler1d = 13
ruler_axes = 8
triad = 4
wall = 1
class magicclass.ext.vtk.const.Mode(value)[source]

Bases: enum.Enum

An enumeration.

iso = 'iso'
lego = 'lego'
mesh = 'mesh'
volume = 'volume'
wireframe = 'wireframe'
class magicclass.ext.vtk.const.Rendering(value)[source]

Bases: enum.Enum

Volume rendering mode suppored in vtk.

additive = 4
average = 3
composite = 0
minip = 2
mip = 1
class magicclass.ext.vtk.const.Representation(value)[source]

Bases: enum.Enum

An enumeration.

points = 0
surface = 2
wireframe = 1

magicclass.ext.vtk.volume module

class magicclass.ext.vtk.volume.Volume(data, _parent)[source]

Bases: magicclass.ext.vtk.components.VtkComponent

property color: numpy.ndarray

Color of the volume.

property contrast_limits: tuple[float, float]

Contrast limits of volume.

property data: numpy.ndarray
events = <SignalGroup 'VolumeSignalGroup' with 4 signals>
property iso_threshold: float

Threshold value to generate isosurface.

This property only has effect on "iso" and "wireframe" rendering.

property jittering: magicclass.ext.vtk.components._V
property mode: str

Projection mode of volume.

property rendering

Rendering mode of the volume.

property shade: magicclass.ext.vtk.components._V
class magicclass.ext.vtk.volume.VolumeSignalGroup(instance: Any = None, name: Optional[str] = None)[source]

Bases: psygnal._group.SignalGroup

Signal group for a volume.

color

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

iso_threshold

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

mode

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

rendering

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

class magicclass.ext.vtk.volume.WidgetGroup(vol: magicclass.ext.vtk.volume.Volume)[source]

Bases: object

property color: magicclass.widgets.ColorEdit
property iso_threshold: magicgui.widgets.FloatSlider
property mode: magicgui.widgets.ComboBox
property rendering: magicgui.widgets.ComboBox
property volume: magicclass.ext.vtk.volume.Volume
magicclass.ext.vtk.volume.split_rgba(col: str | Sequence[float]) tuple[str | Sequence[float], float][source]

magicclass.ext.vtk.widgets module

class magicclass.ext.vtk.widgets.LayerList(data=(), parent: Optional[magicclass.ext.vtk.widgets.VtkCanvas] = None)[source]

Bases: MutableSequence[importlib._bootstrap._T]

events: ListEvents
property parent: magicclass.ext.vtk.widgets.VtkCanvas
class magicclass.ext.vtk.widgets.QtVtkCanvas(parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

class magicclass.ext.vtk.widgets.VtkCanvas[source]

Bases: magicclass.widgets.utils.FreeWidget

add_object(*args, object_type: Optional[str] = None, **kwargs)[source]
add_surface(data: tuple[np.ndarray, np.ndarray] | tuple[np.ndarray])[source]
add_volume(volume: numpy.ndarray, color: Union[Iterable[float], str] = (0.7, 0.7, 0.7), mode: str = 'iso')[source]

Add a 3D volume to the canvas.

Parameters
  • volume (np.ndarray) -- Volume data. Must be 3D array.

  • color (Color, optional) -- Initial color of the volume.

  • mode (str, default is "iso") -- Initial visualization mode of the volume.

Returns

A volume layer.

Return type

Volume

property axes: str

The axes object.

property layers
screenshot() numpy.ndarray[source]

Get screenshot as a numpy array.

Module contents

VTK (Visualization Toolkit) support in a magicgui/magic-class way. This extension submodule depends on vedo.

pip install vedo
class magicclass.ext.vtk.VtkCanvas[source]

Bases: magicclass.widgets.utils.FreeWidget

add_object(*args, object_type: Optional[str] = None, **kwargs)[source]
add_surface(data: tuple[np.ndarray, np.ndarray] | tuple[np.ndarray])[source]
add_volume(volume: numpy.ndarray, color: Union[Iterable[float], str] = (0.7, 0.7, 0.7), mode: str = 'iso')[source]

Add a 3D volume to the canvas.

Parameters
  • volume (np.ndarray) -- Volume data. Must be 3D array.

  • color (Color, optional) -- Initial color of the volume.

  • mode (str, default is "iso") -- Initial visualization mode of the volume.

Returns

A volume layer.

Return type

Volume

property axes: str

The axes object.

property layers
screenshot() numpy.ndarray[source]

Get screenshot as a numpy array.