Krita

FilterMask.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 "FilterMask.h"
7 #include <kis_filter_mask.h>
8 #include <kis_image.h>
9 #include <kis_filter_configuration.h>
10 #include <kis_filter_registry.h>
11 #include <InfoObject.h>
12 
13 FilterMask::FilterMask(KisImageSP image, QString name, Filter &filter, QObject *parent) :
14  Node(image, new KisFilterMask(image, name), parent)
15 {
16  KisFilterMask *mask = dynamic_cast<KisFilterMask*>(this->node().data());
17  KIS_SAFE_ASSERT_RECOVER_RETURN(mask);
18 
19  mask->setFilter(filter.filterConfig()->cloneWithResourcesSnapshot());
20 }
21 
22 FilterMask::FilterMask(KisImageSP image, KisFilterMaskSP mask, QObject *parent):
23  Node(image, mask, parent)
24 {
25 
26 }
27 
28 FilterMask::~FilterMask()
29 {
30 
31 }
32 
34 {
35  return "filtermask";
36 }
37 
38 void FilterMask::setFilter(Filter &filter)
39 {
40  KisFilterMask *mask = dynamic_cast<KisFilterMask*>(this->node().data());
41  KIS_SAFE_ASSERT_RECOVER_RETURN(mask);
42 
43  mask->setFilter(filter.filterConfig()->cloneWithResourcesSnapshot());
44 }
45 
46 Filter * FilterMask::filter()
47 {
48  Filter* filter = new Filter();
49  const KisFilterMask *mask = qobject_cast<const KisFilterMask*>(this->node());
50  KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(mask, 0);
51 
52  filter->setName(mask->filter()->name());
53  filter->setConfiguration(new InfoObject(mask->filter()));
54  return filter;
55 }
56 
InfoObject wrap a properties map.
Definition: InfoObject.h:19
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: FilterMask.cpp:33
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.