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

Describes base behaviour for selection base classes like KisAdjustmentLayer and KisGeneratorLayer. These classes should have a persistent selection that controls the area where filter/generators are applied. The area outside this selection is not affected by the layer. More...

#include <kis_selection_based_layer.h>

+ Inheritance diagram for KisSelectionBasedLayer:

Public Slots

KisLayerlayer ()
 
void slotImageSizeChanged ()
 

Public Member Functions

bool allowAsChild (KisNodeSP node) const override
 
QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
QRect exactBounds () const override
 
QRect extent () const override
 
KisSelectionSP fetchComposedInternalSelection (const QRect &rect) const
 
KisSelectionSP internalSelection () const
 
 KisSelectionBasedLayer (const KisSelectionBasedLayer &rhs)
 
 KisSelectionBasedLayer (KisImageWSP image, const QString &name, KisSelectionSP selection, KisFilterConfigurationSP filterConfig)
 
bool needProjection () const override
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
 Private ()
 
 Private (const Private &rhs)
 
virtual void resetCache (const KoColorSpace *colorSpace)
 
void setDirty () override
 
void setImage (KisImageWSP image) override
 
void setInternalSelection (KisSelectionSP selection)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool supportsLodPainting () const override
 
int thumbnailSeqNo () const override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisSelectionBasedLayer () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisLayer
bool alphaChannelDisabled () const
 
void buildProjectionUpToNode (KisPaintDeviceSP projection, KisNodeSP lastNode, const QRect &rect)
 
QBitArray & channelFlags () const
 
KisFilterMaskSP colorOverlayMask () const
 
const KoColorSpacecolorSpace () const override
 returns the image's colorSpace or null, if there is no image
 
const KoCompositeOpcompositeOp () const override
 returns the layer's composite op for the colorspace of the layer's parent.
 
virtual KisLayerSP createMergedLayerTemplate (KisLayerSP prevLayer)
 
QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
void disableAlphaChannel (bool disable)
 
QList< KisEffectMaskSPeffectMasks () const
 
QList< KisEffectMaskSPeffectMasks (KisNodeSP lastNode) const
 
virtual void fillMergedLayerTemplate (KisLayerSP dstLayer, KisLayerSP prevLayer, bool skipPaintingThisLayer=false)
 
bool hasClones () const
 
bool hasEffectMasks () const
 
virtual KisLayerProjectionPlaneSP internalProjectionPlane () const
 
 KisLayer (const KisLayer &rhs)
 
 KisLayer (KisImageWSP image, const QString &name, quint8 opacity)
 
KisPSDLayerStyleSP layerStyle () const
 
QRect looseUserVisibleBounds () const
 
KisMetaData::StoremetaData ()
 
void notifyChildMaskChanged ()
 
KisLayerSP parentLayer () const
 
QRect partialChangeRect (KisNodeSP lastNode, const QRect &rect)
 
 Private (KisLayer *q)
 
KisPaintDeviceSP projection () const override
 
KisAbstractProjectionPlaneSP projectionPlane () const override
 
void registerClone (KisCloneLayerWSP clone)
 
const QList< KisCloneLayerWSPregisteredClones () const
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
virtual KisSelectionSP selection () const
 
virtual KisSelectionMaskSP selectionMask () const
 
virtual void setChannelFlags (const QBitArray &channelFlags)
 
void setLayerStyle (KisPSDLayerStyleSP layerStyle)
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setTemporary (bool t)
 
bool temporary () const
 
QRect tightUserVisibleBounds () const
 
void unregisterClone (KisCloneLayerWSP clone)
 
void updateClones (const QRect &rect, bool dontInvalidateFrames)
 
 ~KisLayer () override
 
- Public Member Functions inherited from KisNode
bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
virtual KisNodeSP clone () const =0
 
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)
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
virtual void setDirty (const QVector< QRect > &rects)
 
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)
 
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
 
void enableAnimation ()
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
virtual QIcon icon () 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)
 
virtual void setVisible (bool visible, bool loading=false)
 
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 KisNodeFilterInterface
virtual KisFilterConfigurationSP filter () const
 
 KisNodeFilterInterface (const KisNodeFilterInterface &rhs)
 
 KisNodeFilterInterface (KisFilterConfigurationSP filterConfig)
 
