>  Docs Center  >  Libraries  >  Motley  >  MGH_ANIMATOR__DEFINE
Libraries

MGH_ANIMATOR__DEFINE

MGH_ANIMATOR__DEFINE

Class


  MGH_Animator

Purpose


  This class supports basic animation functionality, common to the
  MGH_DGplayer, MGH_Player and MGH_Conductor classes.

Superclasses


  MGH_GUI_Base

Properties


  In addition to those inherited from MGH_GUI_Base:
    N_FRAMES (Get)
      Number of frames currently held by the animator.
    PLAYBACK (Get, Set)
      A named structure of type MGH_ANIMATOR_PLAYBACKINFO containing
      properties controlling playback. See below.
    POSITION (Get, Set)
      The current position of the animator. During playback the
      animator controls the POSITION property but there are times
      when it is desirable to control it from outside.
  There are several properties controlling playback. They are
  accessed collectively via the PLAYBACK property or individually
  via the GetPlayback and SetPlayback methods.
    LOOP
      Controls what happens when playback reaches one of the
      endpoints:
        0 - Stop
        1 - Return to opposite end of animation and repeat in same
            direction
        2 - Play in reverse direction from current end point.
    DELAY
      A 3-element integer array specifying the delay in milliseconds,
      in the form [between frames, additional on first frame,
      additional on last frame]
    RANGE
      A 3-element integer array specifying the playback range and
      stride, in the form [first frame, last frame, stride]. If
      USE_RANGE is not set, then this is ignored (but remembered).
    USE_RANGE
      Set this property to have the playback range and stride
      controlled by the RANGE property. Default is all frames @
      stride one.

Methods


  The methods in this class provide minimal functionality and will
  normally be overriden or extended by subclasses:
    BuildDelayBar
      Show or hide (actually create or destroy) a widget bar with
      fields for setting the delay.
    BuildPlayBar
      Show or hide (actually create or destroy) a bar with "Play",
      "Stop", etc buttons plus a droplist to control the LOOP
      parameter.
    BuildRangeBar
      Show or hide (actually create or destroy) a bar with fields
      for activating the USE_RANGE prperty and setting the RANGE
      parameters.
    BuildSliderBar
      Show or hide (actually create or destroy) a bar with a slider,
      which displays and can be used to reset, the current position.
    CountFrames (deleted??)
      This method is called before the N_FRAMES property is
      evaluated and provides an opportunity to update the
      property. In MGH_Animator this does nothing; subclasses may
      override it to count frames in an animation.
    Display
      Display current frame (if a frame is specified then make it
      the current frame first) and update animation widgets.
    GetPlayBack
      Return parameters that control playback.
    Play
      Initiate playback
    PlayNext
      Specify next frame for playback and set a widget timer
      event. This routine is the main driver of the animation
      logic.
    PlayStop
      Stop playback.
    TimeFrames
      Play the animation once and report the time per frame. The
      frames to be played are controlled by the RANGE and USE_RANGE
      properties. This method calls Display for each frame; this
      displays the frame and updates the slider bar. It does not
      exercise the event-driven animation logic in the Play,
      PlayNext and Playstop methods. I did some ad hoc tests with a
      naked MGH_Animator object with 10,000 frames on my current
      machine (Pentium 3 800 MHz, Windows 2000, IDL 5.5). The

Results



        a) Calling the Display method with the slider-bar update
        disabled (commented out) takes 0.008 ms per frame. Yes
        that's 8 microseconds!
        b) Calling the Display method with the normal slider-bar
        update takes 0.03 ms per frame.
        c) Playing the animation normally with zero delay takes
        0.08 ms per frame, ie. an additional 0.05 ms compared with b).
      Thus the animation overhead is negligible in normal
      animated-graphics applications, where delays & drawing times
      are ~ 30 ms or more.
    Update
      This is a method inherited from MGH_GUI_Base and
      conventionally called to tell a widget application to update
      its state and appearance. The MGH_Animator method counts
      frames and calls the individual Update... routine for each of
      the widget components.
    UpdateDelayBar
    UpdatePlayBar
    UpdateRangeBar
    UpdateSliderBar
      Update the respective widget component.
  OPERATION:
  Too complicated to describe fully here, but note the following
  accelerator keys:
    Ctrl+Space - Stop/Start
    Ctrl+Up - Set play direction backward.
    Ctrl+Down - Set play direction forward.
    Ctrl+Home - Go to beginning of animation (or beginning of range
                  if USE_RANGE is in effect).
    Ctrl+End - Go to end of animation (or end of range if USE_RANGE
                  is in effect).
    Ctrl+Left - Go back one step (one stride if USE_RANGE is in
                  effect).
    Ctrl+Right - Go forward one step (one stride if USE_RANGE is in
                  effect).
###########################################################################
  This software is provided subject to the following conditions:
  1. NIWA makes no representations or warranties regarding the
    accuracy of the software, the use to which the software may
    be put or the results to be obtained from the use of the
    software. Accordingly NIWA accepts no liability for any loss
    or damage (whether direct of indirect) incurred by any person
    through the use of or reliance on the software.
  2. NIWA is to be acknowledged as the original author of the
    software where the software is used or presented in any form.
###########################################################################

Modification History


  Mark Hadfield, 1999-11.
    Written as MGHgrAnimatorBase.
  Mark Hadfield, 2000-05.
    Allowed for larger delay on first & last frames. Delays now in
    milliseconds.
  Mark Hadfield, 2001-07.
    Renamed MGH_Animator. Overhauled as part of a thorough rewrite
    of widget and graphics classes.
  Mark Hadfield, 2001-11.
    Implemented context menus.
  Mark Hadfield, 2002-10.
    Implemented check buttons on the context menus.
  Mark Hadfield, 2004-05.
    Implemented accelerator keys for the play bar and changed
    the play bar's layout to make key-driven operation more logical.
  Mark Hadfield, 2007-10.
    Changed order of operation in the PlayNext method to work
    around problem in IDL 7.0 pre-release: IDL was losing track of
    widget timer events (but only one in every ten or so) if they came
    due when IDL was busy. Solution is to call the Display method
    before generating a new timer event.



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
My Account    |    Contact Us