layout

GridLayout([cell_padding, cell_shape, …])

Provide functionalities for laying out actors in a 2D grid fashion.

Layout

Provide functionalities for laying out actors in a 3D scene.

get_bounding_box_sizes(actor)

Get the bounding box sizes of an actor.

get_grid_cells_position(shapes[, …])

Construct a XY-grid based on the cells content shape.

GridLayout

class fury.layout.GridLayout(cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None)[source]

Bases: fury.layout.Layout

Provide functionalities for laying out actors in a 2D grid fashion.

The GridLayout class lays the actors in a 2D structured grid aligned with the xy-plane.

__init__(self, cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None)[source]
Parameters
cell_padding2-tuple of float or float (optional)

Each grid cell will be padded according to (pad_x, pad_y) i.e. horizontally and vertically. Padding is evenly distributed on each side of the cell. If a single float is provided then both pad_x and pad_y will have the same value.

cell_shape{‘rect’, ‘square’, ‘diagonal’} (optional)

Specifies the desired shape of every grid cell. ‘rect’ ensures the cells are the tightest. ‘square’ ensures the cells are as wide as high. ‘diagonal’ ensures the content of the cells can be rotated without colliding with content of the neighboring cells.

aspect_ratiofloat (optional)

Aspect ratio of the grid (width/height). Default: 16:9.

dimtuple of int (optional)

Dimension (nb_rows, nb_cols) of the grid. If provided, aspect_ratio will be ignored.

compute_positions(self, actors)[source]

Compute the 3D coordinates of some actors.

The coordinates will lie on the xy-plane and form a 2D grid.

Parameters
actorslist of vtkProp3D objects

Actors to be layout in a grid manner.

Returns
list of 3-tuple

The computed 3D coordinates of every actors.

get_cells_shape(self, actors)[source]

Get the 2D shape (on the xy-plane) of some actors according to self.cell_shape.

Parameters
actorslist of vtkProp3D objects

Actors from which to calculate the 2D shape.

Returns
list of 2-tuple

The 2D shape (on the xy-plane) of every actors.

Layout

class fury.layout.Layout[source]

Bases: object

Provide functionalities for laying out actors in a 3D scene.

__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

apply(self, actors)[source]

Position the actors according to a certain layout.

compute_positions(self, _actors)[source]

Compute the 3D coordinates of some actors.

get_bounding_box_sizes

fury.layout.get_bounding_box_sizes(actor)[source]

Get the bounding box sizes of an actor.

get_grid_cells_position

fury.layout.get_grid_cells_position(shapes, aspect_ratio=1.7777777777777777, dim=None)[source]

Construct a XY-grid based on the cells content shape.

This function generates the coordinates of every grid cell. The width and height of every cell correspond to the largest width and the largest height respectively. The grid dimensions will automatically be adjusted to respect the given aspect ratio unless they are explicitly specified.

The grid follows a row-major order with the top left corner being at coordinates (0,0,0) and the bottom right corner being at coordinates (nb_cols*cell_width, -nb_rows*cell_height, 0). Note that the X increases while the Y decreases.

Parameters
shapeslist of tuple of int

The shape (width, height) of every cell content.

aspect_ratiofloat (optional)

Aspect ratio of the grid (width/height). Default: 16:9.

dimtuple of int (optional)

Dimension (nb_rows, nb_cols) of the grid, if provided.

Returns
ndarray

3D coordinates of every grid cell.