summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-11-04 06:27:15 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-11-04 06:27:15 (GMT)
commit867be3fd7a2017377e8ae5cc3ab789b3b01733bd (patch)
tree7e8ae170237570ea391807db70f2f3c76c612804
parent53e486c0e8d23d535711debdd3a71c8ef2211c58 (diff)
parentce14a4a0bc290018e597d0a4f8e9f279c63d4cc0 (diff)
downloadQt-867be3fd7a2017377e8ae5cc3ab789b3b01733bd.zip
Qt-867be3fd7a2017377e8ae5cc3ab789b3b01733bd.tar.gz
Qt-867be3fd7a2017377e8ae5cc3ab789b3b01733bd.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-graphics-team into 4.6
-rw-r--r--demos/boxes/scene.cpp2
-rw-r--r--demos/boxes/trackball.cpp4
-rw-r--r--doc/src/examples/stickman.qdoc9
-rw-r--r--doc/src/frameworks-technologies/statemachine.qdoc10
-rw-r--r--doc/src/snippets/statemachine/main5.cpp2
-rw-r--r--examples/animation/stickman/lifecycle.cpp4
-rw-r--r--src/corelib/statemachine/qstate.cpp31
-rw-r--r--src/corelib/statemachine/qstate.h4
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp30
-rw-r--r--src/corelib/statemachine/qstatemachine.h8
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
-rw-r--r--src/gui/math3d/qgenericmatrix.cpp106
-rw-r--r--src/gui/math3d/qgenericmatrix.h37
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp237
-rw-r--r--src/gui/math3d/qmatrix4x4.h51
-rw-r--r--src/gui/math3d/qquaternion.cpp4
-rw-r--r--src/gui/math3d/qquaternion.h2
-rw-r--r--src/gui/painting/qdrawhelper.cpp10
-rw-r--r--src/gui/painting/qpainterpath.cpp20
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition.cpp24
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition_p.h6
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition.cpp24
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition_p.h8
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp18
-rw-r--r--src/gui/statemachine/qkeyeventtransition.h6
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp30
-rw-r--r--src/gui/statemachine/qmouseeventtransition.h10
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp6
-rw-r--r--tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp168
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp94
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp6
-rw-r--r--tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp4
33 files changed, 452 insertions, 527 deletions
diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp
index 2b75f19..a06e8a1 100644
--- a/demos/boxes/scene.cpp
+++ b/demos/boxes/scene.cpp
@@ -870,7 +870,7 @@ void Scene::renderCubemaps()
float angle = 2.0f * PI * i / m_cubemaps.size();
- center = m_trackBalls[1].rotation().rotateVector(QVector3D(cos(angle), sin(angle), 0.0f));
+ center = m_trackBalls[1].rotation().rotatedVector(QVector3D(cos(angle), sin(angle), 0.0f));
for (int face = 0; face < 6; ++face) {
m_cubemaps[i]->begin(face);
diff --git a/demos/boxes/trackball.cpp b/demos/boxes/trackball.cpp
index 2b1b2e4..76324e6 100644
--- a/demos/boxes/trackball.cpp
+++ b/demos/boxes/trackball.cpp
@@ -93,7 +93,7 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
QLineF delta(m_lastPos, p);
m_angularVelocity = 180*delta.length() / (PI*msecs);
m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized();
- m_axis = transformation.rotateVector(m_axis);
+ m_axis = transformation.rotatedVector(m_axis);
m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation;
}
break;
@@ -118,7 +118,7 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
m_angularVelocity = angle / msecs;
m_axis.normalize();
- m_axis = transformation.rotateVector(m_axis);
+ m_axis = transformation.rotatedVector(m_axis);
m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation;
}
break;
diff --git a/doc/src/examples/stickman.qdoc b/doc/src/examples/stickman.qdoc
index e70c39b..c9e98d0 100644
--- a/doc/src/examples/stickman.qdoc
+++ b/doc/src/examples/stickman.qdoc
@@ -55,9 +55,9 @@
Animations are implemented as composite states. Each child state of the animation state
represents a frame in the animation by setting the position of each joint in the stickman's
skeleton to the positions defined for the particular frame. The frames are then bound together
- with animated transitions that trigger on the source state's polished() signal. Thus, the
- machine will enter the state representing the next frame in the animation immediately after it
- has finished animating into the previous frame.
+ with animated transitions that trigger on the source state's propertiesAssigned() signal. Thus,
+ the machine will enter the state representing the next frame in the animation immediately after
+ it has finished animating into the previous frame.
\image stickman-example1.png
@@ -67,7 +67,8 @@
\snippet examples/animation/stickman/lifecycle.cpp 1
- The states are then bound together with signal transitions that listen to the polished() signal.
+ The states are then bound together with signal transitions that listen to the
+ propertiesAssigned() signal.
\snippet examples/animation/stickman/lifecycle.cpp 2
diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc
index 9614dd3..b0b13a7 100644
--- a/doc/src/frameworks-technologies/statemachine.qdoc
+++ b/doc/src/frameworks-technologies/statemachine.qdoc
@@ -495,9 +495,9 @@
message box will pop up before the geometry of the button has actually been set.
To ensure that the message box does not pop up until the geometry actually reaches its final
- value, we can use the state's polished() signal. The polished() signal will be emitted when the
- the property is assigned its final value, whether this is done immediately or after the animation
- has finished playing.
+ value, we can use the state's propertiesAssigned() signal. The propertiesAssigned() signal will be
+ emitted when the property is assigned its final value, whether this is done immediately or
+ after the animation has finished playing.
\snippet doc/src/snippets/statemachine/main5.cpp 6
@@ -512,14 +512,14 @@
has been assigned the defined value.
If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit
- the polished() signal until these have been executed as well.
+ the propertiesAssigned() signal until these have been executed as well.
\section1 What Happens If A State Is Exited Before The Animation Has Finished
If a state has property assignments, and the transition into the state has animations for the
properties, the state can potentially be exited before the properties have been assigned to the
values defines by the state. This is true in particular when there are transitions out from the
- state that do not depend on the state being polished, as described in the previous section.
+ state that do not depend on the propertiesAssigned signal, as described in the previous section.
The State Machine API guarantees that a property assigned by the state machine either:
\list
diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp
index 346cbce..ff25b7b 100644
--- a/doc/src/snippets/statemachine/main5.cpp
+++ b/doc/src/snippets/statemachine/main5.cpp
@@ -145,7 +145,7 @@ int main(int argv, char **args)
connect(s3, SIGNAL(entered()), messageBox, SLOT(exec()));
s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
//![6]
}
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 250fb85..1b6f9cd 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -194,14 +194,14 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
topLevel->setInitialState(frameState);
else
//! [2]
- previousState->addTransition(previousState, SIGNAL(polished()), frameState);
+ previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState);
//! [2]
previousState = frameState;
}
// Loop
- previousState->addTransition(previousState, SIGNAL(polished()), topLevel->initialState());
+ previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState());
return topLevel;
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 5dc310b..cf718a5 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -140,10 +140,10 @@ void QStatePrivate::emitFinished()
emit q->finished();
}
-void QStatePrivate::emitPolished()
+void QStatePrivate::emitPropertiesAssigned()
{
Q_Q(QState);
- emit q->polished();
+ emit q->propertiesAssigned();
}
/*!
@@ -229,7 +229,7 @@ QList<QAbstractTransition*> QStatePrivate::transitions() const
Instructs this state to set the property with the given \a name of the given
\a object to the given \a value when the state is entered.
- \sa polished()
+ \sa propertiesAssigned()
*/
void QState::assignProperty(QObject *object, const char *name,
const QVariant &value)
@@ -287,15 +287,14 @@ void QState::setErrorState(QAbstractState *state)
/*!
Adds the given \a transition. The transition has this state as the source.
- This state takes ownership of the transition. If the transition is successfully
- added, the function will return the \a transition pointer. Otherwise it will return null.
+ This state takes ownership of the transition.
*/
-QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
+void QState::addTransition(QAbstractTransition *transition)
{
Q_D(QState);
if (!transition) {
qWarning("QState::addTransition: cannot add null transition");
- return 0;
+ return ;
}
transition->setParent(this);
@@ -304,18 +303,17 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
QAbstractState *t = targets.at(i).data();
if (!t) {
qWarning("QState::addTransition: cannot add transition to null state");
- return 0;
+ return ;
}
if ((QAbstractStatePrivate::get(t)->machine() != d->machine())
&& QAbstractStatePrivate::get(t)->machine() && d->machine()) {
qWarning("QState::addTransition: cannot add transition "
"to a state in a different state machine");
- return 0;
+ return ;
}
}
if (machine() != 0 && machine()->configuration().contains(this))
QStateMachinePrivate::get(machine())->registerTransitions(this);
- return transition;
}
/*!
@@ -380,7 +378,8 @@ QAbstractTransition *QState::addTransition(QAbstractState *target)
return 0;
}
UnconditionalTransition *trans = new UnconditionalTransition(target);
- return addTransition(trans);
+ addTransition(trans);
+ return trans;
}
/*!
@@ -493,9 +492,15 @@ bool QState::event(QEvent *e)
*/
/*!
- \fn QState::polished()
+ \fn QState::propertiesAssigned()
+
+ This signal is emitted when all properties have been assigned their final value. If the state
+ assigns a value to one or more properties for which an animation exists (either set on the
+ transition or as a default animation on the state machine), then the signal will not be emitted
+ until all such animations have finished playing.
- This signal is emitted when all properties have been assigned their final value.
+ If there are no relevant animations, or no property assignments defined for the state, then
+ the signal will be emitted immediately before the state is entered.
\sa QState::assignProperty(), QAbstractTransition::addAnimation()
*/
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index 7a47447..423f940 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -76,7 +76,7 @@ public:
QAbstractState *errorState() const;
void setErrorState(QAbstractState *state);
- QAbstractTransition *addTransition(QAbstractTransition *transition);
+ void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
QAbstractTransition *addTransition(QAbstractState *target);
void removeTransition(QAbstractTransition *transition);
@@ -94,7 +94,7 @@ public:
Q_SIGNALS:
void finished();
- void polished();
+ void propertiesAssigned();
protected:
void onEntry(QEvent *event);
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 34c8838..7fe6279 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -94,7 +94,7 @@ public:
QList<QAbstractTransition*> transitions() const;
void emitFinished();
- void emitPolished();
+ void emitPropertiesAssigned();
QAbstractState *errorState;
QAbstractState *initialState;
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index ea5587e..cf951c9 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -159,12 +159,12 @@ QT_BEGIN_NAMESPACE
\brief the restore policy for states of this state machine.
The default value of this property is
- QStateMachine::DoNotRestoreProperties.
+ QStateMachine::DontRestoreProperties.
*/
#ifndef QT_NO_ANIMATION
/*!
- \property QStateMachine::animationsEnabled
+ \property QStateMachine::animated
\brief whether animations are enabled
@@ -187,10 +187,10 @@ QStateMachinePrivate::QStateMachinePrivate()
stop = false;
stopProcessingReason = EventQueueEmpty;
error = QStateMachine::NoError;
- globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
+ globalRestorePolicy = QStateMachine::DontRestoreProperties;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
- animationsEnabled = true;
+ animated = true;
#endif
}
@@ -744,7 +744,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
// Find the animations to use for the state change.
QList<QAbstractAnimation*> selectedAnimations;
- if (animationsEnabled) {
+ if (animated) {
for (int i = 0; i < transitionList.size(); ++i) {
QAbstractTransition *transition = transitionList.at(i);
@@ -809,7 +809,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
if (anim->state() == QAbstractAnimation::Running) {
// The animation is still running. This can happen if the
// animation is a group, and one of its children just finished,
- // and that caused a state to emit its polished() signal, and
+ // and that caused a state to emit its propertiesAssigned() signal, and
// that triggered a transition in the machine.
// Just stop the animation so it is correctly restarted again.
anim->stop();
@@ -831,7 +831,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
}
}
- // Emit polished signal for entered states that have no animated properties.
+ // Emit propertiesAssigned signal for entered states that have no animated properties.
for (int i = 0; i < enteredStates.size(); ++i) {
QState *s = toStandardState(enteredStates.at(i));
if (s
@@ -839,7 +839,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
&& !animationsForState.contains(s)
#endif
)
- QStatePrivate::get(s)->emitPolished();
+ QStatePrivate::get(s)->emitPropertiesAssigned();
}
}
@@ -1130,7 +1130,7 @@ void QStateMachinePrivate::_q_animationFinished()
animations.removeOne(anim);
if (animations.isEmpty()) {
animationsForState.erase(it);
- QStatePrivate::get(toStandardState(state))->emitPolished();
+ QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned();
}
}
@@ -1726,7 +1726,7 @@ QStateMachine::~QStateMachine()
already been saved by the state machine, it will not be overwritten until the property has been
successfully restored.
- \value DoNotRestoreProperties The state machine should not save the initial values of properties
+ \value DontRestoreProperties The state machine should not save the initial values of properties
and restore them later.
\value RestoreProperties The state machine should save the initial values of properties
and restore them later.
@@ -1776,7 +1776,7 @@ QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const
/*!
Sets the restore policy of the state machine to \a restorePolicy. The default
- restore policy is QAbstractState::DoNotRestoreProperties.
+ restore policy is QAbstractState::DontRestoreProperties.
\sa globalRestorePolicy()
*/
@@ -2146,19 +2146,19 @@ void QStateMachine::onExit(QEvent *event)
/*!
Returns whether animations are enabled for this state machine.
*/
-bool QStateMachine::animationsEnabled() const
+bool QStateMachine::isAnimated() const
{
Q_D(const QStateMachine);
- return d->animationsEnabled;
+ return d->animated;
}
/*!
Sets whether animations are \a enabled for this state machine.
*/
-void QStateMachine::setAnimationsEnabled(bool enabled)
+void QStateMachine::setAnimated(bool enabled)
{
Q_D(QStateMachine);
- d->animationsEnabled = enabled;
+ d->animated = enabled;
}
/*!
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 13b6fe2..ff2b667 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -67,7 +67,7 @@ class Q_CORE_EXPORT QStateMachine : public QState
Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
Q_ENUMS(RestorePolicy)
#ifndef QT_NO_ANIMATION
- Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled)
+ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
#endif
public:
class SignalEvent : public QEvent
@@ -109,7 +109,7 @@ public:
};
enum RestorePolicy {
- DoNotRestoreProperties,
+ DontRestoreProperties,
RestoreProperties
};
@@ -133,8 +133,8 @@ public:
bool isRunning() const;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled() const;
- void setAnimationsEnabled(bool enabled);
+ bool isAnimated() const;
+ void setAnimated(bool enabled);
void addDefaultAnimation(QAbstractAnimation *animation);
QList<QAbstractAnimation *> defaultAnimations() const;
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 01c9361..aad5c67 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -207,7 +207,7 @@ public:
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled;
+ bool animated;
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
initializeAnimation(QAbstractAnimation *abstractAnimation,
diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp
index d211229..aa98536 100644
--- a/src/gui/math3d/qgenericmatrix.cpp
+++ b/src/gui/math3d/qgenericmatrix.cpp
@@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE
The contents of the array \a values is assumed to be in
row-major order.
- \sa toValueArray()
+ \sa copyDataTo()
*/
/*!
@@ -102,11 +102,11 @@ QT_BEGIN_NAMESPACE
Returns true if this matrix is the identity; false otherwise.
- \sa setIdentity()
+ \sa setToIdentity()
*/
/*!
- \fn void QGenericMatrix::setIdentity()
+ \fn void QGenericMatrix::setToIdentity()
Sets this matrix to the identity.
@@ -213,9 +213,9 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QGenericMatrix::toValueArray(T *values)
+ \fn void QGenericMatrix::copyDataTo(T *values) const
- Retrieves the N * M items in this matrix and writes them to \a values
+ Retrieves the N * M items in this matrix and copies them to \a values
in row-major order.
*/
@@ -243,4 +243,100 @@ QT_BEGIN_NAMESPACE
\sa data()
*/
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)
+ \relates QGenericMatrix
+
+ Writes the given \a matrix to the given \a stream and returns a
+ reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)
+ \relates QGenericMatrix
+
+ Reads a NxM matrix from the given \a stream into the given \a matrix
+ and returns a reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+#endif
+
+/*!
+ \typedef QMatrix2x2
+ \relates QGenericMatrix
+
+ The QMatrix2x2 type defines a convenient instantiation of the
+ QGenericMatrix template for 2 columns, 2 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix2x3
+ \relates QGenericMatrix
+
+ The QMatrix2x3 type defines a convenient instantiation of the
+ QGenericMatrix template for 2 columns, 3 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix2x4
+ \relates QGenericMatrix
+
+ The QMatrix2x4 type defines a convenient instantiation of the
+ QGenericMatrix template for 2 columns, 4 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix3x2
+ \relates QGenericMatrix
+
+ The QMatrix3x2 type defines a convenient instantiation of the
+ QGenericMatrix template for 3 columns, 2 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix3x3
+ \relates QGenericMatrix
+
+ The QMatrix3x3 type defines a convenient instantiation of the
+ QGenericMatrix template for 3 columns, 3 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix3x4
+ \relates QGenericMatrix
+
+ The QMatrix3x4 type defines a convenient instantiation of the
+ QGenericMatrix template for 3 columns, 4 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix4x2
+ \relates QGenericMatrix
+
+ The QMatrix4x2 type defines a convenient instantiation of the
+ QGenericMatrix template for 4 columns, 2 rows, and qreal as
+ the element type.
+*/
+
+/*!
+ \typedef QMatrix4x3
+ \relates QGenericMatrix
+
+ The QMatrix4x3 type defines a convenient instantiation of the
+ QGenericMatrix template for 4 columns, 3 rows, and qreal as
+ the element type.
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index f178d02..3871754 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -44,6 +44,7 @@
#include <QtCore/qmetatype.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qdatastream.h>
QT_BEGIN_HEADER
@@ -63,7 +64,7 @@ public:
T& operator()(int row, int column);
bool isIdentity() const;
- void setIdentity();
+ void setToIdentity();
void fill(T value);
@@ -76,7 +77,7 @@ public:
bool operator==(const QGenericMatrix<N, M, T>& other) const;
bool operator!=(const QGenericMatrix<N, M, T>& other) const;
- void toValueArray(T *values);
+ void copyDataTo(T *values) const;
T *data() { return m[0]; }
const T *data() const { return m[0]; }
@@ -113,7 +114,7 @@ private:
template <int N, int M, typename T>
Q_INLINE_TEMPLATE QGenericMatrix<N, M, T>::QGenericMatrix()
{
- setIdentity();
+ setToIdentity();
}
template <int N, int M, typename T>
@@ -164,7 +165,7 @@ Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T>::isIdentity() const
}
template <int N, int M, typename T>
-Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::setIdentity()
+Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::setToIdentity()
{
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
@@ -316,7 +317,7 @@ Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M
}
template <int N, int M, typename T>
-Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::toValueArray(T *values)
+Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::copyDataTo(T *values) const
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
@@ -352,6 +353,32 @@ QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
#endif
+#ifndef QT_NO_DATASTREAM
+
+template <int N, int M, typename T>
+QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)
+{
+ for (int row = 0; row < M; ++row)
+ for (int col = 0; col < N; ++col)
+ stream << double(matrix(row, col));
+ return stream;
+}
+
+template <int N, int M, typename T>
+QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)
+{
+ double x;
+ for (int row = 0; row < M; ++row) {
+ for (int col = 0; col < N; ++col) {
+ stream >> x;
+ matrix(row, col) = T(x);
+ }
+ }
+ return stream;
+}
+
+#endif
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QMatrix2x2)
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index 5d624d8..2c3d616 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -73,10 +73,10 @@ static const qreal inv_dist_to_plane = 1. / 1024.;
If the matrix has a special type (identity, translate, scale, etc),
the programmer should follow this constructor with a call to
- inferSpecialType() if they wish QMatrix4x4 to optimize further
+ optimize() if they wish QMatrix4x4 to optimize further
calls to translate(), scale(), etc.
- \sa toValueArray(), inferSpecialType()
+ \sa copyDataTo(), optimize()
*/
QMatrix4x4::QMatrix4x4(const qreal *values)
{
@@ -96,10 +96,10 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
If the matrix has a special type (identity, translate, scale, etc),
the programmer should follow this constructor with a call to
- inferSpecialType() if they wish QMatrix4x4 to optimize further
+ optimize() if they wish QMatrix4x4 to optimize further
calls to translate(), scale(), etc.
- \sa inferSpecialType()
+ \sa optimize()
*/
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
@@ -176,10 +176,10 @@ QMatrix4x4::QMatrix4x4(const qreal *values, int cols, int rows)
If \a matrix has a special type (identity, translate, scale, etc),
the programmer should follow this constructor with a call to
- inferSpecialType() if they wish QMatrix4x4 to optimize further
+ optimize() if they wish QMatrix4x4 to optimize further
calls to translate(), scale(), etc.
- \sa toAffine(), inferSpecialType()
+ \sa toAffine(), optimize()
*/
QMatrix4x4::QMatrix4x4(const QMatrix& matrix)
{
@@ -208,10 +208,10 @@ QMatrix4x4::QMatrix4x4(const QMatrix& matrix)
If \a transform has a special type (identity, translate, scale, etc),
the programmer should follow this constructor with a call to
- inferSpecialType() if they wish QMatrix4x4 to optimize further
+ optimize() if they wish QMatrix4x4 to optimize further
calls to translate(), scale(), etc.
- \sa toTransform(), inferSpecialType()
+ \sa toTransform(), optimize()
*/
QMatrix4x4::QMatrix4x4(const QTransform& transform)
{
@@ -249,7 +249,7 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
- \sa inferSpecialType(), setColumn(), setRow()
+ \sa optimize(), setColumn(), setRow()
*/
/*!
@@ -289,11 +289,11 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
Returns true if this matrix is the identity; false otherwise.
- \sa setIdentity()
+ \sa setToIdentity()
*/
/*!
- \fn void QMatrix4x4::setIdentity()
+ \fn void QMatrix4x4::setToIdentity()
Sets this matrix to the identity.
@@ -694,11 +694,11 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
/*!
Multiplies this matrix by another that scales coordinates by
- the components of \a vector. Returns this matrix.
+ the components of \a vector.
\sa translate(), rotate()
*/
-QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
+void QMatrix4x4::scale(const QVector3D& vector)
{
qreal vx = vector.x();
qreal vy = vector.y();
@@ -732,7 +732,6 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
m[2][3] *= vz;
flagBits = General;
}
- return *this;
}
#endif
@@ -740,11 +739,11 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
\overload
Multiplies this matrix by another that scales coordinates by the
- components \a x, and \a y. Returns this matrix.
+ components \a x, and \a y.
\sa translate(), rotate()
*/
-QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y)
+void QMatrix4x4::scale(qreal x, qreal y)
{
if (flagBits == Identity) {
m[0][0] = x;
@@ -768,18 +767,17 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y)
m[1][3] *= y;
flagBits = General;
}
- return *this;
}
/*!
\overload
Multiplies this matrix by another that scales coordinates by the
- components \a x, \a y, and \a z. Returns this matrix.
+ components \a x, \a y, and \a z.
\sa translate(), rotate()
*/
-QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
+void QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
if (flagBits == Identity) {
m[0][0] = x;
@@ -810,18 +808,17 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
m[2][3] *= z;
flagBits = General;
}
- return *this;
}
/*!
\overload
Multiplies this matrix by another that scales coordinates by the
- given \a factor. Returns this matrix.
+ given \a factor.
\sa translate(), rotate()
*/
-QMatrix4x4& QMatrix4x4::scale(qreal factor)
+void QMatrix4x4::scale(qreal factor)
{
if (flagBits == Identity) {
m[0][0] = factor;
@@ -852,17 +849,16 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
m[2][3] *= factor;
flagBits = General;
}
- return *this;
}
#ifndef QT_NO_VECTOR3D
/*!
Multiplies this matrix by another that translates coordinates by
- the components of \a vector. Returns this matrix.
+ the components of \a vector.
\sa scale(), rotate()
*/
-QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
+void QMatrix4x4::translate(const QVector3D& vector)
{
qreal vx = vector.x();
qreal vy = vector.y();
@@ -895,7 +891,6 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
else if (flagBits != (Rotation | Translation))
flagBits = General;
}
- return *this;
}
#endif
@@ -904,11 +899,11 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
\overload
Multiplies this matrix by another that translates coordinates
- by the components \a x, and \a y. Returns this matrix.
+ by the components \a x, and \a y.
\sa scale(), rotate()
*/
-QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y)
+void QMatrix4x4::translate(qreal x, qreal y)
{
if (flagBits == Identity) {
m[3][0] = x;
@@ -935,18 +930,17 @@ QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y)
else if (flagBits != (Rotation | Translation))
flagBits = General;
}
- return *this;
}
/*!
\overload
Multiplies this matrix by another that translates coordinates
- by the components \a x, \a y, and \a z. Returns this matrix.
+ by the components \a x, \a y, and \a z.
\sa scale(), rotate()
*/
-QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
+void QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
if (flagBits == Identity) {
m[3][0] = x;
@@ -976,20 +970,19 @@ QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
else if (flagBits != (Rotation | Translation))
flagBits = General;
}
- return *this;
}
#ifndef QT_NO_VECTOR3D
/*!
Multiples this matrix by another that rotates coordinates through
- \a angle degrees about \a vector. Returns this matrix.
+ \a angle degrees about \a vector.
\sa scale(), translate()
*/
-QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
+void QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
{
- return rotate(angle, vector.x(), vector.y(), vector.z());
+ rotate(angle, vector.x(), vector.y(), vector.z());
}
#endif
@@ -998,14 +991,14 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
\overload
Multiplies this matrix by another that rotates coordinates through
- \a angle degrees about the vector (\a x, \a y, \a z). Returns this matrix.
+ \a angle degrees about the vector (\a x, \a y, \a z).
\sa scale(), translate()
*/
-QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
+void QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
if (angle == 0.0f)
- return *this;
+ return;
QMatrix4x4 m(1); // The "1" says to not load the identity.
qreal c, s, ic;
if (angle == 90.0f || angle == -270.0f) {
@@ -1027,7 +1020,7 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
if (y == 0.0f) {
if (z != 0.0f) {
// Rotate around the Z axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[0][0] = c;
m.m[1][1] = c;
if (z < 0.0f) {
@@ -1042,7 +1035,7 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
}
} else if (z == 0.0f) {
// Rotate around the Y axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[0][0] = c;
m.m[2][2] = c;
if (y < 0.0f) {
@@ -1057,7 +1050,7 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
}
} else if (y == 0.0f && z == 0.0f) {
// Rotate around the X axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[1][1] = c;
m.m[2][2] = c;
if (x < 0.0f) {
@@ -1102,18 +1095,17 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
flagBits = flags | Rotation;
else
flagBits = Rotation;
- return *this;
}
/*!
\internal
*/
-QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
+void QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
{
// Used by QGraphicsRotation::applyTo() to perform a rotation
// and projection back to 2D in a single step.
if (angle == 0.0f)
- return *this;
+ return;
QMatrix4x4 m(1); // The "1" says to not load the identity.
qreal c, s, ic;
if (angle == 90.0f || angle == -270.0f) {
@@ -1135,7 +1127,7 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
if (y == 0.0f) {
if (z != 0.0f) {
// Rotate around the Z axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[0][0] = c;
m.m[1][1] = c;
if (z < 0.0f) {
@@ -1150,7 +1142,7 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
}
} else if (z == 0.0f) {
// Rotate around the Y axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[0][0] = c;
m.m[2][2] = 1.0f;
if (y < 0.0f) {
@@ -1163,7 +1155,7 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
}
} else if (y == 0.0f && z == 0.0f) {
// Rotate around the X axis.
- m.setIdentity();
+ m.setToIdentity();
m.m[1][1] = c;
m.m[2][2] = 1.0f;
if (x < 0.0f) {
@@ -1206,7 +1198,6 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
flagBits = flags | Rotation;
else
flagBits = Rotation;
- return *this;
}
#ifndef QT_NO_QUATERNION
@@ -1214,11 +1205,11 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z)
/*!
Multiples this matrix by another that rotates coordinates according
to a specified \a quaternion. The \a quaternion is assumed to have
- been normalized. Returns this matrix.
+ been normalized.
\sa scale(), translate(), QQuaternion
*/
-QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
+void QMatrix4x4::rotate(const QQuaternion& quaternion)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
@@ -1254,7 +1245,6 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
flagBits = flags | Rotation;
else
flagBits = Rotation;
- return *this;
}
#endif
@@ -1265,17 +1255,16 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
Multiplies this matrix by another that applies an orthographic
projection for a window with boundaries specified by \a rect.
The near and far clipping planes will be -1 and 1 respectively.
- Returns this matrix.
\sa frustum(), perspective()
*/
-QMatrix4x4& QMatrix4x4::ortho(const QRect& rect)
+void QMatrix4x4::ortho(const QRect& rect)
{
// Note: rect.right() and rect.bottom() subtract 1 in QRect,
// which gives the location of a pixel within the rectangle,
// instead of the extent of the rectangle. We want the extent.
// QRectF expresses the extent properly.
- return ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f);
+ ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f);
}
/*!
@@ -1284,28 +1273,27 @@ QMatrix4x4& QMatrix4x4::ortho(const QRect& rect)
Multiplies this matrix by another that applies an orthographic
projection for a window with boundaries specified by \a rect.
The near and far clipping planes will be -1 and 1 respectively.
- Returns this matrix.
\sa frustum(), perspective()
*/
-QMatrix4x4& QMatrix4x4::ortho(const QRectF& rect)
+void QMatrix4x4::ortho(const QRectF& rect)
{
- return ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f);
+ ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f);
}
/*!
Multiplies this matrix by another that applies an orthographic
projection for a window with lower-left corner (\a left, \a bottom),
upper-right corner (\a right, \a top), and the specified \a nearPlane
- and \a farPlane clipping planes. Returns this matrix.
+ and \a farPlane clipping planes.
\sa frustum(), perspective()
*/
-QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
+void QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
{
// Bail out if the projection volume is zero-sized.
if (left == right || bottom == top || nearPlane == farPlane)
- return *this;
+ return;
// Construct the projection.
qreal width = right - left;
@@ -1324,7 +1312,7 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
(2.0f / width,
2.0f / invheight,
-1.0f));
- return *this;
+ return;
}
#endif
QMatrix4x4 m(1);
@@ -1347,22 +1335,22 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
// Apply the projection.
*this *= m;
- return *this;
+ return;
}
/*!
Multiplies this matrix by another that applies a perspective
frustum projection for a window with lower-left corner (\a left, \a bottom),
upper-right corner (\a right, \a top), and the specified \a nearPlane
- and \a farPlane clipping planes. Returns this matrix.
+ and \a farPlane clipping planes.
\sa ortho(), perspective()
*/
-QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
+void QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
{
// Bail out if the projection volume is zero-sized.
if (left == right || bottom == top || nearPlane == farPlane)
- return *this;
+ return;
// Construct the projection.
QMatrix4x4 m(1);
@@ -1388,7 +1376,6 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
// Apply the projection.
*this *= m;
- return *this;
}
/*!
@@ -1396,22 +1383,21 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
projection. The field of view will be \a angle degrees within
a window with a given \a aspect ratio. The projection will
have the specified \a nearPlane and \a farPlane clipping planes.
- Returns this matrix.
\sa ortho(), frustum()
*/
-QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane)
+void QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane)
{
// Bail out if the projection volume is zero-sized.
if (nearPlane == farPlane || aspect == 0.0f)
- return *this;
+ return;
// Construct the projection.
QMatrix4x4 m(1);
qreal radians = (angle / 2.0f) * M_PI / 180.0f;
qreal sine = qSin(radians);
if (sine == 0.0f)
- return *this;
+ return;
qreal cotan = qCos(radians) / sine;
qreal clip = farPlane - nearPlane;
m.m[0][0] = cotan / aspect;
@@ -1433,7 +1419,6 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
// Apply the projection.
*this *= m;
- return *this;
}
#ifndef QT_NO_VECTOR3D
@@ -1443,9 +1428,8 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
transformation. The \a center value indicates the center of the
view that the \a eye is looking at. The \a up value indicates
which direction should be considered up with respect to the \a eye.
- Returns this matrix.
*/
-QMatrix4x4& QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up)
+void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up)
{
QVector3D forward = (center - eye).normalized();
QVector3D side = QVector3D::crossProduct(forward, up).normalized();
@@ -1471,7 +1455,7 @@ QMatrix4x4& QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, co
m.m[3][3] = 1.0f;
*this *= m;
- return translate(-eye);
+ translate(-eye);
}
#endif
@@ -1480,11 +1464,11 @@ QMatrix4x4& QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, co
Flips between right-handed and left-handed coordinate systems
by multiplying the y and z co-ordinates by -1. This is normally
used to create a left-handed orthographic view without scaling
- the viewport as ortho() does. Returns this matrix.
+ the viewport as ortho() does.
\sa ortho()
*/
-QMatrix4x4& QMatrix4x4::flipCoordinates()
+void QMatrix4x4::flipCoordinates()
{
if (flagBits == Scale || flagBits == (Scale | Translation)) {
m[1][1] = -m[1][1];
@@ -1508,14 +1492,13 @@ QMatrix4x4& QMatrix4x4::flipCoordinates()
m[2][3] = -m[2][3];
flagBits = General;
}
- return *this;
}
/*!
- Retrieves the 16 items in this matrix and writes them to \a values
+ Retrieves the 16 items in this matrix and copies them to \a values
in row-major order.
*/
-void QMatrix4x4::toValueArray(qreal *values) const
+void QMatrix4x4::copyDataTo(qreal *values) const
{
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
@@ -1739,7 +1722,7 @@ QRectF QMatrix4x4::mapRect(const QRectF& rect) const
Returns a pointer to the raw data of this matrix.
- \sa constData(), inferSpecialType()
+ \sa constData(), optimize()
*/
/*!
@@ -1788,94 +1771,8 @@ QMatrix4x4 QMatrix4x4::orthonormalInverse() const
return result;
}
-#ifndef QT_NO_VECTOR3D
-/*!
- Decomposes the current rotation matrix into an \a axis of rotation plus
- an \a angle. The result can be used to construct an equivalent rotation
- matrix using glRotate(). It is assumed that the homogenous coordinate
- is 1.0. The returned vector is guaranteed to be normalized.
-
- \code
- qreal angle;
- QVector3D axis;
-
- matrix.extractAxisAngle(angle, axis);
- glRotate(angle, axis[0], axis[1], axis[2]);
- \endcode
-
- \sa rotate()
-*/
-void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
-{
- // Orientation is dependent on the upper 3x3 matrix; subtract the
- // homogeneous scaling element from the trace of the 4x4 matrix
- qreal tr = m[0][0] + m[1][1] + m[2][2];
- qreal cosa = qreal(0.5f * (tr - 1.0f));
- angle = acos(cosa) * 180.0f / M_PI;
-
- // Any axis will work if r is zero (means no rotation)
- if (qFuzzyIsNull(angle)) {
- axis.setX(1.0f);
- axis.setY(0.0f);
- axis.setZ(0.0f);
- return;
- }
-
- if (angle < 180.0f) {
- axis.setX(m[1][2] - m[2][1]);
- axis.setY(m[2][0] - m[0][2]);
- axis.setZ(m[0][1] - m[1][0]);
- axis.normalize();
- return;
- }
-
- // rads == PI
- qreal tmp;
-
- // r00 is maximum
- if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.setX(0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f));
- tmp = 0.5f / axis.x();
- axis.setY(m[1][0] * tmp);
- axis.setZ(m[2][0] * tmp);
- }
-
- // r11 is maximum
- if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.setY(0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f));
- tmp = 0.5f / axis.y();
- axis.setX(tmp * m[1][0]);
- axis.setZ(tmp * m[2][1]);
- }
-
- // r22 is maximum
- if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.setZ(0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f));
- tmp = 0.5f / axis.z();
- axis.setX(m[2][0]*tmp);
- axis.setY(m[2][1]*tmp);
- }
-}
-
-/*!
- If this is an orthonormal transformation matrix (e.g. only rotations and
- translations have been applied to the matrix, no scaling, or shearing)
- then the world translational component can be obtained by calling this function.
-
- This is most useful for camera matrices, where the negation of this vector
- is effectively the camera world coordinates.
-*/
-QVector3D QMatrix4x4::extractTranslation() const
-{
- return QVector3D
- (m[0][0] * m[3][0] + m[0][1] * m[3][1] + m[0][2] * m[3][2],
- m[1][0] * m[3][0] + m[1][1] * m[3][1] + m[1][2] * m[3][2],
- m[2][0] * m[3][0] + m[2][1] * m[3][1] + m[2][2] * m[3][2]);
-}
-#endif
-
/*!
- Infers the special type of this matrix from its current elements.
+ Optimize the usage of this matrix from its current elements.
Some operations such as translate(), scale(), and rotate() can be
performed more efficiently if the matrix being modified is already
@@ -1888,13 +1785,13 @@ QVector3D QMatrix4x4::extractTranslation() const
the special type and will revert to the safest but least efficient
operations thereafter.
- By calling inferSpecialType() after directly modifying the matrix,
+ By calling optimize() after directly modifying the matrix,
the programmer can force QMatrix4x4 to recover the special type if
the elements appear to conform to one of the known optimized types.
\sa operator()(), data(), translate()
*/
-void QMatrix4x4::inferSpecialType()
+void QMatrix4x4::optimize()
{
// If the last element is not 1, then it can never be special.
if (m[3][3] != 1.0f) {
@@ -2011,7 +1908,7 @@ QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix)
matrix(row, col) = qreal(x);
}
}
- matrix.inferSpecialType();
+ matrix.optimize();
return stream;
}
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index ba74b89..4193bdc 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -63,7 +63,7 @@ class QVariant;
class Q_GUI_EXPORT QMatrix4x4
{
public:
- inline QMatrix4x4() { setIdentity(); }
+ inline QMatrix4x4() { setToIdentity(); }
explicit QMatrix4x4(const qreal *values);
inline QMatrix4x4(qreal m11, qreal m12, qreal m13, qreal m14,
qreal m21, qreal m22, qreal m23, qreal m24,
@@ -87,7 +87,7 @@ public:
inline void setRow(int index, const QVector4D& value);
inline bool isIdentity() const;
- inline void setIdentity();
+ inline void setToIdentity();
inline void fill(qreal value);
@@ -127,36 +127,31 @@ public:
friend inline bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2);
#ifndef QT_NO_VECTOR3D
- QMatrix4x4& scale(const QVector3D& vector);
- QMatrix4x4& translate(const QVector3D& vector);
- QMatrix4x4& rotate(qreal angle, const QVector3D& vector);
+ void scale(const QVector3D& vector);
+ void translate(const QVector3D& vector);
+ void rotate(qreal angle, const QVector3D& vector);
#endif
- QMatrix4x4& scale(qreal x, qreal y);
- QMatrix4x4& scale(qreal x, qreal y, qreal z);
- QMatrix4x4& scale(qreal factor);
- QMatrix4x4& translate(qreal x, qreal y);
- QMatrix4x4& translate(qreal x, qreal y, qreal z);
- QMatrix4x4& rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f);
+ void scale(qreal x, qreal y);
+ void scale(qreal x, qreal y, qreal z);
+ void scale(qreal factor);
+ void translate(qreal x, qreal y);
+ void translate(qreal x, qreal y, qreal z);
+ void rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f);
#ifndef QT_NO_QUATERNION
- QMatrix4x4& rotate(const QQuaternion& quaternion);
+ void rotate(const QQuaternion& quaternion);
#endif
+ void ortho(const QRect& rect);
+ void ortho(const QRectF& rect);
+ void ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
+ void frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
+ void perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane);
#ifndef QT_NO_VECTOR3D
- void extractAxisRotation(qreal &angle, QVector3D &axis) const;
- QVector3D extractTranslation() const;
+ void lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up);
#endif
+ void flipCoordinates();
- QMatrix4x4& ortho(const QRect& rect);
- QMatrix4x4& ortho(const QRectF& rect);
- QMatrix4x4& ortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
- QMatrix4x4& frustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane);
- QMatrix4x4& perspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane);
-#ifndef QT_NO_VECTOR3D
- QMatrix4x4& lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up);
-#endif
- QMatrix4x4& flipCoordinates();
-
- void toValueArray(qreal *values) const;
+ void copyDataTo(qreal *values) const;
QMatrix toAffine() const;
QTransform toTransform() const;
@@ -183,7 +178,7 @@ public:
inline const qreal *data() const { return m[0]; }
inline const qreal *constData() const { return m[0]; }
- void inferSpecialType();
+ void optimize();
operator QVariant() const;
@@ -208,7 +203,7 @@ private:
QMatrix4x4 orthonormalInverse() const;
- QMatrix4x4& projectedRotate(qreal angle, qreal x, qreal y, qreal z);
+ void projectedRotate(qreal angle, qreal x, qreal y, qreal z);
friend class QGraphicsRotation;
};
@@ -330,7 +325,7 @@ inline bool QMatrix4x4::isIdentity() const
return (m[3][3] == 1.0f);
}
-inline void QMatrix4x4::setIdentity()
+inline void QMatrix4x4::setToIdentity()
{
m[0][0] = 1.0f;
m[0][1] = 0.0f;
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index d5ec054..626cb3c 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -288,7 +288,7 @@ void QQuaternion::normalize()
in 3D space. The following code:
\code
- QVector3D result = q.rotateVector(vector);
+ QVector3D result = q.rotatedVector(vector);
\endcode
is equivalent to the following:
@@ -297,7 +297,7 @@ void QQuaternion::normalize()
QVector3D result = (q * QQuaternion(0, vector) * q.conjugate()).vector();
\endcode
*/
-QVector3D QQuaternion::rotateVector(const QVector3D& vector) const
+QVector3D QQuaternion::rotatedVector(const QVector3D& vector) const
{
return (*this * QQuaternion(0, vector) * conjugate()).vector();
}
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 7480a5c..5b2454f 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -95,7 +95,7 @@ public:
QQuaternion conjugate() const;
- QVector3D rotateVector(const QVector3D& vector) const;
+ QVector3D rotatedVector(const QVector3D& vector) const;
QQuaternion &operator+=(const QQuaternion &quaternion);
QQuaternion &operator-=(const QQuaternion &quaternion);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 53edbb0..41602a1 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -7424,6 +7424,14 @@ QT_RECTFILL(qrgb444)
QT_RECTFILL(qargb4444)
#undef QT_RECTFILL
+inline static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ quint32 color)
+{
+ qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
+ INV_PREMUL(color), x, y, width, height, rasterBuffer->bytesPerLine());
+}
+
// Map table for destination image format. Contains function pointers
// for blends of various types unto the destination
@@ -7466,7 +7474,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
- qt_rectfill_quint32
+ qt_rectfill_nonpremul_quint32
},
// Format_ARGB32_Premultiplied
{
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index c40bcee..8133793 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -3037,11 +3037,11 @@ void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadi
bool first = d_func()->elements.size() < 2;
- arcMoveTo(x, y, rxx2, ryy2, 90);
- arcTo(x, y, rxx2, ryy2, 90, 90);
- arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90);
- arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 3*90, 90);
- arcTo(x+w-rxx2, y, rxx2, ryy2, 0, 90);
+ arcMoveTo(x, y, rxx2, ryy2, 180);
+ arcTo(x, y, rxx2, ryy2, 180, -90);
+ arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);
+ arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);
+ arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);
closeSubpath();
d_func()->require_moveTo = true;
@@ -3094,11 +3094,11 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd)
bool first = d_func()->elements.size() < 2;
- arcMoveTo(x, y, rxx2, ryy2, 90);
- arcTo(x, y, rxx2, ryy2, 90, 90);
- arcTo(x, y+h-ryy2, rxx2, ryy2, 2*90, 90);
- arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 3*90, 90);
- arcTo(x+w-rxx2, y, rxx2, ryy2, 0, 90);
+ arcMoveTo(x, y, rxx2, ryy2, 180);
+ arcTo(x, y, rxx2, ryy2, 180, -90);
+ arcTo(x+w-rxx2, y, rxx2, ryy2, 90, -90);
+ arcTo(x+w-rxx2, y+h-ryy2, rxx2, ryy2, 0, -90);
+ arcTo(x, y+h-ryy2, rxx2, ryy2, 270, -90);
closeSubpath();
d_func()->require_moveTo = true;
diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/gui/statemachine/qbasickeyeventtransition.cpp
index 445a253..bf10e3d 100644
--- a/src/gui/statemachine/qbasickeyeventtransition.cpp
+++ b/src/gui/statemachine/qbasickeyeventtransition.cpp
@@ -68,14 +68,14 @@ public:
QEvent::Type eventType;
int key;
- Qt::KeyboardModifiers modifiersMask;
+ Qt::KeyboardModifiers modifierMask;
};
QBasicKeyEventTransitionPrivate::QBasicKeyEventTransitionPrivate()
{
eventType = QEvent::None;
key = 0;
- modifiersMask = Qt::NoModifier;
+ modifierMask = Qt::NoModifier;
}
QBasicKeyEventTransitionPrivate *QBasicKeyEventTransitionPrivate::get(QBasicKeyEventTransition *q)
@@ -106,17 +106,17 @@ QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
/*!
Constructs a new event transition for events of the given \a type for the
- given \a key, with the given \a modifiersMask and \a sourceState.
+ given \a key, with the given \a modifierMask and \a sourceState.
*/
QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiersMask,
+ Qt::KeyboardModifiers modifierMask,
QState *sourceState)
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
{
Q_D(QBasicKeyEventTransition);
d->eventType = type;
d->key = key;
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
@@ -163,23 +163,23 @@ void QBasicKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers mask that this key event transition checks
+ Returns the keyboard modifier mask that this key event transition checks
for.
*/
-Qt::KeyboardModifiers QBasicKeyEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QBasicKeyEventTransition::modifierMask() const
{
Q_D(const QBasicKeyEventTransition);
- return d->modifiersMask;
+ return d->modifierMask;
}
/*!
- Sets the keyboard modifiers mask that this key event transition will check
+ Sets the keyboard modifier mask that this key event transition will check
for.
*/
-void QBasicKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QBasicKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QBasicKeyEventTransition);
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
@@ -191,7 +191,7 @@ bool QBasicKeyEventTransition::eventTest(QEvent *event)
if (event->type() == d->eventType) {
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
return (ke->key() == d->key)
- && ((ke->modifiers() & d->modifiersMask) == d->modifiersMask);
+ && ((ke->modifiers() & d->modifierMask) == d->modifierMask);
}
return false;
}
diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/gui/statemachine/qbasickeyeventtransition_p.h
index 3c2ec7d..87d3dc7 100644
--- a/src/gui/statemachine/qbasickeyeventtransition_p.h
+++ b/src/gui/statemachine/qbasickeyeventtransition_p.h
@@ -69,7 +69,7 @@ public:
QBasicKeyEventTransition(QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiersMask,
+ Qt::KeyboardModifiers modifierMask,
QState *sourceState = 0);
~QBasicKeyEventTransition();
@@ -79,8 +79,8 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
bool eventTest(QEvent *event);
diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp
index 694c319..fe0dea9 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition.cpp
+++ b/src/gui/statemachine/qbasicmouseeventtransition.cpp
@@ -69,7 +69,7 @@ public:
QEvent::Type eventType;
Qt::MouseButton button;
- Qt::KeyboardModifiers modifiersMask;
+ Qt::KeyboardModifiers modifierMask;
QPainterPath path;
};
@@ -149,38 +149,38 @@ void QBasicMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
- Returns the keyboard modifiers mask that this mouse event transition checks
+ Returns the keyboard modifier mask that this mouse event transition checks
for.
*/
-Qt::KeyboardModifiers QBasicMouseEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QBasicMouseEventTransition::modifierMask() const
{
Q_D(const QBasicMouseEventTransition);
- return d->modifiersMask;
+ return d->modifierMask;
}
/*!
- Sets the keyboard modifiers mask that this mouse event transition will check
+ Sets the keyboard modifier mask that this mouse event transition will check
for.
*/
-void QBasicMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QBasicMouseEventTransition);
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
- Returns the path for this mouse event transition.
+ Returns the hit test path for this mouse event transition.
*/
-QPainterPath QBasicMouseEventTransition::path() const
+QPainterPath QBasicMouseEventTransition::hitTestPath() const
{
Q_D(const QBasicMouseEventTransition);
return d->path;
}
/*!
- Sets the path for this mouse event transition.
+ Sets the hit test path for this mouse event transition.
*/
-void QBasicMouseEventTransition::setPath(const QPainterPath &path)
+void QBasicMouseEventTransition::setHitTestPath(const QPainterPath &path)
{
Q_D(QBasicMouseEventTransition);
d->path = path;
@@ -195,7 +195,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event)
if (event->type() == d->eventType) {
QMouseEvent *me = static_cast<QMouseEvent*>(event);
return (me->button() == d->button)
- && ((me->modifiers() & d->modifiersMask) == d->modifiersMask)
+ && ((me->modifiers() & d->modifierMask) == d->modifierMask)
&& (d->path.isEmpty() || d->path.contains(me->pos()));
}
return false;
diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h
index 512e0f8..6754c55 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h
@@ -79,11 +79,11 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
- QPainterPath path() const;
- void setPath(const QPainterPath &path);
+ QPainterPath hitTestPath() const;
+ void setHitTestPath(const QPainterPath &path);
protected:
bool eventTest(QEvent *event);
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index dee3168..a15e671 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QKeyEventTransition::modifiersMask
+ \property QKeyEventTransition::modifierMask
- \brief the keyboard modifiers mask that this key event transition checks for
+ \brief the keyboard modifier mask that this key event transition checks for
*/
class QKeyEventTransitionPrivate : public QEventTransitionPrivate
@@ -133,23 +133,23 @@ void QKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers mask that this key event transition checks
+ Returns the keyboard modifier mask that this key event transition checks
for.
*/
-Qt::KeyboardModifiers QKeyEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QKeyEventTransition::modifierMask() const
{
Q_D(const QKeyEventTransition);
- return d->transition->modifiersMask();
+ return d->transition->modifierMask();
}
/*!
- Sets the keyboard \a modifiers mask that this key event transition will
- check for.
+ Sets the keyboard modifier mask that this key event transition will
+ check for to \a modifierMask.
*/
-void QKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QKeyEventTransition);
- d->transition->setModifiersMask(modifiersMask);
+ d->transition->setModifierMask(modifierMask);
}
/*!
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h
index 8df8138..ab1c155 100644
--- a/src/gui/statemachine/qkeyeventtransition.h
+++ b/src/gui/statemachine/qkeyeventtransition.h
@@ -57,7 +57,7 @@ class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition
{
Q_OBJECT
Q_PROPERTY(int key READ key WRITE setKey)
- Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
+ Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
QKeyEventTransition(QState *sourceState = 0);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
@@ -67,8 +67,8 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
void onTransition(QEvent *event);
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 86cacf7..f5c0cb1 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -70,9 +70,9 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QMouseEventTransition::modifiersMask
+ \property QMouseEventTransition::modifierMask
- \brief the keyboard modifiers mask that this mouse event transition checks for
+ \brief the keyboard modifier mask that this mouse event transition checks for
*/
class QMouseEventTransitionPrivate : public QEventTransitionPrivate
@@ -139,45 +139,45 @@ void QMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
- Returns the keyboard modifiers mask that this mouse event transition checks
+ Returns the keyboard modifier mask that this mouse event transition checks
for.
*/
-Qt::KeyboardModifiers QMouseEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const
{
Q_D(const QMouseEventTransition);
- return d->transition->modifiersMask();
+ return d->transition->modifierMask();
}
/*!
- Sets the keyboard \a modifiers mask that this mouse event transition will
- check for.
+ Sets the keyboard modifier mask that this mouse event transition will
+ check for to \a modifierMask.
*/
-void QMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QMouseEventTransition);
- d->transition->setModifiersMask(modifiersMask);
+ d->transition->setModifierMask(modifierMask);
}
/*!
- Returns the path for this mouse event transition.
+ Returns the hit test path for this mouse event transition.
*/
-QPainterPath QMouseEventTransition::path() const
+QPainterPath QMouseEventTransition::hitTestPath() const
{
Q_D(const QMouseEventTransition);
- return d->transition->path();
+ return d->transition->hitTestPath();
}
/*!
- Sets the \a path for this mouse event transition.
+ Sets the hit test path for this mouse event transition to \a path.
If a valid path has been set, the transition will only trigger if the mouse
event position (QMouseEvent::pos()) is inside the path.
\sa QPainterPath::contains()
*/
-void QMouseEventTransition::setPath(const QPainterPath &path)
+void QMouseEventTransition::setHitTestPath(const QPainterPath &path)
{
Q_D(QMouseEventTransition);
- d->transition->setPath(path);
+ d->transition->setHitTestPath(path);
}
/*!
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h
index 4e324ec..e7f6a45 100644
--- a/src/gui/statemachine/qmouseeventtransition.h
+++ b/src/gui/statemachine/qmouseeventtransition.h
@@ -58,7 +58,7 @@ class Q_GUI_EXPORT QMouseEventTransition : public QEventTransition
{
Q_OBJECT
Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
- Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
+ Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
QMouseEventTransition(QState *sourceState = 0);
QMouseEventTransition(QObject *object, QEvent::Type type,
@@ -68,11 +68,11 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
- QPainterPath path() const;
- void setPath(const QPainterPath &path);
+ QPainterPath hitTestPath() const;
+ void setHitTestPath(const QPainterPath &path);
protected:
void onTransition(QEvent *event);
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index d8ab06e..9b15ab1 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -259,7 +259,7 @@ void tst_QGraphicsTransform::rotation3d()
// Check that "rotation" produces the 4x4 form of the 3x3 matrix.
// i.e. third row and column are 0 0 1 0.
- t.setIdentity();
+ t.setToIdentity();
rotation.applyTo(&t);
QMatrix4x4 r(expected);
if (sizeof(qreal) == sizeof(float) && angle == 268) {
@@ -274,7 +274,7 @@ void tst_QGraphicsTransform::rotation3d()
rotation.setAxis(QVector3D(0, 0, 0));
rotation.setOrigin(QVector3D(10, 10, 0));
- t.setIdentity();
+ t.setToIdentity();
rotation.applyTo(&t);
QVERIFY(t.isIdentity());
@@ -337,7 +337,7 @@ void tst_QGraphicsTransform::rotation3dArbitraryAxis()
// Check that "rotation" produces the 4x4 form of the 3x3 matrix.
// i.e. third row and column are 0 0 1 0.
- t.setIdentity();
+ t.setToIdentity();
rotation.applyTo(&t);
QMatrix4x4 r(expected);
QVERIFY(qFuzzyCompare(t, r));
diff --git a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
index ff5e00f..d6d217f2 100644
--- a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -151,14 +151,8 @@ private slots:
void convertGeneric();
- void extractAxisRotation_data();
- void extractAxisRotation();
-
- void extractTranslation_data();
- void extractTranslation();
-
- void inferSpecialType_data();
- void inferSpecialType();
+ void optimize_data();
+ void optimize();
void columnsAndRows();
@@ -515,13 +509,13 @@ void tst_QMatrixNxN::create2x2()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues2));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix2x2 m6(uniqueValues2);
QVERIFY(isSame(m6, uniqueValues2));
qreal vals[4];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 4; ++index)
QCOMPARE(vals[index], uniqueValues2[index]);
}
@@ -550,13 +544,13 @@ void tst_QMatrixNxN::create3x3()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues3));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix3x3 m6(uniqueValues3);
QVERIFY(isSame(m6, uniqueValues3));
qreal vals[9];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 9; ++index)
QCOMPARE(vals[index], uniqueValues3[index]);
}
@@ -585,13 +579,13 @@ void tst_QMatrixNxN::create4x4()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues4));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix4x4 m6(uniqueValues4);
QVERIFY(isSame(m6, uniqueValues4));
qreal vals[16];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 16; ++index)
QCOMPARE(vals[index], uniqueValues4[index]);
@@ -627,13 +621,13 @@ void tst_QMatrixNxN::create4x3()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues4x3));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix4x3 m6(uniqueValues4x3);
QVERIFY(isSame(m6, uniqueValues4x3));
qreal vals[12];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 12; ++index)
QCOMPARE(vals[index], uniqueValues4x3[index]);
}
@@ -802,7 +796,7 @@ void tst_QMatrixNxN::transposed4x3()
QMatrix4x3 m3(uniqueValues4x3);
QMatrix3x4 m4 = m3.transposed();
qreal values[12];
- m4.toValueArray(values);
+ m4.copyDataTo(values);
for (int index = 0; index < 12; ++index)
QCOMPARE(values[index], transposedValues3x4[index]);
}
@@ -1296,7 +1290,7 @@ void tst_QMatrixNxN::multiply4x3()
QGenericMatrix<3, 3, qreal> m4;
m4 = m1 * m2;
qreal values[9];
- m4.toValueArray(values);
+ m4.copyDataTo(values);
for (int index = 0; index < 9; ++index)
QCOMPARE(values[index], ((const qreal *)m3Values)[index]);
}
@@ -1898,7 +1892,7 @@ void tst_QMatrixNxN::inverted4x4()
}
// Test again, after inferring the special matrix type.
- m1.inferSpecialType();
+ m1.optimize();
m2 = m1.inverted(&inv);
QVERIFY(isSame(m2, (const qreal *)m2Values));
QCOMPARE(inv, invertible);
@@ -1913,12 +1907,12 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
m2.rotate(45.0, 1.0, 0.0, 0.0);
m2.translate(10.0, 0.0, 0.0);
- // Use inferSpecialType() to drop the internal flags that
+ // Use optimize() to drop the internal flags that
// mark the matrix as orthonormal. This will force inverted()
// to compute m3.inverted() the long way. We can then compare
// the result to what the faster algorithm produces on m2.
QMatrix4x4 m3 = m2;
- m3.inferSpecialType();
+ m3.optimize();
bool invertible;
QVERIFY(qFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
QVERIFY(invertible);
@@ -1926,7 +1920,7 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
QMatrix4x4 m4;
m4.rotate(45.0, 0.0, 1.0, 0.0);
QMatrix4x4 m5 = m4;
- m5.inferSpecialType();
+ m5.optimize();
QVERIFY(qFuzzyCompare(m4.inverted(), m5.inverted()));
QMatrix4x4 m6;
@@ -1934,7 +1928,7 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
m1.translate(-20.0, 20.0, 15.0);
m1.rotate(25, 1.0, 0.0, 0.0);
QMatrix4x4 m7 = m6;
- m7.inferSpecialType();
+ m7.optimize();
QVERIFY(qFuzzyCompare(m6.inverted(), m7.inverted()));
}
@@ -2081,7 +2075,7 @@ void tst_QMatrixNxN::scale4x4()
m8.scale(x);
QVERIFY(isSame(m8, (const qreal *)resultValues));
- m8.inferSpecialType();
+ m8.optimize();
m8.scale(1.0f);
QVERIFY(isSame(m8, (const qreal *)resultValues));
@@ -2412,7 +2406,7 @@ void tst_QMatrixNxN::rotate4x4()
if (x != 0 || y != 0 || z != 0) {
QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle);
- QVector3D vq = q.rotateVector(v1);
+ QVector3D vq = q.rotatedVector(v1);
QVERIFY(fuzzyCompare(vq.x(), v1x));
QVERIFY(fuzzyCompare(vq.y(), v1y));
QVERIFY(fuzzyCompare(vq.z(), v1z));
@@ -2509,7 +2503,7 @@ void tst_QMatrixNxN::normalMatrix()
// Perform the test again, after inferring special matrix types.
// This tests the optimized paths in the normalMatrix() function.
- m1.inferSpecialType();
+ m1.optimize();
n1 = m1.normalMatrix();
if (invertible)
@@ -2850,120 +2844,6 @@ void tst_QMatrixNxN::convertGeneric()
QVERIFY(isSame(m11, conv4x4));
}
-void tst_QMatrixNxN::extractAxisRotation_data()
-{
- QTest::addColumn<float>("x");
- QTest::addColumn<float>("y");
- QTest::addColumn<float>("z");
- QTest::addColumn<float>("angle");
-
- QTest::newRow("1, 0, 0, 0 deg") << 1.0f << 0.0f << 0.0f << 0.0f;
- QTest::newRow("1, 0, 0, 90 deg") << 1.0f << 0.0f << 0.0f << 90.0f;
- QTest::newRow("1, 0, 0, 270 deg") << 1.0f << 0.0f << 0.0f << 270.0f;
- QTest::newRow("1, 0, 0, 45 deg") << 1.0f << 0.0f << 0.0f << 45.0f;
- QTest::newRow("1, 0, 0, 120 deg") << 1.0f << 0.0f << 0.0f << 120.0f;
- QTest::newRow("1, 0, 0, 300 deg") << 1.0f << 0.0f << 0.0f << 300.0f;
-
- QTest::newRow("0, 1, 0, 90 deg") << 0.0f << 1.0f << 0.0f << 90.0f;
- QTest::newRow("0, 1, 0, 270 deg") << 0.0f << 1.0f << 0.0f << 270.0f;
- QTest::newRow("0, 1, 0, 45 deg") << 0.0f << 1.0f << 0.0f << 45.0f;
- QTest::newRow("0, 1, 0, 120 deg") << 0.0f << 1.0f << 0.0f << 120.0f;
- QTest::newRow("0, 1, 0, 300 deg") << 0.0f << 1.0f << 0.0f << 300.0f;
-
- QTest::newRow("0, 0, 1, 90 deg") << 0.0f << 0.0f << 1.0f << 90.0f;
- QTest::newRow("0, 0, 1, 270 deg") << 0.0f << 0.0f << 1.0f << 270.0f;
- QTest::newRow("0, 0, 1, 45 deg") << 0.0f << 0.0f << 1.0f << 45.0f;
- QTest::newRow("0, 0, 1, 120 deg") << 0.0f << 0.0f << 1.0f << 120.0f;
- QTest::newRow("0, 0, 1, 300 deg") << 0.0f << 0.0f << 1.0f << 300.0f;
-
- QTest::newRow("1, 1, 1, 90 deg") << 1.0f << 1.0f << 1.0f << 90.0f;
- QTest::newRow("1, 1, 1, 270 deg") << 1.0f << 1.0f << 1.0f << 270.0f;
- QTest::newRow("1, 1, 1, 45 deg") << 1.0f << 1.0f << 1.0f << 45.0f;
- QTest::newRow("1, 1, 1, 120 deg") << 1.0f << 1.0f << 1.0f << 120.0f;
- QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f;
-}
-
-void tst_QMatrixNxN::extractAxisRotation()
-{
- QFETCH(float, x);
- QFETCH(float, y);
- QFETCH(float, z);
- QFETCH(float, angle);
-
- QMatrix4x4 m;
- QVector3D origAxis(x, y, z);
-
- m.rotate(angle, x, y, z);
-
- origAxis.normalize();
- QVector3D extractedAxis;
- qreal extractedAngle;
-
- m.extractAxisRotation(extractedAngle, extractedAxis);
-
- if (angle > 180) {
- QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle));
- QVERIFY(fuzzyCompare(extractedAxis, -origAxis));
- } else {
- QVERIFY(fuzzyCompare(angle, extractedAngle));
- QVERIFY(fuzzyCompare(extractedAxis, origAxis));
- }
-}
-
-void tst_QMatrixNxN::extractTranslation_data()
-{
- QTest::addColumn<QMatrix4x4>("rotation");
- QTest::addColumn<float>("x");
- QTest::addColumn<float>("y");
- QTest::addColumn<float>("z");
-
- static QMatrix4x4 m1;
-
- QTest::newRow("identity, 100, 50, 25")
- << m1 << 100.0f << 50.0f << 250.0f;
-
- m1.rotate(45.0, 1.0, 0.0, 0.0);
- QTest::newRow("rotX 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-
- m1.setIdentity();
- m1.rotate(45.0, 0.0, 1.0, 0.0);
- QTest::newRow("rotY 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-
- m1.setIdentity();
- m1.rotate(75, 0.0, 0.0, 1.0);
- m1.rotate(25, 1.0, 0.0, 0.0);
- m1.rotate(45, 0.0, 1.0, 0.0);
- QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-}
-
-void tst_QMatrixNxN::extractTranslation()
-{
- QFETCH(QMatrix4x4, rotation);
- QFETCH(float, x);
- QFETCH(float, y);
- QFETCH(float, z);
-
- rotation.translate(x, y, z);
-
- QVector3D vec = rotation.extractTranslation();
-
- QVERIFY(fuzzyCompare(vec.x(), x));
- QVERIFY(fuzzyCompare(vec.y(), y));
- QVERIFY(fuzzyCompare(vec.z(), z));
-
- QMatrix4x4 lookAt;
- QVector3D eye(1.5f, -2.5f, 2.5f);
- lookAt.lookAt(eye,
- QVector3D(10.0f, 10.0f, 10.0f),
- QVector3D(0.0f, 1.0f, 0.0f));
-
- QVector3D extEye = lookAt.extractTranslation();
-
- QVERIFY(fuzzyCompare(eye.x(), -extEye.x()));
- QVERIFY(fuzzyCompare(eye.y(), -extEye.y()));
- QVERIFY(fuzzyCompare(eye.z(), -extEye.z()));
-}
-
// Copy of "flagBits" in qmatrix4x4.h.
enum {
Identity = 0x0001, // Identity matrix
@@ -2981,7 +2861,7 @@ struct Matrix4x4
};
// Test the inferring of special matrix types.
-void tst_QMatrixNxN::inferSpecialType_data()
+void tst_QMatrixNxN::optimize_data()
{
QTest::addColumn<void *>("mValues");
QTest::addColumn<int>("flagBits");
@@ -3029,13 +2909,13 @@ void tst_QMatrixNxN::inferSpecialType_data()
QTest::newRow("below")
<< (void *)belowValues << (int)General;
}
-void tst_QMatrixNxN::inferSpecialType()
+void tst_QMatrixNxN::optimize()
{
QFETCH(void *, mValues);
QFETCH(int, flagBits);
QMatrix4x4 m((const qreal *)mValues);
- m.inferSpecialType();
+ m.optimize();
QCOMPARE(reinterpret_cast<Matrix4x4 *>(&m)->flagBits, flagBits);
}
@@ -3362,7 +3242,7 @@ void tst_QMatrixNxN::mapVector()
QFETCH(void *, mValues);
QMatrix4x4 m1((const qreal *)mValues);
- m1.inferSpecialType();
+ m1.optimize();
QVector3D v(3.5f, -1.0f, 2.5f);
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 975b301..9a2b2ed 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -162,7 +162,7 @@ private slots:
void defaultGlobalRestorePolicy();
void globalRestorePolicySetToRestore();
- void globalRestorePolicySetToDoNotRestore();
+ void globalRestorePolicySetToDontRestore();
void noInitialStateForInitialState();
@@ -184,7 +184,7 @@ private slots:
void twoAnimatedTransitions();
void playAnimationTwice();
void nestedTargetStateForAnimation();
- void polishedSignalTransitionsReuseAnimationGroup();
+ void propertiesAssignedSignalTransitionsReuseAnimationGroup();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
@@ -286,8 +286,8 @@ void tst_QStateMachine::transitionToRootState()
machine.addState(initialState);
machine.setInitialState(initialState);
- QAbstractTransition *trans = initialState->addTransition(new EventTransition(QEvent::User, &machine));
- QVERIFY(trans != 0);
+ QAbstractTransition *trans = new EventTransition(QEvent::User, &machine);
+ initialState->addTransition(trans);
QCOMPARE(trans->sourceState(), initialState);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(&machine));
@@ -310,7 +310,7 @@ void tst_QStateMachine::transitionFromRootState()
QState *root = &machine;
QState *s1 = new QState(root);
EventTransition *trans = new EventTransition(QEvent::User, s1);
- QCOMPARE(root->addTransition(trans), static_cast<QAbstractTransition *>(trans));
+ root->addTransition(trans);
QCOMPARE(trans->sourceState(), root);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(s1));
}
@@ -984,7 +984,7 @@ void tst_QStateMachine::customErrorStateNotInGraph()
void tst_QStateMachine::restoreProperties()
{
QStateMachine machine;
- QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DoNotRestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DontRestoreProperties);
machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QObject *object = new QObject(&machine);
@@ -1155,7 +1155,7 @@ void tst_QStateMachine::stateEntryAndExit()
QCOMPARE(t->targetState(), (QAbstractState*)s2);
QCOMPARE(t->targetStates().size(), 1);
QCOMPARE(t->targetStates().at(0), (QAbstractState*)s2);
- QCOMPARE(s1->addTransition(t), (QAbstractTransition*)t);
+ s1->addTransition(t);
QCOMPARE(t->sourceState(), (QState*)s1);
QCOMPARE(t->machine(), &machine);
@@ -1173,7 +1173,7 @@ void tst_QStateMachine::stateEntryAndExit()
s2->removeTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)0);
QCOMPARE(trans->targetState(), (QAbstractState*)s3);
- QCOMPARE(s2->addTransition(trans), trans);
+ s2->addTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)s2);
}
@@ -1319,9 +1319,9 @@ void tst_QStateMachine::assignProperty()
QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
{
- QSignalSpy polishedSpy(s1, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned()));
machine.start();
- QTRY_COMPARE(polishedSpy.count(), 1);
+ QTRY_COMPARE(propertiesAssignedSpy.count(), 1);
}
// nested states
@@ -1340,11 +1340,11 @@ void tst_QStateMachine::assignPropertyWithAnimation()
// Single animation
{
QStateMachine machine;
- QVERIFY(machine.animationsEnabled());
- machine.setAnimationsEnabled(false);
- QVERIFY(!machine.animationsEnabled());
- machine.setAnimationsEnabled(true);
- QVERIFY(machine.animationsEnabled());
+ QVERIFY(machine.isAnimated());
+ machine.setAnimated(false);
+ QVERIFY(!machine.isAnimated());
+ machine.setAnimated(true);
+ QVERIFY(machine.isAnimated());
QObject obj;
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
@@ -1371,7 +1371,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
QCOMPARE(trans->animations().size(), 1);
QCOMPARE(trans->animations().at(0), (QAbstractAnimation*)&anim);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1399,7 +1399,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(150);
trans->addAnimation(&anim2);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1427,7 +1427,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
group.addAnimation(new QPropertyAnimation(&obj, "bar"));
trans->addAnimation(&group);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1473,10 +1473,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(250);
trans->addAnimation(&anim2);
- s21->addTransition(s21, SIGNAL(polished()), s22);
+ s21->addTransition(s21, SIGNAL(propertiesAssigned()), s22);
QFinalState *s3 = new QFinalState(&machine);
- s22->addTransition(s2, SIGNAL(polished()), s3);
+ s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1513,13 +1513,13 @@ void tst_QStateMachine::assignPropertyWithAnimation()
machine.setInitialState(group);
machine.start();
QTRY_COMPARE(machine.configuration().contains(s1), true);
- QSignalSpy polishedSpy(s2, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned()));
emitter.emitSignalWithNoArg();
QTRY_COMPARE(machine.configuration().contains(s2), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
emitter.emitSignalWithNoArg(); // will cause animations from s1-->s2 to abort
QTRY_COMPARE(machine.configuration().contains(s3), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
QCOMPARE(obj.property("foo").toInt(), 911);
QCOMPARE(obj.property("bar").toInt(), 789);
}
@@ -2736,10 +2736,10 @@ void tst_QStateMachine::restorePolicyNotInherited()
}*/
-void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
+void tst_QStateMachine::globalRestorePolicySetToDontRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::DoNotRestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::DontRestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("a", 1);
@@ -3089,7 +3089,7 @@ void tst_QStateMachine::twoAnimations()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
machine.start();
@@ -3117,7 +3117,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3126,7 +3128,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation2);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation2);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3161,7 +3165,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3169,7 +3175,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3213,14 +3221,16 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QState *s2Child2 = new QState(s2);
s2Child2->assignProperty(object, "bar", 11.0);
- QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2Child2);
+ s2Child->addTransition(at);
QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2);
animation->setDuration(2000);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(animation);
- at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
animation = new QPropertyAnimation(object, "foo", s2);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
@@ -3231,7 +3241,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
at->addAnimation(animation);
QState *s3 = new QState(&machine);
- s2->addTransition(s2Child, SIGNAL(polished()), s3);
+ s2->addTransition(s2Child, SIGNAL(propertiesAssigned()), s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3248,7 +3258,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QCOMPARE(counter.counter, 2);
}
-void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
+void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup()
{
QStateMachine machine;
QObject *object = new QObject(&machine);
@@ -3265,9 +3275,9 @@ void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
QParallelAnimationGroup animationGroup;
animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
- s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup);
- s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup);
- s3->addTransition(s3, SIGNAL(polished()), s4);
+ s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup);
+ s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4);
machine.setInitialState(s1);
QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
@@ -3299,7 +3309,8 @@ void tst_QStateMachine::animatedGlobalRestoreProperty()
QState *s4 = new QState(&machine);
QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2);
connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(pa);
@@ -3341,7 +3352,9 @@ void tst_QStateMachine::specificTargetValueOfAnimation()
QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
anim->setEndValue(10.0);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(anim);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(anim);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3495,7 +3508,8 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index e2a606f..3d68a73 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -1432,8 +1432,10 @@ void tst_QVariant::matrix4x4()
QVariant variant;
QMatrix4x4 matrix = qVariantValue<QMatrix4x4>(variant);
QVERIFY(matrix.isIdentity());
- qVariantSetValue(variant, QMatrix4x4().scale(2.0));
- QCOMPARE(QMatrix4x4().scale(2.0), qVariantValue<QMatrix4x4>(variant));
+ QMatrix4x4 m;
+ m.scale(2.0f);
+ qVariantSetValue(variant, m);
+ QCOMPARE(m, qVariantValue<QMatrix4x4>(variant));
void *mmatrix = QMetaType::construct(QVariant::Matrix4x4, 0);
QVERIFY(mmatrix);
diff --git a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
index 71f45ff..f80b579 100644
--- a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
+++ b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
@@ -220,7 +220,7 @@ void tst_QMatrix4x4::mapVector3D()
QVector3D v(10.5f, -2.0f, 3.0f);
QVector3D result;
- m1.inferSpecialType();
+ m1.optimize();
QBENCHMARK {
result = m1 * v;
@@ -244,7 +244,7 @@ void tst_QMatrix4x4::mapVector2D()
QPointF v(10.5f, -2.0f);
QPointF result;
- m1.inferSpecialType();
+ m1.optimize();
QBENCHMARK {
result = m1 * v;