File indexing completed on 2024-05-12 15:58:42
0001 /* 0002 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef _KIS_SELECTION_MASK_ 0007 #define _KIS_SELECTION_MASK_ 0008 0009 #include <QRect> 0010 0011 #include "kis_base_node.h" 0012 0013 #include "kis_types.h" 0014 #include "kis_effect_mask.h" 0015 #include "KisDecoratedNodeInterface.h" 0016 0017 /** 0018 * An selection mask is a single channel mask that applies a 0019 * particular selection to the layer the mask belongs to. A selection 0020 * can contain both vector and pixel selection components. 0021 */ 0022 class KRITAIMAGE_EXPORT KisSelectionMask : public KisEffectMask, public KisDecoratedNodeInterface 0023 { 0024 Q_OBJECT 0025 public: 0026 0027 /** 0028 * Create an empty selection mask. There is filter and no layer 0029 * associated with this mask. 0030 */ 0031 KisSelectionMask(KisImageWSP image, const QString &name = QString()); 0032 0033 ~KisSelectionMask() override; 0034 KisSelectionMask(const KisSelectionMask& rhs); 0035 0036 QIcon icon() const override; 0037 0038 KisNodeSP clone() const override { 0039 return KisNodeSP(new KisSelectionMask(*this)); 0040 } 0041 0042 /// Set the selection of this adjustment layer to a copy of selection. 0043 void setSelection(KisSelectionSP selection); 0044 0045 bool accept(KisNodeVisitor &v) override; 0046 void accept(KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override; 0047 0048 KisBaseNode::PropertyList sectionModelProperties() const override; 0049 void setSectionModelProperties(const KisBaseNode::PropertyList &properties) override; 0050 0051 void setVisible(bool visible, bool isLoading = false) override; 0052 bool active() const; 0053 void setActive(bool active); 0054 0055 QRect needRect(const QRect &rect, PositionToFilthy pos = N_FILTHY) const override; 0056 QRect changeRect(const QRect &rect, PositionToFilthy pos = N_FILTHY) const override; 0057 0058 QRect extent() const override; 0059 QRect exactBounds() const override; 0060 0061 /** 0062 * This method works like the one in KisSelection, but it 0063 * compressed the incoming events instead of processing each of 0064 * them separately. 0065 */ 0066 void notifySelectionChangedCompressed(); 0067 0068 bool decorationsVisible() const override; 0069 void setDecorationsVisible(bool value, bool update) override; 0070 using KisDecoratedNodeInterface::setDecorationsVisible; 0071 0072 void setDirty(const QVector<QRect> &rects) override; 0073 using KisEffectMask::setDirty; 0074 0075 protected: 0076 void flattenSelectionProjection(KisSelectionSP selection, const QRect &dirtyRect) const override; 0077 0078 void mergeInMaskInternal(KisPaintDeviceSP projection, 0079 KisSelectionSP effectiveSelection, 0080 const QRect &applyRect, const QRect &preparedNeedRect, 0081 KisNode::PositionToFilthy maskPos) const override; 0082 0083 bool paintsOutsideSelection() const override; 0084 0085 0086 private: 0087 Q_PRIVATE_SLOT(m_d, void slotSelectionChangedCompressed()) 0088 Q_PRIVATE_SLOT(m_d, void slotConfigChanged()) 0089 0090 struct Private; 0091 Private * const m_d; 0092 }; 0093 0094 #endif //_KIS_SELECTION_MASK_