File indexing completed on 2024-05-12 15:59:05
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef LIBKIS_FILTER_H 0007 #define LIBKIS_FILTER_H 0008 0009 #include <QObject> 0010 0011 #include "kritalibkis_export.h" 0012 #include "libkis.h" 0013 #include <kis_filter_configuration.h> 0014 0015 /** 0016 * Filter: represents a filter and its configuration. A filter is identified by 0017 * an internal name. The configuration for each filter is defined as an InfoObject: 0018 * a map of name and value pairs. 0019 * 0020 * Currently available filters are: 0021 * 0022 * 'autocontrast', 'blur', 'bottom edge detections', 'brightnesscontrast', 'burn', 'colorbalance', 'colortoalpha', 'colortransfer', 0023 * 'desaturate', 'dodge', 'emboss', 'emboss all directions', 'emboss horizontal and vertical', 'emboss horizontal only', 0024 * 'emboss laplascian', 'emboss vertical only', 'gaussian blur', 'gaussiannoisereducer', 'gradientmap', 'halftone', 'hsvadjustment', 0025 * 'indexcolors', 'invert', 'left edge detections', 'lens blur', 'levels', 'maximize', 'mean removal', 'minimize', 'motion blur', 0026 * 'noise', 'normalize', 'oilpaint', 'perchannel', 'phongbumpmap', 'pixelize', 'posterize', 'raindrops', 'randompick', 0027 * 'right edge detections', 'roundcorners', 'sharpen', 'smalltiles', 'sobel', 'threshold', 'top edge detections', 'unsharp', 0028 * 'wave', 'waveletnoisereducer'] 0029 */ 0030 class KRITALIBKIS_EXPORT Filter : public QObject 0031 { 0032 Q_OBJECT 0033 Q_DISABLE_COPY(Filter) 0034 0035 public: 0036 /** 0037 * @brief Filter: create an empty filter object. Until a name is set, the filter cannot 0038 * be applied. 0039 */ 0040 explicit Filter(); 0041 ~Filter() override; 0042 0043 bool operator==(const Filter &other) const; 0044 bool operator!=(const Filter &other) const; 0045 0046 public Q_SLOTS: 0047 0048 /** 0049 * @brief name the internal name of this filter. 0050 * @return the name. 0051 */ 0052 QString name() const; 0053 0054 /** 0055 * @brief setName set the filter's name to the given name. 0056 */ 0057 void setName(const QString &name); 0058 0059 /** 0060 * @return the configuration object for the filter 0061 */ 0062 InfoObject* configuration() const; 0063 0064 /** 0065 * @brief setConfiguration set the configuration object for the filter 0066 */ 0067 void setConfiguration(InfoObject* value); 0068 0069 /** 0070 * @brief Apply the filter to the given node. 0071 * @param node the node to apply the filter to 0072 * @param x 0073 * @param y 0074 * @param w 0075 * @param h describe the rectangle the filter should be apply. 0076 * This is always in image pixel coordinates and not relative to the x, y 0077 * of the node. 0078 * @return @c true if the filter was applied successfully, or 0079 * @c false if the filter could not be applied because the node is locked or 0080 * does not have an editable paint device. 0081 */ 0082 bool apply(Node *node, int x, int y, int w, int h); 0083 0084 /** 0085 * @brief startFilter starts the given filter on the given node. 0086 * 0087 * @param node the node to apply the filter to 0088 * @param x 0089 * @param y 0090 * @param w 0091 * @param h describe the rectangle the filter should be apply. 0092 * This is always in image pixel coordinates and not relative to the x, y 0093 * of the node. 0094 */ 0095 bool startFilter(Node *node, int x, int y, int w, int h); 0096 0097 private: 0098 friend class FilterLayer; 0099 friend class FilterMask; 0100 0101 struct Private; 0102 Private *const d; 0103 0104 KisFilterConfigurationSP filterConfig(); 0105 0106 }; 0107 0108 #endif // LIBKIS_FILTER_H