Krita

TransparencyMask.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 "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
14TransparencyMask::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
26TransparencyMask::TransparencyMask(KisImageSP image, KisTransparencyMaskSP mask, QObject *parent):
27 Node(image, mask, parent)
28{
29
30}
31
32TransparencyMask::~TransparencyMask()
33{
34
35}
36
37Selection *TransparencyMask::selection() const
38{
39 const KisTransparencyMask *mask = qobject_cast<const KisTransparencyMask*>(this->node());
40 return new Selection(mask->selection());
41}
42
43void 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}
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
virtual QString type() const override
type Krita has several types of nodes, split in layers and masks.
QString name(GameStandardAction id)
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.