Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_node_compositeop_command.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
3 * SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include <klocalizedstring.h>
9#include <KoCompositeOp.h>
10#include "kis_node.h"
12#include "kis_command_ids.h"
13
15 KisNodeCommand(kundo2_i18n("Composition Mode Change"), node)
16{
17 m_newCompositeOp = newCompositeOp;
18}
19
20void KisNodeCompositeOpCommand::setCompositeOpImpl(const QString &compositeOp)
21{
26 const QRect oldExtent = m_node->extent();
27 m_node->setCompositeOpId(compositeOp);
28 m_node->setDirty(oldExtent | m_node->extent());
29}
30
38
44
49
51{
52 const KisNodeCompositeOpCommand *other =
53 dynamic_cast<const KisNodeCompositeOpCommand*>(command);
54
55 if (other && other->m_node == m_node) {
56 // verify both commands have been executed and they are consecutive
60
62 return true;
63 }
64
65 return false;
66}
67
69{
70 const KisNodeCompositeOpCommand *other =
71 dynamic_cast<const KisNodeCompositeOpCommand*>(command);
72
73 return other && other->m_node == m_node;
74}
75
77{
78 const KisNodeCompositeOpCommand *other =
79 dynamic_cast<const KisNodeCompositeOpCommand*>(command);
80
81 if (!other || other->m_node != m_node) {
82 return false;
83 }
84
86 return *m_oldCompositeOp == other->m_newCompositeOp;
87}
the base command for commands altering a node
The command for setting the composite op.
bool mergeWith(const KUndo2Command *command) override
KisNodeCompositeOpCommand(KisNodeSP node, const QString &newCompositeOp)
bool canMergeWith(const KUndo2Command *command) const override
void setCompositeOpImpl(const QString &compositeOp)
bool canAnnihilateWith(const KUndo2Command *command) const override
boost::optional< QString > m_oldCompositeOp
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
KUndo2MagicString kundo2_i18n(const char *text)
const QString & compositeOpId() const
virtual QRect extent() const
void setCompositeOpId(const QString &compositeOpId)
virtual void setDirty()
Definition kis_node.cpp:577