Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_image_layer_remove_command.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <klocalizedstring.h>
10#include "kis_image.h"
12
13
15 KisNodeSP node,
16 bool doRedoUpdates,
17 bool doUndoUpdates)
18 : KisImageCommand(kundo2_i18n("Remove Layer"), image),
19 m_node(node),
20 m_doRedoUpdates(doRedoUpdates),
21 m_doUndoUpdates(doUndoUpdates)
22{
23 addSubtree(image, node);
24}
25
29
31{
32 // Simple tail-recursion to remove nodes in bottom-up way
33 //
34 // Alert: the nodes must be traversed in last-to-first order,
35 // because each KisImageLayerRemoveCommandImpl stores a
36 // pointer to the previous node of the stack
37
38 KisNodeSP child = node->lastChild();
39 while (child) {
40 addSubtree(image, child);
41 child = child->prevSibling();
42 }
43
44 new KisImageLayerRemoveCommandImpl(image, node, this);
45}
46
48{
50 if (!image) {
51 return;
52 }
53 UpdateTarget target(image, m_node, image->bounds());
55
56 if (m_doRedoUpdates) {
57 target.update();
58 }
59}
60
62{
64
65 if (m_doUndoUpdates) {
71 if (!image) {
72 return;
73 }
74 image->refreshGraphAsync(m_node, image->bounds());
75 }
76}
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
virtual void undo()
const KUndo2Command * child(int index) const
virtual void redo()
the base command for commands altering a KisImage
void addSubtree(KisImageWSP image, KisNodeSP node)
KisImageLayerRemoveCommand(KisImageWSP image, KisNodeSP node, bool doRedoUpdates=true, bool doUndoUpdates=true)
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
QRect bounds() const override
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
KUndo2MagicString kundo2_i18n(const char *text)
KisNodeSP lastChild() const
Definition kis_node.cpp:367