Motion callback functions

Hi Karin, I've attached some example Python code that monitors the motion of models in Chimera. It registers an OpenState trigger. For your case you might update the color on your plane when the plane moves but the map does not move. Let me know if more details would be helpful. Tom Karin Gross wrote:
Hi Tom,
i have a question concerning rotation and translation of surface models in chimera. I want the user to be able to rotate/translate my plane via mouse, but run the computation of coloring and do the coloring during the movement. Is it possible to register a python callback for this, and get the rotation/translation information?
Thanks -Karin
# ------------------------------------------------------------------------------ # Example code that monitors the motion of models in Chimera. # # Each Chimera Model object has an openState attribute whose value is an # OpenState object. The OpenState object has attributes xform, active, # cofr (center of rotation), bbox (bounding box). These are defined in the # Chimera C++ header file OpenModels.h. (Chimera C++ headers can be downloaded # from http://www.cgl.ucsf.edu/chimera/sourcecode.html). # # This example code monitors changes in the OpenState objects for all models. # class Monitor_Motion: def __init__(self): from chimera import triggers h = triggers.addHandler('OpenState', self.xform_changed_cb, None) self.handler = h def xform_changed_cb(self, trigger_name, call_data, trigger_data): if 'transformation change' in trigger_data.reasons: # The transformation matrix of some model has changed. from chimera import openModels mlist = openModels.list() # All open models. for open_state in trigger_data.modified: models = filter(lambda m: m.openState == open_state, mlist) if models: names = ', '.join(map(lambda m: m.name, models)) print names, 'moved' print open_state.xform def stop_monitoring(self): from chimera import triggers triggers.deleteHandler('OpenState', self.handler) self.handler = None # ------------------------------------------------------------------------------ # mm = Monitor_Motion()
participants (1)
-
Tom Goddard