28 , m_refImage(new
KisImage(new
KisSurrogateUndoStore(), image->width(), image->height(), image->colorSpace(),
"Merge Labeled Layers Reference Image"))
29 , m_prevRefNodeInfoList(nullptr)
30 , m_newRefNodeInfoList(nullptr)
31 , m_prevRefPaintDevice(nullptr)
32 , m_newRefPaintDevice(newRefPaintDevice)
33 , m_currentRoot(image->root())
34 , m_selectedLabels(selectedLabels)
35 , m_groupSelectionPolicy(groupSelectionPolicy)
36 , m_forceRegeneration(true)
37 , m_activeNode(nullptr)
53 bool forceRegeneration,
56 , m_refImage(new
KisImage(new
KisSurrogateUndoStore(), image->width(), image->height(), image->colorSpace(),
"Merge Labeled Layers Reference Image"))
57 , m_prevRefNodeInfoList(prevRefNodeInfoList)
58 , m_newRefNodeInfoList(newRefNodeInfoList)
59 , m_prevRefPaintDevice(prevRefPaintDevice)
60 , m_newRefPaintDevice(newRefPaintDevice)
61 , m_currentRoot(image->root())
62 , m_selectedLabels(selectedLabels)
63 , m_groupSelectionPolicy(groupSelectionPolicy)
64 , m_forceRegeneration(forceRegeneration)
65 , m_activeNode(activeNode)
103 return {
nullptr, {
false,
true}};
106 if (node->inherits(
"KisMask")) {
109 return {
nullptr, {
true,
false}};
115 return {
nullptr, {
true,
false}};
125 return {
nullptr, {
true, node->inherits(
"KisGroupLayer")}};
129 if (node->inherits(
"KisCloneLayer")) {
135 KisNodeSP transformedNode = cloneLayer->reincarnateAsPaintLayer();
138 return {transformedNode, {
true,
false}};
141 if (node->inherits(
"KisAdjustmentLayer")) {
149 transformedNode->
setX(transformedNode->
x() + node->
x());
150 transformedNode->
setY(transformedNode->
y() + node->
y());
155 return {transformedNode, {
false,
false}};
158 if (node->inherits(
"KisGroupLayer")) {
164 return {
nullptr, {
true,
true}};
171 return {node, {
true,
false}};
176 return {node, {
true,
false}};
181 QPair<KisNodeSP, QPair<bool, bool>> result =
collectNode(node);
183 const bool visitNextSibling = result.second.first;
184 const bool visitChildren = result.second.second;
188 nodeList << collectedNode;
192 const QUuid uuid = node->
uuid();
194 const int opacity = node->
opacity();
195 nodeInfoList.append({uuid, sequenceNumber, opacity});
202 const bool mustVisitNextSibling =
collectNodes(node, nodeList, nodeInfoList);
203 if (!mustVisitNextSibling) {
210 return visitNextSibling;
229 for (
KisNodeSP node : currentNodesList) {
236 if (copy->inherits(
"KisLayer")) {
250 currentNodesListCopy << copy;
KisDeleteLaterWrapper< T > * makeKisDeleteLaterWrapper(T value)
const QString COMPOSITE_OVER
void switchCurrentTimeAsync(int frameId, SwitchTimeAsyncFlags options=STAO_NONE)
bool hasAnimation() const
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
KisPaintDeviceSP projection() const
void initialRefreshGraph()
QRect bounds() const override
ReferenceNodeInfoListSP m_prevRefNodeInfoList
bool hasToCheckForChangesInNodes() const
bool collectNodes(KisNodeSP node, QList< KisNodeSP > &nodeList, ReferenceNodeInfoList &nodeInfoList) const
static KisPaintDeviceSP createRefPaintDevice(KisImageSP originalImage, QString name="Merge Labeled Layers Reference Paint Device")
QPair< KisNodeSP, QPair< bool, bool > > collectNode(KisNodeSP node) const
ReferenceNodeInfoListSP m_newRefNodeInfoList
void mergeLabeledLayers()
KisPaintDeviceSP m_prevRefPaintDevice
KisMergeLabeledLayersCommand(KisImageSP image, KisPaintDeviceSP newRefPaintDevice, QList< int > selectedLabels, GroupSelectionPolicy groupSelectionPolicy=GroupSelectionPolicy_SelectAlways)
Construct a new KisMergeLabeledLayersCommand that does not use a cache.
KisPaintDeviceSP m_newRefPaintDevice
GroupSelectionPolicy
Policies to stablish how the groups should be treated.
@ GroupSelectionPolicy_SelectIfColorLabeled
Groups will be taken into account only if they have set an explicit color label. This ignores groups ...
@ GroupSelectionPolicy_NeverSelect
Groups will not be taken into account.
GroupSelectionPolicy m_groupSelectionPolicy
~KisMergeLabeledLayersCommand() override
QList< int > m_selectedLabels
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)
int sequenceNumber() const
QRect exactBounds() const
void prepareClone(KisPaintDeviceSP src)
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
KisSharedPtr< KisPaintDevice > KisPaintDeviceSP
KUndo2MagicString kundo2_noi18n(const QString &text)
KisNodeList sortAndFilterAnyMergeableNodesSafe(const KisNodeList &nodes, KisImageSP image)
void refreshHiddenAreaAsync(KisImageSP image, KisNodeSP rootNode, const QRect &preparedArea)
void mergeMultipleNodes(KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, MergeFlags flags)
virtual KisPaintDeviceSP projection() const =0
void mergeNodeProperties(const KoProperties &properties)
const KoProperties & nodeProperties() const
int colorLabelIndex() const
virtual bool visible(bool recursive=false) const
qint32 y() const override
qint32 x() const override
void setX(qint32 x) override
virtual void setChannelFlags(const QBitArray &channelFlags)
void setY(qint32 y) override
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
KisNodeSP prevSibling() const
virtual KisNodeSP clone() const =0
quint32 childCount() const
KisNodeSP lastChild() const