Changes between Initial Version and Version 1 of ChimeraAnimationState


Ignore:
Timestamp:
Dec 21, 2010, 2:23:25 PM (15 years ago)
Author:
Darren Weber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChimeraAnimationState

    v1 v1  
     1
     2=== State Parameters: Categories ===
     3
     4 * Elements
     5   * 2D Labels
     6   * Models (Molecules, Atoms)
     7   * Surfaces
     8   * Volumes
     9   * Selections
     10 * Display State
     11   * Hidden
     12   * Active for Motion
     13 * Spatial
     14   * Camera
     15   * Model Geometry (Center of Rotation, Xform, etc.)
     16   * Clipping Planes
     17 * Lighting
     18   * Background
     19   * Directional Lights
     20 * Surfacing
     21   * Textures
     22   * Materials (Color, Specular reflection, etc.)
     23   * Transparency
     24 * Rendering
     25   * Model and ribbon styles
     26   * Motion Blur
     27
     28
     29=== State Parameters: initial work based on {{{savepos}}} and {{{reset}}} ===
     30
     31The savepos/reset functionality works with a tuple:
     32{{{
     33#
     34# savepos returns a tuple of various parameters (my comments added)
     35#
     36        return (
     37            chimera.viewer.scaleFactor, #cam
     38            chimera.viewer.viewSize, #cam
     39            cam.center, #cam
     40            cam.nearFar, #cam
     41            cam.focal, #cam
     42            xforms, # spatial/geometry
     43            clips, # per-model clipping
     44            chimera.openModels.cofrMethod, # spatial/geometry
     45            cofr, # spatial/geometry
     46            chimera.viewer.clipping #cam
     47        )
     48}}}
     49
     50
     51
     52=== Parameter Access Methods ===
     53
     54Something like this gains access to a lot of view parameters:
     55{{{
     56for n in dir(chimera.viewer):
     57    print n, eval('type(chimera.viewer.%s)' % n)
     58}}}
     59
     60Some tips in the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html programming FAQ] are useful (esp, items 4, 5, 7-10).
     61
     62
     63
     64==== Attributes: To Copy or Not to Copy, that is the question! ====
     65
     66From the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html FAQ], item (7): Some attributes return a copy of an object.
     67{{{
     68>>> xf = model.openState.xform  # xf is a copy of the model's Xform matrix.
     69>>> xf.zRotate(45)              # This will not rotate the model.
     70
     71>>> c = model.atoms[0].color    # c is the MaterialColor object for the atom
     72>>> c.ambientDiffuse = (1,0,0)  # The Atom color changes immediately to red.
     73}}}
     74
     75Some Chimera objects returned as attributes are always copies, some are always references to the uncopied object. Objects that are always copied include {{{Xform, Vector, Point, Sphere, Element, MolResId, Coord,}}} .... Objects that are never copied include {{{Atom, Bond, PseudoBond, CoordSet, Molecule, Residue, RibbonStyle,}}} .... Object that can be copied have a {{{__copy__}}} method. In order to know if an object type is passed by value is to look at the Chimera C++ header files. Classes without a !WrapPy base class are always copied. This base class is part of the C++ to Python interface generation.
     76
     77
     78
     79==== Color and Material Attributes ====
     80
     81See http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/Main_ColorWellUI.html
     82
     83Also need a function for color interpolations (linear may suffice).  This may be a simple function to interpolate each component of the RGBA tuple from stateA to stateB over N frames (the range of values is between 0-1, so it's a floating point interpolation).
     84
     85Get a PDB molecule to play with:
     86{{{
     87chimera.runCommand('open 2por')
     88om = chimera.openModels.list(all=True)
     89por2 = om[1]
     90}}}
     91
     92Exploring color properties:
     93{{{
     94>>> por2.color
     95<_chimera.MaterialColor object at 0x3d50dc8>
     96>>> por2.color.name()
     97u'_openColor00'
     98>>> por2.color.rgba()
     99(1.0, 1.0, 1.0, 1.0)
     100>>> por2.color.ambientDiffuse
     101(1.0, 1.0, 1.0)
     102>>> por2.color.isTranslucent()
     103False
     104>>> por2.color.opacity
     1051.0
     106}}}
     107
     108Chimera material attributes are collected with color attributes.
     109{{{
     110# chimera.Material object
     111>>> por2.color.material
     112<_chimera.Material object at 0x2fd7c60>
     113>>> por2.color.material.name()  # material name (unicode str)
     114u'default'
     115>>> por2.color.material.shininess
     11630.0
     117>>> por2.color.material.specular
     118(0.85, 0.85, 0.85)
     119>>> por2.color.material.opacity
     1201.0
     121>>> por2.color.material.ambientDiffuse
     122(1.0, 1.0, 1.0)
     123>>> por2.color.material.isTexture()
     124False
     125>>> por2.color.material.isTranslucent()
     126False
     127}}}
     128
     129
     130
     131==== openState attributes ====
     132
     133Get the !OpenState attributes of a model: {{{chimera.openModels.openState(id: int, subid: int)}}}
     134
     135From the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html FAQ], item (10):  The 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.
     136
     137
     138
     139==== 'Active' models ====
     140
     141{{{
     142#
     143# Working with a specific active model:
     144# openState(id: int, subid: int)
     145modelID = chimera.openModels.listIds()[0]
     146model_openState = chimera.openModels.openState(*modelID)
     147if model_openState.active:
     148    # do something useful with it
     149    print model_openState.xform
     150    print model_openState.xform.getRotation()
     151    print model_openState.xform.getTranslation()
     152#
     153# looping over all open-active models
     154#
     155if chimera.openModels.hasActiveModels():
     156    om = chimera.openModels.list(all=True)
     157    for m in om:
     158        if m.openState.active:
     159            # do something useful with it
     160            print m.openState.xform
     161#
     162# Setting 'active' models:
     163# chimera.openModels.setActive(id: int, active: bool)
     164#
     165chimera.openModels.setActive(modelID[0], False)
     166model_openState.active
     167# False
     168chimera.openModels.setActive(modelID[0], True)
     169model_openState.active
     170# True
     171
     172}}}
     173
     174
     175
     176==== openState.xform ====
     177
     178{{{
     179
     180>>> dir(model_openState.xform)
     181['__class__', '__copy__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'apply', 'coordFrame', 'getCoordFrame', 'getOpenGLMatrix', 'getRotation', 'getTranslation', 'identity', 'inverse', 'invert', 'isIdentity', 'lookAt', 'makeOrthogonal', 'multiply', 'premultiply', 'rotate', 'rotation', 'translate', 'translation', 'xRotate', 'xRotation', 'xform', 'yRotate', 'yRotation', 'zAlign', 'zRotate', 'zRotation']
     182
     183>>> help(model_openState.xform)
     184Help on Xform object:
     185
     186...
     187
     188}}}
     189