[Chimera-users] matching scale for different sessions
Thomas Goddard
goddard at cgl.ucsf.edu
Mon May 16 13:37:10 PDT 2005
Hi Jinghua,
I made a couple corrections to the code I sent in the previous email
so that if the command arguments are incorrect an error message is properly
reported.
Tom
---
zoom/ChimeraExtension.py follows:
# ---------------------------------------------------------------------------
# The status line and command entry box at the bottom of the main Chimera
# window prevent the window from being resized by this code to a width
# smaller than about 450 pixels. The status line can be turned off using
# Favorites / Preferences / Messages / Show status line, and the command-line
# can be hidden with Tools / Command-line / hide. Commands can still be
# typed with the command-line hidden.
#
def set_window_size(cmd_name, args):
try:
width, height = map(int, args.split())
except:
from Midas import MidasError
raise MidasError, 'Syntax error: %s <width-in-pixels> <height-in-pixels>' % cmd_name
import chimera
v = chimera.viewer
v.windowSize = (width, height)
#
# If user resizes the main window by hand the above size will not take
# effect unless we reset top level geometry.
#
from chimera import tkgui
app = tkgui.app
top = app.winfo_toplevel()
top.wm_geometry('')
# ---------------------------------------------------------------------------
#
def set_camera_zoom(cmd_name, args):
try:
pixels_per_angstrom = float(args)
except:
from Midas import MidasError
raise MidasError, 'Syntax error: %s <pixels-per-angstrom>' % cmd_name
import chimera
have_bbox, bbox = chimera.openModels.bbox()
if not have_bbox:
return
v = chimera.viewer
width, height = v.windowSize # window size in pixels
min_size = min(width,height)
r = .5 * min_size / pixels_per_angstrom
v.viewSize = r
v.scaleFactor = 1
v.camera.focal = bbox.center().z
# ---------------------------------------------------------------------------
#
import Midas.midas_text
Midas.midas_text.addCommand('windowsize', set_window_size)
Midas.midas_text.addCommand('setzoom', set_camera_zoom)
More information about the Chimera-users
mailing list