Krita

CloneLayer.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 "CloneLayer.h"
7 #include <kis_clone_layer.h>
8 #include <kis_image.h>
9 #include <kis_layer.h>
10 
11 CloneLayer::CloneLayer(KisImageSP image, QString name, KisLayerSP source, QObject *parent) :
12  Node(image, new KisCloneLayer(source, image, name, OPACITY_OPAQUE_U8), parent)
13 {
14 
15 }
16 
17 CloneLayer::CloneLayer(KisCloneLayerSP layer, QObject *parent):
18  Node(layer->image(), layer, parent)
19 {
20 
21 }
22 
23 CloneLayer::~CloneLayer()
24 {
25 
26 }
27 
29 {
30  const KisCloneLayer* layer = qobject_cast<const KisCloneLayer*>(this->node().data());
31  KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(layer, 0);
32 
33  return Node::createNode(0, layer->copyFrom());
34 }
35 
37 {
38  if (!node->node()) return;
39 
40  KisCloneLayerSP layer = qobject_cast<KisCloneLayer*>(this->node().data());
41  KIS_SAFE_ASSERT_RECOVER_RETURN(layer);
42 
43  KisLayerSP source = qobject_cast<KisLayer*>(node->node().data());
44 
45  layer->setCopyFrom(source);
46 }
47 
49 {
50  return "clonelayer";
51 }
virtual QString type() const override
type Krita has several types of nodes, split in layers and masks.
Definition: CloneLayer.cpp:48
void setSourceNode(Node *node)
setSourceNode
Definition: CloneLayer.cpp:36
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition: Node.h:21
Node * sourceNode() const
sourceNode
Definition: CloneLayer.cpp:28
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Oct 6 2022 04:17:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.