
Hi Steve The Chimera programming documentation is abysmal. We usually use the C++ header files which have equivalent Python interfaces. Unfortunately you don't have those in the distribution. I've packaged up the Chimera include directory. You can get them at http://www.cgl.ucsf.edu/home/goddard/chiminc.tar.gz We keep them in /usr/local/chimera/include. You'll want to mostly look at include/_chimera/*.h. Also include/otf/Geom.h is helpful. A) how to rotate/translate the camera
v = chimera.viewer c = v.camera print c.center (5.9539999961853027, -2.186500072479248, 10.296500205993652) c.center = (x, y, z) # to translate camera # Camera always points in -z direction. There is no way to rotate it. v.scaleFactor = 1.5 # to zoom camera
B) how to rotate/translate individual objects C) how to find out the current rotations/translations
om = chimera.openModels mlist = om.list() m = mlist[0] xf = chimera.Xform() axis = chimera.Vector(1, 0, 0) angle = 90 # degrees xf.rotate(axis, angle) print m.openState.xform # 3x3 rotation matrix # last column is translation 0.982695 0.121524 0.139793 -1.07064 0.0250348 0.660639 -0.750287 6.83425 -0.183531 0.740803 0.646164 6.35578 m.openState.globalXform(xf) # Another method # xf.premultiply(m.openState.xform) # changes xf # m.openState.xform = xf # To rotate relative to data axes use # m.openState.localXform(xf) # or # xf.multiply(m.openState.xform) # changes xf # m.openState.xform = xf
D) how to save the current view to a file (haven't worked on this very hard yet, but while I'm asking)
v = chimera.viewer im = v.pilImage() # ImagingCore object from PIL import Image image = Image.Image()._makeself(im) format = 'PNG' # Or 'BMP', 'EPS','GIF', 'JPEG', 'PDF', 'PPM', 'TIFF' path = '/home/goddard/hoohoo.png' image.save(path, format = format)
----------------------
Date: Sun, 11 May 2003 23:21:48 -0500 (CDT) From: Steve Ludtke <stevel@blake.3dem.bioch.bcm.tmc.edu> Reply-To: sludtke@bcm.tmc.edu
Hi again. I decided to take another stab at doing some scripted animations with chimera, but got stuck. I've looked through the available docs pretty thoroughly, and I've spent a lot of time interrogating a live session, but there are still some serious holes, largely because a lot of the code is in C and I don't have the source on that side. Most of the docs seem to focus on manipulating the actual data rather than the viewing framework. I know how to get access to the list of open models and to the current lensviewer. However, I still can't figure out:
A) how to rotate/translate the camera B) how to rotate/translate individual objects C) how to find out the current rotations/translations D) how to save the current view to a file (haven't worked on this very hard yet, but while I'm asking)
If you could send me any sort of code snippet indicating how to do these things, I'd be grateful. I'm sure they are pretty much one-liners, but I can't figure out what the 1 line is...
thx again!
participants (1)
-
Thomas Goddard