Warning, file /office/calligra/libs/flake/KoClipPath.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) 2011 Jan Hambrecht <jaham@gmx.net>
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 KOCLIPPATH_H
0021 #define KOCLIPPATH_H
0022 
0023 #include "flake_export.h"
0024 #include <QList>
0025 #include <QSharedData>
0026 #include <qnamespace.h>
0027 
0028 class KoShape;
0029 class KoPathShape;
0030 class KoViewConverter;
0031 class QPainter;
0032 class QTransform;
0033 class QPainterPath;
0034 class QSizeF;
0035 
0036 /// Shared clip path data
0037 class FLAKE_EXPORT KoClipData : public QSharedData
0038 {
0039 public:
0040     /// Creates clip path data from a single path shape, takes ownership of the path shape
0041     explicit KoClipData(KoPathShape *clipPathShape);
0042 
0043     /// Creates clip path data from multiple path shapes, takes ownership of the path shapes
0044     explicit KoClipData(const QList<KoPathShape*> &clipPathShapes);
0045 
0046     /// Destroys the clip path data
0047     ~KoClipData();
0048 
0049     /// Returns the clip path shapes
0050     QList<KoPathShape*> clipPathShapes() const;
0051 
0052     /// Gives up ownership of clip path shapes
0053     void removeClipShapesOwnership();
0054 
0055 private:
0056     class Private;
0057     Private * const d;
0058 };
0059 
0060 /// Clip path used to clip shapes
0061 class FLAKE_EXPORT KoClipPath
0062 {
0063 public:
0064     /**
0065      * Create a new shape clipping using the given clip data
0066      * @param clippedShape the shape to clip
0067      * @param clipData shared clipping data containing the clip paths
0068      */
0069     KoClipPath(KoShape *clippedShape, KoClipData *clipData);
0070 
0071     ~KoClipPath();
0072 
0073     /// Sets the clip rule to be used for the clip path
0074     void setClipRule(Qt::FillRule clipRule);
0075 
0076     /// Returns the current clip rule
0077     Qt::FillRule clipRule() const;
0078 
0079     /// Returns the current clip path with coordinates in percent of the clipped shape size
0080     QPainterPath path() const;
0081 
0082     /// Returns the current clip path scaled to match the specified shape size
0083     QPainterPath pathForSize(const QSizeF &size) const;
0084 
0085     /// Returns the clip path shapes
0086     QList<KoPathShape*> clipPathShapes() const;
0087 
0088     /**
0089      * Returns the transformation from the clip data path shapes to the
0090      * current document coordinates of the specified clipped shape.
0091      * If the specified clipped shape is null, the transformation 
0092      * from clip data path shapes to shape coordinates of the clipped shape 
0093      * at the time of creating this clip path is being returned.
0094      */
0095     QTransform clipDataTransformation(KoShape *clippedShape) const;
0096 
0097     /// Applies the clipping to the given painter
0098     static void applyClipping(KoShape *clippedShape, QPainter &painter, const KoViewConverter &converter);
0099 
0100 private:
0101     class Private;
0102     Private * const d;
0103 };
0104 
0105 #endif // KOCLIPPATH_H