void DataMarkerLabel::mousePressEvent(QMouseEvent *ev) { m_bMouseMove = false; m_bPressLeft = false; m_moveMode = kMoveMode_None; #if 0 if ( ev->button() != Qt::LeftButton ) { ev->ignore(); return ; } #endif m_oldMousePos = ev->pos(); m_bPressLeft = true; m_pressFrame = m_pressCurrentFrame = -1; ObjectModel *pModel = m_pEditData->getObjectModel(); QModelIndex index = m_pEditData->getSelIndex(); ObjectItem *pItem = pModel->getItemFromIndex(index); // 移動予定のフレームデータ取得 if (ev->y() < height() / 3) { if (pModel->isLayer(index)) { for (int i = m_frameStart; i <= m_frameEnd; i++) { if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1)) { if (pItem->getFrameDataPtr(i)) { m_pressCurrentFrame = m_pressFrame = i; m_moveMode = kMoveMode_Layer; } break; } } } } else if (pModel->isObject(index) && ev->y() < height() * 2 / 3) { for (int i = m_frameStart; i <= m_frameEnd; i++) { if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1)) { if (pItem->getFrameDataPtr(i, true)) { m_pressCurrentFrame = m_pressFrame = i; m_moveMode = kMoveMode_Object; } break; } } } }
void AnimationForm::slot_setColorFromPicker(QRgb rgba) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } int frame = m_pEditData->getSelectFrame() ; ObjectItem *pItem = pModel->getItemFromIndex(index) ; FrameData *pData = pItem->getFrameDataPtr(frame) ; if ( !pData ) { pData = pModel->getFrameDataFromPrevFrame(index, frame, true) ; if ( !pData ) { return ; } FrameData *pNext = pModel->getFrameDataFromNextFrame(index, frame) ; FrameData data = pData->getInterpolation(pNext, frame) ; data.rgba[0] = qRed(rgba) ; data.rgba[1] = qGreen(rgba) ; data.rgba[2] = qBlue(rgba) ; slot_addNewFrameData(index, frame, data); } else { pData->rgba[0] = qRed(rgba) ; pData->rgba[1] = qGreen(rgba) ; pData->rgba[2] = qBlue(rgba) ; addCommandEdit(*pData); } }
FrameData *ObjectItem::getParentFrameDataPtr(int frame) { ObjectItem *parent = m_pParent ; while ( parent ) { FrameData *p = parent->getFrameDataPtr(frame) ; if ( p ) { return p ; } parent = parent->m_pParent ; } return NULL ; }
// 指定フレームのフレームデータを選択する bool AnimationForm::setSelectFrameDataFromFrame( int frame, QModelIndex indexLayer ) { CObjectModel *pModel = m_pEditData->getObjectModel() ; if ( !pModel->isLayer(indexLayer) ) { return false ; } ObjectItem *pItem = pModel->getItemFromIndex(indexLayer) ; FrameData *pData = pItem->getFrameDataPtr(frame) ; if ( !pData ) { return false ; } ui->spinBox_nowSequence->setValue(frame); slot_setUI(*pData); m_pGlWidget->update(); return true ; }
// マウスでのデータ編集終了時 void AnimationForm::slot_frameDataMoveEnd( FrameData dataOld ) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; if ( !pItem ) { return ; } FrameData *p = pItem->getFrameDataPtr(m_pEditData->getSelectFrame()) ; if ( !p ) { return ; } if ( *p != dataOld ) { addCommandEdit(*p, &dataOld) ; } }
// フレームデータ 移動 void AnimationForm::slot_moveFrameData(int prevFrame, int nextFrame) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } if ( prevFrame < 0 || nextFrame < 0 ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; if ( !pItem ) { return ; } if ( !pItem->getFrameDataPtr(prevFrame) ) { return ; } QList<QWidget *> widgets ; widgets << m_pDataMarker << m_pGlWidget ; m_pEditData->cmd_moveFrameData(index, prevFrame, nextFrame, widgets) ; }
// 選択レイヤ変更 void AnimationForm::slot_selectLayerChanged( QModelIndex indexLayer ) { if ( indexLayer.isValid() ) { ui->treeView->setCurrentIndex(indexLayer) ; // m_pEditData->setSelIndex(indexLayer) ; } ObjectItem *p = m_pEditData->getObjectModel()->getItemFromIndex(indexLayer) ; FrameData *pData = p->getFrameDataPtr(m_pEditData->getSelectFrame()) ; if ( pData ) { slot_setUI(*pData) ; } m_pGlWidget->update(); emit sig_changeSelectLayer(indexLayer) ; }
// フレームデータ削除 void AnimationForm::slot_deleteFrameData(void) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !index.isValid() ) { return ; } if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; if ( !pItem ) { return ; } int frame = m_pEditData->getSelectFrame() ; if ( !pItem->getFrameDataPtr(frame) ) { return ; } QList<QWidget *> update ; update << m_pDataMarker << m_pGlWidget ; m_pEditData->cmd_delFrameData(index, frame, update) ; }
void AnimationForm::jumpEndFrame() { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; if ( !pItem ) { return ; } int maxFrame = -1 ; const QList<FrameData> &datas = pItem->getFrameData() ; for ( int i = 0 ; i < datas.size() ; i ++ ) { if ( maxFrame < datas.at(i).frame ) { maxFrame = datas.at(i).frame ; } } if ( !pItem->getFrameDataPtr(maxFrame) ) { return ; } slot_frameChanged(maxFrame) ; }
// 選択レイヤの選択フレームにフレームデータを追加 void AnimationForm::addNowSelectLayerAndFrame( void ) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; if ( !pItem ) { return ; } int frame = m_pEditData->getSelectFrame() ; if ( pItem->getFrameDataPtr(frame) ) { return ; } FrameData *pPrev = pModel->getFrameDataFromPrevFrame(index, frame, true) ; if ( !pPrev ) { return ; } FrameData *pNext = pModel->getFrameDataFromNextFrame(index, frame) ; FrameData data = pPrev->getInterpolation(pNext, frame) ; slot_addNewFrameData(index, frame, data) ; // フレームデータ追加 }
// フレームデータ コピー void AnimationForm::copyFrameData( void ) { CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; FrameData data, *p ; int frame = m_pEditData->getSelectFrame() ; p = pItem->getFrameDataPtr(frame) ; if ( p ) { data = *p ; } else { bool valid ; data = pItem->getDisplayFrameData(frame, &valid) ; if ( !valid ) { return ; } } qDebug() << "Copy Framedata" ; m_pEditData->setCopyFrameData(data) ; }
// フレームデータ ペースト void AnimationForm::pasteFrameData( void ) { if ( !m_pEditData->isCopyData() ) { return ; } CObjectModel *pModel = m_pEditData->getObjectModel() ; QModelIndex index = m_pEditData->getSelIndex() ; if ( !pModel->isLayer(index) ) { return ; } ObjectItem *pItem = pModel->getItemFromIndex(index) ; int frame = m_pEditData->getSelectFrame() ; FrameData *pData = pItem->getFrameDataPtr(frame) ; if ( pData ) { FrameData data = m_pEditData->getCopyFrameData() ; data.frame = frame ; addCommandEdit(data, pData) ; } else { slot_addNewFrameData(index, frame, m_pEditData->getCopyFrameData()) ; // フレームデータ追加 } qDebug() << "Paste Framedata" ; }