Krita

TransparencyMask.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 "TransparencyMask.h"
7 #include <kis_transparency_mask.h>
8 #include <kis_image.h>
9 #include "Selection.h"
10 #include <kis_selection.h>
11 #include <kis_group_layer.h>
12 #include "kis_layer.h"
13 
14 TransparencyMask::TransparencyMask(KisImageSP image, QString name, QObject *parent) :
15  Node(image, new KisTransparencyMask(image, name), parent)
16 {
17  KisTransparencyMask *mask = qobject_cast<KisTransparencyMask*>(this->node().data());
18  KIS_SAFE_ASSERT_RECOVER_RETURN(mask);
19 
20  KisSelectionSP selection = new KisSelection();
21  KisLayerSP layer = qobject_cast<KisLayer*>(image->rootLayer().data());
22 
23  mask->initSelection(selection, layer);
24 }
25 
26 TransparencyMask::TransparencyMask(KisImageSP image, KisTransparencyMaskSP mask, QObject *parent):
27  Node(image, mask, parent)
28 {
29 
30 }
31 
32 TransparencyMask::~TransparencyMask()
33 {
34 
35 }
36 
37 Selection *TransparencyMask::selection() const
38 {
39  const KisTransparencyMask *mask = qobject_cast<const KisTransparencyMask*>(this->node());
40  return new Selection(mask->selection());
41 }
42 
43 void TransparencyMask::setSelection(Selection *selection)
44 {
45  KisTransparencyMask *mask = qobject_cast<KisTransparencyMask*>(this->node().data());
46  mask->setSelection(selection->selection());
47 }
48 
50 {
51  return "transparencymask";
52 }
Selection represents a selection on Krita.
Definition: Selection.h:30
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition: Node.h:21
QString name(StandardShortcut id)
virtual QString type() const override
type Krita has several types of nodes, split in layers and masks.
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.