예제 #1
0
    def test_load_elements(self):
        viewer = IntegrableViewer()

        mesh = viewer.mesh(x=[-1, 1, 0],
                           y=[0, 0, 1],
                           z=[-3, -3, -3],
                           color=[0.0, 0.0, 1.0],
                           indices=[[0, 1, 2]],
                           alpha=0.4,
                           name='mesh_name',
                           extension='dxf')

        assert viewer.last_id == 0

        blocks = viewer.blocks(x=[-3, 3, 0],
                               y=[0, 0, 5],
                               z=[0, 0, 0],
                               block_size=[1.0, 1.0, 1.0],
                               values=[0.5, 1.0, 1.5])

        assert viewer.last_id == 1

        points = viewer.points(vertices=[[-3, 2, 0], [0, 2, 1], [3, 2, 2]],
                               point_size=10.0,
                               values=[1.5, 1.0, 0.5])

        assert viewer.last_id == 2

        lines = viewer.lines(x=[-0.5, 0.5],
                             y=[-2.0, 1.5],
                             z=[-2.0, -2.0],
                             color=[0.2, 0.8, 0.8])

        assert viewer.last_id == 3

        tubes = viewer.tubes(x=[0.5, -0.5, 1.5, 1.5],
                             y=[-2.0, 1.8, 1.8, 0.0],
                             z=[-1.5, -1.5, -1.5, -1.5],
                             color=[0.9, 0.2, 0.2],
                             radius=0.2,
                             resolution=15)

        assert viewer.last_id == 4

        assert viewer.drawable_collection.size() == 5

        assert viewer.get_drawable(0) is mesh
        assert viewer.get_drawable(1) is blocks
        assert viewer.get_drawable(2) is points
        assert viewer.get_drawable(3) is lines
        assert viewer.get_drawable(4) is tubes
예제 #2
0
    def test_drawable_visibility(self):
        viewer = IntegrableViewer()
        viewer.mesh(x=[-1, 1, 0],
                    y=[0, 0, 1],
                    z=[0, 0, 0],
                    indices=[[0, 1, 2]])
        viewer.blocks(x=[-1, 1, 0], y=[0, 0, 1], z=[0, 0, 0], values=[0, 1, 2])

        assert viewer.get_drawable(0).is_visible
        assert viewer.get_drawable(1).is_visible

        viewer.hide_drawable(1)

        assert viewer.get_drawable(0).is_visible
        assert not viewer.get_drawable(1).is_visible

        viewer.hide_drawable(0)
        viewer.show_drawable(1)

        assert not viewer.get_drawable(0).is_visible
        assert viewer.get_drawable(1).is_visible

        viewer.show_drawable(0)
        viewer.show_drawable(1)

        assert viewer.get_drawable(0).is_visible
        assert viewer.get_drawable(1).is_visible