summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qtransform.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-06-02 19:02:42 (GMT)
committerLars Knoll <lars.knoll@nokia.com>2009-06-15 11:00:00 (GMT)
commitb615be69f06a97aff3694065e97541133647d877 (patch)
treedc90aa08d31b6bdde2d534394311d3543a9e9981 /src/gui/painting/qtransform.cpp
parent44766d265c16551043d2739171069fe042c40091 (diff)
downloadQt-b615be69f06a97aff3694065e97541133647d877.zip
Qt-b615be69f06a97aff3694065e97541133647d877.tar.gz
Qt-b615be69f06a97aff3694065e97541133647d877.tar.bz2
implement equality operator in a more sane way
Using qFuzzyCompare for checking whether two transformations are equal doesn't give us too much and is inconsistent with our other matrix classes. Using simple floating point equality is a lot faster as well. Added qFuzzyCompare overloads for QMatrix and QTransform to still allow for fuzzy comparisons. Reviewed-By: Samuel Rødal
Diffstat (limited to 'src/gui/painting/qtransform.cpp')
-rw-r--r--src/gui/painting/qtransform.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4bc20f6..385fde1 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -708,11 +708,15 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
*/
bool QTransform::operator==(const QTransform &o) const
{
-#define qFZ qFuzzyCompare
- return qFZ(affine._m11, o.affine._m11) && qFZ(affine._m12, o.affine._m12) && qFZ(m_13, o.m_13)
- && qFZ(affine._m21, o.affine._m21) && qFZ(affine._m22, o.affine._m22) && qFZ(m_23, o.m_23)
- && qFZ(affine._dx, o.affine._dx) && qFZ(affine._dy, o.affine._dy) && qFZ(m_33, o.m_33);
-#undef qFZ
+ return affine._m11 == o.affine._m11 &&
+ affine._m12 == o.affine._m12 &&
+ affine._m21 == o.affine._m21 &&
+ affine._m22 == o.affine._m22 &&
+ affine._dx == o.affine._dx &&
+ affine._dy == o.affine._dy &&
+ m_13 == o.m_13 &&
+ m_23 == o.m_23 &&
+ m_33 == o.m_33;
}
/*!
@@ -2178,6 +2182,17 @@ QTransform::operator QVariant() const
\sa reset()
*/
+/*!
+ \fn bool qFuzzyCompare(const QTransform& t1, const QTransform& t2)
+
+ \relates QTransform
+ \since 4.6
+
+ Returns true if \a t1 and \a t2 are equal, allowing for a small
+ fuzziness factor for floating-point comparisons; false otherwise.
+*/
+
+
// returns true if the transform is uniformly scaling
// (same scale in x and y direction)
// scale is set to the max of x and y scaling factors