Krita

FilterMask.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 "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
13FilterMask::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
22FilterMask::FilterMask(KisImageSP image, KisFilterMaskSP mask, QObject *parent):
23 Node(image, mask, parent)
24{
25
26}
27
28FilterMask::~FilterMask()
29{
30
31}
32
34{
35 return "filtermask";
36}
37
38void 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
46Filter * 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
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
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.