Skip to content

Commit

Permalink
stereo_ray improvements
Browse files Browse the repository at this point in the history
- move doc string to function
- skip width/height calculation (done by ray command)
- quiet argument for feedback
  • Loading branch information
speleo3 committed May 31, 2012
1 parent 994cef2 commit 415731b
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions stereo_ray.py
@@ -1,7 +1,13 @@
'''
See more here: http://www.pymolwiki.org/index.php/stereo_ray
'''

from pymol import cmd

def stereo_ray(filename, width=0, height=0, quiet=1):
'''
DESCRIPTION
"stereo_ray" ray-traces the current scene twice (separated by
a six-degree rotation around the y axis)
and saves a pair of images that can be combined in any image
Expand All @@ -11,36 +17,22 @@
If the width is given, the height will be calculated.
USAGE
stereo_ray filename [, width [, height]]
EXAMPLE
stereo_ray output, 1000, 600
stereo_ray secondImage.png
'''
'''
if filename.lower().endswith('.png'):
filename = filename[:-4]

from pymol import cmd

def stereo_ray(output='', width='', height=''):

if output == '':
print 'no output filename defined\n'
print 'try: \'stereo_ray filename\''
return -1
# abort if no output file name given

if width == '':
width,height = cmd.get_session()['main'][0:2]
# get dimensions from viewer if not given

elif height == '':
oldWidth,oldHeight = cmd.get_session()['main'][0:2]
height = int(width)*oldHeight/oldWidth
# calculate height from proportions of viewer if
# only width is given

cmd.ray(width, height, angle=-3)
cmd.png(output+"_r")
cmd.png(filename + "_r", quiet=quiet)
cmd.ray(width, height, angle=3)
cmd.png(output+"_l")
cmd.png(filename + "_l", quiet=quiet)

cmd.extend('stereo_ray',stereo_ray)

# vi:expandtab:sw=3

0 comments on commit 415731b

Please sign in to comment.