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 #ifndef KOFILTEREFFECTSTACK 0008 #define KOFILTEREFFECTSTACK 0009 0010 #include "kritaflake_export.h" 0011 0012 #include <QList> 0013 0014 class KoFilterEffect; 0015 class KoXmlWriter; 0016 0017 class QRectF; 0018 0019 /// This class manages a stack of filter effects 0020 class KRITAFLAKE_EXPORT KoFilterEffectStack 0021 { 0022 public: 0023 /// Creates an empty filter effect stack 0024 KoFilterEffectStack(); 0025 0026 /// Destroys the filter effect stack, deleting all filter effects 0027 ~KoFilterEffectStack(); 0028 0029 /** 0030 * The first filter of the list is the first to be applied. 0031 * 0032 * @return the list of filter effects applied on the shape when rendering. 0033 */ 0034 QList<KoFilterEffect*> filterEffects() const; 0035 0036 /** 0037 * Returns if the filter effect stack is empty. 0038 * @return false if the stack contains filter effects, otherwise true 0039 */ 0040 bool isEmpty() const; 0041 0042 /** 0043 * Inserts a new filter at the given position in the filter list. 0044 * 0045 * The filter stack take ownership of the inserted filter effect. 0046 * 0047 * @param index the list index to insert the new filter at 0048 * @param filter the new filter to insert 0049 */ 0050 void insertFilterEffect(int index, KoFilterEffect *filter); 0051 0052 /** 0053 * Appends a new filter at the end of the filter list. 0054 * 0055 * The filter stack take ownership of the appended filter effect. 0056 * 0057 * @param filter the new filter to append 0058 */ 0059 void appendFilterEffect(KoFilterEffect *filter); 0060 0061 /** 0062 * Removes the filter with the given index from the filter list. 0063 * 0064 * The filter gets deleted after removal from the list. 0065 * 0066 * @param index the index of the filter to remove 0067 */ 0068 void removeFilterEffect(int index); 0069 0070 /** 0071 * Take filter effect with given index from the stack and returns it. 0072 * @param index the index of the filter to take 0073 * @return the filter effect, of 0 if no filter effect with the given index exists 0074 */ 0075 KoFilterEffect* takeFilterEffect(int index); 0076 0077 /// Sets the clipping rectangle used for this filter in bounding box units 0078 void setClipRect(const QRectF &clipRect); 0079 0080 /// Returns the clipping rectangle used for this filter in bounding box units 0081 QRectF clipRect() const; 0082 0083 /// Returns the clipping rectangle for the given bounding rect 0084 QRectF clipRectForBoundingRect(const QRectF &boundingRect) const; 0085 0086 /** 0087 * Increments the use-value. 0088 * Returns true if the new value is non-zero, false otherwise. 0089 */ 0090 bool ref(); 0091 0092 /** 0093 * Decrements the use-value. 0094 * Returns true if the new value is non-zero, false otherwise. 0095 */ 0096 bool deref(); 0097 0098 /// Return reference counter 0099 int useCount() const; 0100 0101 /** 0102 * Saves filter stack using given xml writer. 0103 * @param writer the xml writer to write data to 0104 * @param id the filter id to write, used for referencing the filter 0105 */ 0106 void save(KoXmlWriter &writer, const QString &filterId); 0107 0108 /// Returns list of required standard inputs 0109 QSet<QString> requiredStandarsInputs() const; 0110 private: 0111 class Private; 0112 Private * const d; 0113 }; 0114 0115 #endif // KOFILTEREFFECTSTACK