File indexing completed on 2024-05-12 15:58:07

0001 /*
0002  *  SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  *  This program is distributed in the hope that it will be useful,
0007  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0008  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0009  *  GNU General Public License for more details.
0010  *
0011  *  You should have received a copy of the GNU General Public License
0012  *  along with this program; if not, write to the Free Software
0013  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
0014  *  MA 02110-1301, USA.
0015  */
0016 #ifndef KIS_ADJUSTMENT_LAYER_H_
0017 #define KIS_ADJUSTMENT_LAYER_H_
0018 
0019 #include <QObject>
0020 #include <kritaimage_export.h>
0021 #include "kis_selection_based_layer.h"
0022 
0023 class KisFilterConfiguration;
0024 
0025 class KRITAIMAGE_EXPORT KisAdjustmentLayer : public KisSelectionBasedLayer
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * creates a new adjustment layer with the given
0032      * configuration and selection. Note that the selection
0033      * will be _copied_ (with COW, though).
0034      * @param image the image to set this AdjustmentLayer to
0035      * @param name name of the adjustment layer
0036      * @param kfc the configuration for the adjustment layer filter
0037      * @param selection is a mask used by the adjustment layer to
0038      * know where to apply the filter.
0039      */
0040     KisAdjustmentLayer(KisImageWSP image, const QString &name, KisFilterConfigurationSP  kfc, KisSelectionSP selection);
0041     KisAdjustmentLayer(const KisAdjustmentLayer& rhs);
0042     ~KisAdjustmentLayer() override;
0043 
0044     bool accept(KisNodeVisitor &) override;
0045     void accept(KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override;
0046 
0047     /**
0048      * clones this AdjustmentLayer into a KisNodeSP type.
0049      * @return the KisNodeSP returned
0050      */
0051     KisNodeSP clone() const override {
0052         return KisNodeSP(new KisAdjustmentLayer(*this));
0053     }
0054 
0055     /**
0056      * gets the adjustmentLayer's tool filter
0057      * @return QIcon returns the QIcon tool filter
0058      */
0059     QIcon icon() const override;
0060 
0061     /**
0062      * gets the AdjustmentLayer properties describing whether
0063      * or not the node is locked, visible, and the filter
0064      * name is it is a filter. Overrides sectionModelProperties
0065      * in KisLayer, and KisLayer overrides
0066      * sectionModelProperties in KisBaseNode.
0067      * @return KisBaseNode::PropertyList returns a list
0068      * of the properties
0069      */
0070     KisBaseNode::PropertyList sectionModelProperties() const override;
0071 
0072 public:
0073 
0074     /**
0075      * \see KisNodeFilterInterface::setFilter()
0076      */
0077     void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig = true) override;
0078 
0079     void setChannelFlags(const QBitArray & channelFlags) override;
0080 
0081 protected:
0082     // override from KisLayer
0083     QRect incomingChangeRect(const QRect &rect) const override;
0084     // override from KisNode
0085     QRect needRect(const QRect &rect, PositionToFilthy pos = N_FILTHY) const override;
0086 
0087 public Q_SLOTS:
0088     /**
0089      * gets this AdjustmentLayer. Overrides function in
0090      * KisIndirectPaintingSupport
0091      * @return this AdjustmentLayer
0092      */
0093     KisLayer* layer() {
0094         return this;
0095     }
0096 };
0097 
0098 #endif // KIS_ADJUSTMENT_LAYER_H_
0099