Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelectionMask Class Reference

#include <kis_selection_mask.h>

+ Inheritance diagram for KisSelectionMask:

Public Member Functions

bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
bool active () const
 
QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
KisNodeSP clone () const override
 
bool decorationsVisible () const override
 
QRect exactBounds () const override
 
QRect extent () const override
 
QIcon icon () const override
 
 KisSelectionMask (const KisSelectionMask &rhs)
 
 KisSelectionMask (KisImageWSP image, const QString &name=QString())
 
QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
void notifySelectionChangedCompressed ()
 
 Private (KisSelectionMask *_q)
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
void setActive (bool active)
 
void setDecorationsVisible (bool value)
 
void setDecorationsVisible (bool value, bool update) override
 
virtual void setDecorationsVisible (bool value, bool update)=0
 
void setDirty (const QVector< QRect > &rects) override
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setSelection (KisSelectionSP selection)
 Set the selection of this adjustment layer to a copy of selection.
 
void setVisible (bool visible, bool isLoading=false) override
 
void slotConfigChanged ()
 
void slotConfigChangedImpl (bool blockUpdates)
 
void slotSelectionChangedCompressed ()
 
 ~KisSelectionMask () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisEffectMask
void apply (KisPaintDeviceSP projection, const QRect &applyRect, const QRect &needRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
 KisEffectMask (const KisEffectMask &rhs)
 
 KisEffectMask (KisImageWSP image, const QString &name)
 
 ~KisEffectMask () override
 
- Public Member Functions inherited from KisMask
bool allowAsChild (KisNodeSP node) const override
 
const KoColorSpacecolorSpace () const override
 
const KoCompositeOpcompositeOp () const override
 
QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
void initSelection (KisLayerSP parentLayer)
 initSelection initializes an empty selection
 
void initSelection (KisPaintDeviceSP copyFromDevice, KisLayerSP parentLayer)
 initSelection initializes the selection for the mask from the given paint device.
 
void initSelection (KisSelectionSP copyFrom, KisLayerSP parentLayer)
 initSelection initializes the selection for the mask from the given selection's projection.
 
void initSelectionImpl (KisSelectionSP copyFrom, KisLayerSP parentLayer, KisPaintDeviceSP copyFromDevice, KisImageWSP image)
 
 KisMask (const KisMask &rhs)
 
 KisMask (KisImageWSP image, const QString &name)
 
virtual QRect nonDependentExtent () const
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
 Private (KisMask *_q)
 
KisPaintDeviceSP projection () const override
 
KisAbstractProjectionPlaneSP projectionPlane () const override
 
void select (const QRect &rc, quint8 selectedness=MAX_SELECTED)
 
KisSelectionSP selection () const
 
void setImage (KisImageWSP image) override
 
void setSelection (KisSelectionSP selection)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool supportsLodPainting () const override
 
void testingInitSelection (const QRect &rect, KisLayerSP parentLayer)
 
int thumbnailSeqNo () const override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisMask () override
 
- Public Member Functions inherited from KisNode
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
const KisNodefindSymmetricClone (const KisNode *srcRoot, const KisNode *dstRoot, const KisNode *srcTarget)
 
KisNodeSP firstChild () const
 
virtual KisPaintDeviceList getLodCapableDevices () const
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameAdded (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameChange (const KisKeyframeChannel *channel, int time)
 
void handleKeyframeChannelFrameHasBeenRemoved (const KisKeyframeChannel *channel, int time)
 
KisFrameChangeUpdateRecipe handleKeyframeChannelUpdateImpl (const KisKeyframeChannel *channel, int time)
 
int index (const KisNodeSP node) const
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect)
 
 KisNode (const KisNode &rhs)
 
 KisNode (KisImageWSP image)
 
KisNodeSP lastChild () const
 
KisNodeSP nextSibling () const
 
KisNodeProgressProxynodeProgressProxy () const
 
KisNodeSP parent () const
 
KisNodeSP prevSibling () const
 
 Private (KisNode *node)
 
void processDuplicatedClones (const KisNode *srcDuplicationRoot, const KisNode *dstDuplicationRoot, KisNode *node)
 
virtual KisProjectionLeafSP projectionLeaf () const
 
void requestTimeSwitch (int time)
 
virtual void setDirty ()
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
void setDirtyDontResetAnimationCache ()
 
void setDirtyDontResetAnimationCache (const QRect &rect)
 
void setDirtyDontResetAnimationCache (const QVector< QRect > &rects)
 setDirtyDontResetAnimationCache does almost the same thing as usual setDirty() call, but doesn't reset the animation cache (since onion skins are not used when rendering animation.
 
void setGraphListener (KisNodeGraphListener *graphListener)
 
void setImage (KisImageWSP newImage) override
 
virtual void syncLodCache ()
 
 ~KisNode () override
 
- Public Member Functions inherited from KisBaseNode
bool belongsToIsolatedGroup () const
 
bool check (const KoProperties &properties) const
 
bool collapsed () const
 
int colorLabelIndex () const
 
virtual KisPaintDeviceSP colorSampleSourceDevice () const
 
const QString & compositeOpId () const
 
virtual QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
void enableAnimation ()
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
KisImageWSP image () const
 
bool isAnimated () const
 
bool isEditable (bool checkVisibility=true) const
 
virtual bool isFakeNode () const
 
bool isIsolatedRoot () const
 
bool isPinnedToTimeline () const
 
QMap< QString, KisKeyframeChannel * > keyframeChannels () const
 
 KisBaseNode (const KisBaseNode &rhs)
 
 KisBaseNode (KisImageWSP image)
 
void mergeNodeProperties (const KoProperties &properties)
 
QString name () const
 
const KoPropertiesnodeProperties () const
 
quint8 opacity () const
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
void setCollapsed (bool collapsed)
 
void setColorLabelIndex (int index)
 
void setCompositeOpId (const QString &compositeOpId)
 
void setName (const QString &name)
 
void setNodeProperty (const QString &name, const QVariant &value)
 
void setOpacity (quint8 val)
 
void setPercentOpacity (quint8 val)
 
void setPinnedToTimeline (bool pinned)
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
bool supportsLodMoves () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
virtual bool visible (bool recursive=false) const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 
- Public Member Functions inherited from KisIndirectPaintingSupport
bool hasTemporaryTarget () const
 
 KisIndirectPaintingSupport ()
 
void mergeToLayer (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
 
virtual void mergeToLayerThreaded (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, QVector< KisRunnableStrokeJobData * > *jobs)
 
virtual void setCurrentColor (const KoColor &color)
 
void setTemporaryChannelFlags (const QBitArray &channelFlags)
 
void setTemporaryCompositeOp (const QString &id)
 
void setTemporaryOpacity (qreal o)
 
void setTemporarySelection (KisSelectionSP selection)
 
void setTemporaryTarget (KisPaintDeviceSP t)
 
void setupTemporaryPainter (KisPainter *painter) const
 
virtual bool supportsNonIndirectPainting () const
 
KisPaintDeviceSP temporaryTarget () const
 
FinalMergeSuspenderSP trySuspendFinalMerge ()
 
virtual ~KisIndirectPaintingSupport ()
 
- Public Member Functions inherited from KisDecoratedNodeInterface
void setDecorationsVisible (bool value)
 
virtual ~KisDecoratedNodeInterface ()
 

Public Attributes

KisCachedSelection cachedSelection
 
KoColor maskColor
 
KisCachedPaintDevice paintDeviceCache
 
KisSelectionMaskq
 
KisThreadSafeSignalCompressorupdatesCompressor
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisMask
QScopedPointer< QPoint > deferredSelectionOffset
 
KisCachedPaintDevice paintDeviceCache
 
KisAbstractProjectionPlaneSP projectionPlane
 
KisMaskq
 
KisSafeSelectionNodeProjectionStoreSP safeProjection
 
KisSelectionSP selection
 
- Public Attributes inherited from KisNode
KisBusyProgressIndicatorbusyProgressIndicator
 
std::optional< KisFrameChangeUpdateRecipeframeRemovalUpdateRecipe
 
KisNodeGraphListenergraphListener
 
KisNodeProgressProxynodeProgressProxy
 
KisSafeReadNodeList nodes
 
QReadWriteLock nodeSubgraphLock
 
KisNodeWSP parent
 
KisProjectionLeafSP projectionLeaf
 
- Public Attributes inherited from KisBaseNode
bool animated {false}
 
bool collapsed {false}
 
QString compositeOp
 
KisBaseNode::Property hack_visible
 
QUuid id
 
KisImageWSP image
 
QMap< QString, KisKeyframeChannel * > keyframeChannels
 
KisAnimatedOpacityProperty opacityProperty
 
bool pinnedToTimeline {false}
 
KoProperties properties
 
bool supportsLodMoves {false}
 
- Public Attributes inherited from KisIndirectPaintingSupport
QBitArray channelFlags
 
QString compositeOp
 
qreal compositeOpacity
 
bool finalMergeInProgress = true
 
QReadWriteLock lock
 
KisSelectionSP selection
 
KisPaintDeviceSP temporaryTarget
 

Protected Member Functions

void flattenSelectionProjection (KisSelectionSP selection, const QRect &dirtyRect) const override
 
void mergeInMaskInternal (KisPaintDeviceSP projection, KisSelectionSP effectiveSelection, const QRect &applyRect, const QRect &preparedNeedRect, KisNode::PositionToFilthy maskPos, KisRenderPassFlags flags) const override
 
bool paintsOutsideSelection () const override
 
- Protected Member Functions inherited from KisMask
void apply (KisPaintDeviceSP projection, const QRect &applyRect, const QRect &needRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
void baseNodeChangedCallback () override
 
virtual QRect decorateRect (KisPaintDeviceSP &src, KisPaintDeviceSP &dst, const QRect &rc, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
KisKeyframeChannelrequestKeyframeChannel (const QString &id) override
 
bool supportsKeyframeChannel (const QString &id) override
 
- Protected Member Functions inherited from KisNode
virtual QRect accessRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void addKeyframeChannel (KisKeyframeChannel *channel) override
 
void baseNodeChangedCallback () override
 
void baseNodeCollapsedChangedCallback () override
 
void baseNodeInvalidateAllFramesCallback () override
 
virtual void childNodeChanged (KisNodeSP changedChildNode)
 
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time)
 
void notifyParentVisibilityChanged (bool value) override
 
KisBaseNodeSP parentCallback () const override
 
- Protected Member Functions inherited from KisBaseNode
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 
- Protected Member Functions inherited from KisIndirectPaintingSupport
void lockTemporaryTargetForWrite () const
 
void mergeToLayerImpl (KisPaintDeviceSP dst, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, bool cleanResources, WriteLockerSP sharedWriteLock, QVector< KisRunnableStrokeJobData * > *jobs)
 
void releaseResources ()
 
QString temporaryCompositeOp () const
 
virtual void writeMergeData (KisPainter *painter, KisPaintDeviceSP src, const QRect &rc)
 

Private Attributes

Private *const m_d
 

Additional Inherited Members

- Public Types inherited from KisNode
enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 
- Public Types inherited from KisIndirectPaintingSupport
using FinalMergeSuspenderSP = QSharedPointer<FinalMergeSuspender>
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 
- Protected Types inherited from KisIndirectPaintingSupport
using WriteLockerSP = QSharedPointer<WriteLocker>
 

Detailed Description

An selection mask is a single channel mask that applies a particular selection to the layer the mask belongs to. A selection can contain both vector and pixel selection components.

Definition at line 32 of file kis_selection_mask.cpp.

Constructor & Destructor Documentation

◆ KisSelectionMask() [1/2]

KisSelectionMask::KisSelectionMask ( KisImageWSP image,
const QString & name = QString() )

Create an empty selection mask. There is filter and no layer associated with this mask.

Definition at line 51 of file kis_selection_mask.cpp.

53 , m_d(new Private(this))
54{
55 setActive(false);
57
58 m_d->updatesCompressor =
60
61 connect(m_d->updatesCompressor, SIGNAL(timeout()), SLOT(slotSelectionChangedCompressed()));
62
63 connect(KisImageConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
64 m_d->slotConfigChangedImpl(false);
65}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisEffectMask(KisImageWSP image, const QString &name)
static KisImageConfigNotifier * instance()
void setSupportsLodMoves(bool value)
KisImageWSP image
QString name() const
void slotConfigChanged()
void setActive(bool active)
void slotSelectionChangedCompressed()

References connect(), KisSignalCompressor::FIRST_ACTIVE, KisImageConfigNotifier::instance(), m_d, setActive(), KisBaseNode::setSupportsLodMoves(), slotConfigChanged(), and slotSelectionChangedCompressed().

◆ ~KisSelectionMask()

KisSelectionMask::~KisSelectionMask ( )
override

Definition at line 80 of file kis_selection_mask.cpp.

81{
82 m_d->updatesCompressor->deleteLater();
83 delete m_d;
84}

References m_d.

◆ KisSelectionMask() [2/2]

KisSelectionMask::KisSelectionMask ( const KisSelectionMask & rhs)

Definition at line 67 of file kis_selection_mask.cpp.

68 : KisEffectMask(rhs)
69 , m_d(new Private(this))
70{
71 m_d->updatesCompressor =
73
74 connect(m_d->updatesCompressor, SIGNAL(timeout()), SLOT(slotSelectionChangedCompressed()));
75
76 connect(KisImageConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
77 m_d->slotConfigChangedImpl(false);
78}

References connect(), KisImageConfigNotifier::instance(), m_d, KisSignalCompressor::POSTPONE, slotConfigChanged(), and slotSelectionChangedCompressed().

Member Function Documentation

◆ accept() [1/2]

bool KisSelectionMask::accept ( KisNodeVisitor & )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisNodeVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

return false if the visitor could not successfully act on this node instance.

Reimplemented from KisNode.

Definition at line 156 of file kis_selection_mask.cpp.

157{
158 return v.visit(this);
159}
qreal v

References v.

◆ accept() [2/2]

void KisSelectionMask::accept ( KisProcessingVisitor & visitor,
KisUndoAdapter * undoAdapter )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisProcessingVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

The processing visitor differs from node visitor in the way that it accepts undo adapter, that allows the processing to be multithreaded

Reimplemented from KisNode.

Definition at line 161 of file kis_selection_mask.cpp.

162{
163 return visitor.visit(this, undoAdapter);
164}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ active()

bool KisSelectionMask::active ( ) const

Definition at line 190 of file kis_selection_mask.cpp.

191{
192 return nodeProperties().boolProperty("active", true);
193}
bool boolProperty(const QString &name, bool defaultValue=false) const
const KoProperties & nodeProperties() const

References KoProperties::boolProperty(), and KisBaseNode::nodeProperties().

◆ changeRect()

QRect KisSelectionMask::changeRect ( const QRect & rect,
KisNode::PositionToFilthy pos = N_FILTHY ) const
overridevirtual
Returns
internal changeRect() of the node. Do not mix with
See also
projectionPlane()

Some filters will cause a change of pixels those are outside a requested rect. E.g. we change a rect of 2x2, then we want to apply a convolution filter with kernel 4x4 (changeRect is (2+2*3)x(2+2*3)=8x8) to that area. The rect that should be updated on the layer will be exactly 8x8. More than that the needRect for that update will be 14x14. See needRect.

Reimplemented from KisMask.

Definition at line 233 of file kis_selection_mask.cpp.

234{
235 Q_UNUSED(pos);
236
237 // selection masks just add an overlay, so the changed rect is simply passed through
238 return rect;
239}

◆ clone()

KisNodeSP KisSelectionMask::clone ( ) const
inlineoverridevirtual

Implements KisNode.

Definition at line 38 of file kis_selection_mask.h.

38 {
39 return KisNodeSP(new KisSelectionMask(*this));
40 }
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86
KisSelectionMask(KisImageWSP image, const QString &name=QString())

◆ decorationsVisible()

bool KisSelectionMask::decorationsVisible ( ) const
overridevirtual
Returns
true is the layer is allowed to write its decorative information into the stack. The value should be "true" by default.

Implements KisDecoratedNodeInterface.

Definition at line 275 of file kis_selection_mask.cpp.

276{
277 return selection()->isVisible();
278}
KisSelectionSP selection
Definition kis_mask.cc:44

References KisSelection::isVisible, and KisMask::selection.

◆ exactBounds()

QRect KisSelectionMask::exactBounds ( ) const
overridevirtual

Returns the exact bounds of where the actual data resides in this node.

Reimplemented from KisMask.

Definition at line 265 of file kis_selection_mask.cpp.

266{
267 return extent();
268}
QRect extent() const override

References extent().

◆ extent()

QRect KisSelectionMask::extent ( ) const
overridevirtual

The extent and bounds of the mask are those of the selection inside

Reimplemented from KisMask.

Definition at line 241 of file kis_selection_mask.cpp.

242{
243 // since mask overlay is inverted, the mask paints over
244 // the entire image bounds
245 QRect resultRect;
247
248 if (selection) {
249 resultRect = selection->pixelSelection()->defaultBounds()->bounds();
250
251 if (KisNodeSP parent = this->parent()) {
252 resultRect |= parent->extent();
253 }
254
255 } else if (KisNodeSP parent = this->parent()) {
257 if (dev) {
258 resultRect = dev->defaultBounds()->bounds();
259 }
260 }
261
262 return resultRect;
263}
virtual QRect bounds() const =0
KisDefaultBoundsBaseSP defaultBounds() const
virtual KisPaintDeviceSP projection() const =0
virtual QRect extent() const
KisNodeWSP parent
Definition kis_node.cpp:86
KisPixelSelectionSP pixelSelection

References KisDefaultBoundsBase::bounds(), KisPaintDevice::defaultBounds(), KisBaseNode::extent(), KisNode::parent, KisSelection::pixelSelection, KisBaseNode::projection(), and KisMask::selection.

◆ flattenSelectionProjection()

void KisSelectionMask::flattenSelectionProjection ( KisSelectionSP selection,
const QRect & dirtyRect ) const
overrideprotectedvirtual

A special callback for calling selection->updateProjection() during the projection calculation process. Some masks (e.g. selection masks) don't need it, because they do it separately.

Reimplemented from KisMask.

Definition at line 302 of file kis_selection_mask.cpp.

303{
304 Q_UNUSED(selection);
305 Q_UNUSED(dirtyRect);
306}

References KisMask::selection.

◆ icon()

QIcon KisSelectionMask::icon ( ) const
overridevirtual
Returns
the icon used to represent the node type, for instance in the layerbox and in the menu.

Reimplemented from KisEffectMask.

Definition at line 86 of file kis_selection_mask.cpp.

86 {
87 return KisIconUtils::loadIcon("selectionMask");
88}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ mergeInMaskInternal()

void KisSelectionMask::mergeInMaskInternal ( KisPaintDeviceSP projection,
KisSelectionSP effectiveSelection,
const QRect & applyRect,
const QRect & preparedNeedRect,
KisNode::PositionToFilthy maskPos,
KisRenderPassFlags flags ) const
overrideprotectedvirtual

Reimplemented from KisMask.

Definition at line 90 of file kis_selection_mask.cpp.

96{
97 Q_UNUSED(maskPos);
98 Q_UNUSED(preparedNeedRect);
99 Q_UNUSED(flags);
100
101 if (!effectiveSelection) return;
102
103 {
104 KisSelectionSP mainMaskSelection = this->selection();
105 if (mainMaskSelection &&
106 (!mainMaskSelection->isVisible() ||
107 mainMaskSelection->pixelSelection()->defaultBounds()->externalFrameActive())) {
108
109 return;
110 }
111 }
112
113 KisCachedPaintDevice::Guard d1(projection, m_d->paintDeviceCache);
114 KisPaintDeviceSP fillDevice = d1.device();
115 fillDevice->setDefaultPixel(m_d->maskColor);
116
117 const QRect selectionExtent = effectiveSelection->selectedRect();
118
119 if (selectionExtent.contains(applyRect) || selectionExtent.intersects(applyRect)) {
120 KisCachedSelection::Guard s1(m_d->cachedSelection);
121 KisSelectionSP invertedSelection = s1.selection();
122
123 invertedSelection->pixelSelection()->makeCloneFromRough(effectiveSelection->pixelSelection(), applyRect);
124 invertedSelection->pixelSelection()->invert();
125
127 gc.setSelection(invertedSelection);
128 gc.bitBlt(applyRect.topLeft(), fillDevice, applyRect);
129
130 } else {
132 gc.bitBlt(applyRect.topLeft(), fillDevice, applyRect);
133 }
134}
QPointF s1
virtual bool externalFrameActive() const =0
void setDefaultPixel(const KoColor &defPixel)
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)
KisPaintDeviceSP projection() const override
Definition kis_mask.cc:234
QRect selectedRect() const

References KisPainter::bitBlt(), KisPaintDevice::defaultBounds(), KisCachedPaintDevice::Guard::device(), KisDefaultBoundsBase::externalFrameActive(), KisPixelSelection::invert(), KisSelection::isVisible, m_d, KisPaintDevice::makeCloneFromRough(), KisSelection::pixelSelection, KisMask::projection(), s1, KisSelection::selectedRect(), KisMask::selection, KisPaintDevice::setDefaultPixel(), and KisPainter::setSelection().

◆ needRect()

QRect KisSelectionMask::needRect ( const QRect & rect,
KisNode::PositionToFilthy pos = N_FILTHY ) const
overridevirtual
Returns
internal needRect() of the node. Do not mix with
See also
projectionPlane()

Some filters need pixels outside the current processing rect to compute the new value (for instance, convolution filters) See changeRect See accessRect

Reimplemented from KisMask.

Definition at line 225 of file kis_selection_mask.cpp.

226{
227 Q_UNUSED(pos);
228
229 // selection masks just add an overlay, so the needed rect is simply passed through
230 return rect;
231}

◆ notifySelectionChangedCompressed()

void KisSelectionMask::notifySelectionChangedCompressed ( )

This method works like the one in KisSelection, but it compressed the incoming events instead of processing each of them separately.

Definition at line 270 of file kis_selection_mask.cpp.

271{
272 m_d->updatesCompressor->start();
273}

References m_d.

◆ paintsOutsideSelection()

bool KisSelectionMask::paintsOutsideSelection ( ) const
overrideprotectedvirtual

Reimplemented from KisMask.

Definition at line 136 of file kis_selection_mask.cpp.

137{
138 return true;
139}

◆ Private()

KisSelectionMask::Private ( KisSelectionMask * _q)
inline

Definition at line 35 of file kis_selection_mask.cpp.

36 : q(_q)
38 , maskColor(Qt::green, KoColorSpaceRegistry::instance()->rgb8())
39 {}
KisThreadSafeSignalCompressor * updatesCompressor
KisSelectionMask * q
static KoColorSpaceRegistry * instance()

◆ sectionModelProperties()

KisBaseNode::PropertyList KisSelectionMask::sectionModelProperties ( ) const
overridevirtual

Return a the properties of this base node (locked, visible etc, with the right icons for their representation and their state.

Subclasses can extend this list with new properties, like opacity for layers or visualized for masks.

The order of properties is, unfortunately, for now, important, so take care which properties superclasses of your class define.

KisBaseNode defines visible = 0, locked = 1 KisLayer defines opacity = 2, compositeOp = 3 KisMask defines active = 2 (KisMask does not inherit kislayer)

Reimplemented from KisBaseNode.

Definition at line 166 of file kis_selection_mask.cpp.

167{
170 return l;
171}
static KisBaseNode::Property getProperty(const KoID &id, bool state)
virtual PropertyList sectionModelProperties() const

References active(), KisLayerPropertiesIcons::getProperty(), KisBaseNode::sectionModelProperties(), and KisLayerPropertiesIcons::selectionActive.

◆ setActive()

void KisSelectionMask::setActive ( bool active)

WARNING: we have a direct link to the image here, but we must not use it for notification until we are a part of the node graph! Notifications should be emitted iff we have graph listener link set up.

Definition at line 195 of file kis_selection_mask.cpp.

196{
197 KisImageSP image = this->image();
198 KisLayerSP parentLayer = qobject_cast<KisLayer*>(parent().data());
199
200 if (active && parentLayer) {
201 KisSelectionMaskSP activeMask = parentLayer->selectionMask();
202 if (activeMask && activeMask != this) {
203 activeMask->setActive(false);
204 }
205 }
206
207 const bool oldActive = this->active();
208 setNodeProperty("active", active);
209
210
217 if (graphListener() &&
218 image && oldActive != active) {
219
222 }
223}
KisUndoAdapter * undoAdapter() const
void setNodeProperty(const QString &name, const QVariant &value)
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:498
void baseNodeChangedCallback() override
Definition kis_mask.cc:532
KisNodeGraphListener * graphListener
Definition kis_node.cpp:87

References active(), KisMask::baseNodeChangedCallback(), KisUndoAdapter::emitSelectionChanged(), KisNode::graphListener, KisBaseNode::image, KisNode::parent, KisLayer::selectionMask(), setActive(), KisBaseNode::setNodeProperty(), and KisImage::undoAdapter().

◆ setDecorationsVisible() [1/3]

void KisDecoratedNodeInterface::setDecorationsVisible ( bool value)

Convenience override for setDecorationsVisible()

Definition at line 38 of file KisDecoratedNodeInterface.cpp.

14{
16}
float value(const T *src, size_t ch)
void setDecorationsVisible(bool value, bool update) override

◆ setDecorationsVisible() [2/3]

void KisSelectionMask::setDecorationsVisible ( bool value,
bool update )
overridevirtual

Enable or disable writing decorative information into layer stack.

Implements KisDecoratedNodeInterface.

Definition at line 280 of file kis_selection_mask.cpp.

281{
282 if (value == decorationsVisible()) return;
283
284 const QRect oldExtent = extent();
285
287
288 if (update) {
289 setDirty(oldExtent | extent());
290 }
291}
virtual void setDirty()
Definition kis_node.cpp:577
bool decorationsVisible() const override
void setVisible(bool visible)

References decorationsVisible(), extent(), KisMask::selection, KisNode::setDirty(), KisSelection::setVisible(), and value().

◆ setDecorationsVisible() [3/3]

virtual void KisDecoratedNodeInterface::setDecorationsVisible ( bool value,
bool update )
virtual

Enable or disable writing decorative information into layer stack.

Implements KisDecoratedNodeInterface.

◆ setDirty()

void KisSelectionMask::setDirty ( const QVector< QRect > & rects)
overridevirtual

Add the given rects to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node.

Reimplemented from KisNode.

Definition at line 293 of file kis_selection_mask.cpp.

294{
295 KisImageSP image = this->image();
296
297 if (image && image->overlaySelectionMask() == this) {
299 }
300}
KisSelectionMaskSP overlaySelectionMask() const
Definition kis_image.cc:685

References KisBaseNode::image, KisImage::overlaySelectionMask(), and KisNode::setDirty().

◆ setSectionModelProperties()

void KisSelectionMask::setSectionModelProperties ( const KisBaseNode::PropertyList & properties)
overridevirtual

Change the section model properties.

Reimplemented from KisBaseNode.

Definition at line 173 of file kis_selection_mask.cpp.

174{
176 setActive(properties.at(2).state.toBool());
177}
KoProperties properties
virtual void setSectionModelProperties(const PropertyList &properties)

References KisBaseNode::properties, setActive(), and KisBaseNode::setSectionModelProperties().

◆ setSelection()

void KisSelectionMask::setSelection ( KisSelectionSP selection)

Set the selection of this adjustment layer to a copy of selection.

Definition at line 141 of file kis_selection_mask.cpp.

142{
143 if (selection) {
145 } else {
147
149 KisFillPainter gc(KisPaintDeviceSP(this->selection()->pixelSelection().data()));
150 gc.fillRect(image()->bounds(), KoColor(Qt::white, cs), MAX_SELECTED);
151 gc.end();
152 }
153 setDirty();
154}
#define bounds(x, a, b)
const quint8 MAX_SELECTED
Definition kis_global.h:32
KisSharedPtr< KisPaintDevice > KisPaintDeviceSP
Definition kis_types.h:73
void setSelection(KisSelectionSP selection)
Definition kis_mask.cc:252
const KoColorSpace * alpha8()

References KoColorSpaceRegistry::alpha8(), bounds, KisPainter::end(), KisFillPainter::fillRect(), KisBaseNode::image, KoColorSpaceRegistry::instance(), MAX_SELECTED, KisMask::selection, KisNode::setDirty(), and KisMask::setSelection().

◆ setVisible()

void KisSelectionMask::setVisible ( bool visible,
bool loading = false )
overridevirtual

Set the visible status of this node. Visible nodes are active in the graph (except for selections masks which can be active while hidden), that is to say, they are taken into account when merging. Invisible nodes play no role in the final image , but will be modified when modifying all layers, for instance when cropping.

Toggling the visibility of a node will not automatically lead to recomposition.

Parameters
visiblethe new visibility state
isLoadingif true, the property is set during loading.

Reimplemented from KisBaseNode.

Definition at line 179 of file kis_selection_mask.cpp.

180{
181 const bool oldVisible = this->visible(false);
182 setNodeProperty("visible", visible);
183
184 if (!isLoading && visible != oldVisible) {
185 if (selection())
187 }
188}
virtual bool visible(bool recursive=false) const

References KisMask::selection, KisBaseNode::setNodeProperty(), KisSelection::setVisible(), and KisBaseNode::visible().

◆ slotConfigChanged()

void KisSelectionMask::slotConfigChanged ( )

◆ slotConfigChangedImpl()

void KisSelectionMask::slotConfigChangedImpl ( bool blockUpdates)

◆ slotSelectionChangedCompressed()

void KisSelectionMask::slotSelectionChangedCompressed ( )

Member Data Documentation

◆ cachedSelection

KisCachedSelection KisSelectionMask::cachedSelection

Definition at line 42 of file kis_selection_mask.cpp.

◆ m_d

Private* const KisSelectionMask::m_d
private

Definition at line 91 of file kis_selection_mask.h.

◆ maskColor

KoColor KisSelectionMask::maskColor

Definition at line 44 of file kis_selection_mask.cpp.

◆ paintDeviceCache

KisCachedPaintDevice KisSelectionMask::paintDeviceCache

Definition at line 41 of file kis_selection_mask.cpp.

◆ q

KisSelectionMask* KisSelectionMask::q

Definition at line 40 of file kis_selection_mask.cpp.

◆ updatesCompressor

KisThreadSafeSignalCompressor* KisSelectionMask::updatesCompressor

Definition at line 43 of file kis_selection_mask.cpp.


The documentation for this class was generated from the following files: