00001 #ifndef OBJECTANIMATION_QT_H 00002 #define OBJECTANIMATION_QT_H 00003 00004 #include <QtGui/QtGui> 00005 #include "Media/FrameRange.H" 00006 #include "Util/log.H" 00007 #include <utility> 00008 00009 #include "NeovisionII/NeoAnnotate/AnimationDelegate.qt.H" 00010 00011 class ObjectAnimation : public QObject 00012 { 00013 Q_OBJECT 00014 00015 public: 00016 00017 //! A structure to hold all necessary information about frame 00018 struct FrameState 00019 { 00020 QPointF pos; 00021 bool visible; 00022 bool is_keyframe; 00023 }; 00024 00025 //! Construct a new object animation with a specified framerange and initial position. 00026 /*! The masterFrameRange parameter must be the FrameRange for the entire move so that 00027 frames can be properly mapped into the animation.*/ 00028 ObjectAnimation(int frameNum, FrameRange masterFrameRange, QPointF initialPos); 00029 00030 //! Perform position interpolation on the fly 00031 FrameState getFrameState(int frameNum); 00032 00033 //! Move a keyframe from one frame to another (likely because of a drag-and-drop operation) 00034 bool moveKeyframe(int from_fnum, int to_fnum); 00035 00036 //! Insert a new keyframe at frameNumber indicating the object is at position pos 00037 void setPosition(int frameNum, QPointF pos, bool visible=true); 00038 00039 //! Draw a dropdown context menu to allow users to modify the animation 00040 void constructContextMenu(QPoint pos, int column); 00041 00042 //! Get the animation framerange 00043 FrameRange getFrameRange() const { return itsMasterFrameRange; } 00044 00045 //! Find the bounding keyframes for a given framenumber 00046 /*! If the requested frame is either before the first keyframe, or after the last, 00047 then both iterators in the pair will just be set to itsKeyframes.end()*/ 00048 std::pair<QMap<int, FrameState>::const_iterator, 00049 QMap<int, FrameState>::const_iterator> 00050 getBoundingKeyframes(int fnum); 00051 00052 AnimationDelegate::FrameType getFrameType(int fnum); 00053 00054 QMap<int, FrameState>& getKeyFrames() { return itsKeyFrames; } 00055 00056 //! Clear all keyframes from the keyframe storage 00057 void clear(); 00058 signals: 00059 void animationChanged(); 00060 00061 private: 00062 QMap<int, FrameState> itsKeyFrames; 00063 00064 FrameRange itsMasterFrameRange; 00065 }; 00066 00067 #endif //OBJECTANIMATION_QT_H 00068