Beispiel #1
0
def test_ball_and_stick_renderer():
    from collections import defaultdict
    from chemlab.io import datafile
    from chemlab.db.cirdb import CirDB
    
    v = QtViewer()
    v.add_post_processing(SSAOEffect, kernel_radius = 0.15)
    
    #v.widget.background_color = black
    #mol = Molecule([Atom("O", [-0.499, 0.249, 0.0]),
    #                Atom("H", [-0.402, 0.249, 0.0]),
    #                Atom("H", [-0.532, 0.198, 0.10])])
    
    #mol.bonds = np.array([[0, 1],[0, 2]])
    
    #mol = CirDB().get("molecule", "moronic acid")
    mol = datafile('tests/data/3ZJE.pdb').read('molecule')
    mol.bonds = find_bonds(mol)
    
    ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array, mol.bonds)

    
    # Try without bonds
    # ar2 = v.add_renderer(BallAndStickRenderer, mol.r_array + 0.5, mol.type_array, np.array([]))
    
    v.run()
Beispiel #2
0
def test_ball_and_stick_renderer():
    from collections import defaultdict
    from chemlab.io import datafile
    from chemlab.db.cirdb import CirDB

    v = QtViewer()
    v.add_post_processing(SSAOEffect, kernel_radius=0.15)

    #v.widget.background_color = black
    #mol = Molecule([Atom("O", [-0.499, 0.249, 0.0]),
    #                Atom("H", [-0.402, 0.249, 0.0]),
    #                Atom("H", [-0.532, 0.198, 0.10])])

    #mol.bonds = np.array([[0, 1],[0, 2]])

    #mol = CirDB().get("molecule", "moronic acid")
    mol = datafile('tests/data/3ZJE.pdb').read('molecule')
    mol.bonds = find_bonds(mol)

    ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array,
                        mol.bonds)

    # Try without bonds
    # ar2 = v.add_renderer(BallAndStickRenderer, mol.r_array + 0.5, mol.type_array, np.array([]))

    v.run()
Beispiel #3
0
def test_ball_and_stick_renderer():

    v = QtViewer()
    v.add_post_processing(SSAOEffect, kernel_radius=0.15)

    mol = datafile('tests/data/3ZJE.pdb').read('molecule')
    mol.bonds = find_bonds(mol)

    ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array,
                        mol.bonds)
    # ar2 = v.add_renderer(BallAndStickRenderer, mol.r_array + 0.5, mol.type_array, np.array([]))

    v.run()
Beispiel #4
0
def test_ball_and_stick_renderer():


    v = QtViewer()
    v.add_post_processing(SSAOEffect, kernel_radius = 0.15)
    
    mol = datafile('tests/data/3ZJE.pdb').read('molecule')
    mol.bonds = find_bonds(mol)

    ar = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array, mol.bonds)
    # ar2 = v.add_renderer(BallAndStickRenderer, mol.r_array + 0.5, mol.type_array, np.array([]))

    v.run()
Beispiel #5
0
def test_gamma():
    cdb = ChemlabDB()

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    v.widget.camera.orbit_y(3.14/3)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='phong')

    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #6
0
def test_gamma():
    cdb = ChemlabDB()

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    v.widget.camera.orbit_y(3.14/3)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='phong')

    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #7
0
def test_outline():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.outline import OutlineEffect

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer,
                        mol.r_array,
                        mol.type_array,
                        'impostors',
                        shading='toon')

    v.add_post_processing(OutlineEffect, 'depthnormal')
    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #8
0
def test_glow():
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')

    v = QtViewer()
    colors = np.array([(255, 0, 0, 255)] * mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array,
                        [0.1] * mol.n_atoms, colors)

    ge = v.add_post_processing(GlowEffect)

    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time() * 10.0) * 0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    v.run()
Beispiel #9
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)] * mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array,
                        [0.1] * mol.n_atoms, colors)

    ge = v.add_post_processing(GlowEffect)

    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time() * 10.0) * 0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #10
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    from PySide import QtCore

    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)

    ge = v.add_post_processing(GlowEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time()*10.0)*0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #11
0
def test_multiple_post_processing():
    v = QtViewer()
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('/home/gabriele/projects/LiCl/interface/loafintjc-heat/equilibrium.gro').read('system')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')

    # Adding multiple post processing effects


    v.add_post_processing(SSAOEffect)
    v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(FXAAEffect)

    v.run()
