AnimationDelegate.qt.C

00001 #ifndef ANIMATION_DELEGATE_QT_C
00002 #define ANIMATION_DELEGATE_QT_C
00003 
00004 
00005 #include "NeovisionII/NeoAnnotate/AnimationDelegate.qt.H"
00006 #include "Util/log.H"
00007 
00008 
00009 AnimationDelegate::AnimationDelegate(QObject *parent)
00010 {
00011   itsFrameType = AnimationDelegate::Invisible;
00012 }
00013 
00014 void AnimationDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
00015         const QModelIndex &index) const
00016 {
00017 
00018   QRect rect = option.rect;
00019 
00020   QColor         currFrameColor(200, 255, 255);
00021   QColor          selectedColor(225, 225, 255);
00022   QColor selectedCurrFrameColor(195, 225, 225);
00023 
00024   if(option.state & QStyle::State_Selected)
00025   {
00026     painter->fillRect(rect, option.palette.highlight());
00027   }
00028   else
00029   {
00030     if(index.row() == itsSelectedRow)
00031     {
00032       if(itsCurrentFrameIndex == index.column())
00033         painter->fillRect(rect, selectedCurrFrameColor);
00034       else
00035         painter->fillRect(rect, selectedColor);
00036     }
00037     else if(itsCurrentFrameIndex == index.column())
00038       painter->fillRect(rect, currFrameColor);
00039   }
00040 
00041 
00042   FrameType type = FrameType(index.model()->data(index, Qt::DisplayRole).toInt());
00043   if(type == Invisible)
00044     return;
00045 
00046 
00047   painter->setRenderHint(QPainter::Antialiasing, true);
00048   //painter->setBrush(QBrush(Qt::black));
00049   if(type == VisibleKeyframe)
00050   {
00051     int radius = 4;
00052     painter->setBrush(QColor(0, 255, 0));
00053     painter->drawEllipse(QRectF(rect.x() + rect.width()/2 - radius,
00054                                  rect.y() + rect.height()/2 - radius,
00055                                  2*radius, 2*radius));
00056   }
00057   if(type == InvisibleKeyframe)
00058   {
00059     int radius = 4;
00060     painter->setBrush(QColor(255, 0, 0));
00061     painter->drawEllipse(QRectF(rect.x() + rect.width()/2 - radius,
00062                                  rect.y() + rect.height()/2 - radius,
00063                                  2*radius, 2*radius));
00064   }
00065   else if(type == Tween)
00066   {
00067     painter->drawLine(rect.x(),  rect.y() + rect.height()/2,
00068                       rect.x() + rect.width(), rect.y() + rect.height()/2);
00069   }
00070 }
00071 
00072 QSize AnimationDelegate::sizeHint(const QStyleOptionViewItem & /* option */,
00073     const QModelIndex & /* index */) const
00074 {
00075   return QSize(10,10);
00076 }
00077 
00078 void AnimationDelegate::setFrameType(FrameType type)
00079 {
00080   itsFrameType = type;
00081 }
00082 
00083 void AnimationDelegate::frameIndexChanged(int fnum)
00084 {
00085   itsCurrentFrameIndex = fnum;
00086 }
00087 
00088 #endif //ANIMATION_DELEGATE_QT_C
Generated on Sun May 8 08:41:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3