Krita

FilterLayer.cpp
1 /*
2  * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <[email protected]>
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 
14 FilterLayer::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 
20 FilterLayer::FilterLayer(KisAdjustmentLayerSP layer, QObject *parent):
21  Node(layer->image(), layer, parent)
22 {
23 
24 }
25 
26 FilterLayer::~FilterLayer()
27 {
28 
29 }
30 
32 {
33  return "filterlayer";
34 }
35 
36 void 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 
46 Filter * 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 
InfoObject wrap a properties map.
Definition: InfoObject.h:19
Selection represents a selection on Krita.
Definition: Selection.h:30
Filter: represents a filter and its configuration.
Definition: Filter.h:30
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
QString type() const override
type Krita has several types of nodes, split in layers and masks.
Definition: FilterLayer.cpp:31
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition: Node.h:21
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.