Example #1
0
def test_quiver():
    t = np.linspace(0, 2 * np.pi)
    points = np.array([np.cos(t), np.sin(t), np.cos(t) * np.sin(t)]).T
    grads = np.roll(points, 10)

    arrows = vpl.quiver(points, grads, color=grads)
    assert arrows.shape == t.shape
Example #2
0
    def test_quiver(self):
        t = np.linspace(0, 2 * np.pi)
        points = np.array([np.cos(t), np.sin(t), np.cos(t) * np.sin(t)]).T
        grads = np.roll(points, 10)

        arrows = vpl.quiver(points, grads, color=grads)
        self.assertEqual(arrows.shape, t.shape)

        vpl.show()
Example #3
0
def test_qfigure():
    vpl.QtFigure._abc_assert_no_abstract_methods()

    self = vpl.QtFigure("a Qt widget figure")

    assert self is vpl.gcf()

    direction = np.array([1, 0, 0])
    vpl.quiver(np.array([0, 0, 0]), direction)
    vpl.view(camera_direction=direction)
    vpl.reset_camera()

    self.show(block=False)
    self.close()

    self.showMaximized(block=not VTKPLOTLIB_WINDOWLESS_TEST)
    out = vpl.screenshot_fig(fig=self)
    vpl.close(fig=self)

    globals().update(locals())
    return out
Example #4
0
    def test_view(self):
        vpl.auto_figure(True)
        vpl.close()
        grads = np.array(vpl.geometry.orthogonal_bases(np.random.rand(3)))
        point = np.random.uniform(-10, 10, 3)
        vpl.quiver(np.broadcast_to(point, (3, 3)), grads, color=np.eye(3))

        vpl.view(focal_point=point,
                 camera_position=point - grads[0],
                 up_view=grads[1])
        #        vpl.view(camera_direction=grads[0],
        #                 up_view=grads[1],
        #                 )
        #
        vpl.reset_camera()
        #        vpl.view(point)

        vpl.text(
            "Should be looking in the direction of the red arrow, with the green arrow pointing up"
        )
        vpl.show()
Example #5
0
    @property
    def window_name(self):
        if hasattr(self, "_renWin"):
            return self.renWin.GetWindowName()
        return self._window_name

    @window_name.setter
    def window_name(self, window_name):
        if hasattr(self, "_renWin"):
            self.renWin.SetWindowName(window_name)
        self._window_name = window_name


if __name__ == "__main__":
    Figure._abc_assert_no_abstract_methods()
    import vtkplotlib as vpl

    self = vpl.figure("a normal vtk figure")

    # vpl.plot(np.random.uniform(-10, 10, (20, 3)))

    direction = np.array([1, 0, 0])
    vpl.quiver(np.array([0, 0, 0]), direction)
    vpl.view(camera_direction=direction)
    vpl.reset_camera()

    # vpl.save_fig(Path.home() / "img.jpg", 1080)

    self.show()