Commit 69204e38 authored by Adrian Page's avatar Adrian Page

Add coordinate conversion helpers.

svn path=/trunk/koffice/; revision=663987
parent 892c3fe2
......@@ -566,6 +566,16 @@ QPoint KisImage::documentToIntPixel(const QPointF &documentCoord) const
return QPoint((int)pixelCoord.x(), (int)pixelCoord.y());
}
QRectF KisImage::documentToPixel(const QRectF &documentRect) const
{
return QRectF(documentToPixel(documentRect.topLeft()), documentToPixel(documentRect.bottomRight()));
}
QRect KisImage::documentToIntPixel(const QRectF &documentRect) const
{
return documentToPixel(documentRect).toAlignedRect();
}
QPointF KisImage::pixelToDocument(const QPointF &pixelCoord) const
{
return QPointF(pixelCoord.x() / xRes(), pixelCoord.y() / yRes());
......
......@@ -253,6 +253,20 @@ public:
*/
QPoint documentToIntPixel(const QPointF &documentCoord) const;
/**
* Convert a document rectangle to a pixel rectangle.
*
* @param documentCoord PostScript Pt coordinate to convert.
*/
QRectF documentToPixel(const QRectF &documentRect) const;
/**
* Convert a document rectangle to an integer pixel rectangle.
*
* @param documentCoord PostScript Pt coordinate to convert.
*/
QRect documentToIntPixel(const QRectF &documentRect) const;
/**
* Convert a pixel coordinate to a document coordinate.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment