本文整理汇总了Python中chemlab.graphics.qtviewer.QtViewer类的典型用法代码示例。如果您正苦于以下问题:Python QtViewer类的具体用法?Python QtViewer怎么用?Python QtViewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QtViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pickers
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
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: showsys
def showsys(sys, width=400, height=400):
v = QtViewer()
w = v.widget
w.initializeGL()
w.resize(width, height)
w.resizeGL(width, height)
sr = v.add_renderer(AtomRenderer, sys.r_array, sys.type_array,
backend='impostors')
if sys.box_vectors is not None:
v.add_renderer(BoxRenderer, sys.box_vectors)
w.camera.autozoom(sys.r_array)
w.camera.orbit_y(3.14/4)
w.camera.orbit_x(3.14/4)
w.paintGL()
# Make sure to finish everything
data = glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE)
# Make pil image to save as png
image = pil_Image.fromstring('RGB', (width, height), data)
b = BytesIO()
image.save(b, format='png')
data = b.getvalue()
# Cleanup
del v
del w
# Save as png
return ipy_Image(data=data)
示例4: test_pickers
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()
示例5: test_cylinder_impostor_renderer
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()
示例6: test_toon_shading
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()
示例7: showmol
def showmol(mol, style='ball-and-stick',
width=300, height=300):
v = QtViewer()
w = v.widget
if style == 'ball-and-stick':
bs = v.add_renderer(BallAndStickRenderer,
mol.r_array,
mol.type_array,
mol.bonds)
elif style == 'vdw':
sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array,
backend='impostors')
w.camera.autozoom(mol.r_array)
# Make sure to finish everything
image = w.toimage(width, height)
b = BytesIO()
image.save(b, format='png')
data = b.getvalue()
# Cleanup
del v
del w
# Save as png
return ipy_Image(data=data)
示例8: showsys
def showsys(sys, width=400, height=400):
v = QtViewer()
w = v.widget
sr = v.add_renderer(AtomRenderer, sys.r_array, sys.type_array,
backend='impostors')
if sys.box_vectors is not None:
v.add_renderer(BoxRenderer, sys.box_vectors)
w.camera.autozoom(sys.r_array)
w.camera.orbit_y(3.14/4)
w.camera.orbit_x(3.14/4)
image = w.toimage(width, height)
b = BytesIO()
image.save(b, format='png')
data = b.getvalue()
# Cleanup
del v
del w
# Save as png
return ipy_Image(data=data)
示例9: test_glow
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()
示例10: showmol
def showmol(mol, style="ball-and-stick", width=300, height=300):
v = QtViewer()
w = v.widget
if style == "ball-and-stick":
bs = v.add_renderer(BallAndStickRenderer, mol.r_array, mol.type_array, mol.bonds)
elif style == "vdw":
sr = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array, backend="impostors")
w.camera.autozoom(mol.r_array)
# Make sure to finish everything
glBindTexture(w.textures["color"])
glActiveTexture(GL_TEXTURE0)
data = glGetTexImage(GL_TEXTURE_2D, 0, RGB, GL_UNSIGNED_BYTE)
# data = glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE) # Make pil image to save as png
image = pil_Image.fromstring("RGB", (width, height), data)
b = BytesIO()
image.save(b, format="png")
data = b.getvalue()
# Cleanup
del v
del w
# Save as png
return ipy_Image(data=data)
示例11: test_point_renderer
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()
示例12: test_line_renderer
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()
示例13: test_triangle_renderer
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()
示例14: test_atom_renderer
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()
示例15: test_point_fog
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()