wiki:Implementation

Implementation Notes on Adding an Action to Chimera Animation (revised September 11, 2012: David Mischel)

  1. Actions in Animation are analogous to Keyframes but have a different implementation. To add a new Action based on a chimera command, there are several components required
  2. Define a new subclass of Cmd with attributes specific to the chimera command
    • name: label for display on the Actions palette
    • cmd: the Chimera command name
    • cmd_fmt: the string format of all parameters and flags
    • param_order: the order of parameters to satisfy the cmd_fmt substitutions
    • loadParams(): defines parameters for this Cmd
    • paramDict: a dictionary of variables available to this command
      • variables can be IntParam, FloatParam, StrParam, ChoiceParam
      • each member of paramDict is keyed by its name
      • each member of ParaDict is a dictionary with these keys
        • name: param name
        • required: boolean
        • def_val: default value
        • choices: optional, for ChoiceParam types
        • gui: optional dictionary for a widget to manage this parameter in the properties dialog
          • label: string for labeling the widget
          • widget: a Tkinter widget type (e.g., Tkinter.Entry)
          • If gui is not present in paramDict, nothing will be shown for the param in the properties dialog for this Action
    • callback(): the function in Midas which is actually called with the appropriate param argument.
    • cb_param(): callback to get a param object based on Cmd's variables.
    • update(): function called when parameters are changed if any recalculation is required
    • balloon_msg(): helpful tool tip which shows the current parameters set on the Action
  3. To support single frame stepping in Animation, an Animation callback has to be handed in to the Midas command. Most Midas commands use a default callback. To enable single frame stepping that callback has to be replaced with the Animation callback. This is done in Action.initAction() which adds the optional “removalHandler” to the param returned by Midas.
    • Modify the Chimera command in libs/Midas/init.py by dividing it into a parameter config function, which returns a param, and an execution function (e.g., rock()), which uses it.
    • Currently, Midas._tickMotionHandler(), Midas._flight() and Midas._movement() have been modified to accept the optional handler from Animation. If a future Action relies on a different movement function which uses the callback, that function will also have to be modified.
    • When Animation begins to play the frames of an Action the callback is registered on the 'transition_frame' trigger. This will be called for each frame.
    • Midas command release their handlers when they are done so it does not have to be done in Animation.
  4. Cmds have to included in the cmds dictionary in Cmd.py
Last modified 14 years ago Last modified on Sep 11, 2012, 3:35:22 PM
Note: See TracWiki for help on using the wiki.