88 #ifndef QT_NO_GRAPHICSVIEW 92 #include <QtCore/qtimeline.h> 93 #include <QtCore/qpoint.h> 94 #include <QtCore/qpointer.h> 95 #include <QtCore/qpair.h> 96 #include <QtGui/qmatrix.h> 120 {
return step < other.
step; }
122 {
return step == other.
step; }
144 step = qMin<qreal>(qMax<qreal>(
step, 0), 1);
147 return source->
last().value;
149 qreal stepBefore = 0;
151 qreal valueBefore = source->
first().step == 0 ? source->
first().value : defaultValue;
155 for (
int i = 0; i < source->
size() && step >= source->
at(i).step; ++i) {
156 stepBefore = source->
at(i).step;
157 valueBefore = source->
at(i).value;
161 for (
int j = source->
size() - 1; j >= 0 && step < source->
at(j).step; --j) {
162 stepAfter = source->
at(j).step;
163 valueAfter = source->
at(j).value;
167 return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
172 if (step < 0.0 || step > 1.0) {
173 qWarning(
"QGraphicsItemAnimation::%s: invalid step = %f", method, step);
177 Pair pair(step, value);
180 if (result != binList->
end())
181 result->value = value;
262 if (step < 0.0 || step > 1.0)
263 qWarning(
"QGraphicsItemAnimation::posAt: invalid step = %f", step);
304 if (step < 0.0 || step > 1.0)
305 qWarning(
"QGraphicsItemAnimation::matrixAt: invalid step = %f", step);
326 if (step < 0.0 || step > 1.0)
327 qWarning(
"QGraphicsItemAnimation::rotationAt: invalid step = %f", step);
350 for (
int i = 0; i <
d->
rotation.size(); ++i)
363 if (step < 0.0 || step > 1.0)
364 qWarning(
"QGraphicsItemAnimation::xTranslationAt: invalid step = %f", step);
376 if (step < 0.0 || step > 1.0)
377 qWarning(
"QGraphicsItemAnimation::yTranslationAt: invalid step = %f", step);
415 if (step < 0.0 || step > 1.0)
416 qWarning(
"QGraphicsItemAnimation::verticalScaleAt: invalid step = %f", step);
428 if (step < 0.0 || step > 1.0)
429 qWarning(
"QGraphicsItemAnimation::horizontalScaleAt: invalid step = %f", step);
467 if (step < 0.0 || step > 1.0)
468 qWarning(
"QGraphicsItemAnimation::verticalShearAt: invalid step = %f", step);
480 if (step < 0.0 || step > 1.0)
481 qWarning(
"QGraphicsItemAnimation::horizontalShearAt: invalid step = %f", step);
540 if (x < 0.0 || x > 1.0) {
541 qWarning(
"QGraphicsItemAnimation::setStep: invalid step = %f", x);
614 #endif // QT_NO_GRAPHICSVIEW void insertUniquePair(qreal step, qreal value, QList< Pair > *binList, const char *method)
QList< QPair< qreal, QPointF > > shearList() const
Returns all explicitly inserted shears.
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 sp...
void reset()
Resets the item to its starting position and transformation.
#define QT_END_NAMESPACE
This macro expands to.
void clear()
Clears the scheduled transformations used for the animation, but retains the item and timeline...
QList< QPair< qreal, qreal > > rotationList() const
Returns all explicitly inserted rotations.
void setPosAt(qreal step, const QPointF &pos)
Sets the position of the item at the given step value to the point specified.
void setTimeLine(QTimeLine *timeLine)
Sets the timeline object used to control the rate of animation to the timeLine specified.
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.
void setMatrix(const QMatrix &matrix, bool combine=false)
Sets the item's affine transformation matrix.
QList< Pair > yTranslation
void setTranslationAt(qreal step, qreal dx, qreal dy)
Sets the translation of the item at the given step value using the horizontal and vertical coordinate...
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
QPointF pos() const
Returns the position of the item in parent coordinates.
long ASN1_INTEGER_get ASN1_INTEGER * a
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 sp...
QList< Pair > verticalScale
The QObject class is the base class of all Qt objects.
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.
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...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
qreal xTranslationAt(qreal step) const
Returns the horizontal translation of the item at the specified step value.
qreal x() const
Returns the x-coordinate of this point.
The QTimeLine class provides a timeline for controlling animations.
QMatrix matrix() const
Returns the item's affine transformation matrix.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem.
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
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...
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
const T & at(int i) const
Returns the item at index position i in the list.
QMatrix matrixAt(qreal step) const
Returns the matrix used to transform the item at the specified step value.
QGraphicsItem * item() const
Returns the item on which the animation object operates.
Q_CORE_EXPORT void qWarning(const char *,...)
QList< Pair > horizontalScale
void setRotationAt(qreal step, qreal angle)
Sets the rotation of the item at the given step value to the angle specified.
QMatrix & shear(qreal sh, qreal sv)
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the mat...
QTimeLine * timeLine() const
Returns the timeline object used to control the rate at which the animation occurs.
void qSort(RandomAccessIterator start, RandomAccessIterator end)
QList< QPair< qreal, QPointF > > posList() const
Returns all explicitly inserted positions.
void setStep(qreal x)
Sets the current step value for the animation, causing the transformations scheduled at this step to ...
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
T & first()
Returns a reference to the first item in the list.
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 angle(const QPointF &p1, const QPointF &p2)
virtual void beforeAnimationStep(qreal step)
This method is meant to be overridden by subclassed that needs to execute additional code before a ne...
qreal linearValueForStep(qreal step, QList< Pair > *source, qreal defaultValue=0)
QGraphicsItemAnimation * q
QList< Pair > xTranslation
QPointer< QTimeLine > timeLine
qreal horizontalShearAt(qreal step) const
Returns the horizontal shear for the item at the specified step value.
T & last()
Returns a reference to the last item in the list.
int size() const
Returns the number of items in the list.
QGraphicsItemAnimation(QObject *parent=0)
Constructs an animation object with the given parent.
QGraphicsItemAnimationPrivate * d
qreal y() const
Returns the y-coordinate of this point.
QList< QPair< qreal, QPointF > > scaleList() const
Returns all explicitly inserted scales.
bool operator<(const Pair &other) const
QGraphicsItemAnimationPrivate()
QList< QPair< qreal, QPointF > > translationList() const
Returns all explicitly inserted translations.
bool operator==(const Pair &other) const
QMatrix & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
QPointF posAt(qreal step) const
Returns the position of the item at the given step value.
QList< Pair > verticalShear
qreal rotationAt(qreal step) const
Returns the angle at which the item is rotated at the specified 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 ...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
virtual ~QGraphicsItemAnimation()
Destroys the animation object.
QList< Pair > horizontalShear
void setItem(QGraphicsItem *item)
Sets the specified item to be used in the animation.
The QList class is a template class that provides lists.
qreal yTranslationAt(qreal step) const
Returns the vertical translation of the item at the specified step value.