Warning, file /office/calligra/libs/flake/KoViewConverter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KOVIEWCONVERTER_H
0021 #define KOVIEWCONVERTER_H
0022 
0023 #include "flake_export.h"
0024 
0025 #include <QtGlobal>
0026 
0027 class QPointF;
0028 class QRectF;
0029 class QSizeF;
0030 
0031 /**
0032  * The interface for view conversions.
0033  *
0034  * All KoShape based objects are using a postscript-point (pt) based measurement system
0035  * which requires a conversion to view coordinates (in pixel sizes) at the moment
0036  * we are painting, and a conversion to the normalized coordinate system if we
0037  * receive mouse events so we can figure out which KoShape object was touched.
0038  *
0039  * The zoom level is expressed on a scale of 0.0 to 1.0 to infinite, where 1.0 is
0040  * 100%
0041  */
0042 class FLAKE_EXPORT KoViewConverter
0043 {
0044 public:
0045     KoViewConverter();
0046     virtual ~KoViewConverter() {}
0047 
0048     /**
0049      * Convert a coordinate in pt to pixels.
0050      * @param documentPoint the point in the document coordinate system of a KoShape.
0051      */
0052     virtual QPointF documentToView(const QPointF &documentPoint) const;
0053 
0054     /**
0055      * Convert a coordinate in pixels to pt.
0056      * @param viewPoint the point in the coordinate system of the widget, or window.
0057      */
0058     virtual QPointF viewToDocument(const QPointF &viewPoint) const;
0059 
0060     /**
0061      * Convert a rectangle in pt to pixels.
0062      * @param documentRect the rect in the document coordinate system of a KoShape.
0063      */
0064     virtual QRectF documentToView(const QRectF &documentRect) const;
0065 
0066     /**
0067      * Convert a rectangle in pixels to pt.
0068      * @param viewRect the rect in the coordinate system of the widget, or window.
0069      */
0070     virtual QRectF viewToDocument(const QRectF &viewRect) const;
0071 
0072     /**
0073      * Convert a size in pt to pixels.
0074      * @param documentSize the size in pt.
0075      * @return the size in pixels.
0076      */
0077     virtual QSizeF documentToView(const QSizeF& documentSize) const;
0078 
0079     /**
0080      * Convert a size in pixels to pt.
0081      * @param viewSize the size in pixels.
0082      * @return the size in pt.
0083      */
0084     virtual QSizeF viewToDocument(const QSizeF& viewSize) const;
0085 
0086     /**
0087      * Convert a single x coordinate in pt to pixels.
0088      * @param documentX the x coordinate in pt.
0089      * @return the x coordinate in pixels.
0090      */
0091     virtual qreal documentToViewX(qreal documentX) const;
0092 
0093     /**
0094      * Convert a single y coordinate in pt to pixels.
0095      * @param documentY the y coordinate in pt.
0096      * @return the y coordinate in pixels.
0097      */
0098     virtual qreal documentToViewY(qreal documentY) const;
0099 
0100     /**
0101      * Convert a single x coordinate in pixels to pt.
0102      * @param viewX the x coordinate in pixels.
0103      * @return the x coordinate in pt.
0104      */
0105     virtual qreal viewToDocumentX(qreal viewX) const;
0106 
0107     /**
0108      * Convert a single y coordinate in pixels to pt.
0109      * @param viewY the y coordinate in pixels.
0110      * @return the y coordinate in pt.
0111      */
0112     virtual qreal viewToDocumentY(qreal viewY) const;
0113 
0114     /**
0115      * Retrieve the zoom levels of the individual x and y axes.
0116      * @param zoomX a pointer to a qreal which will be modified to the horizontal zoom.
0117      * @param zoomY a pointer to a qreal which will be modified to the vertical zoom.
0118      */
0119     virtual void zoom(qreal *zoomX, qreal *zoomY) const;
0120 
0121     /**
0122      * Set the zoom level. 1.0 is 100%.
0123      */
0124     virtual void setZoom(qreal zoom);
0125 
0126     /**
0127      * Return the current zoom level. 1.0 is 100%.
0128      */
0129     qreal zoom() const;
0130 
0131 private:
0132     qreal m_zoomLevel; // 1.0 is 100%
0133 };
0134 
0135 #endif