File indexing completed on 2024-12-22 04:15:07

0001 /*
0002  *  SPDX-FileCopyrightText: 2013 Lukáš Tvrdý <lukast.dev@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_offset_processing_visitor.h"
0008 
0009 #include <klocalizedstring.h>
0010 
0011 #include "commands_new/kis_node_move_command2.h"
0012 
0013 #include "kis_group_layer.h"
0014 #include "kis_paint_layer.h"
0015 #include "kis_adjustment_layer.h"
0016 #include "generator/kis_generator_layer.h"
0017 
0018 #include "kis_transparency_mask.h"
0019 #include "kis_filter_mask.h"
0020 #include "kis_selection_mask.h"
0021 
0022 #include "kis_external_layer_iface.h"
0023 
0024 #include "kis_paint_device.h"
0025 #include "kis_transaction.h"
0026 #include "kis_undo_adapter.h"
0027 #include <kis_transform_worker.h>
0028 #include "lazybrush/kis_colorize_mask.h"
0029 
0030 
0031 KisOffsetProcessingVisitor::KisOffsetProcessingVisitor(const QPoint &offsetPoint, const QRect &rect)
0032     :   m_offset(offsetPoint),
0033         m_wrapRect(rect)
0034 
0035 {
0036 }
0037 
0038 void KisOffsetProcessingVisitor::offsetPaintDevice(KisPaintDeviceSP device, KisUndoAdapter *undoAdapter)
0039 {
0040     KisTransaction transaction(device);
0041     KisTransformWorker::offset(device, m_offset, m_wrapRect);
0042     transaction.commit(undoAdapter);
0043 }
0044 
0045 void KisOffsetProcessingVisitor::visitNodeWithPaintDevice(KisNode *node, KisUndoAdapter *undoAdapter)
0046 {
0047     offsetPaintDevice(node->paintDevice(), undoAdapter);
0048 }
0049 
0050 void KisOffsetProcessingVisitor::visitExternalLayer(KisExternalLayer *layer, KisUndoAdapter *undoAdapter)
0051 {
0052     Q_UNUSED(layer);
0053     Q_UNUSED(undoAdapter);
0054 }
0055 
0056 void KisOffsetProcessingVisitor::visitColorizeMask(KisColorizeMask *node, KisUndoAdapter *undoAdapter)
0057 {
0058     QVector<KisPaintDeviceSP> devices = node->allPaintDevices();
0059 
0060     Q_FOREACH (KisPaintDeviceSP device, devices) {
0061         offsetPaintDevice(device, undoAdapter);
0062     }
0063 }