virtual void notifyColorSpaceChanged ()
 
virtual void setFilter (KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)
 
virtual ~KisNodeFilterInterface ()
 

Public Attributes

KisSignalAutoConnectionsStore imageConnections
 
KisPaintDeviceSP paintDevice
 
KisSelectionSP selection
 
bool useSelectionInProjection
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisLayer
QBitArray channelFlags
 
KisCloneLayersList clonesList
 
KisPSDLayerStyleSP layerStyle
 
KisLayerStyleProjectionPlaneSP layerStyleProjectionPlane
 
KisLayerMasksCache masksCache
 
KisMetaData::StoremetaDataStore {nullptr}
 
KisLayerProjectionPlaneSP projectionPlane
 
KisSafeNodeProjectionStoreSP safeProjection
 
- 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 copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const override
 
QRect cropChangeRectBySelection (const QRect &rect) const
 
void initSelection ()
 
QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
KisKeyframeChannelrequestKeyframeChannel (const QString &id) override
 
void setUseSelectionInProjection (bool value) const
 
bool supportsKeyframeChannel (const QString &id) override
 
- Protected Member Functions inherited from KisLayer
virtual QRect amortizedProjectionRectForCleanupInChangePass () const
 
QRect applyMasks (const KisPaintDeviceSP source, KisPaintDeviceSP destination, const QRect &requestedRect, KisNodeSP filthyNode, KisNodeSP lastNode, KisRenderPassFlags flags) const
 
bool canMergeAndKeepBlendOptions (KisLayerSP otherLayer)
 
QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
void childNodeChanged (KisNodeSP changedChildNode) override
 
virtual QRect incomingChangeRect (const QRect &rect) const
 
