Example #1
0
def test_invalidkeywords():

    with pytest.raises(TypeError):
        display.set(nonsense=5.0)

    with pytest.raises(ValueError):
        display.get("nonsense")
Example #2
0
def test_invalidkeywords():

    with pytest.raises(TypeError):
        display.set(nonsense=5.0)

    with pytest.raises(ValueError):
        display.get("nonsense")
Example #3
0
def test_dof():
    """
    dof, dof_fnumber, dof_focaldist
    """
    display.set(dof=True, dof_fnumber=3.2, dof_focaldist=12.0)
    assert display.get("dof")
    assert display.get("dof_fnumber") == pytest.approx(3.2)
    assert display.get("dof_focaldist") == 12.0
Example #4
0
def test_dof():
    """
    dof, dof_fnumber, dof_focaldist
    """
    display.set(dof=True, dof_fnumber=3.2, dof_focaldist=12.0)
    assert display.get("dof")
    assert display.get("dof_fnumber") == pytest.approx(3.2)
    assert display.get("dof_focaldist") == 12.0
Example #5
0
def test_size():
    """
    size
    """
    currsize = display.get("size")
    assert len(currsize) == 2
    display.set(size=currsize[::1])
    assert display.get("size") == currsize[::1]

    display.set(size=(100,200))
    assert display.get("size") == [100, 200]
Example #6
0
def test_size():
    """
    size
    """
    currsize = display.get("size")
    assert len(currsize) == 2
    display.set(size=currsize[::1])
    assert display.get("size") == currsize[::1]

    display.set(size=(100, 200))
    assert display.get("size") == [100, 200]
Example #7
0
def test_snapshot(tmpdir, file_3nob):

    from vmd import molecule, molrep, display
    m =  molecule.load("mae", file_3nob)
    molrep.addrep(m, "NewCartoon")
    display.set(size=(512, 512))

    tmpdir = str(tmpdir)
    render.render("snapshot", os.path.join(tmpdir, "test.tga"))

    # If it's an empty header, the file size will be way too small here
    assert os.path.getsize(os.path.join(tmpdir, "test.tga")) == 786450
Example #8
0
def init_display(display_options, axes_options):
    """Function for initializing VMD scene options

    Parameters
    ----------
    display_options : dict
        scene/display options for VMD. These are specified as key-value
        pairs for each attribute in the VMD display options list. For
        this complete list, see the following:

            https://www.ks.uiuc.edu/Research/vmd/current/ug/node126.html

    """

    display.set(**display_options)
    if 'set_location' in axes_options.keys():
        axes.set_location(axes_options['set_location'])
    display.update()
Example #9
0
def test_rendergetset():
    """
    tests:
    antialias, ambientocclusion, aoambient, aodirect, shadows,
    """
    display.set(antialias=False, ambientocclusion=True)

    with pytest.raises(TypeError):
        display.set(antialias=5)

    assert not display.get("antialias")
    assert display.get("ambientocclusion")

    display.set(ambientocclusion=False, aoambient=1.0, aodirect=3.0)
    assert not display.get("ambientocclusion")
    assert display.get("aoambient") == 1.0
    assert display.get("aodirect") == 3.0

    display.set(shadows=True)
    assert display.get("shadows")
Example #10
0
def test_rendergetset():
    """
    tests:
    antialias, ambientocclusion, aoambient, aodirect, shadows,
    """
    display.set(antialias=False, ambientocclusion=True)

    with pytest.raises(TypeError):
        display.set(antialias=5)

    assert not display.get("antialias")
    assert display.get("ambientocclusion")

    display.set(ambientocclusion=False, aoambient=1.0, aodirect=3.0)
    assert not display.get("ambientocclusion")
    assert display.get("aoambient") == 1.0
    assert display.get("aodirect") == 3.0

    display.set(shadows=True)
    assert display.get("shadows")
Example #11
0
def test_3dgetset():
    """
    tests: eyesep, focallength, height, distance, nearclip, farclip,
    depthcueue, culling, stereo, projection
    """

    modes = display.stereomodes()
    assert len(modes) == 11

    display.set(eyesep=2.0, focallength=10.0, height=200,
                distance=20, stereo=modes[0])

    assert display.get("eyesep") == 2.0
    assert display.get("focallength") == 10.0
    assert display.get("height") == 200
    assert display.get("distance") == 20
    assert display.get("stereo") == modes[0]

    # Default values from DisplayDevice.C
    assert display.get("nearclip") == 0.5
    assert display.get("farclip") == 10.0
    display.set(nearclip=10.0, farclip=30.0)
    assert display.get("nearclip") == 10.0
    assert display.get("farclip") == 30.0

    with pytest.raises(ValueError):
        display.set(nearclip=10.0, farclip=5.0)

    display.set(culling=False)
    assert not display.get("culling")
    with pytest.raises(TypeError):
        display.set(culling=5.0)

    assert "QuadBuffered" in modes
    display.set(stereo="QuadBuffered")
    assert display.get("stereo") == "QuadBuffered"

    display.set(projection=display.PROJ_PERSP)
    assert display.get("projection") == display.PROJ_PERSP

    with pytest.raises(ValueError):
        display.set(projection="invalid")

    display.set(depthcue=True)
    assert display.get("depthcue")
    with pytest.raises(TypeError):
        display.set(depthcueue="hello")
Example #12
0
def test_3dgetset():
    """
    tests: eyesep, focallength, height, distance, nearclip, farclip,
    depthcueue, culling, stereo, projection
    """

    modes = display.stereomodes()
    assert len(modes) == 11

    display.set(eyesep=2.0,
                focallength=10.0,
                height=200,
                distance=20,
                stereo=modes[0])

    assert display.get("eyesep") == 2.0
    assert display.get("focallength") == 10.0
    assert display.get("height") == 200
    assert display.get("distance") == 20
    assert display.get("stereo") == modes[0]

    # Default values from DisplayDevice.C
    assert display.get("nearclip") == 0.5
    assert display.get("farclip") == 10.0
    display.set(nearclip=10.0, farclip=30.0)
    assert display.get("nearclip") == 10.0
    assert display.get("farclip") == 30.0

    with pytest.raises(ValueError):
        display.set(nearclip=10.0, farclip=5.0)

    display.set(culling=False)
    assert not display.get("culling")
    with pytest.raises(TypeError):
        display.set(culling=5.0)

    assert "QuadBuffered" in modes
    display.set(stereo="QuadBuffered")
    assert display.get("stereo") == "QuadBuffered"

    display.set(projection=display.PROJ_PERSP)
    assert display.get("projection") == display.PROJ_PERSP

    with pytest.raises(ValueError):
        display.set(projection="invalid")

    display.set(depthcue=True)
    assert display.get("depthcue")
    with pytest.raises(TypeError):
        display.set(depthcueue="hello")