void ModelSelectionPane::FlipAnimationStart(FlipDirection direction)
{
    if(FlipDirection_NULL == direction)
        return;

    if(OnAnimation()) {
        m_animation.setCurrentTime(300);
        m_animation.stop();
    }

    if(FlipDirection_Left == direction) {
        m_curPaneIndex--;
    } else {
        m_curPaneIndex++;
    }

    int source_x = ui->itemsetpane->x();
    int source_y = ui->itemsetpane->y();
    int target_x = m_curPaneIndex * -width();
    int target_y = source_y;

    m_animation.setStartValue(QPoint(source_x, source_y));
    m_animation.setEndValue(QPoint(target_x,target_y));
    m_animation.setTargetObject(ui->itemsetpane);
    m_animation.setDuration(300);
    m_animation.start();
}
bool ModelSelectionPane::PaneIndexDraw()
{
    if((m_curPaneIndex >= m_paneIndexCount) || (m_curPaneIndex < 0) || (OnAnimation()))
        return false;

    if(m_paneIndexCount > 0) {
        int indexPaneW = INDEX_ITEM_SPACE*(m_paneIndexCount+2);
        int indexPaneH = INDEX_PANE_HEIGHT;
        int indexPaneX = (width() - indexPaneW)/2;
        int indexPaneY = ui->indexwidget->y();

        ui->indexwidget->setVisible(true);
        ui->indexwidget->setGeometry(indexPaneX, indexPaneY, indexPaneW, indexPaneH);

        // new index labels
        if(m_indexLabelList.count() < m_paneIndexCount) {
            int mallocLabelCount = m_paneIndexCount - m_indexLabelList.count();
            for(int i = 0; i < mallocLabelCount; i++) {
                QLabel* pIndexLabel = new QLabel(ui->indexwidget);
                pIndexLabel->resize(INDEX_PIXMAP_RADIUS*2, INDEX_PIXMAP_RADIUS*2);
                m_indexLabelList.append(pIndexLabel);
            }
        }

        int x = 0;
        int y = 0;
        for(int i = 0; i < m_indexLabelList.count(); i++) {
            if(i < m_paneIndexCount) {
                m_indexLabelList[i]->setVisible(true);
                m_indexLabelList[i]->setPixmap(i == m_curPaneIndex ? m_selectedPix : m_unselectedPix);
                x = INDEX_ITEM_SPACE*(i+1) - INDEX_PIXMAP_RADIUS;
                y = (INDEX_PANE_HEIGHT - INDEX_PIXMAP_RADIUS*2) / 2;
                m_indexLabelList[i]->move(x, y);
            } else {
                m_indexLabelList[i]->setVisible(false);
            }
        }
    } else {
        ui->indexwidget->setVisible(false);
    }

    return true;
}
Ejemplo n.º 3
0
void GraphBase::UpDateStrategy(QString strategyName)
{

    //存入原来的位置
    this->mAnimationStartPosition.clear();
    for (NodeBase *node : mNodes)
    {
        node->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
        mAnimationStartPosition.push_back(node->scenePos());
    }

    if (strategyName == "Circular")
    {
        vtkSmartPointer<vtkCircularLayoutStrategy> circularStrategy
            = vtkSmartPointer<vtkCircularLayoutStrategy>::New();
        mStoredLayout->SetLayoutStrategy(circularStrategy);
    }
    if (strategyName == "ForceDirected")
    {
        vtkSmartPointer<vtkForceDirectedLayoutStrategy> forceStrategy
            = vtkSmartPointer<vtkForceDirectedLayoutStrategy>::New();
        mStoredLayout->SetLayoutStrategy(forceStrategy);
    }
    if (strategyName == "Fast2D")
    {
        vtkSmartPointer<vtkFast2DLayoutStrategy> fastStrategy
            = vtkSmartPointer<vtkFast2DLayoutStrategy>::New();
        mStoredLayout->SetLayoutStrategy(fastStrategy);
    }

    mStoredLayout->Update();
    mOutPutGraph = mStoredLayout->GetOutput();


    UpdateEndPosition(strategyName);
    QTimeLine *animation = new QTimeLine();
    animation->setUpdateInterval(50);
    connect(animation, SIGNAL(valueChanged(qreal)), this, SLOT(OnAnimation(qreal)));
    connect(animation, SIGNAL(finished()), this, SLOT(OnAnimationEnd()));
    
    animation->start();
}