12#include <QPainterPath>
14#include <QVarLengthArray>
22 const qreal w = qMax(
static_cast<qreal
>(1e-5), size.width());
23 const qreal h = qMax(
static_cast<qreal
>(1e-5), size.height());
24 return QTransform().scale(1.0/w, 1.0/h);
29 const qreal w = qMax(
static_cast<qreal
>(1e-5), size.width());
30 const qreal h = qMax(
static_cast<qreal
>(1e-5), size.height());
31 return QTransform().scale(w/1.0, h/1.0);
43 , clipPath(rhs.clipPath)
44 , clipRule(rhs.clipRule)
45 , coordinates(rhs.coordinates)
46 , initialTransformToShape(rhs.initialTransformToShape)
47 , initialShapeSize(rhs.initialShapeSize)
49 Q_FOREACH (
KoShape *shape, rhs.shapes) {
53 shapes.append(clonedShape);
66 QTransform t = pathShape->absoluteTransformation();
67 result->addPath(t.map(pathShape->outline()));
72 Q_FOREACH (
const KoShape *child, shapes) {
73 collectShapePath(result, child);
82 if (clipShapes.isEmpty())
85 clipPath = QPainterPath();
86 clipPath.setFillRule(Qt::WindingFill);
90 Q_FOREACH (
KoShape *path, clipShapes) {
93 collectShapePath(&clipPath, path);
99 Qt::FillRule clipRule = Qt::WindingFill;
110 d->compileClipPath();
145 return d->coordinates;
154 const QRectF shapeLocalBoundingRect = shape->
outline().boundingRect();
158 if (!path.isEmpty()) {
159 painter.setClipPath(path, Qt::IntersectClip);
180 Q_FOREACH (
KoShape *shape,
d->shapes) {
198 return d->initialTransformToShape;
204 const QSizeF currentShapeSize = clippedShape->
outline().boundingRect().size();
205 const qreal sx = currentShapeSize.width() /
d->initialShapeSize.width();
206 const qreal sy = currentShapeSize.height() /
d->initialShapeSize.height();
207 QTransform scaleTransform = QTransform().scale(sx, sy);
212 return d->initialTransformToShape * scaleTransform * currentShapeTransform;
QTransform scaleFromPercent(const QSizeF &size)
QTransform scaleToPercent(const QSizeF &size)
Clip path used to clip shapes.
void setClipRule(Qt::FillRule clipRule)
Sets the clip rule to be used for the clip path.
KoFlake::CoordinateSystem coordinates
QList< KoPathShape * > clipPathShapes() const
Returns the clip path shapes.
QPainterPath path() const
Returns the current clip path with coordinates in percent of the clipped shape size.
QPainterPath clipPath
the compiled clip path in shape coordinates of the clipped shape
QTransform initialTransformToShape
initial transformation to shape coordinates of the clipped shape
QList< KoShape * > clipShapes() const
QSizeF initialShapeSize
initial size of clipped shape
KoClipPath(QList< KoShape * > clipShapes, KoFlake::CoordinateSystem coordinates)
void collectShapePath(QPainterPath *result, const KoShape *shape)
KoClipPath * clone() const
static void applyClipping(KoShape *clippedShape, QPainter &painter)
Applies the clipping to the given painter.
QTransform clipDataTransformation(KoShape *clippedShape) const
QPainterPath pathForSize(const QSizeF &size) const
Returns the current clip path scaled to match the specified shape size.
QSharedDataPointer< Private > d
KoClipPath & operator=(const KoClipPath &)
QList< KoShape * > shapes
Private(const Private &rhs)
The position of a path point within a path shape.
virtual QPainterPath outline() const
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
KoClipPath * clipPath() const
Returns the currently set clip path or 0 if there is no clip path set.
QTransform absoluteTransformation() const
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
#define KIS_ASSERT_RECOVER(cond)
QTransform mapToRect(const QRectF &rect)