Commit a68a37d6 authored by Thomas Zander's avatar Thomas Zander

QMatrix is deprecated, replace with QTransform

svn path=/trunk/koffice/; revision=1145827
parent eea3a25a
......@@ -20,7 +20,7 @@
#include "kis_paint_device.h"
#include <QRect>
#include <QMatrix>
#include <QTransform>
#include <QImage>
#include <QList>
#include <QHash>
......
......@@ -19,7 +19,7 @@
#include "kis_shear_visitor.h"
#include <math.h>
#include <QApplication>
#include <QMatrix>
#include <QTransform>
#include <QRect>
#include <kis_debug.h>
......
......@@ -248,7 +248,7 @@ QImage KisAutoBrush::createBrushPreview()
pixel[i] = qRgb(v, v, v);
}
}
return image.transformed(QMatrix().rotate(-d->angle * 180 / M_PI));
return image.transformed(QTransform().rotate(-d->angle * 180 / M_PI));
}
QPointF KisAutoBrush::hotSpot(double scaleX, double scaleY, double rotation) const
......
......@@ -491,7 +491,7 @@ KisFixedPaintDeviceSP KisBrush::paintDevice(const KoColorSpace * colorSpace,
if (angle != 0.0)
{
outputImage = outputImage.transformed(QMatrix().rotate(-angle * 180 / M_PI));
outputImage = outputImage.transformed(QTransform().rotate(-angle * 180 / M_PI));
}
int outputWidth = outputImage.width();
......
......@@ -122,7 +122,7 @@ void KisQImagemask::rotation(double angle)
for (int i = 0; i < 256; ++i) table.append(qRgb(i, i, i));
m_data.setColorTable(table);
QImage tmp = m_data.convertToFormat(QImage::Format_RGB32);
tmp = tmp.transformed(QMatrix().rotate(-angle * 180 / M_PI));
tmp = tmp.transformed(QTransform().rotate(-angle * 180 / M_PI));
m_data = QImage(tmp.width(), tmp.height(), QImage::Format_Indexed8);
// Do not use convertToFormat to go back to Indexed8, since it is quiet
// a slow general operation, while we know that we are outputing a grayscale image
......
......@@ -30,7 +30,7 @@
#include <QHash>
#include <QTransform>
#include <QImage>
#include <QMatrix>
#include <QTransform>
#include <kis_random_accessor.h>
#include <kis_random_sub_accessor.h>
......@@ -282,7 +282,7 @@ void SprayBrush::paint(KisPaintDeviceSP dab, KisPaintDeviceSP source,
if ( !m_brushQImage.isNull() )
{
QMatrix m;
QTransform m;
m.rotate(rad2deg(rotationZ));
if (m_shapeDynamicsProperties->randomSize){
......
......@@ -194,7 +194,7 @@ void KisToolLine::mouseReleaseEvent(KoPointerEvent *e)
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(m_startPos));
path->lineTo(resolutionMatrix.map(m_endPos));
......
......@@ -103,7 +103,7 @@ void KisToolPath::addPathShape(KoPathShape* pathShape)
// Compute the outline
KisImageWSP image = kiscanvas->view()->image();
QMatrix matrix;
QTransform matrix;
matrix.scale(image->xRes(), image->yRes());
matrix.translate(pathShape->position().x(), pathShape->position().y());
QPainterPath mapedOutline = matrix.map(pathShape->outline());
......@@ -198,7 +198,7 @@ void KisToolPath::LocalTool::paintPath(KoPathShape &pathShape, QPainter &painter
if (!kisCanvas)
return;
QMatrix matrix;
QTransform matrix;
matrix.scale(kisCanvas->image()->xRes(), kisCanvas->image()->yRes());
matrix.translate(pathShape.position().x(), pathShape.position().y());
m_parentTool->paintToolOutline(&painter, m_parentTool->pixelToView(matrix.map(pathShape.outline())));
......
......@@ -183,7 +183,7 @@ void KisToolSelectMagnetic::LocalTool::paintPath(KoPathShape &pathShape, QPainte
if (!kisCanvas)
return;
QMatrix matrix;
QTransform matrix;
matrix.scale(kisCanvas->image()->xRes(), kisCanvas->image()->yRes());
matrix.translate(pathShape.position().x(), pathShape.position().y());
......
......@@ -133,7 +133,7 @@ void KisToolSelectOutline::mouseReleaseEvent(KoPointerEvent *event)
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(m_points[0]));
for (int i = 1; i < m_points.count(); i++)
......
......@@ -22,7 +22,7 @@
#include <QPen>
#include <QLayout>
#include <QVBoxLayout>
#include <QMatrix>
#include <QTransform>
#include <klocale.h>
......@@ -127,7 +127,7 @@ void KisToolSelectPath::LocalTool::paintPath(KoPathShape &pathShape, QPainter &p
if (!kisCanvas)
return;
QMatrix matrix;
QTransform matrix;
matrix.scale(kisCanvas->image()->xRes(), kisCanvas->image()->yRes());
matrix.translate(pathShape.position().x(), pathShape.position().y());
m_selectingTool->paintToolOutline(&painter, m_selectingTool->pixelToView(matrix.map(pathShape.outline())));
......@@ -163,7 +163,7 @@ void KisToolSelectPath::LocalTool::addPathShape(KoPathShape* pathShape)
painter.setOpacity(OPACITY_OPAQUE_U8);
painter.setCompositeOp(tmpSel->colorSpace()->compositeOp(COMPOSITE_OVER));
QMatrix matrix;
QTransform matrix;
matrix.scale(image->xRes(), image->yRes());
matrix.translate(pathShape->position().x(), pathShape->position().y());
painter.fillPainterPath(matrix.map(pathShape->outline()));
......
......@@ -102,7 +102,7 @@ void KisToolSelectPolygonal::LocalTool::finishPolyline(const QVector<QPointF> &p
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(points[0]));
for (int i = 1; i < points.count(); i++)
......
......@@ -88,7 +88,7 @@ void KisToolPolygon::finishPolyline(const QVector<QPointF>& points)
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(points[0]));
for (int i = 1; i < points.count(); i++)
......
......@@ -94,7 +94,7 @@ void KisToolPolyline::finishPolyline(const QVector<QPointF>& points)
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(points[0]));
for (int i = 1; i < points.count(); i++)
......
......@@ -147,7 +147,7 @@ void KisToolStar::mouseReleaseEvent(KoPointerEvent *event)
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / currentImage()->xRes(), 1 / currentImage()->yRes());
path->moveTo(resolutionMatrix.map(coord[0]));
for (int i = 1; i < coord.count(); i++)
......
......@@ -718,19 +718,19 @@ void KisToolTransform::transform()
if (currentSelection()->hasShapeSelection()) {
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(1 / image()->xRes(), 1 / image()->yRes());
QPointF center = resolutionMatrix.map(m_originalCenter);
QMatrix matrix;
QTransform matrix;
matrix.translate(center.x(), center.y());
matrix.rotate(m_a / M_PI*180);
matrix.translate(-center.x(), -center.y());
KisShapeSelection* shapeSelection = static_cast<KisShapeSelection*>(currentSelection()->shapeSelection());
QList<KoShape *> shapes = shapeSelection->shapeManager()->shapes();
QList<QMatrix> m_oldMatrixList;
QList<QMatrix> m_newMatrixList;
QList<QTransform> m_oldMatrixList;
QList<QTransform> m_newMatrixList;
foreach(KoShape *shape, shapes) {
m_oldMatrixList << shape->transformation();
m_newMatrixList << shape->transformation()*matrix;
......
......@@ -1283,15 +1283,15 @@ void KisToolTransform::applyTransform()
// KisShapeSelection* currentShapeSelection = static_cast<KisShapeSelection*>(currentSelection()->shapeSelection());
// QList<KoShape *> currentShapes = currentShapeSelection->shapeManager()->shapes();
// QList<KoShape *> previousShapes = m_previousShapeSelection->shapeManager()->shapes();
// QList<QMatrix> m_oldMatrixList;
// QList<QMatrix> m_newMatrixList;
// QList<QTransform> m_oldMatrixList;
// QList<QTransform> m_newMatrixList;
// for (int i = 0; i < origShapes.size(); ++i) {
// KoShape *origShape = origShapes.at(i);
// QMatrix origMatrix = origShape->transformation();
// QMatrix previousMatrix = previousShapes.at(i)->transformation();
// QTransform origMatrix = origShape->transformation();
// QTransform previousMatrix = previousShapes.at(i)->transformation();
// QPointF center = origMatrix.map(QPointF(0.5 * origShape->size().width(), 0.5 * origShape->size().height()));
// QMatrix rotateMatrix;
// QTransform rotateMatrix;
// rotateMatrix.translate(center.x(), center.y());
// rotateMatrix.rotate(180. * m_a / M_PI);
// rotateMatrix.translate(-center.x(), -center.y());
......
......@@ -432,15 +432,15 @@ QUndoCommand* KisShapeLayer::transform(double xscale, double yscale, double x
if(shapes.isEmpty())
return 0;
QMatrix matrix;
QTransform matrix;
matrix.translate(transF.x(), transF.y());
matrix.scale(xscale,yscale);
matrix.rotate(angle*180/M_PI);
QList<QMatrix> oldTransformations;
QList<QMatrix> newTransformations;
QList<QTransform> oldTransformations;
QList<QTransform> newTransformations;
foreach(const KoShape* shape, shapes) {
QMatrix oldTransform = shape->transformation();
QTransform oldTransform = shape->transformation();
oldTransformations.append(oldTransform);
newTransformations.append(oldTransform*matrix);
......
......@@ -297,7 +297,7 @@ QPainterPath KisShapeSelection::selectionOutline()
QPainterPath outline;
foreach(KoShape * shape, shapesList) {
QMatrix shapeMatrix = shape->absoluteTransformation(0);
QTransform shapeMatrix = shape->absoluteTransformation(0);
outline = outline.united(shapeMatrix.map(shape->outline()));
}
m_outline = outline;
......@@ -316,7 +316,7 @@ void KisShapeSelection::renderToProjection(KisSelection* projection)
{
Q_ASSERT(projection);
Q_ASSERT(m_image);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(m_image->xRes(), m_image->yRes());
QRectF boundingRect = resolutionMatrix.mapRect(selectionOutline().boundingRect());
......@@ -334,7 +334,7 @@ void KisShapeSelection::renderSelection(KisSelection* projection, const QRect& r
Q_ASSERT(projection);
Q_ASSERT(m_image);
QMatrix resolutionMatrix;
QTransform resolutionMatrix;
resolutionMatrix.scale(m_image->xRes(), m_image->yRes());
QTime t;
......
......@@ -51,7 +51,7 @@ void KisShapeSelectionModel::add(KoShape *child)
m_shapeSelection->setDirty();
QRect updateRect = child->boundingRect().toAlignedRect();
QMatrix matrix;
QTransform matrix;
matrix.scale(m_image->xRes(), m_image->yRes());
updateRect = matrix.mapRect(updateRect);
......@@ -76,7 +76,7 @@ void KisShapeSelectionModel::remove(KoShape *child)
m_shapeSelection->setDirty();
}
QMatrix matrix;
QTransform matrix;
matrix.scale(m_image->xRes(), m_image->yRes());
updateRect = matrix.mapRect(updateRect);
if (m_shapeSelection) { // No m_shapeSelection indicates the selection is being deleted
......@@ -132,7 +132,7 @@ void KisShapeSelectionModel::childChanged(KoShape * child, KoShape::ChangeType t
QRectF changedRect = m_shapeMap[child];
changedRect = changedRect.unite(child->boundingRect());
QMatrix matrix;
QTransform matrix;
matrix.scale(m_image->xRes(), m_image->yRes());
changedRect = matrix.mapRect(changedRect);
......
......@@ -186,11 +186,11 @@ void KisSelectionDecoration::drawDecoration(QPainter& painter, const QPoint& doc
}
if (m_mode == Ants && selection && selection->hasPixelSelection()) {
QMatrix matrix;
QTransform matrix;
matrix.scale(sx / view()->image()->xRes(), sy / view()->image()->yRes());
QMatrix oldWorldMatrix = painter.worldMatrix();
painter.setWorldMatrix(matrix, true);
QTransform oldWorldMatrix = painter.worldTransform();
painter.setWorldTransform(matrix, true);
QTime t;
t.start();
......@@ -214,7 +214,7 @@ void KisSelectionDecoration::drawDecoration(QPainter& painter, const QPoint& doc
dbgRender << "Polygons :" << i;
dbgRender << "Painting marching ants :" << t.elapsed();
painter.setWorldMatrix(oldWorldMatrix);
painter.setWorldTransform(oldWorldMatrix);
}
if (m_mode == Ants && selection && selection->hasShapeSelection()) {
KisShapeSelection* shapeSelection = static_cast<KisShapeSelection*>(selection->shapeSelection());
......@@ -231,7 +231,7 @@ void KisSelectionDecoration::drawDecoration(QPainter& painter, const QPoint& doc
painter.setRenderHint(QPainter::Antialiasing);
QColor outlineColor = Qt::black;
QMatrix zoomMatrix;
QTransform zoomMatrix;
zoomMatrix.scale(sx, sy);
QPen backgroundPen(Qt::white);
......
......@@ -49,7 +49,7 @@ void KisShapeSelectionTest::testAddChild()
QCOMPARE(selection->selectedExactRect(), QRect(0, 0, 100, 100));
QRect rect(50, 50, 100, 100);
QMatrix matrix;
QTransform matrix;
matrix.scale(1 / image->xRes(), 1 / image->yRes());
rect = matrix.mapRect(rect);
......
......@@ -21,7 +21,7 @@
#include <QLabel>
#include <QWidget>
#include <QPolygonF>
#include <QMatrix>
#include <QTransform>
#include <klocale.h>
#include <kaction.h>
......@@ -253,7 +253,7 @@ QRectF KisTool::pixelToView(const QRectF &pixelRect) const
QPainterPath KisTool::pixelToView(const QPainterPath &pixelPolygon) const
{
QMatrix matrix;
QTransform matrix;
qreal zoomX, zoomY;
canvas()->viewConverter()->zoom(&zoomX, &zoomY);
matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes());
......@@ -262,7 +262,7 @@ QPainterPath KisTool::pixelToView(const QPainterPath &pixelPolygon) const
QPolygonF KisTool::pixelToView(const QPolygonF &pixelPath) const
{
QMatrix matrix;
QTransform matrix;
qreal zoomX, zoomY;
canvas()->viewConverter()->zoom(&zoomX, &zoomY);
matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes());
......
......@@ -60,7 +60,7 @@ QPointF KoConnectionShapePrivate::escapeDirection(int handleId) const
Q_Q(const KoConnectionShape);
QPointF direction;
if (handleConnected(handleId)) {
QMatrix absoluteMatrix = q->absoluteTransformation(0);
QTransform absoluteMatrix = q->absoluteTransformation(0);
QPointF handlePoint = absoluteMatrix.map(handles[handleId]);
QPointF centerPoint;
if (handleId == StartHandle)
......@@ -82,7 +82,7 @@ QPointF KoConnectionShapePrivate::escapeDirection(int handleId) const
direction = QPointF(1.0, 0.0);
// transform escape direction by using our own transformation matrix
QMatrix invMatrix = absoluteMatrix.inverted();
QTransform invMatrix = absoluteMatrix.inverted();
direction = invMatrix.map(direction) - invMatrix.map(QPointF());
direction /= sqrt(direction.x() * direction.x() + direction.y() * direction.y());
}
......@@ -387,7 +387,7 @@ bool KoConnectionShape::loadOdf(const KoXmlElement & element, KoShapeLoadingCont
// if there is none, use the bounding rectangle of the parsed path
viewBox = outline().boundingRect();
}
QMatrix viewMatrix;
QTransform viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
d->map(viewMatrix);
......@@ -444,7 +444,7 @@ void KoConnectionShape::finishLoadingConnection()
QRectF targetRect = QRectF(p1, p2).normalized();
// transform the normalized coordinates back to our target rectangle
QMatrix viewMatrix;
QTransform viewMatrix;
viewMatrix.translate(targetRect.x(), targetRect.y());
viewMatrix.scale(kX, kY);
d->map(viewMatrix);
......
......@@ -23,7 +23,7 @@
#include <KoGenericRegistry.h>
#include <KoFilterEffectFactoryBase.h>
#include <QtCore/QObject>
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
#include "flake_export.h"
......
......@@ -21,7 +21,7 @@
#include "KoViewConverter.h"
#include <QtCore/QRectF>
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
class KoFilterEffectRenderContext::Private
{
......
......@@ -40,10 +40,10 @@ public:
}
QGradient * gradient;
QMatrix matrix;
QTransform matrix;
};
KoGradientBackground::KoGradientBackground(QGradient * gradient, const QMatrix &matrix)
KoGradientBackground::KoGradientBackground(QGradient * gradient, const QTransform &matrix)
: KoShapeBackground(*(new KoGradientBackgroundPrivate()))
{
Q_D(KoGradientBackground);
......@@ -53,7 +53,7 @@ KoGradientBackground::KoGradientBackground(QGradient * gradient, const QMatrix &
Q_ASSERT(d->gradient->coordinateMode() == QGradient::ObjectBoundingMode);
}
KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QMatrix &matrix)
KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QTransform &matrix)
: KoShapeBackground(*(new KoGradientBackgroundPrivate()))
{
Q_D(KoGradientBackground);
......@@ -67,13 +67,13 @@ KoGradientBackground::~KoGradientBackground()
{
}
void KoGradientBackground::setMatrix(const QMatrix &matrix)
void KoGradientBackground::setTransform(const QTransform &matrix)
{
Q_D(KoGradientBackground);
d->matrix = matrix;
}
QMatrix KoGradientBackground::matrix() const
QTransform KoGradientBackground::transform() const
{
Q_D(const KoGradientBackground);
return d->matrix;
......@@ -126,7 +126,7 @@ void KoGradientBackground::paint(QPainter &painter, const QPainterPath &fillPath
{
Q_D(const KoGradientBackground);
QBrush brush(*d->gradient);
brush.setMatrix(d->matrix);
brush.setTransform(d->matrix);
painter.setBrush(brush);
painter.drawPath(fillPath);
......@@ -136,7 +136,7 @@ void KoGradientBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &co
{
Q_D(KoGradientBackground);
QBrush brush(*d->gradient);
brush.setMatrix(d->matrix);
brush.setTransform(d->matrix);
KoOdfGraphicStyles::saveOdfFillStyle(style, context.mainStyles(), brush);
}
......@@ -153,7 +153,7 @@ bool KoGradientBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF
const QGradient * gradient = brush.gradient();
if (gradient) {
d->gradient = KoFlake::cloneGradient(gradient);
d->matrix = brush.matrix();
d->matrix = brush.transform();
return true;
}
}
......
......@@ -23,7 +23,7 @@
#include "KoShapeBackground.h"
#include "flake_export.h"
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
#include <QtGui/QGradient>
class KoGradientBackgroundPrivate;
......@@ -36,22 +36,22 @@ public:
* Creates new gradient background from given gradient.
* The background takes ownership of the given gradient.
*/
explicit KoGradientBackground(QGradient *gradient, const QMatrix &matrix = QMatrix());
explicit KoGradientBackground(QGradient *gradient, const QTransform &matrix = QTransform());
/**
* Create new gradient background from the given gradient.
* A clone of the given gradient is used.
*/
explicit KoGradientBackground(const QGradient &gradient, const QMatrix &matrix = QMatrix());
explicit KoGradientBackground(const QGradient &gradient, const QTransform &matrix = QTransform());
/// Destroys the background
virtual ~KoGradientBackground();
/// Sets the transform matrix
void setMatrix(const QMatrix &matrix);
void setTransform(const QTransform &matrix);
/// Returns the transform matrix
QMatrix matrix() const;
QTransform transform() const;
/**
* Sets a new gradient.
......
......@@ -81,10 +81,10 @@ void KoParameterShape::paintHandles(QPainter & painter, const KoViewConverter &
Q_D(KoParameterShape);
applyConversion(painter, converter);
QMatrix worldMatrix = painter.worldMatrix();
painter.setMatrix(QMatrix());
QTransform worldMatrix = painter.worldTransform();
painter.setTransform(QTransform());
QMatrix matrix;
QTransform matrix;
matrix.rotate(45.0);
QPolygonF poly(d->handleRect(QPointF(0, 0), handleRadius));
poly = matrix.map(poly);
......@@ -103,10 +103,10 @@ void KoParameterShape::paintHandle(QPainter & painter, const KoViewConverter & c
Q_D(KoParameterShape);
applyConversion(painter, converter);
QMatrix worldMatrix = painter.worldMatrix();
painter.setMatrix(QMatrix());
QTransform worldMatrix = painter.worldTransform();
painter.setTransform(QTransform());
QMatrix matrix;
QTransform matrix;
matrix.rotate(45.0);
QPolygonF poly(d->handleRect(QPointF(0, 0), handleRadius));
poly = matrix.map(poly);
......@@ -117,7 +117,7 @@ void KoParameterShape::paintHandle(QPainter & painter, const KoViewConverter & c
void KoParameterShape::setSize(const QSizeF &newSize)
{
Q_D(KoParameterShape);
QMatrix matrix(resizeMatrix(newSize));
QTransform matrix(resizeMatrix(newSize));
for (int i = 0; i < d->handles.size(); ++i) {
d->handles[i] = matrix.map(d->handles[i]);
......@@ -130,7 +130,7 @@ QPointF KoParameterShape::normalize()
{
Q_D(KoParameterShape);
QPointF offset(KoPathShape::normalize());
QMatrix matrix;
QTransform matrix;
matrix.translate(-offset.x(), -offset.y());
for (int i = 0; i < d->handles.size(); ++i) {
......
......@@ -248,7 +248,7 @@ bool KoPathPoint::activeControlPoint2() const
return d->activeControlPoint2;
}
void KoPathPoint::map(const QMatrix &matrix, bool mapGroup)
void KoPathPoint::map(const QTransform &matrix, bool mapGroup)
{
if (d->pointGroup && mapGroup) {
d->pointGroup->map(matrix);
......@@ -276,16 +276,16 @@ void KoPathPoint::paint(QPainter &painter, int handleRadius, PointTypes types, b
painter.drawLine(point(), controlPoint1());