Ejemplo n.º 1
0
void EditorView::startAnimation(char const *slot)
{
    QTimeLine *anim = new QTimeLine(zoomAnimationTimes * zoomAnimationInterval, this);
    anim->setUpdateInterval(zoomAnimationInterval);

    connect(anim, SIGNAL(valueChanged(qreal)), this, slot);
    connect(anim, SIGNAL(finished()), this, SLOT(animFinished()));
    anim->start();
}
void LinkDialogProcessorGraphicsItem::animationStart() {
    animateExpansion_ = 0.1f;

    QTimeLine* anim = new QTimeLine(50, this);
    anim->setUpdateInterval(20);
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(animate(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(animationEnd()));
    anim->start();
}
Ejemplo n.º 3
0
void LinkDialogGraphicsScene::wheelAction(float offset) {
    currentScrollSteps_ = offset;

    QTimeLine* anim = new QTimeLine(750, this);
    anim->setUpdateInterval(20);
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(executeTimeLine(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(terminateTimeLine()));
    anim->start();
}
Ejemplo n.º 4
0
void MyQGraphicsView::wheelEvent ( QWheelEvent * event )
{
    int numDegrees = event->delta() / 8;
    int numSteps = numDegrees / 15;  // see QWheelEvent documentation
    _numScheduledScalings += numSteps;
    if (_numScheduledScalings * numSteps < 0)  // if user moved the wheel in another direction, we reset previously scheduled scalings
        _numScheduledScalings = numSteps;
 
    QTimeLine *anim = new QTimeLine(350, this);
    anim->setUpdateInterval(50);
 
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(scalingTime(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(animFinished()));
    anim->start();
}
Ejemplo n.º 5
0
void PathologyViewer::zoom(float numSteps) {
  if (!_img) {
    return;
  }
  _numScheduledScalings += numSteps;
  if (_numScheduledScalings * numSteps < 0)  {
    _numScheduledScalings = numSteps;
  }

  QTimeLine *anim = new QTimeLine(300, this);
  anim->setUpdateInterval(5);

  connect(anim, SIGNAL(valueChanged(qreal)), SLOT(scalingTime(qreal)));
  connect(anim, SIGNAL(finished()), SLOT(zoomFinished()));
  anim->start();
}
Ejemplo n.º 6
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();
}
Ejemplo n.º 7
0
//cppcheck-suppress unusedFunction
void VMainGraphicsView::wheelEvent(QWheelEvent *event)
{
    int numSteps = event->delta() / 8 / 15;  // see QWheelEvent documentation

    _numScheduledScalings += numSteps;
    if (_numScheduledScalings * numSteps < 0)
    {  // if user moved the wheel in another direction, we reset
        _numScheduledScalings = numSteps;       // previously scheduled scalings
    }

    QTimeLine *anim = new QTimeLine(300, this);
    anim->setUpdateInterval(20);

    if (QApplication::keyboardModifiers() == Qt::ControlModifier)
    {// If you press CTRL this code will be executed
        connect(anim, &QTimeLine::valueChanged, this, &VMainGraphicsView::scalingTime);
    }
    else
    {
        connect(anim, &QTimeLine::valueChanged, this, &VMainGraphicsView::scrollingTime);
    }
    connect(anim, &QTimeLine::finished, this, &VMainGraphicsView::animFinished);
    anim->start();
}
Ejemplo n.º 8
0
void PointSetAnnotationTool::keyPressEvent(QKeyEvent *event) {
  if (event->key() == Qt::Key::Key_Escape) {
    cancelAnnotation();
  }
  else if (event->key() == Qt::Key::Key_Delete && event->modifiers() == Qt::ShiftModifier) {
    if (_generating) {
      cancelAnnotation();
    }
    else {
      QSet<QtAnnotation*> selectedAnnotations = _annotationPlugin->getSelectedAnnotations();
      for (QSet<QtAnnotation*>::iterator it = selectedAnnotations.begin(); it != selectedAnnotations.end(); ++it) {
        _annotationPlugin->deleteAnnotation(*it);
      }
    }
  }
  else if (event->key() == Qt::Key::Key_Delete) {
    if (_generating) {
      if (_annotationPlugin->getGeneratedAnnotation()->getAnnotation()->getCoordinates().size() < 2) {
        cancelAnnotation();
      }
      else {
        _annotationPlugin->getGeneratedAnnotation()->removeCoordinate(-1);
        if (!_annotationPlugin->getGeneratedAnnotation()->getAnnotation()->getCoordinates().empty()) {
          Point prev = _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->getCoordinate(-1);
          _last = Point(prev.getX() * _viewer->getSceneScale(), prev.getY() * _viewer->getSceneScale());
        }
      }
    }
    else if (_annotationPlugin->getActiveAnnotation()) {
      if (_annotationPlugin->getActiveAnnotation()->getAnnotation()->getCoordinates().size() <= 1) {
        _annotationPlugin->deleteAnnotation(_annotationPlugin->getActiveAnnotation());
      }
      else if (_annotationPlugin->getActiveAnnotation()->getActiveSeedPoint() > -1) {
        int activeSeedPoint = _annotationPlugin->getActiveAnnotation()->getActiveSeedPoint();
        _annotationPlugin->getActiveAnnotation()->removeCoordinate(activeSeedPoint);
        if (activeSeedPoint - 1 >= 0) {
          _annotationPlugin->getActiveAnnotation()->setActiveSeedPoint(activeSeedPoint - 1);
        }
        else {
          _annotationPlugin->getActiveAnnotation()->setActiveSeedPoint(_annotationPlugin->getActiveAnnotation()->getAnnotation()->getCoordinates().size() - 1);
        }
      }
      else if (_annotationPlugin->getActiveAnnotation()) {
        _annotationPlugin->getActiveAnnotation()->removeCoordinate(-1);
      }
    }
  }
  else if (event->key() == Qt::Key::Key_Z) {
    if (_annotationPlugin->getActiveAnnotation()) {
      QTimeLine * anim = new QTimeLine(500);

      _start_zoom = _viewer->mapToScene(_viewer->viewport()->rect()).boundingRect();
      _end_zoom = _annotationPlugin->getActiveAnnotation()->mapToScene(_annotationPlugin->getActiveAnnotation()->boundingRect()).boundingRect();
      anim->setFrameRange(0, 100);
      anim->setUpdateInterval(5);

      connect(anim, SIGNAL(valueChanged(qreal)), SLOT(zoomToAnnotation(qreal)));
      connect(anim, SIGNAL(finished()), SLOT(zoomToAnnotationFinished()));
      anim->start();
    }
  }
}