QRect masksChangeRect (const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
 
QRect masksNeedRect (const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const
 
QRect needRectForOriginal (const QRect &rect) const
 
virtual QRect outgoingChangeRect (const QRect &rect) const
 
QList< KisEffectMaskSPsearchEffectMasks (KisNodeSP lastNode) const
 
QRect updateProjection (const QRect &rect, KisNodeSP filthyNode, KisRenderPassFlags flags)
 
- 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 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

Describes base behaviour for selection base classes like KisAdjustmentLayer and KisGeneratorLayer. These classes should have a persistent selection that controls the area where filter/generators are applied. The area outside this selection is not affected by the layer.

Definition at line 31 of file kis_selection_based_layer.cpp.

Constructor & Destructor Documentation

◆ KisSelectionBasedLayer() [1/2]

KisSelectionBasedLayer::KisSelectionBasedLayer ( KisImageWSP image,
const QString & name,
KisSelectionSP selection,
KisFilterConfigurationSP filterConfig )

creates a new layer with the given selection. Note that the selection will be copied (with COW, though).

Parameters
imagethe image to set this layer to
namename of the layer
selectionis a mask used by the layer to know where to apply the filter/generator.

Definition at line 44 of file kis_selection_based_layer.cpp.

49 KisNodeFilterInterface(filterConfig),
50 m_d(new Private())
51{
52 if (!selection) {
54 } else {
56 }
57
58 KisImageSP imageSP = image.toStrongRef();
59 if (!imageSP) {
60 return;
61 }
62 m_d->paintDevice = KisPaintDeviceSP(new KisPaintDevice(this, imageSP->colorSpace(), KisDefaultBoundsSP(new KisDefaultBounds(image))));
63 m_d->imageConnections.addConnection(imageSP.data(), SIGNAL(sigSizeChanged(QPointF,QPointF)), this, SLOT(slotImageSizeChanged()));
64}
const quint8 OPACITY_OPAQUE_U8
const KoColorSpace * colorSpace() const
KisNodeFilterInterface(KisFilterConfigurationSP filterConfig)
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
KisSharedPtr< KisPaintDevice > KisPaintDeviceSP
Definition kis_types.h:73
KisImageWSP image
QString name() const
friend class KisLayer
Definition kis_node.h:383
void setInternalSelection(KisSelectionSP selection)

References KisImage::colorSpace(), KisSharedPtr< T >::data(), KisBaseNode::image, initSelection(), m_d, selection, setInternalSelection(), slotImageSizeChanged(), and KisWeakSharedPtr< T >::toStrongRef().

◆ KisSelectionBasedLayer() [2/2]

KisSelectionBasedLayer::KisSelectionBasedLayer ( const KisSelectionBasedLayer & rhs)

Definition at line 66 of file kis_selection_based_layer.cpp.

67 : KisLayer(rhs)
70 , m_d(new Private(*rhs.m_d))
71{
72 setInternalSelection(rhs.m_d->selection);
73
74 m_d->paintDevice = new KisPaintDevice(*rhs.m_d->paintDevice.data());
75}

References m_d, and setInternalSelection().

◆ ~KisSelectionBasedLayer()

KisSelectionBasedLayer::~KisSelectionBasedLayer ( )
override

Definition at line 78 of file kis_selection_based_layer.cpp.

79{
80 delete m_d;
81}

References m_d.

Member Function Documentation

◆ allowAsChild()

bool KisSelectionBasedLayer::allowAsChild ( KisNodeSP node) const
overridevirtual

tells whether the @node can be a child of this layer

Parameters
nodeto be connected node
Returns
tells if to be connected is a child of KisMask

Implements KisNode.

Definition at line 117 of file kis_selection_based_layer.cpp.

118{
119 return node->inherits("KisMask");
120}

◆ copyOriginalToProjection()

void KisSelectionBasedLayer::copyOriginalToProjection ( const KisPaintDeviceSP original,
KisPaintDeviceSP projection,
const QRect & rect ) const
overrideprotectedvirtual

Layers can override this method to get some special behavior when copying data from original to projection, e.g. blend in indirect painting device. If you need to modify data outside rect, please also override outgoingChangeRect() method.

When we paint with a selection, the deselected areas will not be overwritten by copyAreaOptimized(), so we need to clear them beforehand

Reimplemented from KisLayer.

Definition at line 172 of file kis_selection_based_layer.cpp.

175{
176 KisSelectionSP tempSelection;
177
178 if (m_d->useSelectionInProjection) {
179 tempSelection = fetchComposedInternalSelection(rect);
180
186 }
187
188 KisPainter::copyAreaOptimized(rect.topLeft(), original, projection, rect, tempSelection);
189}
virtual void clear()
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:820
KisSelectionSP fetchComposedInternalSelection(const QRect &rect) const
KisPaintDeviceSP original() const override

References KisPaintDevice::clear(), KisPainter::copyAreaOptimized(), fetchComposedInternalSelection(), m_d, original(), and KisLayer::projection().

◆ createThumbnail()

QImage KisSelectionBasedLayer::createThumbnail ( qint32 w,
qint32 h,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )
overridevirtual

copies the image and reformats it to thumbnail size and returns the new thumbnail image.

Parameters
wwidth of the thumbnail to create
hheight of the thumbnail to create
Returns
the thumbnail image created.

Reimplemented from KisLayer.

Definition at line 370 of file kis_selection_based_layer.cpp.

371{
372 KisSelectionSP originalSelection = internalSelection();
373 KisPaintDeviceSP originalDevice = original();
374
375 return originalDevice && originalSelection ?
376 originalDevice->createThumbnail(w, h, aspectRatioMode, 1,
379 QImage();
380}
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
KisSelectionSP internalSelection() const

References KisPaintDevice::createThumbnail(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), internalSelection(), and original().

◆ cropChangeRectBySelection()

QRect KisSelectionBasedLayer::cropChangeRectBySelection ( const QRect & rect) const
protected

Definition at line 191 of file kis_selection_based_layer.cpp.

192{
193 return m_d->selection ?
194 rect & m_d->selection->selectedRect() :
195 rect;
196}

References m_d.

◆ exactBounds()

QRect KisSelectionBasedLayer::exactBounds ( ) const
overridevirtual

returns the exact bounds of where the actual data resides in this layer, taking selection into account

Reimplemented from KisLayer.

Definition at line 347 of file kis_selection_based_layer.cpp.

348{
349 QRect resultRect;
350
351 if (m_d->selection) {
352 resultRect = m_d->selection->selectedExactRect();
353
354 // copy for thread safety!
356
357 if (temporaryTarget) {
358 resultRect |= temporaryTarget->exactBounds();
359 }
360
361 } else {
362 KisImageSP image = this->image().toStrongRef();
364 resultRect = image->bounds();
365 }
366
367 return resultRect;
368}
QRect bounds() const override
QRect exactBounds() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KisImage::bounds(), KisPaintDevice::exactBounds(), KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, KisIndirectPaintingSupport::temporaryTarget, and KisWeakSharedPtr< T >::toStrongRef().

◆ extent()

QRect KisSelectionBasedLayer::extent ( ) const
overridevirtual

gets an approximation of where the bounds on actual data are in this layer, taking selection into account

Reimplemented from KisLayer.

Definition at line 324 of file kis_selection_based_layer.cpp.

325{
326 QRect resultRect;
327
328 if (m_d->selection) {
329 resultRect = m_d->selection->selectedRect();
330
331 // copy for thread safety!
333
334 if (temporaryTarget) {
335 resultRect |= temporaryTarget->extent();
336 }
337
338 } else {
339 KisImageSP image = this->image().toStrongRef();
341 resultRect = image->bounds();
342 }
343
344 return resultRect;
345}
QRect extent() const

References KisImage::bounds(), KisPaintDevice::extent(), KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, KisIndirectPaintingSupport::temporaryTarget, and KisWeakSharedPtr< T >::toStrongRef().

◆ fetchComposedInternalSelection()

KisSelectionSP KisSelectionBasedLayer::fetchComposedInternalSelection ( const QRect & rect) const

When painted in indirect painting mode, the internal selection might not contain actual selection, because a part of it is stored on an indirect painting device. This method returns the merged copy of the real selection. The area in rect only is guaranteed to be prepared. The content of the rest of the selection is undefined.

WARNING: we don't try to clone the selection entirely, because it might be unsafe for shape selections.

TODO: make cloning of vector selections safe! See a comment in KisShapeSelection::clone().

Definition at line 143 of file kis_selection_based_layer.cpp.

144{
145 if (!m_d->selection) return KisSelectionSP();
146 m_d->selection->updateProjection(rect);
147
148 KisSelectionSP tempSelection = m_d->selection;
149
151
152 if (hasTemporaryTarget()) {
160 tempSelection = new KisSelection();
161
162 KisPainter::copyAreaOptimized(rect.topLeft(), m_d->selection->pixelSelection(), tempSelection->pixelSelection(), rect);
163
164 KisPainter gc2(tempSelection->pixelSelection());
166 gc2.bitBlt(rect.topLeft(), temporaryTarget(), rect);
167 }
168
169 return tempSelection;
170}
KisSharedPtr< KisSelection > KisSelectionSP
Definition kis_types.h:149
void setupTemporaryPainter(KisPainter *painter) const
KisPixelSelectionSP pixelSelection

References KisPainter::bitBlt(), KisPainter::copyAreaOptimized(), KisIndirectPaintingSupport::hasTemporaryTarget(), m_d, KisSelection::pixelSelection, KisIndirectPaintingSupport::setupTemporaryPainter(), and KisIndirectPaintingSupport::temporaryTarget.

◆ initSelection()

void KisSelectionBasedLayer::initSelection ( )
protected

Definition at line 83 of file kis_selection_based_layer.cpp.

84{
86 m_d->selection->pixelSelection()->setDefaultPixel(KoColor(Qt::white, m_d->selection->pixelSelection()->colorSpace()));
87 m_d->selection->pixelSelection()->setSupportsWraparoundMode(true);
88 m_d->selection->setParentNode(this);
89 m_d->selection->updateProjection();
90}
QSharedPointer< T > toQShared(T *ptr)

References KisBaseNode::image, m_d, and toQShared().

◆ internalSelection()

KisSelectionSP KisSelectionBasedLayer::internalSelection ( ) const

Returns the selection of the layer

Do not mix it with selection() which returns the currently active selection of the image

Definition at line 226 of file kis_selection_based_layer.cpp.

227{
228 return m_d->selection;
229}

References m_d.

◆ layer

KisLayer * KisSelectionBasedLayer::layer ( )
inlineslot

gets this layer. Overridden function in KisIndirectPaintingSupport

Returns
this AdjustmentLayer

Definition at line 194 of file kis_selection_based_layer.h.

194 {
195 return this;
196 }

◆ needProjection()

bool KisSelectionBasedLayer::needProjection ( ) const
overridevirtual

Reimplemented from KisLayer.

Definition at line 133 of file kis_selection_based_layer.cpp.

134{
135 return m_d->selection;
136}

References m_d.

◆ needRect()

QRect KisSelectionBasedLayer::needRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
overrideprotectedvirtual
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 KisNode.

Definition at line 198 of file kis_selection_based_layer.cpp.

199{
200 Q_UNUSED(pos);
201 return rect;
202}

◆ original()

KisPaintDeviceSP KisSelectionBasedLayer::original ( ) const
overridevirtual

Return the layer data before the effect masks have had their go at it.

Implements KisLayer.

Definition at line 123 of file kis_selection_based_layer.cpp.

124{
125 return m_d->paintDevice;
126}

References m_d.

◆ paintDevice()

KisPaintDeviceSP KisSelectionBasedLayer::paintDevice ( ) const
overridevirtual

Return the paintdevice you can use to change pixels on. For a paint layer these will be paint pixels, for an adjustment layer or a mask the selection paint device.

Returns
the paint device to paint on. Can be 0 if the actual node type does not support painting.

Implements KisBaseNode.

◆ Private() [1/2]

KisSelectionBasedLayer::Private ( )
inline

◆ Private() [2/2]

KisSelectionBasedLayer::Private ( const Private & rhs)
inline

Definition at line 35 of file kis_selection_based_layer.cpp.

35: useSelectionInProjection(rhs.useSelectionInProjection) {}

◆ requestKeyframeChannel()

KisKeyframeChannel * KisSelectionBasedLayer::requestKeyframeChannel ( const QString & id)
overrideprotectedvirtual

Attempt to create the requested channel. Used internally by getKeyframeChannel. Subclasses should implement this method to catch any new channel types they support.

Parameters
idchannel to create
Returns
newly created channel or null

Reimplemented from KisBaseNode.

Definition at line 294 of file kis_selection_based_layer.cpp.

295{
296 if (id == KisKeyframeChannel::Raster.id()) {
297 KisRasterKeyframeChannel *contentChannel = m_d->selection->pixelSelection()->createKeyframeChannel(KisKeyframeChannel::Raster);
298 contentChannel->setFilenameSuffix(".pixelselection");
299 return contentChannel;
300 }
301
303}
static const KoID Raster
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
void setFilenameSuffix(const QString &suffix)
virtual KisKeyframeChannel * requestKeyframeChannel(const QString &id)

References m_d, KisKeyframeChannel::Raster, KisBaseNode::requestKeyframeChannel(), and KisRasterKeyframeChannel::setFilenameSuffix().

◆ resetCache()

void KisSelectionBasedLayer::resetCache ( const KoColorSpace * colorSpace)
virtual

resets cached projection of lower layer to a new device

Returns
void

Reimplemented in KisGeneratorLayer.

Definition at line 204 of file kis_selection_based_layer.cpp.

205{
206 KisImageSP imageSP = image().toStrongRef();
207 if (!imageSP) {
208 return;
209 }
210
211 if (!colorSpace)
212 colorSpace = imageSP->colorSpace();
213
214 Q_ASSERT(colorSpace);
215
216 if (!m_d->paintDevice) {
218 } else if (m_d->paintDevice->colorSpace() != colorSpace) {
219 m_d->paintDevice->clear();
220 m_d->paintDevice->convertTo(colorSpace);
221 } else {
222 m_d->paintDevice->clear();
223 }
224}
KisWeakSharedPtr< KisNode > KisNodeWSP
Definition kis_types.h:87
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225

References KisImage::colorSpace(), KisLayer::colorSpace(), KisBaseNode::image, m_d, and KisWeakSharedPtr< T >::toStrongRef().

◆ setDirty()

void KisSelectionBasedLayer::setDirty ( )
overridevirtual

Mark a layer as dirty. We can't use KisLayer's one as our extent() function doesn't fit for this

Reimplemented from KisNode.

Definition at line 314 of file kis_selection_based_layer.cpp.

315{
316 Q_ASSERT(image());
317 KisImageSP imageSP = image().toStrongRef();
318 if (!imageSP) {
319 return;
320 }
321 setDirty(imageSP->bounds());
322}

References KisImage::bounds(), KisBaseNode::image, setDirty(), and KisWeakSharedPtr< T >::toStrongRef().

◆ setImage()

void KisSelectionBasedLayer::setImage ( KisImageWSP image)
overridevirtual

Set the image this layer belongs to.

Reimplemented from KisLayer.

Definition at line 104 of file kis_selection_based_layer.cpp.

105{
106 m_d->imageConnections.clear();
107 m_d->paintDevice->setDefaultBounds(KisDefaultBoundsSP(new KisDefaultBounds(image)));
108 m_d->selection->setDefaultBounds(KisDefaultBoundsSP(new KisDefaultBounds(image)));
109 m_d->selection->setResolutionProxy(m_d->selection->resolutionProxy()->createOrCloneDetached(image));
111
112 if (image) {
113 m_d->imageConnections.addConnection(image.data(), SIGNAL(sigSizeChanged(QPointF,QPointF)), this, SLOT(slotImageSizeChanged()));
114 }
115}
KisSharedPtr< KisDefaultBounds > KisDefaultBoundsSP
void setImage(KisImageWSP image) override
Definition kis_layer.cc:378

References KisWeakSharedPtr< T >::data(), KisBaseNode::image, m_d, KisLayer::setImage(), and slotImageSizeChanged().

◆ setInternalSelection()

void KisSelectionBasedLayer::setInternalSelection ( KisSelectionSP selection)

sets the selection of this layer to a copy of selection

Parameters
selectionthe selection to set
Returns
void

Sanity check for the case when the image is present

Definition at line 231 of file kis_selection_based_layer.cpp.

232{
233 if (selection) {
234 m_d->selection = new KisSelection(*selection.data());
235 m_d->selection->setParentNode(this);
236 m_d->selection->setDefaultBounds(new KisDefaultBounds(image()));
237 m_d->selection->setResolutionProxy(toQShared(new KisImageResolutionProxy(image())));
238 m_d->selection->pixelSelection()->setSupportsWraparoundMode(true);
239 m_d->selection->updateProjection();
240
241 KisPixelSelectionSP pixelSelection = m_d->selection->pixelSelection();
242 if (pixelSelection->framesInterface()) {
243 addKeyframeChannel(pixelSelection->keyframeChannel());
245 }
246
247 KisImageSP imageSP = image().toStrongRef();
248 if (imageSP) {
252 if (m_d->selection->pixelSelection()->defaultBounds()->bounds() != imageSP->bounds()) {
253 qWarning() << "WARNING: KisSelectionBasedLayer::setInternalSelection"
254 << "New selection has suspicious default bounds";
255 qWarning() << "WARNING:" << ppVar(m_d->selection->pixelSelection()->defaultBounds()->bounds());
256 qWarning() << "WARNING:" << ppVar(imageSP->bounds());
257 }
258 }
259
260 } else {
261 m_d->selection = 0;
262 }
263}
KisRasterKeyframeChannel * keyframeChannel() const
KisPaintDeviceFramesInterface * framesInterface()
#define ppVar(var)
Definition kis_debug.h:155
void enableAnimation()
void addKeyframeChannel(KisKeyframeChannel *channel) override
Definition kis_node.cpp:351

References KisNode::addKeyframeChannel(), KisImage::bounds(), KisSharedPtr< T >::data(), KisBaseNode::enableAnimation(), KisPaintDevice::framesInterface(), KisBaseNode::image, KisPaintDevice::keyframeChannel(), m_d, ppVar, selection, toQShared(), and KisWeakSharedPtr< T >::toStrongRef().

◆ setUseSelectionInProjection()

void KisSelectionBasedLayer::setUseSelectionInProjection ( bool value) const
protected

Sets if the selection should be used in copyOriginalToProjection() method.

Default value is 'true'. The descendants should override it to get desired behaviour.

Must be called only once in the child's constructor

Definition at line 138 of file kis_selection_based_layer.cpp.

139{
140 m_d->useSelectionInProjection = value;
141}
float value(const T *src, size_t ch)

References m_d, and value().

◆ setX()

void KisSelectionBasedLayer::setX ( qint32 x)
overridevirtual

sets this layer's y coordinate, taking selection into account

Parameters
xx coordinate

Reimplemented from KisLayer.

Definition at line 275 of file kis_selection_based_layer.cpp.

276{
277 if (m_d->selection) {
278 m_d->selection->setX(x);
279 }
280}

References m_d, and x().

◆ setY()

void KisSelectionBasedLayer::setY ( qint32 y)
overridevirtual

sets this layer's y coordinate, taking selection into account

Parameters
yy coordinate

Reimplemented from KisLayer.

Definition at line 282 of file kis_selection_based_layer.cpp.

283{
284 if (m_d->selection) {
285 m_d->selection->setY(y);
286 }
287}

References m_d, and y().

◆ slotImageSizeChanged

void KisSelectionBasedLayer::slotImageSizeChanged ( )
slot

Make sure exactBounds() of the selection got recalculated after the image changed

Definition at line 92 of file kis_selection_based_layer.cpp.

93{
94 if (m_d->selection) {
99 m_d->selection->pixelSelection()->setDirty();
100 setDirty();
101 }
102}

References m_d, and setDirty().

◆ supportsKeyframeChannel()

bool KisSelectionBasedLayer::supportsKeyframeChannel ( const QString & id)
overrideprotectedvirtual

Ideally, this function would be used to query for keyframe support before trying to create channels. The ability to query would help in cases such as animation curves where you might want to ask which channels it supports before allowing the user to add.

Parameters
idqueried channel
Returns
bool whether it supports said channel or not.

Reimplemented from KisBaseNode.

Definition at line 305 of file kis_selection_based_layer.cpp.

306{
307 if (id == KisKeyframeChannel::Raster.id()) {
308 return true;
309 }
310
312}
virtual bool supportsKeyframeChannel(const QString &id)

References KisKeyframeChannel::Raster, and KisBaseNode::supportsKeyframeChannel().

◆ supportsLodPainting()

bool KisSelectionBasedLayer::supportsLodPainting ( ) const
overridevirtual

Returns true if the node can be painted via KisPaintDevice. Notable exceptions are selection-based layers and masks.

Reimplemented from KisBaseNode.

Definition at line 289 of file kis_selection_based_layer.cpp.

290{
291 return !m_d->selection || !m_d->selection->hasShapeSelection();
292}

References m_d.

◆ thumbnailSeqNo()

int KisSelectionBasedLayer::thumbnailSeqNo ( ) const
overridevirtual
Returns
a sequence number of the thumbnail of the node. Every time the layer changes, the sequence number increases.

Reimplemented from KisLayer.

Definition at line 382 of file kis_selection_based_layer.cpp.

383{
384 KisSelectionSP originalSelection = internalSelection();
385 KisPaintDeviceSP originalDevice = original();
386
387 return originalDevice && originalSelection ? originalDevice->sequenceNumber() : -1;
388}
int sequenceNumber() const

References internalSelection(), original(), and KisPaintDevice::sequenceNumber().

◆ x()

qint32 KisSelectionBasedLayer::x ( ) const
overridevirtual

gets this layer's x coordinate, taking selection into account

Returns
x-coordinate value

Reimplemented from KisLayer.

Definition at line 265 of file kis_selection_based_layer.cpp.

266{
267 return m_d->selection ? m_d->selection->x() : 0;
268}

References m_d.

◆ y()

qint32 KisSelectionBasedLayer::y ( ) const
overridevirtual

gets this layer's y coordinate, taking selection into account

Returns
y-coordinate value

Reimplemented from KisLayer.

Definition at line 270 of file kis_selection_based_layer.cpp.

271{
272 return m_d->selection ? m_d->selection->y() : 0;
273}

References m_d.

Member Data Documentation

◆ imageConnections

KisSignalAutoConnectionsStore KisSelectionBasedLayer::imageConnections

Definition at line 40 of file kis_selection_based_layer.cpp.

◆ m_d

Private* const KisSelectionBasedLayer::m_d
private

Definition at line 200 of file kis_selection_based_layer.h.

◆ paintDevice

KisPaintDeviceSP KisSelectionBasedLayer::paintDevice

Definition at line 38 of file kis_selection_based_layer.cpp.

◆ selection

KisSelectionSP KisSelectionBasedLayer::selection

Definition at line 37 of file kis_selection_based_layer.cpp.

◆ useSelectionInProjection

bool KisSelectionBasedLayer::useSelectionInProjection

Definition at line 39 of file kis_selection_based_layer.cpp.


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