Krita

FilterLayer.cpp
1/*
2 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "FilterLayer.h"
7#include <kis_adjustment_layer.h>
8#include <kis_image.h>
9#include <kis_filter_configuration.h>
10#include <kis_filter_registry.h>
11#include <InfoObject.h>
12#include <kis_selection.h>
13
14FilterLayer::FilterLayer(KisImageSP image, QString name, Filter &filter, Selection &selection, QObject *parent) :
15 Node(image, new KisAdjustmentLayer(image, name, filter.filterConfig()->cloneWithResourcesSnapshot(), selection.selection()), parent)
16{
17
18}
19
20FilterLayer::FilterLayer(KisAdjustmentLayerSP layer, QObject *parent):
21 Node(layer->image(), layer, parent)
22{
23
24}
25
26FilterLayer::~FilterLayer()
27{
28
29}
30
32{
33 return "filterlayer";
34}
35
36void FilterLayer::setFilter(Filter &filter)
37{
38 if (!this->node()) return;
39 KisAdjustmentLayer *layer = dynamic_cast<KisAdjustmentLayer*>(this->node().data());
40 //getting the default configuration here avoids trouble with versioning.
41 if (layer) {
42 layer->setFilter(filter.filterConfig()->cloneWithResourcesSnapshot());
43 }
44}
45
46Filter * FilterLayer::filter()
47{
48 Filter* filter = new Filter();
49 const KisAdjustmentLayer *layer = qobject_cast<const KisAdjustmentLayer*>(this->node());
50 filter->setName(layer->filter()->name());
51 filter->setConfiguration(new InfoObject(layer->filter()));
52 return filter;
53}
54
QString type() const override
type Krita has several types of nodes, split in layers and masks.
InfoObject wrap a properties map.
Definition InfoObject.h:20
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition Node.h:24
Selection represents a selection on Krita.
Definition Selection.h:31
QString name(StandardAction id)
T qobject_cast(QObject *object)
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.