File indexing completed on 2024-05-12 15:56:40

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2009 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #include "KoFilterEffectRenderContext.h"
0008 #include "KoViewConverter.h"
0009 
0010 #include <QRectF>
0011 #include <QTransform>
0012 
0013 class Q_DECL_HIDDEN KoFilterEffectRenderContext::Private
0014 {
0015 public:
0016     Private(const KoViewConverter &viewConverter)
0017         : converter(viewConverter)
0018     {}
0019 
0020     QRectF filterRegion;
0021     QRectF shapeBound;
0022     const KoViewConverter & converter;
0023 };
0024 
0025 KoFilterEffectRenderContext::KoFilterEffectRenderContext(const KoViewConverter &converter)
0026 : d(new Private(converter))
0027 {
0028 }
0029 
0030 KoFilterEffectRenderContext::~KoFilterEffectRenderContext()
0031 {
0032     delete d;
0033 }
0034 
0035 QRectF KoFilterEffectRenderContext::filterRegion() const
0036 {
0037     return d->filterRegion;
0038 }
0039 
0040 void KoFilterEffectRenderContext::setFilterRegion(const QRectF &filterRegion)
0041 {
0042     d->filterRegion = filterRegion;
0043 }
0044 
0045 void KoFilterEffectRenderContext::setShapeBoundingBox(const QRectF &bound)
0046 {
0047     d->shapeBound = bound;
0048 }
0049 
0050 QPointF KoFilterEffectRenderContext::toUserSpace(const QPointF &value) const
0051 {
0052     return QPointF(value.x()*d->shapeBound.width(), value.y()*d->shapeBound.height());
0053 }
0054 
0055 qreal KoFilterEffectRenderContext::toUserSpaceX(qreal value) const
0056 {
0057     return value * d->shapeBound.width();
0058 }
0059 
0060 qreal KoFilterEffectRenderContext::toUserSpaceY(qreal value) const
0061 {
0062     return value * d->shapeBound.height();
0063 }
0064 
0065 const KoViewConverter * KoFilterEffectRenderContext::viewConverter() const
0066 {
0067     return &d->converter;
0068 }