本文整理汇总了Python中chemlab.graphics.qtviewer.QtViewer.run方法的典型用法代码示例。如果您正苦于以下问题:Python QtViewer.run方法的具体用法?Python QtViewer.run怎么用?Python QtViewer.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chemlab.graphics.qtviewer.QtViewer
的用法示例。
在下文中一共展示了QtViewer.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pickers
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_pickers():
from chemlab.graphics.pickers import SpherePicker, CylinderPicker
from chemlab.core.molecule import guess_bonds
#mol = datafile('tests/data/benzene.mol').read('molecule')
mol = ChemlabDB().get('molecule', 'example.water')
centers = mol.r_array
radii = np.array([0.05]*mol.n_atoms)
colors = np.array([[0, 255, 255, 255]]*mol.n_atoms)
bounds = mol.r_array.take(mol.bonds, axis=0)
b_radii = np.array([0.05]*mol.n_bonds)
b_colors = np.array([[0, 255, 255, 255]]*mol.n_bonds)
v = QtViewer()
#v.widget.camera.autozoom(mol.r_array)
sr = v.add_renderer(SphereImpostorRenderer, centers, radii*1.2, colors, transparent=False)
cr = v.add_renderer(CylinderImpostorRenderer, bounds, b_radii, b_colors)
sp = SpherePicker(v.widget, centers, radii*1.2)
cp = CylinderPicker(v.widget, bounds, b_radii)
def on_click(evt):
x, y = v.widget.screen_to_normalized(evt.x(), evt.y())
a_i, a_d = sp.pick(x, y)
b_i, b_d = cp.pick(x, y)
print('A', a_d)
print('B', b_d)
v.widget.clicked.connect(on_click)
v.run()
示例2: test_glow
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
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()
示例3: test_cylinder_impostor_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_cylinder_impostor_renderer():
from chemlab.graphics.renderers import CylinderImpostorRenderer
bounds = np.array([[[-1.0, 0.0, 0.0], [-1.0, 1.0, 0.0]],
[[1.0, 0.0, 0.0], [1.0, 3.0, 0.0]],
[[1.0, 0.0, 0.0], [1.0, 0.0, 1.0]]])
radii = np.array([0.5, 0.3, 0.3])
colors = np.array([blue, orange, green])
bounds = np.array([[[0.0, 0.0, 0.0], [0.0, 1.0, 0.0]]])
radii = np.array([0.2])
colors = np.array([blue])
# Test for speed
# random bounds
#n = 50000
#bounds = np.random.rand(n, 2, 3) * 10
#radii = np.random.rand(n)/10.0
#colors = np.array([blue] * n)
import time
v = QtViewer()
t0 = time.time()
ar = v.add_renderer(CylinderImpostorRenderer, bounds, radii, colors)
#ar = v.add_renderer(CylinderRenderer, bounds, radii* 2.0, colors)
sr = v.add_renderer(SphereImpostorRenderer, bounds[:, 0], radii, colors)
sr = v.add_renderer(SphereImpostorRenderer, bounds[:, 1], radii, colors)
print time.time() - t0
#ar = v.add_renderer(CylinderRenderer, bounds, radii, colors)
#ar.update_bounds(bounds)
v.run()
示例4: test_glow
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
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()
示例5: test_pickers
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_pickers():
from chemlab.graphics.pickers import SpherePicker
from chemlab.io import datafile
mol = datafile('/home/gabriele/projects/LiCl/interface/loafintjc-heat/equilibrium.gro').read('system')
centers = [[0.0, 0.0, 0.0], [1.0, 0.0, 1.0]]
radii = np.array([1.0, 0.5])
colors = [[0, 255, 255, 100], [255, 255, 0, 100]]
centers = mol.r_array
radii = np.array([0.2]*mol.n_atoms)
colors = np.array([[0, 255, 255, 255]]*mol.n_atoms)
v = QtViewer()
sr = v.add_renderer(SphereImpostorRenderer, centers, radii, colors, transparent=False)
#sr = v.add_renderer(SphereImpostorRenderer, centers,
# radii*1.5, [[255, 255, 255, 50]]*mol.n_atoms, transparent=True)
sp = SpherePicker(v.widget, centers, radii)
def on_click(evt):
x, y = v.widget.screen_to_normalized(evt.x(), evt.y())
print sp.pick(x, y)
v.widget.clicked.connect(on_click)
v.run()
示例6: test_ball_and_stick_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
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()
示例7: test_toon_shading
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_toon_shading():
from chemlab.db import ChemlabDB, CirDB
from chemlab.io import datafile
from chemlab.graphics import colors
from chemlab.core.molecule import guess_bonds
cdb = ChemlabDB()
#mol = cdb.get('molecule', 'example.norbornene')
mol = datafile('tests/data/3ZJE.pdb').read('system')
v = QtViewer()
#v.widget.post_processing = FXAAEffect(v.widget)
#v.widget.post_processing = SSAOEffect(v.widget, kernel_size=64, kernel_radius=1.0, ssao_power=2.0)
v.widget.camera.autozoom(mol.r_array)
#sr = v.add_renderer(AtomRenderer, mol.r_array,
# mol.type_array, 'impostors',
# shading='toon')
#sr = v.add_renderer(AtomRenderer, mol.r_array,
# mol.type_array, 'polygons',
# shading='toon')
ar = v.add_renderer(BallAndStickRenderer,
mol.r_array, mol.type_array,
guess_bonds(mol.r_array, mol.type_array),
shading='toon')
v.run()
示例8: test_cylinder_impostor_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_cylinder_impostor_renderer():
bounds = np.array([[[-1.0, 0.0, 0.0], [-1.0, 1.0, 0.0]],
[[1.0, 0.0, 0.0], [1.0, 3.0, 0.0]],
[[1.0, 0.0, 0.0], [1.0, 0.0, 1.0]]])
radii = np.array([0.5, 0.3, 0.3])
colors = np.array([colors.blue, colors.orange, colors.green])
bounds = np.array([[[0.0, 0.0, 0.0], [0.0, 1.0, 0.0]]])
radii = np.array([0.2])
colors = np.array([colors.blue])
# Test for speed
# random bounds
#n = 50000
#bounds = np.random.rand(n, 2, 3) * 10
#radii = np.random.rand(n)/10.0
#colors = np.array([colors.blue] * n)
v = QtViewer()
ar = v.add_renderer(CylinderImpostorRenderer, bounds, radii, colors)
sr = v.add_renderer(SphereImpostorRenderer, bounds[:, 0], radii, colors)
sr = v.add_renderer(SphereImpostorRenderer, bounds[:, 1], radii, colors)
v.run()
# Test updates
ar.update_radii([0.1])
bounds[0,0] -= 1.0
ar.update_bounds(bounds)
ar.update_colors([colors.green])
v.run()
# Test emptiness
ar.change_attributes([], [], [])
示例9: test_point_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_point_renderer():
'''To see if we're able to render a triangle'''
vertices = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [2.0, 0.0, 0.0]]
colors = [colors.blue] * 3
v = QtViewer()
tr = v.add_renderer(PointRenderer, vertices, colors)
v.run()
示例10: test_line_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_line_renderer():
vectors = np.array([[0.0, 0.0, 0.0], [0.0, 1.0, 0.0],
[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
colors = [blue, orange, orange, orange]
v = QtViewer()
ar = v.add_renderer(LineRenderer, vectors, colors)
v.run()
示例11: test_triangle_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_triangle_renderer():
'''To see if we're able to render a triangle'''
vertices = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [2.0, 0.0, 0.0]]
normals = [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]
colors = [colors.blue]* 3
v = QtViewer()
tr = v.add_renderer(TriangleRenderer, vertices, normals, colors, shading='toon')
v.run()
示例12: test_atom_renderer
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_atom_renderer():
'''Simple rendering of atoms as spheres'''
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])])
v = QtViewer()
ar = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array)
v.run()
示例13: test_noeffect
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_noeffect():
v = QtViewer()
centers = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0]]
radii = [0.5, 0.1, 0.5]
colors_ = np.array([colors.orange, colors.blue, colors.forest_green])
sr = v.add_renderer(SphereImpostorRenderer, centers, radii, colors_)
v.widget.post_processing.append(NoEffect(v.widget))
v.run()
示例14: test_point_fog
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_point_fog():
'''To see if we're able to render a triangle'''
NPOINTS = 10000
vertices = (np.random.random((NPOINTS, 3))-0.5)*3
colors = [colors.blue] * NPOINTS
v = QtViewer()
tr = v.add_renderer(PointRenderer, vertices, colors)
v.run()
示例15: test_text_ui
# 需要导入模块: from chemlab.graphics.qtviewer import QtViewer [as 别名]
# 或者: from chemlab.graphics.qtviewer.QtViewer import run [as 别名]
def test_text_ui():
v = QtViewer()
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])])
# To add some interaction to it
ar = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, "impostors")
tr = v.add_ui(TextUI, 100, 100, 'Hello guys')
v.run()