def test_wireframe_renderer(): v = QtViewer() #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") ar = v.add_renderer(WireframeRenderer, mol.r_array, mol.type_array, mol.bonds) # Try without bonds #ar2 = v.add_renderer(WireframeRenderer, mol.r_array + 0.5, mol.type_array, np.array([])) v.run()
from chemlab.db import CirDB from chemlab.graphics import QtViewer from chemlab.graphics.renderers import AtomRenderer from chemlab.graphics.postprocessing import FXAAEffect, SSAOEffect # A series of compounds to display compounds = ["methane", "ethane", "propane", "butane"] db = CirDB() # Prepare the viewer v = QtViewer() v.widget.initializeGL() v.add_post_processing(SSAOEffect, kernel_size=128, kernel_radius=1.0) v.add_post_processing(FXAAEffect) for compound in compounds: mol = db.get("molecule", compound) rend = v.add_renderer(AtomRenderer, mol.r_array, mol.type_array) v.widget.camera.autozoom(mol.r_array) # Give some extra zoom v.widget.camera.mouse_zoom(1.0) v.widget.toimage(300, 300).save(compound + '.png') # Cleanup v.remove_renderer(rend)
from chemlab.mviewer.representations import BallAndStickRepresentation from chemlab.graphics.qt.qttrajectory import format_time from .core import * from chemlab.db import CirDB from chemlab.io import datafile from chemlab.core import System import numpy as np db = CirDB() def display_system(system, autozoom=True): '''Display a `~chemlab.core.System` instance at screen''' viewer.clear() viewer.add_representation(BallAndStickRepresentation, system) if autozoom: autozoom_() viewer.update() msg(str(system)) def display_molecule(mol, autozoom=True): '''Display a `~chemlab.core.Molecule` instance in the viewer. This function wraps the molecule in a system before displaying it. '''
def test_cir(): db = CirDB() bz = db.get("molecule", "norbornene")