19 #include <QGraphicsRotation>
20 #include <QEasingCurve>
25 #include "rotation_p.h"
30 RotationAnimation::RotationAnimation(
QObject *parent, qint8 reference, Qt::Axis axis, qreal angle)
31 : EasingAnimation(parent),
35 m_reference(reference)
39 RotationAnimation::~RotationAnimation()
43 Qt::Axis RotationAnimation::axis()
const
48 void RotationAnimation::setAxis(
const Qt::Axis &axis)
53 qint8 RotationAnimation::reference()
const
58 void RotationAnimation::setReference(
const qint8 &reference)
60 m_reference = reference;
63 qreal RotationAnimation::angle()
const
68 void RotationAnimation::setAngle(
const qreal &angle)
73 void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
86 const qreal widgetWidth = m_object->size().width();
87 const qreal widgetHeight = m_object->size().height();
89 if (axis() == Qt::XAxis) {
90 switch (reference()) {
92 vector.setX(widgetWidth/2);
93 vector.setY(widgetHeight/2);
96 vector.setX(widgetWidth/2);
100 vector.setX(widgetWidth/2);
101 vector.setY(widgetHeight);
105 }
else if(axis() == Qt::YAxis) {
106 switch (reference()) {
108 vector.setX(widgetWidth/2);
109 vector.setY(widgetHeight/2);
113 vector.setY(widgetHeight/2);
116 vector.setX(widgetWidth);
117 vector.setY(widgetHeight/2);
121 }
else if (axis() == Qt::ZAxis) {
122 switch (reference()) {
124 vector.setX(widgetWidth/2);
125 vector.setY(widgetHeight/2);
129 vector.setX(widgetWidth/2);
134 vector.setX(widgetWidth/2);
135 vector.setY(widgetHeight);
140 vector.setY(widgetHeight/2);
144 vector.setX(widgetWidth);
145 vector.setY(widgetHeight/2);
150 m_rotation->setOrigin(vector);
151 m_rotation->setAxis(axis());
154 transformation.
append(m_rotation);
155 m_object->setTransformations(transformation);
158 void RotationAnimation::updateEffectiveTime(
int currentTime)
160 if (targetWidget()) {
161 qreal delta = currentTime * angle() / qreal(duration());
162 m_rotation->setAngle(delta);
168 #include "rotation_p.moc"
void append(const T &value)