Changes between Version 2 and Version 3 of ChimeraAnimationTasks


Ignore:
Timestamp:
Dec 8, 2010, 4:15:36 PM (15 years ago)
Author:
Darren Weber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChimeraAnimationTasks

    v2 v3  
    77}}}
    88
    9 Some tips in the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html programming FAQ] are useful (esp, items 4, 5, 7-10).  Note, take a look at the code for {{{chimera.update.checkForChanges()}}}, as this may be helpful in detecting changes for transitions and for checking the validity of state parameters.
     9Some tips in the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html programming FAQ] are useful (esp, items 4, 5, 7-10). 
    1010
    11 {{{chimera.OpenModels.addRemoveHandler(func, data)}}} can be used to add a trigger handler when removing models.  This might be useful in the creation of a state instance as a way to maintain integrity or validity of the saved state.  It may depend on whether the state instance keeps a reference or a copy of models in the saved state.  For efficiency, it is better to keep a reference.  For validity, it could be better to keep a copy.  Perhaps a copy is required only when a model is removed, so the copy action could be triggered then.
     11==== openState attribute (from FAQ) ====
     12
     13Get the OpenState attributes of a model: {{{chimera.openModels.openState(id: int, subid: int)}}}
     14
     15The openState attribute of a Model controls whether that model is active for motion ('.active'), and contains the model's transformation matrix ('.xform') and center of rotation ('.cofr'). Since some models must move in synchrony (e.g. a molecule and its surface), OpenState instances may be shared among multiple models. If you create a model that needs a shared openState with another model, then when adding your model to the list of open models with chimera.openModels.add(), you should use the 'sameAs' keyword to specify the other model.
     16
     17==== 'Active' models ====
     18
     19{{{
     20#
     21# Working with a specific active model:
     22# openState(id: int, subid: int)
     23modelID = chimera.openModels.listIds()[0]
     24model_openState = chimera.openModels.openState(*modelID)
     25if model_openState.active:
     26    # do something useful with it
     27    print model_openState.xform
     28#
     29# looping over all open-active models
     30#
     31if chimera.openModels.hasActiveModels():
     32    om = chimera.openModels.list(all=True)
     33    for m in om:
     34        if m.openState.active:
     35            # do something useful with it
     36            print m.openState.xform
     37#
     38# Setting 'active' models:
     39# chimera.openModels.setActive(id: int, active: bool)
     40#
     41chimera.openModels.setActive(modelID[0], False)
     42model_openState.active
     43# False
     44chimera.openModels.setActive(modelID[0], True)
     45model_openState.active
     46# True
     47
     48}}}
     49
     50
     51=== Integrity Checking ===
     52
     53Take a look at the code for {{{chimera.update.checkForChanges()}}}.  This may be helpful in checking the validity of state parameters and in automatically detecting changes for transitions.
     54
     55Also, {{{chimera.OpenModels.addRemoveHandler(func, data)}}} might be used to add a trigger handler when removing models.  This might be useful in the creation of a state instance as a way to maintain integrity or validity of the saved state.  It may depend on whether the state instance keeps a reference or a copy of models in the saved state.  For efficiency, it is better to keep a reference.  For validity, it could be better to keep a copy.  Perhaps a copy is required only when a model is removed, so the copy action could be triggered then.  If a state instance that is registered as a handler is deleted, then call {{{chimera.OpenModels.deleteRemoveHandler(handler)}}} to delete the trigger handler.
     56