void ObjectItem::applyFrameDataFromParent() { QList<FrameData> datas ; for ( int i = 0 ; i < m_frameDatas.size() ; i ++ ) { FrameData data = m_frameDatas[i] ; bool valid ; QMatrix4x4 mat = getDisplayMatrix(data.frame, &valid) ; if ( !valid ) { continue ; } data.applyMatrix(mat) ; datas.append(data) ; } FrameData old ; int frame = getParentFrameMax() ; for ( int i = 0 ; i < frame ; i ++ ) { if ( getFrameDataPtr(i) ) { old = *getFrameDataPtr(i) ; continue ; } FrameData *parent = getParentFrameDataPtr(i) ; if ( !parent ) { continue ; } bool valid ; FrameData data ; data = getDisplayFrameData(i, &valid) ; if ( !valid ) { continue ; } QMatrix4x4 mat = getDisplayMatrix(i, &valid) ; if ( !valid ) { continue ; } data.applyMatrix(mat) ; if ( !(old.frame&0x8000) ) { if ( old.rot_z != data.rot_z ) { for ( int j = old.frame + 1 ; j < data.frame ; j ++ ) { bool b ; FrameData tmp = getDisplayFrameData(j, &b) ; if ( !b ) { continue ; } QMatrix4x4 mat = getDisplayMatrix(j, &b) ; if ( !b ) { continue ; } tmp.applyMatrix(mat); datas.append(tmp) ; } } } old = data ; datas.append(data); } m_frameDatas = datas ; }
bool ObjectItem::isContain(ObjectItem **ppRet, QPoint &pos, int frame, bool bChild, bool bCheckFlag) { if (bChild) { for (int i = childCount() - 1; i >= 0; i--) { if (child(i)->isContain(ppRet, pos, frame, true)) { return true; } } } if (bCheckFlag) { int flag = data(Qt::CheckStateRole).toInt(); if (!(flag & kState_Disp) || (flag & kState_Lock)) { // 非表示 return false; } } bool valid; FrameData d = getDisplayFrameData(frame, &valid); if (valid && isContain(d, pos, getDisplayMatrix(frame))) { *ppRet = this; return true; } return false; }
QPointF ObjectItem::getBezierPos(int frame, bool *pValid) { FrameData *pPrev = getFrameDataFromPrevFrame(frame+1) ; FrameData *pNext = getFrameDataFromNextFrame(frame) ; QMatrix4x4 m0, m1 ; QList<QPointF> list ; bool valid ; float t ; if ( !pPrev || !pNext || (!pPrev->path[0].bValid && !pNext->path[1].bValid) ) { goto __FAILED ; } if ( pNext->frame-pPrev->frame == 0 ) { qDebug() << "Error same frame" ; goto __FAILED ; } m0 = getDisplayMatrix(pPrev->frame, &valid) ; if ( !valid ) { goto __FAILED ; } if ( frame == pPrev->frame ) { if ( pValid ) { *pValid = true ; } return QPointF(m0.column(3).x(), m0.column(3).y()) ; } m1 = getDisplayMatrix(pNext->frame, &valid) ; if ( !valid ) { goto __FAILED ; } if ( frame == pNext->frame ) { if ( pValid ) { *pValid = true ; } return QPointF(m0.column(3).x(), m0.column(3).y()) ; } list << QPointF(m0.column(3).x(), m0.column(3).y()) ; list << QPointF(m0.column(3).x() + pPrev->path[0].v.x(), m0.column(3).y() + pPrev->path[0].v.y()) ; list << QPointF(m1.column(3).x() + pNext->path[1].v.x(), m1.column(3).y() + pNext->path[1].v.y()) ; list << QPointF(m1.column(3).x(), m1.column(3).y()) ; t = (frame-pPrev->frame) / (float)(pNext->frame-pPrev->frame) ; if ( pValid ) { *pValid = true ; } return util::getBezierPoint(list, t) ; __FAILED: if ( pValid ) { *pValid = false ; } return QPointF(0, 0) ; }