Пример #1
0
def test_get_grid_cell_position():

    shapes = 10 * [(50, 50), (50, 50), (50, 50), (80, 50)]

    npt.assert_raises(ValueError, get_grid_cells_position, shapes=shapes,
                      dim=(1, 1))

    CS = get_grid_cells_position(shapes=shapes)
    npt.assert_equal(CS.shape, (42, 3))
    npt.assert_almost_equal(CS[-1], [480., -250., 0])
Пример #2
0
    def compute_positions(self, actors):
        """Compute the 3D coordinates of some actors.
        The coordinates will lie on the xy-plane and form a 2D grid.
        Parameters
        ----------
        actors : list of `vtkProp3D` objects
            Actors to be layout in a grid manner.
        Returns
        -------
        list of 3-tuple
            The computed 3D coordinates of every actors.
        """
        shapes = self.get_cells_shape(actors)

        # Add padding, if any, around every cell.
        shapes = [np.array(self.cell_padding) / 2. + s for s in shapes]
        positions = get_grid_cells_position(shapes, self.aspect_ratio,
                                            self.dim)

        positions += self.position_offset
        return positions