AnimationFrame.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef ANIMATIONFRAME_H
00011 #define ANIMATIONFRAME_H
00012 
00013 #include <string>
00014 
00015 /**
00016  *  Stores information about a single frame in an animation.
00017  *
00018  *  An animation frame contains three values: name, frame number, and time.  The
00019  *  name is not used internally, but is provided so that objects can provide a
00020  *  meaningful way for the user to uniquely identify a frame.  The frame number
00021  *  is zero-based and should be unique to each frame in an animation.  The time
00022  *  value corresponds to either seconds after midnight on January 1, 1970 UTC or
00023  *  elapsed seconds after the start of the animation.  A double precision value
00024  *  is used to allow milliseconds to be specified as a fractional second.  A
00025  *  negative time value, which is the default state, indicates that time is not
00026  *  associated with the frame.
00027  *
00028  *  @see     Animation
00029  */
00030 class AnimationFrame
00031 {
00032 public:
00033    /**
00034     *  Constructs a default empty animation frame.
00035     */
00036    AnimationFrame() :
00037       mName(""),
00038       mFrameNumber(0),
00039       mTime(-1.0)
00040    {}
00041 
00042    /**
00043     *  Constructs an animation frame with no associated time.
00044     *
00045     *  @param   name
00046     *           The frame name.
00047     *  @param   frameNumber
00048     *           The frame number.  %Any positive number can be used to create
00049     *           the frame, but the number should be unique for all frames in an
00050     *           animation.
00051     *
00052     *  @see     Animation
00053     */
00054    AnimationFrame(const std::string& name, unsigned int frameNumber) :
00055       mName(name),
00056       mFrameNumber(frameNumber),
00057       mTime(-1.0)
00058    {}
00059 
00060    /**
00061     *  Constructs an animation frame with an associated time value.
00062     *
00063     *  @param   name
00064     *           The frame name.
00065     *  @param   frameNumber
00066     *           The frame number.  %Any positive number can be used to create
00067     *           the frame, but the number should be unique for all frames in an
00068     *           animation.
00069     *  @param   time
00070     *           The frame time in seconds after midnight, January 1, 1970 UTC or
00071     *           elapsed seconds after the start of the animation.  A fractional
00072     *           second represents milliseconds.
00073     *
00074     *  @see     Animation
00075     */
00076    AnimationFrame(const std::string& name, unsigned int frameNumber, double time) :
00077       mName(name),
00078       mFrameNumber(frameNumber),
00079       mTime(time)
00080    {}
00081 
00082    /**
00083     *  Queries whether this frame has a lesser frame number or time than this
00084     *  frame.
00085     *
00086     *  @param   frame
00087     *           The animation frame to compare against this frame.
00088     *
00089     *  @return  If the time value of this frame and \e frame are both valid,
00090     *           returns \c true if the time value of this frame is less than the
00091     *           time value of \e frame.  If the time value of either this frame
00092     *           or \e frame is invalid (negative), returns \c true if the frame
00093     *           number of this frame is less than the frame number of
00094     *           \e frame.
00095     */
00096    bool operator< (const AnimationFrame& frame) const
00097    {
00098       if ((mTime >= 0.0) && (frame.mTime >= 0.0))
00099       {
00100          return (mTime < frame.mTime);
00101       }
00102 
00103       return (mFrameNumber < frame.mFrameNumber);
00104    }
00105 
00106    /**
00107     *  Queries whether this frame has a greater frame number or time than this
00108     *  frame.
00109     *
00110     *  @param   frame
00111     *           The animation frame to compare against this frame.
00112     *
00113     *  @return  If the time value of this frame and \e frame are both valid,
00114     *           returns \c true if the time value of this frame is greater than
00115     *           the time value of \e frame.  If the time value of either this
00116     *           frame or \e frame is invalid (negative), returns \c true if the
00117     *           frame number of this frame is greater than the frame number of
00118     *           \e frame.
00119     */
00120    bool operator> (const AnimationFrame& frame) const
00121    {
00122       if ((mTime >= 0.0) && (frame.mTime >= 0.0))
00123       {
00124          return (mTime > frame.mTime);
00125       }
00126 
00127       return (mFrameNumber > frame.mFrameNumber);
00128    }
00129 
00130    /**
00131     *  Queries whether an animation frame is identical to this frame.
00132     *
00133     *  @param   frame
00134     *           The animation frame to compare against this frame.
00135     *
00136     *  @return  Returns \c true if both the frame number and time of this frame
00137     *           are equal to those of \e frame.
00138     */
00139    bool operator== (const AnimationFrame& frame) const
00140    {
00141       return ((mFrameNumber == frame.mFrameNumber) && (mTime == frame.mTime));
00142    }
00143 
00144    /**
00145     *  Queries whether an animation frame is different from this frame.
00146     *
00147     *  @param   frame
00148     *           The animation frame to compare against this frame.
00149     *
00150     *  @return  Returns \c true if both the frame number and time of this frame
00151     *           are different than those of \e frame.
00152     */
00153    bool operator!= (const AnimationFrame& frame) const
00154    {
00155       return ((mFrameNumber != frame.mFrameNumber) || (mTime != frame.mTime));
00156    }
00157 
00158    /**
00159     *  The frame name.
00160     */
00161    std::string mName;
00162 
00163    /**
00164     *  The frame number.
00165     *
00166     *  The frame number is zero-based and each frame in an animation should have
00167     *  a unique number.
00168     *
00169     *  @see     Animation
00170     */
00171    unsigned int mFrameNumber;
00172 
00173    /**
00174     *  The frame time.
00175     *
00176     *  If the frame type is ::FRAME_TIME, the time is specified in seconds after
00177     *  midnight, January 1, 1970 UTC.  If the frame type is
00178     *  ::FRAME_ELAPSED_TIME, the time is specified in elapsed seconds after the
00179     *  start of the animation.  In both cases, a fractional second represents
00180     *  milliseconds.
00181     */
00182    double mTime;
00183 };
00184 
00185 #endif

Software Development Kit - Opticks 4.9.0 Build 16218