Qt 4.8
Public Slots | Public Functions | Protected Functions | Properties | List of all members
QGraphicsItemAnimation Class Reference

The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem. More...

#include <qgraphicsitemanimation.h>

Inheritance diagram for QGraphicsItemAnimation:
QObject

Public Slots

void reset ()
 Resets the item to its starting position and transformation. More...
 
void setStep (qreal x)
 Sets the current step value for the animation, causing the transformations scheduled at this step to be performed. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

void clear ()
 Clears the scheduled transformations used for the animation, but retains the item and timeline. More...
 
qreal horizontalScaleAt (qreal step) const
 Returns the horizontal scale for the item at the specified step value. More...
 
qreal horizontalShearAt (qreal step) const
 Returns the horizontal shear for the item at the specified step value. More...
 
QGraphicsItemitem () const
 Returns the item on which the animation object operates. More...
 
QMatrix matrixAt (qreal step) const
 Returns the matrix used to transform the item at the specified step value. More...
 
QPointF posAt (qreal step) const
 Returns the position of the item at the given step value. More...
 
QList< QPair< qreal, QPointF > > posList () const
 Returns all explicitly inserted positions. More...
 
 QGraphicsItemAnimation (QObject *parent=0)
 Constructs an animation object with the given parent. More...
 
qreal rotationAt (qreal step) const
 Returns the angle at which the item is rotated at the specified step value. More...
 
QList< QPair< qreal, qreal > > rotationList () const
 Returns all explicitly inserted rotations. More...
 
QList< QPair< qreal, QPointF > > scaleList () const
 Returns all explicitly inserted scales. More...
 
void setItem (QGraphicsItem *item)
 Sets the specified item to be used in the animation. More...
 
void setPosAt (qreal step, const QPointF &pos)
 Sets the position of the item at the given step value to the point specified. More...
 
void setRotationAt (qreal step, qreal angle)
 Sets the rotation of the item at the given step value to the angle specified. More...
 
void setScaleAt (qreal step, qreal sx, qreal sy)
 Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy. More...
 
void setShearAt (qreal step, qreal sh, qreal sv)
 Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv. More...
 
void setTimeLine (QTimeLine *timeLine)
 Sets the timeline object used to control the rate of animation to the timeLine specified. More...
 
void setTranslationAt (qreal step, qreal dx, qreal dy)
 Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy. More...
 
QList< QPair< qreal, QPointF > > shearList () const
 Returns all explicitly inserted shears. More...
 
QTimeLinetimeLine () const
 Returns the timeline object used to control the rate at which the animation occurs. More...
 
QList< QPair< qreal, QPointF > > translationList () const
 Returns all explicitly inserted translations. More...
 
qreal verticalScaleAt (qreal step) const
 Returns the vertical scale for the item at the specified step value. More...
 
qreal verticalShearAt (qreal step) const
 Returns the vertical shear for the item at the specified step value. More...
 
qreal xTranslationAt (qreal step) const
 Returns the horizontal translation of the item at the specified step value. More...
 
qreal yTranslationAt (qreal step) const
 Returns the vertical translation of the item at the specified step value. More...
 
virtual ~QGraphicsItemAnimation ()
 Destroys the animation object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

virtual void 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. More...
 
virtual void beforeAnimationStep (qreal step)
 This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Properties

QGraphicsItemAnimationPrivated
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem.

Since
4.2

The QGraphicsItemAnimation class animates a QGraphicsItem. You can schedule changes to the item's transformation matrix at specified steps. The QGraphicsItemAnimation class has a current step value. When this value changes the transformations scheduled at that step are performed. The current step of the animation is set with the setStep() function.

QGraphicsItemAnimation will do a simple linear interpolation between the nearest adjacent scheduled changes to calculate the matrix. For instance, if you set the position of an item at values 0.0 and 1.0, the animation will show the item moving in a straight line between these positions. The same is true for scaling and rotation.

It is usual to use the class with a QTimeLine. The timeline's QTimeLine::valueChanged() signal is then connected to the setStep() slot. For example, you can set up an item for rotation by calling setRotationAt() for different step values. The animations timeline is set with the setTimeLine() function.

An example animation with a timeline follows:

QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
QTimeLine *timer = new QTimeLine(5000);
timer->setFrameRange(0, 100);
animation->setItem(ball);
animation->setTimeLine(timer);
for (int i = 0; i < 200; ++i)
animation->setPosAt(i / 200.0, QPointF(i, i));
scene->setSceneRect(0, 0, 250, 250);
scene->addItem(ball);
QGraphicsView *view = new QGraphicsView(scene);
view->show();
timer->start();

Note that steps lie between 0.0 and 1.0. It may be necessary to use QTimeLine::setUpdateInterval(). The default update interval is 40 ms. A scheduled transformation cannot be removed when set, so scheduling several transformations of the same kind (e.g., rotations) at the same step is not recommended.

See also
QTimeLine, {Graphics View Framework}

Definition at line 62 of file qgraphicsitemanimation.h.

Constructors and Destructors

◆ QGraphicsItemAnimation()

QGraphicsItemAnimation::QGraphicsItemAnimation ( QObject parent = 0)

Constructs an animation object with the given parent.

Definition at line 191 of file qgraphicsitemanimation.cpp.

192  : QObject(parent), d(new QGraphicsItemAnimationPrivate)
193 {
194  d->q = this;
195 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
QGraphicsItemAnimationPrivate * d

◆ ~QGraphicsItemAnimation()

QGraphicsItemAnimation::~QGraphicsItemAnimation ( )
virtual

Destroys the animation object.

Definition at line 200 of file qgraphicsitemanimation.cpp.

201 {
202  delete d;
203 }
QGraphicsItemAnimationPrivate * d

Functions

◆ afterAnimationStep()

void QGraphicsItemAnimation::afterAnimationStep ( qreal  step)
protectedvirtual

This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place.

The animation step is provided for use in cases where the action depends on its value.

Definition at line 607 of file qgraphicsitemanimation.cpp.

Referenced by setStep().

608 {
609  Q_UNUSED(step);
610 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ beforeAnimationStep()

void QGraphicsItemAnimation::beforeAnimationStep ( qreal  step)
protectedvirtual

This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place.

The animation step is provided for use in cases where the action depends on its value.

Definition at line 591 of file qgraphicsitemanimation.cpp.

Referenced by setStep().

592 {
593  Q_UNUSED(step);
594 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ clear()

void QGraphicsItemAnimation::clear ( )

Clears the scheduled transformations used for the animation, but retains the item and timeline.

Definition at line 516 of file qgraphicsitemanimation.cpp.

517 {
518  d->xPosition.clear();
519  d->yPosition.clear();
520  d->rotation.clear();
521  d->verticalScale.clear();
522  d->horizontalScale.clear();
523  d->verticalShear.clear();
524  d->horizontalShear.clear();
525  d->xTranslation.clear();
526  d->yTranslation.clear();
527 }
QGraphicsItemAnimationPrivate * d

◆ horizontalScaleAt()

qreal QGraphicsItemAnimation::horizontalScaleAt ( qreal  step) const

Returns the horizontal scale for the item at the specified step value.

See also
setScaleAt()

Definition at line 426 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

427 {
428  if (step < 0.0 || step > 1.0)
429  qWarning("QGraphicsItemAnimation::horizontalScaleAt: invalid step = %f", step);
430 
431  return d->linearValueForStep(step, &d->horizontalScale, 1);
432 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ horizontalShearAt()

qreal QGraphicsItemAnimation::horizontalShearAt ( qreal  step) const

Returns the horizontal shear for the item at the specified step value.

See also
setShearAt()

Definition at line 478 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

479 {
480  if (step < 0.0 || step > 1.0)
481  qWarning("QGraphicsItemAnimation::horizontalShearAt: invalid step = %f", step);
482 
483  return d->linearValueForStep(step, &d->horizontalShear, 0);
484 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ item()

QGraphicsItem * QGraphicsItemAnimation::item ( ) const

Returns the item on which the animation object operates.

See also
setItem()

Definition at line 210 of file qgraphicsitemanimation.cpp.

Referenced by setItem().

211 {
212  return d->item;
213 }
QGraphicsItemAnimationPrivate * d

◆ matrixAt()

QMatrix QGraphicsItemAnimation::matrixAt ( qreal  step) const

Returns the matrix used to transform the item at the specified step value.

Definition at line 302 of file qgraphicsitemanimation.cpp.

Referenced by setStep().

303 {
304  if (step < 0.0 || step > 1.0)
305  qWarning("QGraphicsItemAnimation::matrixAt: invalid step = %f", step);
306 
307  QMatrix matrix;
308  if (!d->rotation.isEmpty())
309  matrix.rotate(rotationAt(step));
310  if (!d->verticalScale.isEmpty())
311  matrix.scale(horizontalScaleAt(step), verticalScaleAt(step));
312  if (!d->verticalShear.isEmpty())
313  matrix.shear(horizontalShearAt(step), verticalShearAt(step));
314  if (!d->xTranslation.isEmpty())
315  matrix.translate(xTranslationAt(step), yTranslationAt(step));
316  return matrix;
317 }
qreal verticalScaleAt(qreal step) const
Returns the vertical scale for the item at the specified step value.
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
qreal xTranslationAt(qreal step) const
Returns the horizontal translation of the item at the specified step value.
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
Q_CORE_EXPORT void qWarning(const char *,...)
QMatrix & shear(qreal sh, qreal sv)
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the mat...
Definition: qmatrix.cpp:957
qreal horizontalScaleAt(qreal step) const
Returns the horizontal scale for the item at the specified step value.
qreal verticalShearAt(qreal step) const
Returns the vertical shear for the item at the specified step value.
qreal horizontalShearAt(qreal step) const
Returns the horizontal shear for the item at the specified step value.
QGraphicsItemAnimationPrivate * d
QMatrix & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qmatrix.cpp:941
qreal rotationAt(qreal step) const
Returns the angle at which the item is rotated at the specified step value.
qreal yTranslationAt(qreal step) const
Returns the vertical translation of the item at the specified step value.

◆ posAt()

QPointF QGraphicsItemAnimation::posAt ( qreal  step) const

Returns the position of the item at the given step value.

See also
setPosAt()

Definition at line 260 of file qgraphicsitemanimation.cpp.

Referenced by setStep().

261 {
262  if (step < 0.0 || step > 1.0)
263  qWarning("QGraphicsItemAnimation::posAt: invalid step = %f", step);
264 
265  return QPointF(d->linearValueForStep(step, &d->xPosition, d->startPos.x()),
266  d->linearValueForStep(step, &d->yPosition, d->startPos.y()));
267 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ posList()

QList< QPair< qreal, QPointF > > QGraphicsItemAnimation::posList ( ) const

Returns all explicitly inserted positions.

See also
posAt(), setPosAt()

Definition at line 290 of file qgraphicsitemanimation.cpp.

291 {
293  for (int i = 0; i < d->xPosition.size(); ++i)
294  list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
295 
296  return list;
297 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QGraphicsItemAnimationPrivate * d
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ reset

void QGraphicsItemAnimation::reset ( )
slot

Resets the item to its starting position and transformation.

You can call setStep(0) instead.

Definition at line 572 of file qgraphicsitemanimation.cpp.

573 {
574  if (!d->item)
575  return;
576  d->startPos = d->item->pos();
577  d->startMatrix = d->item->matrix();
578 }
QPointF pos() const
Returns the position of the item in parent coordinates.
QMatrix matrix() const
Returns the item&#39;s affine transformation matrix.
QGraphicsItemAnimationPrivate * d

◆ rotationAt()

qreal QGraphicsItemAnimation::rotationAt ( qreal  step) const

Returns the angle at which the item is rotated at the specified step value.

See also
setRotationAt()

Definition at line 324 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

325 {
326  if (step < 0.0 || step > 1.0)
327  qWarning("QGraphicsItemAnimation::rotationAt: invalid step = %f", step);
328 
329  return d->linearValueForStep(step, &d->rotation);
330 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ rotationList()

QList< QPair< qreal, qreal > > QGraphicsItemAnimation::rotationList ( ) const

Returns all explicitly inserted rotations.

See also
rotationAt(), setRotationAt()

Definition at line 347 of file qgraphicsitemanimation.cpp.

348 {
350  for (int i = 0; i < d->rotation.size(); ++i)
351  list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
352 
353  return list;
354 }
QGraphicsItemAnimationPrivate * d
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ scaleList()

QList< QPair< qreal, QPointF > > QGraphicsItemAnimation::scaleList ( ) const

Returns all explicitly inserted scales.

See also
verticalScaleAt(), horizontalScaleAt(), setScaleAt()

Definition at line 451 of file qgraphicsitemanimation.cpp.

452 {
454  for (int i = 0; i < d->horizontalScale.size(); ++i)
455  list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
456 
457  return list;
458 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QGraphicsItemAnimationPrivate * d
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ setItem()

void QGraphicsItemAnimation::setItem ( QGraphicsItem item)

Sets the specified item to be used in the animation.

See also
item()

Definition at line 220 of file qgraphicsitemanimation.cpp.

221 {
222  d->item = item;
223  d->startPos = d->item->pos();
224 }
QPointF pos() const
Returns the position of the item in parent coordinates.
QGraphicsItem * item() const
Returns the item on which the animation object operates.
QGraphicsItemAnimationPrivate * d

◆ setPosAt()

void QGraphicsItemAnimation::setPosAt ( qreal  step,
const QPointF point 
)

Sets the position of the item at the given step value to the point specified.

See also
posAt()

Definition at line 279 of file qgraphicsitemanimation.cpp.

280 {
281  d->insertUniquePair(step, pos.x(), &d->xPosition, "setPosAt");
282  d->insertUniquePair(step, pos.y(), &d->yPosition, "setPosAt");
283 }
void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
QGraphicsItemAnimationPrivate * d

◆ setRotationAt()

void QGraphicsItemAnimation::setRotationAt ( qreal  step,
qreal  angle 
)

Sets the rotation of the item at the given step value to the angle specified.

See also
rotationAt()

Definition at line 337 of file qgraphicsitemanimation.cpp.

338 {
339  d->insertUniquePair(step, angle, &d->rotation, "setRotationAt");
340 }
void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
qreal angle(const QPointF &p1, const QPointF &p2)
QGraphicsItemAnimationPrivate * d

◆ setScaleAt()

void QGraphicsItemAnimation::setScaleAt ( qreal  step,
qreal  sx,
qreal  sy 
)

Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy.

See also
verticalScaleAt(), horizontalScaleAt()

Definition at line 440 of file qgraphicsitemanimation.cpp.

441 {
442  d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt");
443  d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt");
444 }
void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
QGraphicsItemAnimationPrivate * d

◆ setShearAt()

void QGraphicsItemAnimation::setShearAt ( qreal  step,
qreal  sh,
qreal  sv 
)

Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv.

See also
verticalShearAt(), horizontalShearAt()

Definition at line 492 of file qgraphicsitemanimation.cpp.

493 {
494  d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt");
495  d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt");
496 }
void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
QGraphicsItemAnimationPrivate * d

◆ setStep

void QGraphicsItemAnimation::setStep ( qreal  x)
slot

Sets the current step value for the animation, causing the transformations scheduled at this step to be performed.

Definition at line 538 of file qgraphicsitemanimation.cpp.

Referenced by setTimeLine().

539 {
540  if (x < 0.0 || x > 1.0) {
541  qWarning("QGraphicsItemAnimation::setStep: invalid step = %f", x);
542  return;
543  }
544 
546 
547  d->step = x;
548  if (d->item) {
549  if (!d->xPosition.isEmpty() || !d->yPosition.isEmpty())
550  d->item->setPos(posAt(x));
551  if (!d->rotation.isEmpty()
552  || !d->verticalScale.isEmpty()
553  || !d->horizontalScale.isEmpty()
554  || !d->verticalShear.isEmpty()
555  || !d->horizontalShear.isEmpty()
556  || !d->xTranslation.isEmpty()
557  || !d->yTranslation.isEmpty()) {
559  }
560  }
561 
563 }
void setMatrix(const QMatrix &matrix, bool combine=false)
Sets the item&#39;s affine transformation matrix.
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.
QMatrix matrixAt(qreal step) const
Returns the matrix used to transform the item at the specified step value.
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void beforeAnimationStep(qreal step)
This method is meant to be overridden by subclassed that needs to execute additional code before a ne...
QGraphicsItemAnimationPrivate * d
QPointF posAt(qreal step) const
Returns the position of the item at the given step value.
virtual void afterAnimationStep(qreal step)
This method is meant to be overridden in subclasses that need to execute additional code after a new ...

◆ setTimeLine()

void QGraphicsItemAnimation::setTimeLine ( QTimeLine timeLine)

Sets the timeline object used to control the rate of animation to the timeLine specified.

See also
timeLine()

Definition at line 243 of file qgraphicsitemanimation.cpp.

244 {
245  if (d->timeLine == timeLine)
246  return;
247  if (d->timeLine)
248  delete d->timeLine;
249  if (!timeLine)
250  return;
251  d->timeLine = timeLine;
252  connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setStep(qreal)));
253 }
double qreal
Definition: qglobal.h:1193
#define SLOT(a)
Definition: qobjectdefs.h:226
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QTimeLine * timeLine() const
Returns the timeline object used to control the rate at which the animation occurs.
void setStep(qreal x)
Sets the current step value for the animation, causing the transformations scheduled at this step to ...
QGraphicsItemAnimationPrivate * d

◆ setTranslationAt()

void QGraphicsItemAnimation::setTranslationAt ( qreal  step,
qreal  dx,
qreal  dy 
)

Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy.

See also
xTranslationAt(), yTranslationAt()

Definition at line 388 of file qgraphicsitemanimation.cpp.

389 {
390  d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt");
391  d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt");
392 }
void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
QGraphicsItemAnimationPrivate * d

◆ shearList()

QList< QPair< qreal, QPointF > > QGraphicsItemAnimation::shearList ( ) const

Returns all explicitly inserted shears.

See also
verticalShearAt(), horizontalShearAt(), setShearAt()

Definition at line 503 of file qgraphicsitemanimation.cpp.

504 {
506  for (int i = 0; i < d->horizontalShear.size(); ++i)
507  list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
508 
509  return list;
510 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QGraphicsItemAnimationPrivate * d
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ timeLine()

QTimeLine * QGraphicsItemAnimation::timeLine ( ) const

Returns the timeline object used to control the rate at which the animation occurs.

See also
setTimeLine()

Definition at line 232 of file qgraphicsitemanimation.cpp.

Referenced by setTimeLine().

233 {
234  return d->timeLine;
235 }
QGraphicsItemAnimationPrivate * d

◆ translationList()

QList< QPair< qreal, QPointF > > QGraphicsItemAnimation::translationList ( ) const

Returns all explicitly inserted translations.

See also
xTranslationAt(), yTranslationAt(), setTranslationAt()

Definition at line 399 of file qgraphicsitemanimation.cpp.

400 {
402  for (int i = 0; i < d->xTranslation.size(); ++i)
403  list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
404 
405  return list;
406 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QGraphicsItemAnimationPrivate * d
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ verticalScaleAt()

qreal QGraphicsItemAnimation::verticalScaleAt ( qreal  step) const

Returns the vertical scale for the item at the specified step value.

See also
setScaleAt()

Definition at line 413 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

414 {
415  if (step < 0.0 || step > 1.0)
416  qWarning("QGraphicsItemAnimation::verticalScaleAt: invalid step = %f", step);
417 
418  return d->linearValueForStep(step, &d->verticalScale, 1);
419 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ verticalShearAt()

qreal QGraphicsItemAnimation::verticalShearAt ( qreal  step) const

Returns the vertical shear for the item at the specified step value.

See also
setShearAt()

Definition at line 465 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

466 {
467  if (step < 0.0 || step > 1.0)
468  qWarning("QGraphicsItemAnimation::verticalShearAt: invalid step = %f", step);
469 
470  return d->linearValueForStep(step, &d->verticalShear, 0);
471 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ xTranslationAt()

qreal QGraphicsItemAnimation::xTranslationAt ( qreal  step) const

Returns the horizontal translation of the item at the specified step value.

See also
setTranslationAt()

Definition at line 361 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

362 {
363  if (step < 0.0 || step > 1.0)
364  qWarning("QGraphicsItemAnimation::xTranslationAt: invalid step = %f", step);
365 
366  return d->linearValueForStep(step, &d->xTranslation);
367 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

◆ yTranslationAt()

qreal QGraphicsItemAnimation::yTranslationAt ( qreal  step) const

Returns the vertical translation of the item at the specified step value.

See also
setTranslationAt()

Definition at line 374 of file qgraphicsitemanimation.cpp.

Referenced by matrixAt().

375 {
376  if (step < 0.0 || step > 1.0)
377  qWarning("QGraphicsItemAnimation::yTranslationAt: invalid step = %f", step);
378 
379  return d->linearValueForStep(step, &d->yTranslation);
380 }
Q_CORE_EXPORT void qWarning(const char *,...)
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimationPrivate * d

Properties

◆ d

QGraphicsItemAnimationPrivate* QGraphicsItemAnimation::d
private

The documentation for this class was generated from the following files: