23
23
#include <QtCore/QPointF>
24
24
#include <QtCore/QRectF>
26
#include "flake_export.h"
27
29
* The interface for view conversions.
28
31
* All KoShape based objects are using a postscript-point (pt) based measurement system
29
32
* which requires a conversion to view coordinates (in pixel sizes) at the moment
30
33
* we are painting, and a conversion to the normalized coordinate system if we
31
34
* receive mouse events so we can figure out which KoShape object was touched.
36
* The zoom level is expressed on a scale of 0.0 to 1.0 to infinite, where 1.0 is
39
class FLAKE_EXPORT KoViewConverter
37
43
virtual ~KoViewConverter() {}
40
46
* Convert a coordinate in pt to pixels.
41
47
* @param documentPoint the point in the document coordinate system of a KoShape.
43
virtual QPointF documentToView(const QPointF &documentPoint) const = 0;
49
virtual QPointF documentToView(const QPointF &documentPoint) const;
46
52
* Convert a coordinate in pixels to pt.
47
53
* @param viewPoint the point in the coordinate system of the widget, or window.
49
virtual QPointF viewToDocument(const QPointF &viewPoint) const = 0;
55
virtual QPointF viewToDocument(const QPointF &viewPoint) const;
52
58
* Convert a rectangle in pt to pixels.
53
59
* @param documentRect the rect in the document coordinate system of a KoShape.
55
virtual QRectF documentToView(const QRectF &documentRect) const = 0;
61
virtual QRectF documentToView(const QRectF &documentRect) const;
58
64
* Convert a rectangle in pixels to pt.
59
65
* @param viewRect the rect in the coordinate system of the widget, or window.
61
virtual QRectF viewToDocument(const QRectF &viewRect) const = 0;
67
virtual QRectF viewToDocument(const QRectF &viewRect) const;
64
70
* Convert a size in pt to pixels.
65
71
* @param documentSize the size in pt.
66
72
* @return the size in pixels.
68
virtual QSizeF documentToView(const QSizeF& documentSize) const = 0;
74
virtual QSizeF documentToView(const QSizeF& documentSize) const;
71
77
* Convert a size in pixels to pt.
72
78
* @param viewSize the size in pixels.
73
79
* @return the size in pt.
75
virtual QSizeF viewToDocument(const QSizeF& viewSize) const = 0;
81
virtual QSizeF viewToDocument(const QSizeF& viewSize) const;
78
84
* Convert a single x coordinate in pt to pixels.
79
85
* @param documentX the x coordinate in pt.
80
86
* @return the x coordinate in pixels.
82
virtual qreal documentToViewX(qreal documentX) const = 0;
88
virtual qreal documentToViewX(qreal documentX) const;
85
91
* Convert a single y coordinate in pt to pixels.
86
92
* @param documentY the y coordinate in pt.
87
93
* @return the y coordinate in pixels.
89
virtual qreal documentToViewY(qreal documentY) const = 0;
95
virtual qreal documentToViewY(qreal documentY) const;
92
98
* Convert a single x coordinate in pixels to pt.
93
99
* @param viewX the x coordinate in pixels.
94
100
* @return the x coordinate in pt.
96
virtual qreal viewToDocumentX(qreal viewX) const = 0;
102
virtual qreal viewToDocumentX(qreal viewX) const;
99
105
* Convert a single y coordinate in pixels to pt.
100
106
* @param viewY the y coordinate in pixels.
101
107
* @return the y coordinate in pt.
103
virtual qreal viewToDocumentY(qreal viewY) const = 0;
109
virtual qreal viewToDocumentY(qreal viewY) const;
106
112
* Retrieve the zoom levels of the individual x and y axes.
107
113
* @param zoomX a pointer to a qreal which will be modified to the horizontal zoom.
108
114
* @param zoomY a pointer to a qreal which will be modified to the vertical zoom.
110
virtual void zoom(qreal *zoomX, qreal *zoomY) const = 0;
116
virtual void zoom(qreal *zoomX, qreal *zoomY) const;
119
* Set the zoom level. 1.0 is 100%.
121
virtual void setZoom(qreal zoom);
124
* Return the current zoom level. 1.0 is 100%.
129
qreal m_zoomLevel; // 1.0 is 100%