Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QGraphicsItemAnimationPrivate Class Reference

Classes

struct  Pair
 

Public Functions

void insertUniquePair (qreal step, qreal value, QList< Pair > *binList, const char *method)
 
qreal linearValueForStep (qreal step, QList< Pair > *source, qreal defaultValue=0)
 
 QGraphicsItemAnimationPrivate ()
 

Public Variables

QList< PairhorizontalScale
 
QList< PairhorizontalShear
 
QGraphicsItemitem
 
QGraphicsItemAnimationq
 
QList< Pairrotation
 
QMatrix startMatrix
 
QPointF startPos
 
qreal step
 
QPointer< QTimeLinetimeLine
 
QList< PairverticalScale
 
QList< PairverticalShear
 
QList< PairxPosition
 
QList< PairxTranslation
 
QList< PairyPosition
 
QList< PairyTranslation
 

Detailed Description

Definition at line 100 of file qgraphicsitemanimation.cpp.

Constructors and Destructors

◆ QGraphicsItemAnimationPrivate()

QGraphicsItemAnimationPrivate::QGraphicsItemAnimationPrivate ( )
inline

Definition at line 103 of file qgraphicsitemanimation.cpp.

Functions

◆ insertUniquePair()

void QGraphicsItemAnimationPrivate::insertUniquePair ( qreal  step,
qreal  value,
QList< Pair > *  binList,
const char *  method 
)

Definition at line 170 of file qgraphicsitemanimation.cpp.

Referenced by QGraphicsItemAnimation::setPosAt(), QGraphicsItemAnimation::setRotationAt(), QGraphicsItemAnimation::setScaleAt(), QGraphicsItemAnimation::setShearAt(), and QGraphicsItemAnimation::setTranslationAt().

171 {
172  if (step < 0.0 || step > 1.0) {
173  qWarning("QGraphicsItemAnimation::%s: invalid step = %f", method, step);
174  return;
175  }
176 
177  Pair pair(step, value);
178 
179  QList<Pair>::iterator result = qBinaryFind(binList->begin(), binList->end(), pair);
180  if (result != binList->end())
181  result->value = value;
182  else {
183  *binList << pair;
184  qSort(binList->begin(), binList->end());
185  }
186 }
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
Q_CORE_EXPORT void qWarning(const char *,...)
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181

◆ linearValueForStep()

qreal QGraphicsItemAnimationPrivate::linearValueForStep ( qreal  step,
QList< Pair > *  source,
qreal  defaultValue = 0 
)

Definition at line 140 of file qgraphicsitemanimation.cpp.

Referenced by QGraphicsItemAnimation::horizontalScaleAt(), QGraphicsItemAnimation::horizontalShearAt(), QGraphicsItemAnimation::posAt(), QGraphicsItemAnimation::rotationAt(), QGraphicsItemAnimation::verticalScaleAt(), QGraphicsItemAnimation::verticalShearAt(), QGraphicsItemAnimation::xTranslationAt(), and QGraphicsItemAnimation::yTranslationAt().

141 {
142  if (source->isEmpty())
143  return defaultValue;
144  step = qMin<qreal>(qMax<qreal>(step, 0), 1);
145 
146  if (step == 1)
147  return source->last().value;
148 
149  qreal stepBefore = 0;
150  qreal stepAfter = 1;
151  qreal valueBefore = source->first().step == 0 ? source->first().value : defaultValue;
152  qreal valueAfter = source->last().value;
153 
154  // Find the closest step and value before the given step.
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;
158  }
159 
160  // Find the closest step and value after the given step.
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;
164  }
165 
166  // Do a simple linear interpolation.
167  return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
168 }
double qreal
Definition: qglobal.h:1193
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

Properties

◆ horizontalScale

QList<Pair> QGraphicsItemAnimationPrivate::horizontalScale

◆ horizontalShear

QList<Pair> QGraphicsItemAnimationPrivate::horizontalShear

◆ item

QGraphicsItem* QGraphicsItemAnimationPrivate::item

◆ q

QGraphicsItemAnimation* QGraphicsItemAnimationPrivate::q

◆ rotation

QList<Pair> QGraphicsItemAnimationPrivate::rotation

◆ startMatrix

QMatrix QGraphicsItemAnimationPrivate::startMatrix

◆ startPos

QPointF QGraphicsItemAnimationPrivate::startPos

◆ step

qreal QGraphicsItemAnimationPrivate::step

Definition at line 115 of file qgraphicsitemanimation.cpp.

Referenced by QGraphicsItemAnimation::setStep().

◆ timeLine

QPointer<QTimeLine> QGraphicsItemAnimationPrivate::timeLine

◆ verticalScale

QList<Pair> QGraphicsItemAnimationPrivate::verticalScale

◆ verticalShear

QList<Pair> QGraphicsItemAnimationPrivate::verticalShear

◆ xPosition

QList<Pair> QGraphicsItemAnimationPrivate::xPosition

◆ xTranslation

QList<Pair> QGraphicsItemAnimationPrivate::xTranslation

◆ yPosition

QList<Pair> QGraphicsItemAnimationPrivate::yPosition

◆ yTranslation

QList<Pair> QGraphicsItemAnimationPrivate::yTranslation

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