⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qgraphicsitemanimation.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    QMatrix matrix;    if (!d->rotation.isEmpty())        matrix.rotate(rotationAt(step));    if (!d->verticalScale.isEmpty())        matrix.scale(horizontalScaleAt(step), verticalScaleAt(step));    if (!d->verticalShear.isEmpty())        matrix.shear(horizontalShearAt(step), verticalShearAt(step));    if (!d->xTranslation.isEmpty())        matrix.translate(xTranslationAt(step), yTranslationAt(step));    return matrix;}/*!  Returns the angle at which the item is rotated at the specified \a step value.  \sa setRotationAt()*/qreal QGraphicsItemAnimation::rotationAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::rotationAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->rotation);}/*!  Sets the rotation of the item at the given \a step value to the \a angle specified.  \sa rotationAt()*/void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle){    d->insertUniquePair(step, angle, &d->rotation, "setRotationAt");}/*!  Returns all explicitly inserted rotations.  \sa rotationAt(), setRotationAt()*/QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const{    QList<QPair<qreal, qreal> > list;    for (int i = 0; i < d->rotation.size(); ++i)        list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);        return list;}/*!  Returns the horizontal translation of the item at the specified \a step value.  \sa setTranslationAt()*/qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::xTranslationAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->xTranslation);}/*!  Returns the vertical translation of the item at the specified \a step value.  \sa setTranslationAt()*/qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::yTranslationAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->yTranslation);}/*!  Sets the translation of the item at the given \a step value using the horizontal  and vertical coordinates specified by \a dx and \a dy.  \sa xTranslationAt(), yTranslationAt()*/void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy){    d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt");    d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt");}/*!  Returns all explicitly inserted translations.  \sa xTranslationAt(), yTranslationAt(), setTranslationAt()*/QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const{    QList<QPair<qreal, QPointF> > list;    for (int i = 0; i < d->xTranslation.size(); ++i)        list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));        return list;}/*!  Returns the vertical scale for the item at the specified \a step value.  \sa setScaleAt()*/qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::verticalScaleAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->verticalScale, 1);}/*!  Returns the horizontal scale for the item at the specified \a step value.  \sa setScaleAt()*/qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::horizontalScaleAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->horizontalScale, 1);}/*!  Sets the scale of the item at the given \a step value using the horizontal and  vertical scale factors specified by \a sx and \a sy.  \sa verticalScaleAt(), horizontalScaleAt()*/void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy){    d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt");    d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt");}/*!  Returns all explicitly inserted scales.  \sa verticalScaleAt(), horizontalScaleAt(), setScaleAt()*/QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const{    QList<QPair<qreal, QPointF> > list;    for (int i = 0; i < d->horizontalScale.size(); ++i)        list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));        return list;}/*!  Returns the vertical shear for the item at the specified \a step value.  \sa setShearAt()*/qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::verticalShearAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->verticalShear, 0);}/*!  Returns the horizontal shear for the item at the specified \a step value.  \sa setShearAt()*/qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const{    if (step < 0.0 || step > 1.0)        qWarning("QGraphicsItemAnimation::horizontalShearAt: invalid step = %f", step);    return d->linearValueForStep(step, &d->horizontalShear, 0);}/*!  Sets the shear of the item at the given \a step value using the horizontal and  vertical shear factors specified by \a sh and \a sv.  \sa verticalShearAt(), horizontalShearAt()*/void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv){    d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt");    d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt");}/*!  Returns all explicitly inserted shears.  \sa verticalShearAt(), horizontalShearAt(), setShearAt()*/QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const{    QList<QPair<qreal, QPointF> > list;    for (int i = 0; i < d->horizontalShear.size(); ++i)        list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));        return list;}/*!  Clears the scheduled transformations used for the animation, but  retains the item and timeline.*/void QGraphicsItemAnimation::clear(){    d->xPosition.clear();    d->yPosition.clear();    d->rotation.clear();    d->verticalScale.clear();    d->horizontalScale.clear();    d->verticalShear.clear();    d->horizontalShear.clear();    d->xTranslation.clear();    d->yTranslation.clear();}/*!  \fn void QGraphicsItemAnimation::setStep(qreal step)  Sets the current \a step value for the animation, causing the  transformations scheduled at this step to be performed.*/void QGraphicsItemAnimation::setStep(qreal x){    if (x < 0.0 || x > 1.0) {        qWarning("QGraphicsItemAnimation::setStep: invalid step = %f", x);        return;    }    beforeAnimationStep(x);    d->step = x;    if (d->item) {        if (!d->xPosition.isEmpty() || !d->yPosition.isEmpty())            d->item->setPos(posAt(x));        if (!d->rotation.isEmpty()            || !d->verticalScale.isEmpty()            || !d->horizontalScale.isEmpty()            || !d->verticalShear.isEmpty()            || !d->horizontalShear.isEmpty()            || !d->xTranslation.isEmpty()            || !d->yTranslation.isEmpty()) {            d->item->setMatrix(d->startMatrix * matrixAt(x));        }    }    afterAnimationStep(x);}/*!Resets the item to its starting position and transformation.*/void QGraphicsItemAnimation::reset(){    if (!d->item)        return;    d->startPos = d->item->pos();    d->startMatrix = d->item->matrix();}/*!  \fn void QGraphicsItemAnimation::beforeAnimationStep(qreal step)  This method is meant to be overridden by subclassed that needs to  execute additional code before a new step takes place. The  animation \a step is provided for use in cases where the action  depends on its value.*/void QGraphicsItemAnimation::beforeAnimationStep(qreal step){    Q_UNUSED(step);}/*!  \fn void QGraphicsItemAnimation::afterAnimationStep(qreal step)  This method is meant to be overridden in subclasses that need to  execute additional code after a new step has taken place. The  animation \a step is provided for use in cases where the action  depends on its value.*/void QGraphicsItemAnimation::afterAnimationStep(qreal step){    Q_UNUSED(step);}#endif // QT_NO_GRAPHICSVIEW

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -