"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pymol/viewing.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

viewing.py  (pymol-v1.8.6.0.tar.bz2):viewing.py  (pymol-v2.1.0.tar.bz2)
skipping to change at line 38 skipping to change at line 38
import pymol import pymol
from . import selector from . import selector
import copy import copy
from . import parsing from . import parsing
import re import re
cmd = sys.modules["pymol.cmd"] cmd = sys.modules["pymol.cmd"]
from .cmd import _cmd,lock,unlock,Shortcut,QuietException,_raising, \ from .cmd import _cmd,lock,unlock,Shortcut,QuietException,_raising, \
_feedback,fb_module,fb_mask, \ _feedback,fb_module,fb_mask, \
repres,repres_sc, is_string, is_list, is_ok, is_error, \ repres,repres_sc, is_string, is_list, is_ok, is_error, \
repmasks,repmasks_sc, \
toggle_dict,toggle_sc,stereo_dict,stereo_sc, \ toggle_dict,toggle_sc,stereo_dict,stereo_sc, \
palette_dict, palette_sc, window_dict, window_sc, \ palette_dict, palette_sc, window_dict, window_sc, \
safe_list_eval, safe_alpha_list_eval, \ safe_list_eval, safe_alpha_list_eval, \
location_code, location_sc, boolean_dict, boolean_sc, \ location_code, location_sc, boolean_dict, boolean_sc, \
DEFAULT_ERROR, DEFAULT_SUCCESS DEFAULT_ERROR, DEFAULT_SUCCESS
palette_colors_dict = { palette_colors_dict = {
'rainbow_cycle' : 'magenta blue cyan green yellow orange red magenta ', 'rainbow_cycle' : 'magenta blue cyan green yellow orange red magenta ',
'rainbow_cycle_rev' : 'magenta red orange yellow green cyan blue magenta ', 'rainbow_cycle_rev' : 'magenta red orange yellow green cyan blue magenta ',
'rainbow' : 'blue cyan green yellow orange red', 'rainbow' : 'blue cyan green yellow orange red',
skipping to change at line 485 skipping to change at line 486
_self.unlock(r,_self) _self.unlock(r,_self)
else: else:
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.onoff(_self._COb,str(name),0,0); r = _cmd.onoff(_self._COb,str(name),0,0);
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def _rep_to_repmask(rep):
repn = 0
for rep in rep.split():
rep = repmasks_sc.auto_err(rep, 'representation')
repn |= repmasks[rep]
return repn
def toggle(representation="lines", selection="all", _self=cmd): def toggle(representation="lines", selection="all", _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"toggle" toggles the visibility of a representation within a "toggle" toggles the visibility of a representation within a
selection. selection.
USAGE USAGE
toggle [ representation [, selection ]] toggle [ representation [, selection ]]
skipping to change at line 521 skipping to change at line 529
SEE ALSO SEE ALSO
show, hide show, hide
''' '''
r = DEFAULT_ERROR r = DEFAULT_ERROR
try: try:
_self.lock(_self) _self.lock(_self)
if representation == 'object': if representation == 'object':
repn = -2 repn = -2
else: else:
rep = representation repn = _rep_to_repmask(representation)
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep];
# preprocess selection # preprocess selection
selection = selector.process(selection) selection = selector.process(selection)
r = _cmd.toggle(_self._COb,str(selection),int(repn)); r = _cmd.toggle(_self._COb,str(selection),int(repn));
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def show(representation="", selection="", _self=cmd): def _showhide(rep, selection, value, _self):
if not selection and (rep in ("", "all") or '(' in rep or '/' in rep):
# rep looks like a selection
selection = rep
rep = "wire" if value else "everything"
selection = selector.process(selection) or "all"
repn = _rep_to_repmask(rep)
r = DEFAULT_ERROR
with _self.lockcm:
r = _cmd.showhide(_self._COb, str(selection), int(repn), value)
if _self._raising(r,_self): raise QuietException
return r
def show(representation="wire", selection="", _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"show" turns on representations for objects and selections. "show" turns on representations for objects and selections.
USAGE USAGE
show [ representation [, selection ]] show [ representation [, selection ]]
ARGUMENTS ARGUMENTS
skipping to change at line 567 skipping to change at line 589
show show
show ribbon show ribbon
show lines, (name CA+C+N) show lines, (name CA+C+N)
SEE ALSO SEE ALSO
hide, enable, disable hide, enable, disable
''' '''
r = DEFAULT_ERROR return _showhide(representation, selection, 1, _self)
try:
_self.lock(_self)
if (representation=="") and (selection==""):
if is_ok(_cmd.showhide(_self._COb,"(all)",repres['lines'],1)): #
show lines by default
r = _cmd.showhide(_self._COb,"(all)",repres['nonbonded'],2)
elif (representation!="") and (selection!=""):
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep];
# preprocess selection
selection = selector.process(selection)
#
r = _cmd.showhide(_self._COb,str(selection),int(repn),1);
elif representation=='all':
if is_ok(_cmd.showhide(_self._COb,"all",repres['lines'],1)): # s
how lines by default
r = _cmd.showhide(_self._COb,"all",repres['nonbonded'], 1) #
nonbonded
elif (representation[0:1]=='(') or '/' in representation:
# preprocess selection
selection = selector.process(representation)
#
if is_ok(_cmd.showhide(_self._COb,str(selection),repres['lines']
,1)):
r = _cmd.showhide(_self._COb,str(selection),repres['nonbonde
d'],2);
else: # selection==""
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep]
r = _cmd.showhide(_self._COb,"all",int(repn),1);
finally:
_self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException
return r
def show_as(representation="", selection="", _self=cmd): def show_as(representation="wire", selection="", _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"as" turns on and off atom and bond representations. "as" turns on and off atom and bond representations.
USAGE USAGE
as representation [, selection ] as representation [, selection ]
ARGUMENTS ARGUMENTS
skipping to change at line 638 skipping to change at line 629
NOTES NOTES
"selection" can be an object name "selection" can be an object name
"as" alone will turn on lines and nonbonded and hide everything else. "as" alone will turn on lines and nonbonded and hide everything else.
SEE ALSO SEE ALSO
show, hide, enable, disable show, hide, enable, disable
''' '''
r = DEFAULT_ERROR return _showhide(representation, selection, 2, _self)
try:
_self.lock(_self)
vis_sel = None
if (representation=="") and (selection==""):
if is_ok(_cmd.showhide(_self._COb,str(selection),-1,0)):
if is_ok(_cmd.showhide(_self._COb,"(all)",repres['lines'],1)
):
r = _cmd.showhide(_self._COb,"(all)",repres['nonbonded']
,1)
elif (representation!="") and (selection!=""):
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep]
# preprocess selection
selection = selector.process(selection)
# user specified 'visible' -- this has always been problematic
if "visible".startswith(selection.lower()) and len(selection.spl def hide(representation="everything", selection="",_self=cmd):
it())==1:
vis_sel = _self.get_unused_name("_vis")
_self.select(vis_sel, selection)
selection = vis_sel
if is_ok(_cmd.showhide(_self._COb,str(selection),-1,0)):
r = _cmd.showhide(_self._COb,str(selection),int(repn),1)
elif representation=='all':
if is_ok(_cmd.showhide(_self._COb,str(selection),-1,0)):
if if_ok(_cmd.showhide(_self._COb,"all",repres['lines'],1)):
# show lines by default
r = _cmd.showhide(_self._COb,"all",repres['nonbonded'],1
) # show nonbonded by default
elif (representation[0:1]=='(') or '/' in representation:
# preprocess selection
selection = selector.process(representation)
if is_ok(_cmd.showhide(_self._COb,str(selection),-1,0)):
r = _cmd.showhide(_self._COb,str(selection),repres['lines'],
1)
else: # selection==""
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep];
if is_ok(_cmd.showhide(_self._COb,"all",-1,0)):
r = _cmd.showhide(_self._COb,"all",int(repn),1);
finally:
if vis_sel is not None:
_self.delete(vis_sel)
_self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException
return r
def hide(representation="", selection="",_self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"hide" turns off atom and bond representations. "hide" turns off atom and bond representations.
USAGE USAGE
hide [ representation [, selection ]] hide [ representation [, selection ]]
ARGUMENTS ARGUMENTS
skipping to change at line 717 skipping to change at line 664
PYMOL API PYMOL API
cmd.hide(string representation, string selection) cmd.hide(string representation, string selection)
SEE ALSO SEE ALSO
show, enable, disable show, enable, disable
''' '''
r = DEFAULT_ERROR return _showhide(representation, selection, 0, _self)
try:
_self.lock(_self)
if (representation=="") and (selection==""):
r = _cmd.showhide(_self._COb,"@",0,0);
elif (representation!="") and (selection!=""):
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep];
selection = selector.process(selection)
r = _cmd.showhide(_self._COb,str(selection),int(repn),0);
elif (representation=='all'):
r = _cmd.showhide(_self._COb,"@",0,0);
elif (representation[0:1]=='(') or '/' in representation:
selection = selector.process(representation)
r = _cmd.showhide(_self._COb,str(selection),-1,0);
else: # selection == ""
rep = representation
rep = repres_sc.auto_err(rep,'representation')
repn = repres[rep];
r = _cmd.showhide(_self._COb,"all",int(repn),0);
finally:
_self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException
return r
def get_view(output=1, quiet=1, _self=cmd): def get_view(output=1, quiet=1, _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"get_view" returns and optionally prints out the current view "get_view" returns and optionally prints out the current view
information in a format which can be embedded into a command information in a format which can be embedded into a command
script and can be used in subsequent calls to "set_view". script and can be used in subsequent calls to "set_view".
If a log file is currently open, get_view will not write the view If a log file is currently open, get_view will not write the view
skipping to change at line 1623 skipping to change at line 1546
def window(action='show', x=0, y=0, width=0, height=0, _self=cmd): def window(action='show', x=0, y=0, width=0, height=0, _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"window" controls the visibility of PyMOL\'s output window "window" controls the visibility of PyMOL\'s output window
USAGE USAGE
window [ action [, x [, y [, width [, height ]]]]] window [ action [, x [, y [, width [, height ]]]]]
NOTES
This command is not fully implemented in MacPyMOL.
PYMOL API PYMOL API
cmd.window(string action, int x, int y, int width, int height) cmd.window(string action, int x, int y, int width, int height)
''' '''
action = window_sc.auto_err(action,'action') action = window_sc.auto_err(action,'action')
action = window_dict[str(action)] action = window_dict[str(action)]
r = DEFAULT_ERROR r = DEFAULT_ERROR
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.window(_self._COb,action,int(x),int(y),int(width),int(heigh from pymol.gui import get_qtwindow as getPyMOLWindow
t)) qt_window = getPyMOLWindow()
if qt_window:
r = DEFAULT_SUCCESS
qt_window.window_cmd(action, int(x),int(y),int(width),int(height
))
else:
r = _cmd.window(_self._COb,action,int(x),int(y),int(width),int(h
eight))
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def viewport(width=-1,height=-1,_self=cmd): def viewport(width=-1,height=-1,_self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"viewport" changes the size of the graphics display area. "viewport" changes the size of the graphics display area.
skipping to change at line 1863 skipping to change at line 1788
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.draw(_self._COb,int(width),int(height), r = _cmd.draw(_self._COb,int(width),int(height),
int(antialias),int(quiet)) int(antialias),int(quiet))
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def ray(width=0, height=0, antialias=-1, angle=0.0, shift=0.0, def ray(width=0, height=0, antialias=-1, angle=0.0, shift=0.0,
renderer=-1, quiet=1, async=0, _self=cmd): renderer=-1, quiet=1, async_=0, _self=cmd, **kwargs):
''' '''
DESCRIPTION DESCRIPTION
"ray" creates a ray-traced image of the current frame. This "ray" creates a ray-traced image of the current frame. This
can take some time (up to several minutes, depending on image can take some time (up to several minutes, depending on image
complexity). complexity).
USAGE USAGE
ray [width [,height [,antialias [,angle [,shift [,renderer [,quiet ray [width [,height [,antialias [,angle [,shift [,renderer [,quiet
skipping to change at line 1925 skipping to change at line 1850
built-in ray-tracing engine. built-in ray-tracing engine.
PYMOL API PYMOL API
cmd.ray(int width, int height, int antialias, float angle, cmd.ray(int width, int height, int antialias, float angle,
float shift, int renderer, int quiet, int async) float shift, int renderer, int quiet, int async)
SEE ALSO SEE ALSO
draw, png, save draw, png, save
''' '''
async_ = int(kwargs.pop('async', async_))
if kwargs:
raise pymol.CmdException('unknown argument: ' + ', '.join(kwargs))
arg_tup = (int(width),int(height), arg_tup = (int(width),int(height),
int(antialias),float(angle), int(antialias),float(angle),
float(shift),int(renderer),int(quiet),_self) float(shift),int(renderer),int(quiet),_self)
# stop movies, rocking, and sculpting if they're on... # stop movies, rocking, and sculpting if they're on...
if _self.get_movie_playing(): if _self.get_movie_playing():
_self.mstop() _self.mstop()
if _self.get_setting_boolean("sculpting"): if _self.get_setting_boolean("sculpting"):
_self.set("sculpting","off",quiet=1) _self.set("sculpting","off",quiet=1)
if _self.rock(-2)>0: if _self.rock(-2)>0:
_self.rock(0) _self.rock(0)
# #
r = DEFAULT_ERROR r = DEFAULT_ERROR
if not async: if not async_:
r = _ray(*arg_tup) r = _ray(*arg_tup)
else: else:
render_thread = threading.Thread(target=_ray, args=arg_tup) render_thread = threading.Thread(target=_ray, args=arg_tup)
render_thread.setDaemon(1) render_thread.setDaemon(1)
render_thread.start() render_thread.start()
r = DEFAULT_SUCCESS r = DEFAULT_SUCCESS
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def refresh(_self=cmd): def refresh(_self=cmd):
skipping to change at line 1976 skipping to change at line 1906
r = None r = None
if thread.get_ident() == pymol.glutThread: if thread.get_ident() == pymol.glutThread:
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.refresh_now(_self._COb) r = _cmd.refresh_now(_self._COb)
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
else: else:
try: try:
_self.lock(_self) _self.lock(_self)
r = _self._do("_ cmd._refresh(_self=cmd)",_self=_self) r = _self._do("_ cmd._refresh()")
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise QuietException if _self._raising(r,_self): raise QuietException
return r return r
def reset(object='',_self=cmd): def reset(object='',_self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"reset" restores the rotation matrix to identity, sets the origin "reset" restores the rotation matrix to identity, sets the origin
 End of changes. 15 change blocks. 
128 lines changed or deleted 48 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)