Beispiel #12
0
def test_glow():
    from PySide import QtCore
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    
    v = QtViewer()
    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)

    ge = v.add_post_processing(GlowEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    def changeglow():
        #ge.radius = np.sin(time.time()*10.0) + 2.5
        colors[0][3] = 255 * (np.sin(time.time()*10.0)*0.5 + 0.5)
        sr.update_colors(colors)
        v.widget.update()

    timer = QtCore.QTimer()
    timer.timeout.connect(changeglow)
    timer.start(10)
    v.run()
Beispiel #13
0
def test_multiple_post_processing():
    v = QtViewer()
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('/home/gabriele/projects/LiCl/interface/loafintjc-heat/equilibrium.gro').read('system')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')

    # Adding multiple post processing effects


    v.add_post_processing(SSAOEffect)
    v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(GammaCorrectionEffect, 2.0)
    #v.add_post_processing(FXAAEffect)

    v.run()
Beispiel #14
0
def test_offline():
    # Api for PNG saving
    v = QtViewer()
    mol = cdb.get('molecule', 'example.norbornene')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')
    v.add_post_processing(SSAOEffect, kernel_size=128)
    v.add_post_processing(FXAAEffect)
    ne = v.add_post_processing(NoEffect)
    
    v.widget.camera.autozoom(mol.r_array)
    
    def dump():
        image = v.widget.toimage(2048, 2048)
        image.save("/tmp/hello.png")
        os.system("eog /tmp/hello.png")        
        
    from PySide.QtCore import Qt
    v.key_actions[Qt.Key_A] = dump
    
    v.run()
Beispiel #15
0
def test_offline():
    # Api for PNG saving
    v = QtViewer()
    mol = cdb.get('molecule', 'example.norbornene')
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, 'impostors', shading='toon')
    v.add_post_processing(SSAOEffect, kernel_size=128)
    v.add_post_processing(FXAAEffect)
    ne = v.add_post_processing(NoEffect)
    
    v.widget.camera.autozoom(mol.r_array)
    
    def dump():
        image = v.widget.toimage(2048, 2048)
        image.save("/tmp/hello.png")
        os.system("eog /tmp/hello.png")        
        
    from PySide.QtCore import Qt
    v.key_actions[Qt.Key_A] = dump
    
    v.run()
Beispiel #16
0
def test_glow():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.glow import GlowEffect
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    #mol = datafile('tests/data/3ZJE.pdb').read('system')

    v = QtViewer()

    colors = np.array([(255, 0, 0, 255)]*mol.n_atoms)
    colors[0][3] = 0
    
    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(SphereImpostorRenderer, mol.r_array, [0.1]*mol.n_atoms,
                        colors)
    
    v.add_post_processing(GlowEffect)
    #v.add_post_processing(SSAOEffect, ssao_power = 5.0)
    #v.add_post_processing(FXAAEffect)
    #v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #17
0
def test_outline():

    mol = cdb.get('molecule', 'example.norbornene')

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='toon')

    v.add_post_processing(OutlineEffect, 'depthnormal')
    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #18
0
def test_outline():

    mol = cdb.get('molecule', 'example.norbornene')

    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='toon')

    #v.add_post_processing(OutlineEffect, 'depthnormal')
    v.add_post_processing(OutlineEffect, 'depthnormal', color=[0, 0, 1])
    v.add_post_processing(SSAOEffect, ssao_power=4.0)
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()
Beispiel #19
0
def test_outline():
    from chemlab.db import ChemlabDB, CirDB
    from chemlab.io import datafile
    from chemlab.graphics.postprocessing.outline import OutlineEffect
    
    cdb = ChemlabDB()
    mol = cdb.get('molecule', 'example.norbornene')
    
    mol = datafile('tests/data/3ZJE.pdb').read('system')
    #mol = datafile('tests/data/water.gro').read('system')
    #mol = datafile('tests/data/benzene.mol').read('molecule')
    v = QtViewer()

    v.widget.camera.autozoom(mol.r_array)
    sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
                        'impostors', shading='toon')
    
    v.add_post_processing(OutlineEffect, 'depthonly')
    v.add_post_processing(FXAAEffect)
    v.add_post_processing(GammaCorrectionEffect)
    v.run()