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

#include <kis_image.h>

+ Inheritance diagram for KisImage:

Classes

class  KisImagePrivate
 

Public Slots

void explicitRegenerateLevelOfDetail ()
 
KisImageGlobalSelectionManagementInterfaceglobalSelectionManagementInterface () const
 
void requestRedoDuringStroke ()
 
void requestStrokeCancellation ()
 
void requestStrokeEnd ()
 
void requestStrokeEndActiveNode ()
 
void requestUndoDuringStroke ()
 
void stopIsolatedMode ()
 
UndoResult tryUndoUnfinishedLod0Stroke ()
 

Signals

void sigAboutToBeDeleted ()
 
void sigColorSpaceChanged (const KoColorSpace *cs)
 
void sigImageModified ()
 
void sigImageModifiedWithoutUndo ()
 
void sigImageUpdated (const QRect &)
 
void sigInternalStopIsolatedModeRequested ()
 
void sigIsolatedModeChanged ()
 
void sigLayersChangedAsync ()
 
void sigNodeAddedAsync (KisNodeSP node, KisNodeAdditionFlags flags)
 
void sigNodeChanged (KisNodeSP node)
 
void sigNodeCollapsedChanged ()
 
void sigProfileChanged (const KoColorProfile *profile)
 
void sigProofingConfigChanged ()
 
void sigRedoDuringStrokeRequested ()
 
void sigRemoveNodeAsync (KisNodeSP node)
 
void sigRequestNodeReselection (KisNodeSP activeNode, const KisNodeList &selectedNodes)
 
void sigResolutionChanged (double xRes, double yRes)
 
void sigSizeChanged (const QPointF &oldStillPoint, const QPointF &newStillPoint)
 
void sigStrokeCancellationRequested ()
 
void sigStrokeEndRequested ()
 
void sigStrokeEndRequestedActiveNodeFiltered ()
 
void sigUndoDuringStrokeRequested ()
 

Public Member Functions

void aboutToAddANode (KisNode *parent, int index) override
 
void aboutToRemoveANode (KisNode *parent, int index) override
 
void addAnnotation (KisAnnotationSP annotation)
 
void addComposition (KisLayerCompositionSP composition)
 
void addJob (KisStrokeId id, KisStrokeJobData *data) override
 
KisProjectionUpdatesFilterCookie addProjectionUpdatesFilter (KisProjectionUpdatesFilterSP filter) override
 
void addSpontaneousJob (KisSpontaneousJob *spontaneousJob)
 
bool allowMasksOnRootNode () const
 
KisImageAnimationInterfaceanimationInterface () const
 
KisAnnotationSP annotation (const QString &type)
 
bool assignImageProfile (const KoColorProfile *profile, bool blockAllUpdates=false)
 
bool assignLayerProfile (KisNodeSP node, const KoColorProfile *profile)
 
void barrierLock (bool readOnly=false)
 Wait until all the queued background jobs are completed and lock the image.
 
vKisAnnotationSP_it beginAnnotations ()
 
void blockUpdates () override
 blockUpdates block updating the image projection
 
QRect bounds () const override
 
bool cancelStroke (KisStrokeId id) override
 
bool canReselectGlobalSelection ()
 
KisImageclone (bool exactCopy=false)
 
const KoColorSpacecolorSpace () const
 
KisCompositeProgressProxycompositeProgressProxy ()
 
QList< KisLayerCompositionSPcompositions ()
 
void convertImageColorSpace (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
 
void convertImageProjectionColorSpace (const KoColorSpace *dstColorSpace)
 
void convertLayerColorSpace (KisNodeSP node, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
 
QImage convertToQImage (const QSize &scaledImageSize, const KoColorProfile *profile)
 
QImage convertToQImage (qint32 x1, qint32 y1, qint32 width, qint32 height, const KoColorProfile *profile)
 
QImage convertToQImage (QRect imageRect, const KoColorProfile *profile)
 
void copyFromImage (const KisImage &rhs)
 
void cropImage (const QRect &newRect)
 start asynchronous operation on cropping the image
 
void cropNode (KisNodeSP node, const QRect &newRect, const bool activeFrameOnly=false)
 start asynchronous operation on cropping a subtree of nodes starting at node
 
void cropNodes (KisNodeList nodes, const QRect &newRect, const bool activeFrameOnly=false)
 
int currentLevelOfDetail () const
 
KisProjectionUpdatesFilterCookie currentProjectionUpdatesFilter () const override
 
KoColor defaultProjectionColor () const
 
void disableDirtyRequests () override
 
void disableUIUpdates () override
 
QPoint documentToImagePixelFloored (const QPointF &documentCoord) const
 
QPointF documentToPixel (const QPointF &documentCoord) const
 
QRectF documentToPixel (const QRectF &documentRect) const
 
QRect effectiveLodBounds () const
 
void enableDirtyRequests () override
 
QVector< QRect > enableUIUpdates () override
 
vKisAnnotationSP_it endAnnotations ()
 
void endStroke (KisStrokeId id) override
 
void flatten (KisNodeSP activeNode)
 
void flattenLayer (KisLayerSP layer)
 
KisSelectionSP globalSelection () const
 
KisNodegraphOverlayNode () const override
 
bool hasOverlaySelectionMask () const
 
bool hasUpdatesRunning () const override
 
qint32 height () const
 
void immediateLockForReadOnly ()
 
void initialRefreshGraph ()
 
void invalidateAllFrames () override
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect) override
 
bool isIdle (bool allowLocked=false)
 
bool isIsolatingGroup () const
 
bool isIsolatingLayer () const
 
KisNodeSP isolationRootNode () const
 
void keyframeChannelAboutToBeRemoved (KisNode *node, KisKeyframeChannel *channel) override
 
void keyframeChannelHasBeenAdded (KisNode *node, KisKeyframeChannel *channel) override
 
 KisImage (KisUndoStore *undoStore, qint32 width, qint32 height, const KoColorSpace *colorSpace, const QString &name)
 colorSpace can be null. In that case, it will be initialised to a default color space.
 
const KUndo2CommandlastExecutedCommand () const override
 
bool locked () const
 
KisLodPreferences lodPreferences () const
 
void mergeDown (KisLayerSP l, const KisMetaData::MergeStrategy *strategy)
 
void mergeMultipleLayers (QList< KisNodeSP > mergedLayers, KisNodeSP putAfter)
 
QPointF mirrorAxesCenter () const
 
void moveCompositionDown (KisLayerCompositionSP composition)
 
void moveCompositionUp (KisLayerCompositionSP composition)
 
qint32 nChildLayers () const
 
QString nextLayerName (const QString &baseName="") const
 
qint32 nHiddenLayers () const
 
qint32 nlayers () const
 
void nodeChanged (KisNode *node) override
 
void nodeCollapsedChanged (KisNode *node) override
 
void nodeHasBeenAdded (KisNode *parent, int index, KisNodeAdditionFlags flags) override
 
void notifyAboutToBeDeleted ()
 
void notifyBatchUpdateEnded () override
 
void notifyBatchUpdateStarted () override
 
void notifyLayersChanged ()
 use if the layers have changed completely (eg. when flattening)
 
void notifyProjectionUpdated (const QRect &rc) override
 
void notifySelectionChanged () override
 
void notifyUIUpdateCompleted (const QRect &rc) override
 
KisSelectionMaskSP overlaySelectionMask () const
 
QPointF pixelToDocument (const QPoint &pixelCoord) const
 
QPointF pixelToDocument (const QPointF &pixelCoord) const
 
QRectF pixelToDocument (const QRectF &pixelCoord) const
 
KisPostExecutionUndoAdapterpostExecutionUndoAdapter () const override
 
const KoColorProfileprofile () const
 
KisPaintDeviceSP projection () const
 
KisProofingConfigurationSP proofingConfiguration () const
 proofingConfiguration
 
void purgeUnusedData (bool isCancellable)
 purge all pixels that have default pixel to free up memory
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
virtual void refreshGraphAsync (KisNodeSP root, const QVector< QRect > &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)=0
 
void refreshGraphAsync (KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
 
void refreshGraphAsync (KisNodeSP root=nullptr, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void removeAnnotation (const QString &type)
 
void removeComposition (KisLayerCompositionSP composition)
 
KisProjectionUpdatesFilterSP removeProjectionUpdatesFilter (KisProjectionUpdatesFilterCookie cookie) override
 removes already installed filter from the stack of updates filers
 
void requestProjectionUpdate (KisNode *node, const QVector< QRect > &rects, KisProjectionUpdateFlags flags) override
 
void requestTimeSwitch (int time) override
 
void resizeImage (const QRect &newRect)
 start asynchronous operation on resizing the image
 
KisGroupLayerSP rootLayer () const
 
void rotateImage (double radians)
 start asynchronous operation on rotating the image
 
void rotateNode (KisNodeSP node, double radians, KisSelectionSP selection)
 start asynchronous operation on rotating a subtree of nodes starting at node
 
void rotateNodes (KisNodeList nodes, double radians, KisSelectionSP selection)
 
void scaleImage (const QSize &size, qreal xres, qreal yres, KisFilterStrategy *filterStrategy)
 start asynchronous operation on scaling the image
 
void scaleNode (KisNodeSP node, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection)
 start asynchronous operation on scaling a subtree of nodes starting at node
 
void scaleNodes (KisNodeList nodes, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection)
 
void setAllowMasksOnRootNode (bool value)
 
void setDefaultProjectionColor (const KoColor &color)
 
void setLodPreferences (const KisLodPreferences &value)
 
void setMirrorAxesCenter (const QPointF &value) const
 
void setModifiedWithoutUndo ()
 
void setOverlaySelectionMask (KisSelectionMaskSP mask)
 
void setProofingConfiguration (KisProofingConfigurationSP proofingConfig)
 setProofingConfiguration, this sets the image's proofing configuration, and signals the proofingConfiguration has changed.
 
void setResolution (double xres, double yres)
 
void setRootLayer (KisGroupLayerSP rootLayer)
 
void setUndoStore (KisUndoStore *undoStore)
 
void setWorkingThreadsLimit (int value)
 
void setWrapAroundModeAxis (WrapAroundAxis value)
 
void setWrapAroundModePermitted (bool value)
 
void shear (double angleX, double angleY)
 start asynchronous operation on shearing the image
 
void shearNode (KisNodeSP node, double angleX, double angleY, KisSelectionSP selection)
 start asynchronous operation on shearing a subtree of nodes starting at node
 
void shearNodes (KisNodeList nodes, double angleX, double angleY, KisSelectionSP selection)
 
KisImageSignalRoutersignalRouter ()
 
QSize size () const
 
bool startIsolatedMode (KisNodeSP node, bool isolateLayer, bool isolateGroup)
 
KisStrokeId startStroke (KisStrokeStrategy *strokeStrategy) override
 
bool tryBarrierLock (bool readOnly=false)
 Tries to lock the image without waiting for the jobs to finish.
 
void unblockUpdates () override
 unblockUpdates unblock updating the image project. This only restarts the scheduler and does not schedule a full refresh.
 
KisUndoAdapterundoAdapter () const
 
KisUndoStoreundoStore ()
 
void unifyLayersColorSpace ()
 
void unlock ()
 
void waitForDone ()
 
qint32 width () const
 
int workingThreadsLimit () const
 
bool wrapAroundModeActive () const
 
WrapAroundAxis wrapAroundModeAxis () const
 
bool wrapAroundModePermitted () const
 
double xRes () const
 
double yRes () const
 
 ~KisImage () override
 
- Public Member Functions inherited from KisStrokesFacade
virtual ~KisStrokesFacade ()
 
- Public Member Functions inherited from KisStrokeUndoFacade
virtual ~KisStrokeUndoFacade ()
 
- Public Member Functions inherited from KisUpdatesFacade
void refreshGraphAsync (KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root=nullptr, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
virtual ~KisUpdatesFacade ()
 
- Public Member Functions inherited from KisProjectionUpdateListener
virtual ~KisProjectionUpdateListener ()
 
- Public Member Functions inherited from KisNodeFacade
bool addNode (KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis, KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
bool addNode (KisNodeSP node, KisNodeSP parent, quint32 index, KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
bool addNode (KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
 KisNodeFacade ()
 
 KisNodeFacade (KisNodeSP root)
 
bool moveNode (KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis)
 
bool moveNode (KisNodeSP node, KisNodeSP parent, quint32 index)
 
bool removeNode (KisNodeSP node)
 
const KisNodeSP root () const
 
void setRoot (KisNodeSP root)
 
virtual ~KisNodeFacade ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisNodeGraphListener
virtual void aboutToMoveNode (KisNode *node, int oldIndex, int newIndex)
 
int graphSequenceNumber () const
 
 KisNodeGraphListener ()
 
virtual void nodeHasBeenMoved (KisNode *node, int oldIndex, int newIndex)
 
virtual void nodeHasBeenRemoved (KisNode *parent, int index)
 
 Private ()
 
virtual ~KisNodeGraphListener ()
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

static KisImageSP fromQImage (const QImage &image, KisUndoStore *undoStore)
 

Private Types

enum  CopyPolicy { CONSTRUCT = 1 , REPLACE = 2 , EXACT_COPY = 4 }
 

Private Member Functions

void copyFromImageImpl (const KisImage &rhs, int policy)
 
void emitSizeChanged ()
 
 KisImage (const KisImage &rhs, KisUndoStore *undoStore, bool exactCopy)
 
KisImageoperator= (const KisImage &rhs)
 
void refreshHiddenArea (KisNodeSP rootNode, const QRect &preparedArea)
 
void resizeImageImpl (const QRect &newRect, bool cropLayers)
 
void rotateImpl (const KUndo2MagicString &actionName, KisNodeList nodes, double radians, bool resizeImage, KisSelectionSP selection)
 
void rotateImpl (const KUndo2MagicString &actionName, KisNodeSP rootNode, double radians, bool resizeImage, KisSelectionSP selection)
 
void safeRemoveTwoNodes (KisNodeSP node1, KisNodeSP node2)
 
void setProjectionColorSpace (const KoColorSpace *colorSpace)
 
void setSize (const QSize &size)
 
void shearImpl (const KUndo2MagicString &actionName, KisNodeList nodes, bool resizeImage, double angleX, double angleY, KisSelectionSP selection)
 
void shearImpl (const KUndo2MagicString &actionName, KisNodeSP rootNode, bool resizeImage, double angleX, double angleY, KisSelectionSP selection)
 

Private Attributes

KisImagePrivatem_d
 

Friends

class KisImageGlobalSelectionManagementInterface
 
class KisImageResizeCommand
 

Additional Inherited Members

- Public Attributes inherited from KisNodeFacade
KisNodeWSP root
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisNodeGraphListener
int sequenceNumber
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

This is the image class, it contains a tree of KisLayer stack and meta information about the image. And it also provides some functions to manipulate the whole image.

Definition at line 56 of file kis_image.h.

Member Enumeration Documentation

◆ CopyPolicy

enum KisImage::CopyPolicy
private
Enumerator
CONSTRUCT 

we are copy-constructing a new KisImage

REPLACE 

we are replacing the current KisImage with another

EXACT_COPY 

Definition at line 124 of file kis_image.h.

124 {
125 CONSTRUCT = 1,
126 REPLACE = 2,
127 EXACT_COPY = 4,
128 };
@ REPLACE
we are replacing the current KisImage with another
Definition kis_image.h:126
@ CONSTRUCT
we are copy-constructing a new KisImage
Definition kis_image.h:125

Constructor & Destructor Documentation

◆ KisImage() [1/2]

KisImage::KisImage ( KisUndoStore * undoStore,
qint32 width,
qint32 height,
const KoColorSpace * colorSpace,
const QString & name )

colorSpace can be null. In that case, it will be initialised to a default color space.

Definition at line 315 of file kis_image.cc.

316 : QObject(0)
317 , KisShared()
318 , m_d(new KisImagePrivate(this, width, height,
321{
322 // make sure KisImage belongs to the GUI thread
323 moveToThread(qApp->thread());
325
326 setObjectName(name);
327 setRootLayer(new KisGroupLayer(this, "root", OPACITY_OPAQUE_U8));
328}
const quint8 OPACITY_OPAQUE_U8
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisImagePrivate * m_d
Definition kis_image.h:1275
const KoColorSpace * colorSpace() const
void sigInternalStopIsolatedModeRequested()
qint32 width() const
void stopIsolatedMode()
qint32 height() const
KisUndoStore * undoStore()
void setRootLayer(KisGroupLayerSP rootLayer)

References connect(), OPACITY_OPAQUE_U8, setRootLayer(), sigInternalStopIsolatedModeRequested(), and stopIsolatedMode().

◆ ~KisImage()

KisImage::~KisImage ( )
override

Request the tools to end currently running strokes

Definition at line 330 of file kis_image.cc.

331{
335 waitForDone();
336
337 delete m_d;
338 disconnect(); // in case Qt gets confused
339}
void waitForDone()

References m_d, and waitForDone().

◆ KisImage() [2/2]

KisImage::KisImage ( const KisImage & rhs,
KisUndoStore * undoStore,
bool exactCopy )
private

Definition at line 565 of file kis_image.cc.

566 : KisNodeFacade(),
568 KisShared(),
569 m_d(new KisImagePrivate(this,
570 rhs.width(), rhs.height(),
571 rhs.colorSpace(),
574{
575 // make sure KisImage belongs to the GUI thread
576 moveToThread(qApp->thread());
578
579 copyFromImageImpl(rhs, CONSTRUCT | (exactCopy ? EXACT_COPY : 0));
580}
The KisDumbUndoStore class doesn't actually save commands, so you cannot undo or redo!
KisImageAnimationInterface * animationInterface() const
void copyFromImageImpl(const KisImage &rhs, int policy)
Definition kis_image.cc:415

References connect(), CONSTRUCT, copyFromImageImpl(), EXACT_COPY, sigInternalStopIsolatedModeRequested(), and stopIsolatedMode().

Member Function Documentation

◆ aboutToAddANode()

void KisImage::aboutToAddANode ( KisNode * parent,
int index )
overridevirtual

Inform the model that we're going to add a node.

Reimplemented from KisNodeGraphListener.

Definition at line 582 of file kis_image.cc.

583{
585 SANITY_CHECK_LOCKED("aboutToAddANode");
586}
#define SANITY_CHECK_LOCKED(name)
Definition kis_image.cc:112
virtual void aboutToAddANode(KisNode *parent, int index)

References KisNodeGraphListener::aboutToAddANode(), and SANITY_CHECK_LOCKED.

◆ aboutToRemoveANode()

void KisImage::aboutToRemoveANode ( KisNode * parent,
int index )
overridevirtual

Inform the model we're going to remove a node.

Reimplemented from KisNodeGraphListener.

Definition at line 604 of file kis_image.cc.

605{
606 KisNodeSP deletedNode = parent->at(index);
607 if (!dynamic_cast<KisSelectionMask*>(deletedNode.data()) &&
608 deletedNode == m_d->isolationRootNode) {
609
611 }
612
614 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
615 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
616 this->keyframeChannelAboutToBeRemoved(node.data(), chan);
617 }
618 });
619
621
622 SANITY_CHECK_LOCKED("aboutToRemoveANode");
624}
void emitAboutToRemoveANode(KisNode *parent, int index)
KisImageSignalRouter signalRouter
Definition kis_image.cc:273
void keyframeChannelAboutToBeRemoved(KisNode *node, KisKeyframeChannel *channel) override
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327
void recursiveApplyNodes(NodePointer node, Functor func)
QMap< QString, KisKeyframeChannel * > keyframeChannels
virtual void aboutToRemoveANode(KisNode *parent, int index)

References KisNodeGraphListener::aboutToRemoveANode(), KisSharedPtr< T >::data(), KisImageSignalRouter::emitAboutToRemoveANode(), KisImage::KisImagePrivate::isolationRootNode, keyframeChannelAboutToBeRemoved(), KisBaseNode::keyframeChannels, m_d, KisLayerUtils::recursiveApplyNodes(), SANITY_CHECK_LOCKED, sigInternalStopIsolatedModeRequested(), and KisImage::KisImagePrivate::signalRouter.

◆ addAnnotation()

void KisImage::addAnnotation ( KisAnnotationSP annotation)

Add an annotation for this image. This can be anything: Gamma, EXIF, etc. Note that the "icc" annotation is reserved for the color strategies. If the annotation already exists, overwrite it with this one.

Definition at line 1834 of file kis_image.cc.

1835{
1836 // Find the icc annotation, if there is one
1837 vKisAnnotationSP_it it = m_d->annotations.begin();
1838 while (it != m_d->annotations.end()) {
1839 if ((*it)->type() == annotation->type()) {
1840 *it = annotation;
1842 return;
1843 }
1844 ++it;
1845 }
1846 m_d->annotations.push_back(annotation);
1848}
vKisAnnotationSP annotations
Definition kis_image.cc:265
KisAnnotationSP annotation(const QString &type)
void setModifiedWithoutUndo()
vKisAnnotationSP::iterator vKisAnnotationSP_it
Definition kis_types.h:181

References annotation(), KisImage::KisImagePrivate::annotations, m_d, and setModifiedWithoutUndo().

◆ addComposition()

void KisImage::addComposition ( KisLayerCompositionSP composition)

Adds a new layer composition, will be saved with the image

Definition at line 2452 of file kis_image.cc.

2453{
2454 m_d->compositions.append(composition);
2455}
QList< KisLayerCompositionSP > compositions
Definition kis_image.cc:252

References KisImage::KisImagePrivate::compositions, and m_d.

◆ addJob()

void KisImage::addJob ( KisStrokeId id,
KisStrokeJobData * data )
overridevirtual

Implements KisStrokesFacade.

Definition at line 2101 of file kis_image.cc.

2102{
2104 m_d->scheduler.addJob(id, data);
2105}
KisUpdateScheduler scheduler
Definition kis_image.cc:275
void addJob(KisStrokeId id, KisStrokeJobData *data) override
static KisUpdateTimeMonitor * instance()

References KisUpdateScheduler::addJob(), KisUpdateTimeMonitor::instance(), m_d, KisUpdateTimeMonitor::reportJobStarted(), and KisImage::KisImagePrivate::scheduler.

◆ addProjectionUpdatesFilter()

KisProjectionUpdatesFilterCookie KisImage::addProjectionUpdatesFilter ( KisProjectionUpdatesFilterSP filter)
overridevirtual

Installs a filter object that will filter all the incoming projection update requests. If the filter return true, the incoming update is dropped.

NOTE: you can add multiple filters to the image, but the calls to add/remove must be nested and balanced. E.g.

auto cookie1 = image->addProjectionUpdatesFilter(filter1);
auto cookie2 = image->addProjectionUpdatesFilter(filter2);
image->removeProjectionUpdatesFilter(cookie2)
image->removeProjectionUpdatesFilter(cookie1)
// image->removeProjectionUpdatesFilter(cookie1)
// image->removeProjectionUpdatesFilter(cookie2)

Implements KisUpdatesFacade.

Definition at line 2234 of file kis_image.cc.

2235{
2237
2238 m_d->projectionUpdatesFilters.append(filter);
2239
2240 return KisProjectionUpdatesFilterCookie(filter.data());
2241}
QVector< KisProjectionUpdatesFilterSP > projectionUpdatesFilters
Definition kis_image.cc:271
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
void * KisProjectionUpdatesFilterCookie
Definition kis_types.h:285

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, and KisImage::KisImagePrivate::projectionUpdatesFilters.

◆ addSpontaneousJob()

void KisImage::addSpontaneousJob ( KisSpontaneousJob * spontaneousJob)

Adds a spontaneous job to the updates queue.

A spontaneous job may do some trivial tasks in the background, like updating the outline of selection or purging unused tiles from the existing paint devices.

Definition at line 2224 of file kis_image.cc.

2225{
2226 m_d->scheduler.addSpontaneousJob(spontaneousJob);
2227}
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)

References KisUpdateScheduler::addSpontaneousJob(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ allowMasksOnRootNode()

bool KisImage::allowMasksOnRootNode ( ) const
See also
setAllowMasksOnRootNode()

Definition at line 2621 of file kis_image.cc.

2622{
2623 return m_d->allowMasksOnRootNode;
2624}

References KisImage::KisImagePrivate::allowMasksOnRootNode, and m_d.

◆ animationInterface()

KisImageAnimationInterface * KisImage::animationInterface ( ) const

Definition at line 2579 of file kis_image.cc.

2580{
2581 return m_d->animationInterface;
2582}
KisImageAnimationInterface * animationInterface
Definition kis_image.cc:274

References KisImage::KisImagePrivate::animationInterface, and m_d.

◆ annotation()

KisAnnotationSP KisImage::annotation ( const QString & type)

get the annotation with the given type, can return 0

Definition at line 1850 of file kis_image.cc.

1851{
1852 vKisAnnotationSP_it it = m_d->annotations.begin();
1853 while (it != m_d->annotations.end()) {
1854 if ((*it) && (*it)->type() == type) {
1855 return *it;
1856 }
1857 else if (!*it) {
1858 qWarning() << "Skipping deleted annotation";
1859 }
1860 ++it;
1861 }
1862 return KisAnnotationSP(0);
1863}
KisSharedPtr< KisAnnotation > KisAnnotationSP
Definition kis_types.h:179

References KisImage::KisImagePrivate::annotations, and m_d.

◆ assignImageProfile()

bool KisImage::assignImageProfile ( const KoColorProfile * profile,
bool blockAllUpdates = false )

Set the profile of the image to the new profile and do the same for all layers that have the same colorspace and profile of the image. It doesn't do any pixel conversion.

This is essential if you have loaded an image that didn't have an embedded profile to which you want to attach the right profile.

Returns
false if the profile could not be assigned

Definition at line 1463 of file kis_image.cc.

1464{
1465 if (!profile) return false;
1466
1467 const KoColorSpace *srcColorSpace = m_d->colorSpace;
1468 bool imageProfileIsSame = *srcColorSpace->profile() == *profile;
1469
1470 imageProfileIsSame &=
1472 [profile] (KisNodeSP node) {
1473 return *node->colorSpace()->profile() != *profile;
1474 });
1475
1476 if (imageProfileIsSame) {
1477 dbgImage << "Trying to set the same image profile again" << ppVar(srcColorSpace->profile()->name()) << ppVar(profile->name());
1478 return true;
1479 }
1480
1481 KUndo2MagicString actionName = kundo2_i18n("Assign Profile");
1482
1483 KisImageSignalVector emitSignals;
1484 emitSignals << ProfileChangedSignal;
1485
1486 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1487 if (!dstColorSpace) return false;
1488
1489 KisProcessingApplicator applicator(this, m_d->rootLayer,
1491 (!blockAllUpdates ?
1493 KisProcessingApplicator::NO_IMAGE_UPDATES),
1494 emitSignals, actionName);
1495
1496 applicator.applyCommand(
1497 new KisImagePrivate::SetImageProjectionColorSpace(dstColorSpace,
1498 KisImageWSP(this),
1501
1502 applicator.applyVisitor(
1504 srcColorSpace, dstColorSpace),
1506
1507 applicator.applyCommand(
1508 new KisImagePrivate::SetImageProjectionColorSpace(srcColorSpace,
1509 KisImageWSP(this),
1512
1513
1514 applicator.end();
1515
1516 return true;
1517}
@ ProfileChangedSignal
const KoColorSpace * colorSpace
Definition kis_image.cc:244
KisGroupLayerSP rootLayer
Definition kis_image.cc:249
const KoColorProfile * profile() const
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
virtual const KoColorProfile * profile() const =0
#define ppVar(var)
Definition kis_debug.h:155
#define dbgImage
Definition kis_debug.h:46
KisWeakSharedPtr< KisImage > KisImageWSP
Definition kis_types.h:70
KUndo2MagicString kundo2_i18n(const char *text)
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()

References KisProcessingApplicator::applyCommand(), KisProcessingApplicator::applyVisitor(), KisStrokeJobData::BARRIER, KisImage::KisImagePrivate::colorSpace, colorSpace(), KoColorSpaceRegistry::colorSpace(), KisStrokeJobData::CONCURRENT, dbgImage, KisProcessingApplicator::end(), KisCommandUtils::FlipFlopCommand::FINALIZING, KisCommandUtils::FlipFlopCommand::INITIALIZING, KoColorSpaceRegistry::instance(), kundo2_i18n(), m_d, KoColorProfile::name, KisProcessingApplicator::NO_IMAGE_UPDATES, KisProcessingApplicator::NO_UI_UPDATES, ppVar, profile(), KoColorSpace::profile(), ProfileChangedSignal, KisProcessingApplicator::RECURSIVE, KisLayerUtils::recursiveFindNode(), and KisImage::KisImagePrivate::rootLayer.

◆ assignLayerProfile()

bool KisImage::assignLayerProfile ( KisNodeSP node,
const KoColorProfile * profile )

Set the profile of the layer and all its children to the new profile. It doesn't do any pixel conversion.

This is essential if you have loaded an image that didn't have an embedded profile to which you want to attach the right profile.

Returns
false if the profile could not be assigned

Definition at line 1433 of file kis_image.cc.

1434{
1435 const KoColorSpace *srcColorSpace = node->colorSpace();
1436
1437 if (!node->projectionLeaf()->isLayer()) return false;
1438 if (!profile || *srcColorSpace->profile() == *profile) return false;
1439
1440 KUndo2MagicString actionName = kundo2_i18n("Assign Profile to Layer");
1441
1442 KisImageSignalVector emitSignals;
1443
1444 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1445 if (!dstColorSpace) return false;
1446
1447 KisProcessingApplicator applicator(this, node,
1450 emitSignals, actionName);
1451
1452 applicator.applyVisitor(
1454 srcColorSpace, dstColorSpace),
1456
1457 applicator.end();
1458
1459 return true;
1460}
virtual const KoColorSpace * colorSpace() const =0
KisProjectionLeafSP projectionLeaf
Definition kis_node.cpp:93

References KisProcessingApplicator::applyVisitor(), colorSpace(), KisBaseNode::colorSpace(), KoColorSpaceRegistry::colorSpace(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), KoColorSpaceRegistry::instance(), kundo2_i18n(), KisProcessingApplicator::NO_UI_UPDATES, profile(), KoColorSpace::profile(), KisNode::projectionLeaf, and KisProcessingApplicator::RECURSIVE.

◆ barrierLock()

void KisImage::barrierLock ( bool readOnly = false)

Wait until all the queued background jobs are completed and lock the image.

KisImage object has a local scheduler that executes long-running image rendering/modifying jobs (we call them "strokes") in a background. Basically, one should either access the image from the scope of such jobs (strokes) or just lock the image before using.

Calling barrierLock() will wait until all the queued operations are finished and lock the image, so you can start accessing it in a safe way.

readOnly tells the image if the caller is going to modify the image during holding the lock. Locking with non-readOnly access will reset all the internal caches of the image (lod-planes) when the lock status will be lifted.

Definition at line 756 of file kis_image.cc.

757{
758 if (!locked()) {
763 m_d->lockedForReadOnly = readOnly;
764 } else {
765 m_d->lockedForReadOnly &= readOnly;
766 }
767
768 m_d->lockCount++;
769}
void notifyWaitOnImageStarted(KisImage *image)
void notifyWaitOnImageEnded(KisImage *image)
static KisBusyWaitBroker * instance()
void requestStrokeEnd()
bool locked() const
Definition kis_image.cc:751

References KisUpdateScheduler::barrierLock(), KisBusyWaitBroker::instance(), KisImage::KisImagePrivate::lockCount, locked(), KisImage::KisImagePrivate::lockedForReadOnly, m_d, KisBusyWaitBroker::notifyWaitOnImageEnded(), KisBusyWaitBroker::notifyWaitOnImageStarted(), requestStrokeEnd(), and KisImage::KisImagePrivate::scheduler.

◆ beginAnnotations()

vKisAnnotationSP_it KisImage::beginAnnotations ( )

Start of an iteration over the annotations of this image (including the ICC Profile)

Definition at line 1878 of file kis_image.cc.

1879{
1880 return m_d->annotations.begin();
1881}

References KisImage::KisImagePrivate::annotations, and m_d.

◆ blockUpdates()

void KisImage::blockUpdates ( )
overridevirtual

blockUpdates block updating the image projection

Implements KisUpdatesFacade.

Definition at line 818 of file kis_image.cc.

References KisUpdateScheduler::blockUpdates(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ bounds()

QRect KisImage::bounds ( ) const
overridevirtual
Returns
the exact bounds of the image in pixel coordinates.

Implements KisUpdatesFacade.

Definition at line 1742 of file kis_image.cc.

1743{
1744 return QRect(0, 0, width(), height());
1745}

References height(), and width().

◆ cancelStroke()

bool KisImage::cancelStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2112 of file kis_image.cc.

2113{
2114 return m_d->scheduler.cancelStroke(id);
2115}
bool cancelStroke(KisStrokeId id) override

References KisUpdateScheduler::cancelStroke(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ canReselectGlobalSelection()

bool KisImage::canReselectGlobalSelection ( )

Returns whether we can reselect current global selection

See also
reselectGlobalSelection()

Definition at line 705 of file kis_image.cc.

706{
708}
KisSelectionMaskSP deselectedGlobalSelectionMask
Definition kis_image.cc:248

References KisImage::KisImagePrivate::deselectedGlobalSelectionMask, and m_d.

◆ clone()

KisImage * KisImage::clone ( bool exactCopy = false)

Makes a copy of the image with all the layers. If possible, shallow copies of the layers are made.

exactCopy shows if the copied image should look exactly the same as the other one (according to it's .kra xml representation). It means that the layers will have the same UUID keys and, therefore, you are not expected to use the copied image anywhere except for saving. Don't use this option if you plan to work with the copied image later.

Definition at line 405 of file kis_image.cc.

406{
407 return new KisImage(*this, 0, exactCopy);
408}
KisImage(KisUndoStore *undoStore, qint32 width, qint32 height, const KoColorSpace *colorSpace, const QString &name)
colorSpace can be null. In that case, it will be initialised to a default color space.
Definition kis_image.cc:315

References KisImage().

◆ colorSpace()

const KoColorSpace * KisImage::colorSpace ( ) const

The default colorspace of this image: new layers will have this colorspace and the projection will have this colorspace.

Definition at line 1524 of file kis_image.cc.

1525{
1526 return m_d->colorSpace;
1527}

References KisImage::KisImagePrivate::colorSpace, and m_d.

◆ compositeProgressProxy()

KisCompositeProgressProxy * KisImage::compositeProgressProxy ( )

Definition at line 746 of file kis_image.cc.

747{
749}
KisCompositeProgressProxy compositeProgressProxy
Definition kis_image.cc:278

References KisImage::KisImagePrivate::compositeProgressProxy, and m_d.

◆ compositions()

QList< KisLayerCompositionSP > KisImage::compositions ( )

Returns the layer compositions for the image

Definition at line 2447 of file kis_image.cc.

2448{
2449 return m_d->compositions;
2450}

References KisImage::KisImagePrivate::compositions, and m_d.

◆ convertImageColorSpace()

void KisImage::convertImageColorSpace ( const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags )

Convert the image and all its layers to the dstColorSpace

Definition at line 1394 of file kis_image.cc.

1397{
1398 m_d->convertImageColorSpaceImpl(dstColorSpace, true, renderingIntent, conversionFlags);
1399}
void convertImageColorSpaceImpl(const KoColorSpace *dstColorSpace, bool convertLayers, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)

References KisImage::KisImagePrivate::convertImageColorSpaceImpl(), and m_d.

◆ convertImageProjectionColorSpace()

void KisImage::convertImageProjectionColorSpace ( const KoColorSpace * dstColorSpace)

◆ convertLayerColorSpace()

void KisImage::convertLayerColorSpace ( KisNodeSP node,
const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags )

Convert layer and all its child layers to dstColorSpace

Definition at line 1292 of file kis_image.cc.

1296{
1297 if (!node->projectionLeaf()->isLayer()) return;
1298 // must not be an image root, use convertImageColorSpace() for that:
1299 KIS_SAFE_ASSERT_RECOVER_RETURN(!node->image() || (node.data() != node->image()->rootLayer().data()));
1300
1301 const KoColorSpace *srcColorSpace = node->colorSpace();
1302
1303 if (!dstColorSpace || *srcColorSpace == *dstColorSpace) return;
1304
1305 KUndo2MagicString actionName =
1306 kundo2_i18n("Convert Layer Color Space");
1307
1308 KisImageSignalVector emitSignals;
1309
1310 KisProcessingApplicator applicator(this, node,
1312 emitSignals, actionName);
1313
1314 applicator.applyVisitor(
1316 srcColorSpace, dstColorSpace,
1317 renderingIntent, conversionFlags),
1319
1320 applicator.end();
1321}
KisGroupLayerSP rootLayer() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KisImageWSP image

References KisProcessingApplicator::applyVisitor(), KisBaseNode::colorSpace(), KisStrokeJobData::CONCURRENT, KisSharedPtr< T >::data(), KisProcessingApplicator::end(), KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN, kundo2_i18n(), KisNode::projectionLeaf, KisProcessingApplicator::RECURSIVE, and rootLayer().

◆ convertToQImage() [1/3]

QImage KisImage::convertToQImage ( const QSize & scaledImageSize,
const KoColorProfile * profile )

Render a thumbnail of the projection onto a QImage.

Definition at line 1707 of file kis_image.cc.

1708{
1709 if (scaledImageSize.isEmpty()) {
1710 return QImage();
1711 }
1712
1714 KisPainter gc;
1715 gc.copyAreaOptimized(QPoint(0, 0), projection(), dev, bounds());
1716 gc.end();
1717 double scaleX = qreal(scaledImageSize.width()) / width();
1718 double scaleY = qreal(scaledImageSize.height()) / height();
1719
1720
1721 if (scaleX < 1.0/256 || scaleY < 1.0/256) {
1722 // quick checking if we're not trying to scale too much
1723 // convertToQImage uses KisFixedPoint values, which means that the scale cannot be smaller than 1/2^8
1724 // BUG:432182
1725 // FIXME: would be best to extend KisFixedPoint instead
1726 return convertToQImage(size(), profile).scaled(scaledImageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
1727 }
1728
1729 KoDummyUpdaterHolder updaterHolder;
1730 QPointer<KoUpdater> updater = updaterHolder.updater();
1731
1732 KisTransformWorker worker(dev, scaleX, scaleY, 0.0, 0.0, 0.0, 0.0, 0.0, updater, KisFilterStrategyRegistry::instance()->value("Bicubic"));
1733 worker.run();
1734
1735 return dev->convertToQImage(profile);
1736}
float value(const T *src, size_t ch)
static KisFilterStrategyRegistry * instance()
QImage convertToQImage(qint32 x1, qint32 y1, qint32 width, qint32 height, const KoColorProfile *profile)
KisPaintDeviceSP projection() const
QSize size() const
Definition kis_image.h:547
QRect bounds() const override
QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
A holder for an updater that does nothing.
Definition KoUpdater.h:116
KoUpdater * updater()

References bounds(), colorSpace(), KisPaintDevice::convertToQImage(), convertToQImage(), KisPainter::copyAreaOptimized(), KisPainter::end(), height(), KisFilterStrategyRegistry::instance(), profile(), projection(), KisTransformWorker::run(), size(), KoDummyUpdaterHolder::updater(), value(), and width().

◆ convertToQImage() [2/3]

QImage KisImage::convertToQImage ( qint32 x1,
qint32 y1,
qint32 width,
qint32 height,
const KoColorProfile * profile )

◆ convertToQImage() [3/3]

QImage KisImage::convertToQImage ( QRect imageRect,
const KoColorProfile * profile )

Render the projection onto a QImage. (this is an overloaded function)

Definition at line 1679 of file kis_image.cc.

1681{
1682 qint32 x;
1683 qint32 y;
1684 qint32 w;
1685 qint32 h;
1686 imageRect.getRect(&x, &y, &w, &h);
1687 return convertToQImage(x, y, w, h, profile);
1688}

References convertToQImage(), and profile().

◆ copyFromImage()

void KisImage::copyFromImage ( const KisImage & rhs)

Definition at line 410 of file kis_image.cc.

411{
413}

References copyFromImageImpl(), and REPLACE.

◆ copyFromImageImpl()

void KisImage::copyFromImageImpl ( const KisImage & rhs,
int policy )
private

We should replace the root before emitting any signals, because some of the layers may be subscribed to sigSizeChanged() signal (e.g. KisSelectionBasedLayer). So the old layers should be fully detached before we actually Q_EMIT this signal.

We should also change all the dimensional properties of the image before setting the image on the nodes, because some nodes may emit signals if something changes internally (e.g. resolution).

See bug 447599 for more details.

Definition at line 415 of file kis_image.cc.

416{
417 // make sure we choose exactly one from REPLACE and CONSTRUCT
418 KIS_ASSERT_RECOVER_RETURN(bool(policy & REPLACE) != bool(policy & CONSTRUCT));
419
432 const bool sizeChanged = m_d->width != rhs.width() || m_d->height != rhs.height();
433 const bool colorSpaceChanged = *m_d->colorSpace != *rhs.colorSpace();
434 const bool resolutionChanged = m_d->xres != rhs.m_d->xres || m_d->yres != rhs.m_d->yres;
435
436 if (sizeChanged) {
437 m_d->width = rhs.width();
438 m_d->height = rhs.height();
439 }
440
441 if (colorSpaceChanged) {
442 m_d->colorSpace = rhs.colorSpace();
443 }
444
445 if (resolutionChanged) {
446 m_d->xres = rhs.m_d->xres;
447 m_d->yres = rhs.m_d->yres;
448 }
449
450 // from KisImage::KisImage(const KisImage &, KisUndoStore *, bool)
451 setObjectName(rhs.objectName());
452
453 KisNodeSP oldRoot = this->root();
454 KisNodeSP newRoot = rhs.root()->clone();
455 newRoot->setGraphListener(this);
456 newRoot->setImage(this);
457
458 m_d->rootLayer = dynamic_cast<KisGroupLayer*>(newRoot.data());
459 setRoot(newRoot);
460
461 if (oldRoot) {
462 oldRoot->setImage(0);
463 oldRoot->setGraphListener(0);
464 oldRoot->disconnect();
465 }
466
467 // only when replacing do we need to Q_EMIT signals
468#define EMIT_IF_NEEDED if (!(policy & REPLACE)) {} else emit
469
470 if (sizeChanged) {
471 EMIT_IF_NEEDED sigSizeChanged(QPointF(), QPointF());
472 }
473 if (colorSpaceChanged) {
475 }
476 if (resolutionChanged) {
478 }
479
481
482 if (rhs.m_d->proofingConfig) {
484 if (policy & REPLACE) {
485 setProofingConfiguration(proofingConfig);
486 } else {
487 m_d->proofingConfig = proofingConfig;
488 }
489 }
490
491 bool exactCopy = policy & EXACT_COPY;
492
493 if (exactCopy || rhs.m_d->isolationRootNode || rhs.m_d->overlaySelectionMask) {
496
497 QQueue<KisNodeSP> linearizedNodes;
499 [&linearizedNodes](KisNodeSP node) {
500 linearizedNodes.enqueue(node);
501 });
503 [&linearizedNodes, exactCopy, &rhs, this](KisNodeSP node) {
504 KisNodeSP refNode = linearizedNodes.dequeue();
505
506 if (exactCopy) {
507 node->setUuid(refNode->uuid());
508 }
509
510 if (rhs.m_d->isolationRootNode &&
511 rhs.m_d->isolationRootNode == refNode) {
512 m_d->isolationRootNode = node;
513 }
514
515 if (rhs.m_d->overlaySelectionMask &&
516 KisNodeSP(rhs.m_d->overlaySelectionMask) == refNode) {
517 m_d->targetOverlaySelectionMask = dynamic_cast<KisSelectionMask*>(node.data());
520 }
521
522
523 // Re-establish DefaultBounds Instances for Existing Nodes
524 // This is a workaround for copy-constructors failing to pass
525 // proper DefaultBounds due to either lacking image data on construction
526 // We should change the way "DefaultBounds" works to try to make it
527 // safer for threading races.
528 using KeyframeChannelContainer = QMap<QString, KisKeyframeChannel*>;
529 KeyframeChannelContainer keyframeChannels = node->keyframeChannels();
530 for (KeyframeChannelContainer::iterator i = keyframeChannels.begin();
531 i != keyframeChannels.end(); i++) {
532 keyframeChannels[i.key()]->setNode(node);
533 }
534 });
535 }
536
538 [](KisNodeSP node) {
539 dbgImage << "Node: " << (void *)node.data();
540 });
541
542
543
544 m_d->compositions.clear();
545
546 Q_FOREACH (KisLayerCompositionSP comp, rhs.m_d->compositions) {
547 m_d->compositions << toQShared(new KisLayerComposition(*comp, this));
548 }
549
551
552 vKisAnnotationSP newAnnotations;
553 Q_FOREACH (KisAnnotationSP annotation, rhs.m_d->annotations) {
554 newAnnotations << annotation->clone();
555 }
556 m_d->annotations = newAnnotations;
557
561
562#undef EMIT_IF_NEEDED
563}
KisProofingConfigurationSP proofingConfig
Definition kis_image.cc:245
KisSelectionMaskSP targetOverlaySelectionMask
Definition kis_image.cc:250
KisSelectionMaskSP overlaySelectionMask
Definition kis_image.cc:251
QAtomicInt disableUIUpdateSignals
Definition kis_image.cc:267
QAtomicInt disableDirtyRequests
Definition kis_image.cc:276
void sigLayersChangedAsync()
void sigResolutionChanged(double xRes, double yRes)
void sigColorSpaceChanged(const KoColorSpace *cs)
void setProofingConfiguration(KisProofingConfigurationSP proofingConfig)
setProofingConfiguration, this sets the image's proofing configuration, and signals the proofingConfi...
void sigSizeChanged(const QPointF &oldStillPoint, const QPointF &newStillPoint)
The KisProofingConfiguration struct Little struct that stores the proofing configuration for a given ...
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
#define EMIT_IF_NEEDED
QSharedPointer< T > toQShared(T *ptr)
QUuid uuid() const
void setUuid(const QUuid &id)
void notifyChildMaskChanged()
Definition kis_layer.cc:493
void setRoot(KisNodeSP root)
void setImage(KisImageWSP newImage) override
Definition kis_node.cpp:254
virtual KisNodeSP clone() const =0
void setGraphListener(KisNodeGraphListener *graphListener)
Definition kis_node.cpp:289

References KisImage::KisImagePrivate::allowMasksOnRootNode, annotation(), KisImage::KisImagePrivate::annotations, KisNode::clone(), KisImage::KisImagePrivate::colorSpace, colorSpace(), KisImage::KisImagePrivate::compositions, CONSTRUCT, KisSharedPtr< T >::data(), dbgImage, KisImage::KisImagePrivate::disableDirtyRequests, KisImage::KisImagePrivate::disableUIUpdateSignals, EMIT_IF_NEEDED, EXACT_COPY, KisImage::KisImagePrivate::height, height(), KisImage::KisImagePrivate::isolateGroup, KisImage::KisImagePrivate::isolateLayer, KisImage::KisImagePrivate::isolationRootNode, KisBaseNode::keyframeChannels, KIS_ASSERT_RECOVER_NOOP, KIS_ASSERT_RECOVER_RETURN, m_d, KisLayer::notifyChildMaskChanged(), KisImage::KisImagePrivate::overlaySelectionMask, KisImage::KisImagePrivate::projectionUpdatesFilters, KisImage::KisImagePrivate::proofingConfig, KisLayerUtils::recursiveApplyNodes(), REPLACE, KisNodeFacade::root, KisImage::KisImagePrivate::rootLayer, KisNode::setGraphListener(), KisNode::setImage(), setProofingConfiguration(), KisNodeFacade::setRoot(), KisBaseNode::setUuid(), sigColorSpaceChanged(), sigLayersChangedAsync(), sigResolutionChanged(), sigSizeChanged(), KisImage::KisImagePrivate::targetOverlaySelectionMask, toQShared(), KisBaseNode::uuid(), KisImage::KisImagePrivate::width, width(), KisImage::KisImagePrivate::xres, and KisImage::KisImagePrivate::yres.

◆ cropImage()

void KisImage::cropImage ( const QRect & newRect)

start asynchronous operation on cropping the image

The method will drop all the image data outside newRect and resize the image to fit the new size. The GUI will get correct notification with old and new sizes, so it adjust canvas origin accordingly and avoid jumping of the canvas on screen

Parameters
newRectthe rectangle of the image which will be cut-out

Please note that the actual operation starts asynchronously in a background, so you cannot expect the image having new size right after this call.

Definition at line 870 of file kis_image.cc.

871{
872 resizeImageImpl(newRect, true);
873}
void resizeImageImpl(const QRect &newRect, bool cropLayers)
Definition kis_image.cc:834

References resizeImageImpl().

◆ cropNode()

void KisImage::cropNode ( KisNodeSP node,
const QRect & newRect,
const bool activeFrameOnly = false )

start asynchronous operation on cropping a subtree of nodes starting at node

The method will drop all the layer data outside newRect. Neither image nor a layer will be moved anywhere

Parameters
nodenode to crop
newRectthe rectangle of the layer which will be cut-out
activeFrameOnlywhether to crop every animation frame or just the current one.

Please note that the actual operation starts asynchronously in a background, so you cannot expect the image having new size right after this call.

Definition at line 931 of file kis_image.cc.

932{
933 const bool isLayer = qobject_cast<KisLayer*>(node.data());
934 KUndo2MagicString actionName = isLayer ?
935 kundo2_i18n("Crop Layer") :
936 kundo2_i18n("Crop Mask");
937
938 KisImageSignalVector emitSignals;
939
940 KisCropSavedExtraData *extraData =
942 newRect, node);
943
944 KisProcessingApplicator applicator(this, node,
946 emitSignals, actionName, extraData);
947
948 KisProcessingVisitorSP visitor =
949 new KisCropProcessingVisitor(newRect, true, false);
950
951 if (node->isAnimated() && activeFrameOnly) {
952 // Crop active frame..
953 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
954 } else {
955 // Crop all frames..
956 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
957 }
958 applicator.end();
959}
static bool isLayer(KisNodeSP node)
bool isAnimated() const

References KisProcessingApplicator::applyVisitor(), KisProcessingApplicator::applyVisitorAllFrames(), KisStrokeJobData::CONCURRENT, KisCropSavedExtraData::CROP_LAYER, KisSharedPtr< T >::data(), KisProcessingApplicator::end(), KisBaseNode::isAnimated(), isLayer(), kundo2_i18n(), and KisProcessingApplicator::RECURSIVE.

◆ cropNodes()

void KisImage::cropNodes ( KisNodeList nodes,
const QRect & newRect,
const bool activeFrameOnly = false )

◆ currentLevelOfDetail()

int KisImage::currentLevelOfDetail ( ) const
Returns
current level of detail which is used when processing the image. Current working zoom = 2 ^ (- currentLevelOfDetail()). Default value is null, which means we work on the original image.

Definition at line 2549 of file kis_image.cc.

2550{
2552}

References KisUpdateScheduler::currentLevelOfDetail(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ currentProjectionUpdatesFilter()

KisProjectionUpdatesFilterCookie KisImage::currentProjectionUpdatesFilter ( ) const
overridevirtual

Return the cookie of the lastly-installed filter

See also
addProjectionUpdatesFilter()

Implements KisUpdatesFacade.

Definition at line 2258 of file kis_image.cc.

2259{
2260 return !m_d->projectionUpdatesFilters.isEmpty() ?
2261 m_d->projectionUpdatesFilters.last().data() :
2263}

References m_d, and KisImage::KisImagePrivate::projectionUpdatesFilters.

◆ defaultProjectionColor()

KoColor KisImage::defaultProjectionColor ( ) const
See also
setDefaultProjectionColor()

Definition at line 1801 of file kis_image.cc.

1802{
1805 }
1806
1808}
static KoColor createTransparent(const KoColorSpace *cs)
Definition KoColor.cpp:681
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55
KoColor defaultProjectionColor() const

References KisImage::KisImagePrivate::colorSpace, KoColor::createTransparent(), KisGroupLayer::defaultProjectionColor(), KIS_ASSERT_RECOVER, m_d, and KisImage::KisImagePrivate::rootLayer.

◆ disableDirtyRequests()

void KisImage::disableDirtyRequests ( )
overridevirtual

Disables the processing of all the setDirty() requests that come to the image. The incoming requests are effectively dropped.

This feature is used by KisProcessingApplicator. For many cases it provides its own updates interface, which recalculates the whole subtree of nodes. But while we change any particular node, it can ask for an update itself. This method is a way of blocking such intermediate (and excessive) requests.

NOTE: this is a convenience function for addProjectionUpdatesFilter() that installs a predefined filter that eats everything. Please note that these calls are not recursive.

WARNING: The calls to enable/disable must be balanced.

Implements KisUpdatesFacade.

Definition at line 2265 of file kis_image.cc.

2266{
2269}
QStack< KisProjectionUpdatesFilterCookie > disabledUpdatesCookies
Definition kis_image.cc:272
KisProjectionUpdatesFilterCookie addProjectionUpdatesFilter(KisProjectionUpdatesFilterSP filter) override

References addProjectionUpdatesFilter(), KisImage::KisImagePrivate::disabledUpdatesCookies, m_d, and toQShared().

◆ disableUIUpdates()

void KisImage::disableUIUpdates ( )
overridevirtual

Disables notification of the UI about the changes in the image. This feature is used by KisProcessingApplicator. It is needed when we change the size of the image. In this case, the whole image will be reloaded into UI by sigSizeChanged(), so there is no need to inform the UI about individual dirty rects.

The last call to enableUIUpdates() will return the list of updates that were requested while they were blocked.

Implements KisUpdatesFacade.

Definition at line 2277 of file kis_image.cc.

2278{
2280}

References KisImage::KisImagePrivate::disableUIUpdateSignals, and m_d.

◆ documentToImagePixelFloored()

QPoint KisImage::documentToImagePixelFloored ( const QPointF & documentCoord) const

Convert a document coordinate to an integer pixel coordinate rounded down.

Parameters
documentCoordPostScript Pt coordinate to convert.

Definition at line 1564 of file kis_image.cc.

1565{
1566 QPointF pixelCoord = documentToPixel(documentCoord);
1567 return QPoint(qFloor(pixelCoord.x()), qFloor(pixelCoord.y()));
1568}
QPointF documentToPixel(const QPointF &documentCoord) const

References documentToPixel().

◆ documentToPixel() [1/2]

QPointF KisImage::documentToPixel ( const QPointF & documentCoord) const

Convert a document coordinate to a pixel coordinate.

Parameters
documentCoordPostScript Pt coordinate to convert.

Definition at line 1559 of file kis_image.cc.

1560{
1561 return QPointF(documentCoord.x() * xRes(), documentCoord.y() * yRes());
1562}
double xRes() const
double yRes() const

References xRes(), and yRes().

◆ documentToPixel() [2/2]

QRectF KisImage::documentToPixel ( const QRectF & documentRect) const

Convert a document rectangle to a pixel rectangle.

Parameters
documentRectPostScript Pt rectangle to convert.

Definition at line 1570 of file kis_image.cc.

1571{
1572 return QRectF(documentToPixel(documentRect.topLeft()), documentToPixel(documentRect.bottomRight()));
1573}

References documentToPixel().

◆ effectiveLodBounds()

QRect KisImage::effectiveLodBounds ( ) const

Returns the actual bounds of the image, taking LevelOfDetail into account. This value is used as a bounds() value of KisDefaultBounds object.

Definition at line 1747 of file kis_image.cc.

1748{
1749 QRect boundRect = bounds();
1750
1751 const int lod = currentLevelOfDetail();
1752 if (lod > 0) {
1753 KisLodTransform t(lod);
1754 boundRect = t.map(boundRect);
1755 }
1756
1757 return boundRect;
1758}
int currentLevelOfDetail() const

References bounds(), currentLevelOfDetail(), and KisLodTransform::map().

◆ emitSizeChanged()

void KisImage::emitSizeChanged ( )
private

◆ enableDirtyRequests()

void KisImage::enableDirtyRequests ( )
overridevirtual
See also
disableDirtyRequests()

Implements KisUpdatesFacade.

Definition at line 2271 of file kis_image.cc.

2272{
2275}
KisProjectionUpdatesFilterSP removeProjectionUpdatesFilter(KisProjectionUpdatesFilterCookie cookie) override
removes already installed filter from the stack of updates filers

References KisImage::KisImagePrivate::disabledUpdatesCookies, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and removeProjectionUpdatesFilter().

◆ enableUIUpdates()

QVector< QRect > KisImage::enableUIUpdates ( )
overridevirtual
See also
disableUIUpdates

Implements KisUpdatesFacade.

Definition at line 2297 of file kis_image.cc.

2298{
2299 m_d->disableUIUpdateSignals.deref();
2300
2301 QRect rect;
2302 QVector<QRect> postponedUpdates;
2303
2305 postponedUpdates.append(rect);
2306 }
2307
2308 return postponedUpdates;
2309}
KisLocklessStack< QRect > savedDisabledUIUpdates
Definition kis_image.cc:268

References KisImage::KisImagePrivate::disableUIUpdateSignals, m_d, KisLocklessStack< T >::pop(), and KisImage::KisImagePrivate::savedDisabledUIUpdates.

◆ endAnnotations()

vKisAnnotationSP_it KisImage::endAnnotations ( )

end of an iteration over the annotations of this image

Definition at line 1883 of file kis_image.cc.

1884{
1885 return m_d->annotations.end();
1886}

References KisImage::KisImagePrivate::annotations, and m_d.

◆ endStroke()

void KisImage::endStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2107 of file kis_image.cc.

2108{
2109 m_d->scheduler.endStroke(id);
2110}
void endStroke(KisStrokeId id) override

References KisUpdateScheduler::endStroke(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ explicitRegenerateLevelOfDetail

void KisImage::explicitRegenerateLevelOfDetail ( )
slot

Explicitly start regeneration of LoD planes of all the devices in the image. This call should be performed when the user is idle, just to make the quality of image updates better.

Definition at line 2554 of file kis_image.cc.

2555{
2557
2558 if (pref.lodSupported() && pref.lodPreferred()) {
2560 }
2561}
bool lodSupported() const
bool lodPreferred() const
KisLodPreferences lodPreferences() const

References KisUpdateScheduler::explicitRegenerateLevelOfDetail(), KisUpdateScheduler::lodPreferences(), KisLodPreferences::lodPreferred(), KisLodPreferences::lodSupported(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ flatten()

void KisImage::flatten ( KisNodeSP activeNode)

Merge all visible layers and discard hidden ones.

Definition at line 1653 of file kis_image.cc.

1654{
1655 KisLayerUtils::flattenImage(this, activeNode);
1656}
void flattenImage(KisImageSP image, KisNodeSP activeNode, MergeFlags flags)

References KisLayerUtils::flattenImage().

◆ flattenLayer()

void KisImage::flattenLayer ( KisLayerSP layer)

flatten the layer: that is, the projection becomes the layer and all subnodes are removed. If this is not a paint layer, it will morph into a paint layer.

Definition at line 1668 of file kis_image.cc.

1669{
1670 KisLayerUtils::flattenLayer(this, layer);
1671}
void flattenLayer(KisImageSP image, KisLayerSP layer, MergeFlags flags)

References KisLayerUtils::flattenLayer().

◆ fromQImage()

KisImageSP KisImage::fromQImage ( const QImage & image,
KisUndoStore * undoStore )
static

Definition at line 341 of file kis_image.cc.

342{
343 const KoColorSpace *colorSpace = 0;
344
345 switch (image.format()) {
346 case QImage::Format_Invalid:
347 case QImage::Format_Mono:
348 case QImage::Format_MonoLSB:
350 break;
351 case QImage::Format_Indexed8:
352 case QImage::Format_RGB32:
353 case QImage::Format_ARGB32:
354 case QImage::Format_ARGB32_Premultiplied:
356 break;
357 case QImage::Format_RGB16:
359 break;
360 case QImage::Format_ARGB8565_Premultiplied:
361 case QImage::Format_RGB666:
362 case QImage::Format_ARGB6666_Premultiplied:
363 case QImage::Format_RGB555:
364 case QImage::Format_ARGB8555_Premultiplied:
365 case QImage::Format_RGB888:
366 case QImage::Format_RGB444:
367 case QImage::Format_ARGB4444_Premultiplied:
368 case QImage::Format_RGBX8888:
369 case QImage::Format_RGBA8888:
370 case QImage::Format_RGBA8888_Premultiplied:
372 break;
373 case QImage::Format_BGR30:
374 case QImage::Format_A2BGR30_Premultiplied:
375 case QImage::Format_RGB30:
376 case QImage::Format_A2RGB30_Premultiplied:
378 break;
379 case QImage::Format_Alpha8:
381 break;
382 case QImage::Format_Grayscale8:
384 break;
385 case QImage::Format_Grayscale16:
387 break;
388 case QImage::Format_RGBX64:
389 case QImage::Format_RGBA64:
390 case QImage::Format_RGBA64_Premultiplied:
392 break;
393 default:
394 colorSpace = 0;
395 }
396
397 KisImageSP img = new KisImage(undoStore, image.width(), image.height(), colorSpace, i18n("Imported Image"));
398 KisPaintLayerSP layer = new KisPaintLayer(img, img->nextLayerName(), 255);
399 layer->paintDevice()->convertFromQImage(image, 0, 0, 0);
400 img->addNode(layer.data(), img->rootLayer().data());
401
402 return img;
403}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
QString nextLayerName(const QString &baseName="") const
Definition kis_image.cc:715
void convertFromQImage(const QImage &image, const KoColorProfile *profile, qint32 offsetX=0, qint32 offsetY=0)
QString id() const
Definition KoID.cpp:63
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
KisPaintDeviceSP paintDevice
const KoColorSpace * graya8(const QString &profile=QString())
const KoColorSpace * graya16(const QString &profile=QString())
const KoColorSpace * rgb8(const QString &profileName=QString())
const KoColorSpace * rgb16(const QString &profileName=QString())
const KoColorSpace * alpha8()

References KisNodeFacade::addNode(), KoColorSpaceRegistry::alpha8(), colorSpace(), KoColorSpaceRegistry::colorSpace(), KisPaintDevice::convertFromQImage(), KisSharedPtr< T >::data(), Float32BitsColorDepthID, KoColorSpaceRegistry::graya16(), KoColorSpaceRegistry::graya8(), KoID::id(), KoColorSpaceRegistry::instance(), KisImage(), nextLayerName(), KisPaintLayer::paintDevice, KoColorSpaceRegistry::rgb16(), KoColorSpaceRegistry::rgb8(), RGBAColorModelID, rootLayer(), and undoStore().

◆ globalSelection()

KisSelectionSP KisImage::globalSelection ( ) const
Returns
the global selection object or 0 if there is none. The global selection is always read-write.

Definition at line 695 of file kis_image.cc.

696{
697 KisSelectionMaskSP selectionMask = m_d->rootLayer->selectionMask();
698 if (selectionMask) {
699 return selectionMask->selection();
700 } else {
701 return 0;
702 }
703}
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:498
KisSelectionSP selection
Definition kis_mask.cc:44

References m_d, KisImage::KisImagePrivate::rootLayer, KisMask::selection, and KisLayer::selectionMask().

◆ globalSelectionManagementInterface

KisImageGlobalSelectionManagementInterface * KisImage::globalSelectionManagementInterface ( ) const
slot

A special interface that commands use to modify image's global selection

Definition at line 710 of file kis_image.cc.

711{
713}
KisImageGlobalSelectionManagementInterface globalSelectionInterface
Definition kis_image.cc:247

References KisImage::KisImagePrivate::globalSelectionInterface, and m_d.

◆ graphOverlayNode()

KisNode * KisImage::graphOverlayNode ( ) const
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2426 of file kis_image.cc.

2427{
2428 return m_d->overlaySelectionMask.data();
2429}

References KisSharedPtr< T >::data(), m_d, and KisImage::KisImagePrivate::overlaySelectionMask.

◆ hasOverlaySelectionMask()

bool KisImage::hasOverlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 690 of file kis_image.cc.

691{
693}

References m_d, and KisImage::KisImagePrivate::overlaySelectionMask.

◆ hasUpdatesRunning()

bool KisImage::hasUpdatesRunning ( ) const
overridevirtual
Returns
true if there are some updates in the updates queue. Please note, that is doesn't guarantee that there are no updates running in the updater context at the very moment. To guarantee that there are no updates left at all, please use barrier jobs instead.

Implements KisUpdatesFacade.

Definition at line 2229 of file kis_image.cc.

2230{
2232}

References KisUpdateScheduler::hasUpdatesRunning(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ height()

qint32 KisImage::height ( ) const

Return the height of the image

Definition at line 1595 of file kis_image.cc.

1596{
1597 return m_d->height;
1598}

References KisImage::KisImagePrivate::height, and m_d.

◆ immediateLockForReadOnly()

void KisImage::immediateLockForReadOnly ( )

[low-level] Lock the image without waiting for all the internal job queues are processed

WARNING: Don't use it unless you really know what you are doing! Use barrierLock() instead!

Waits for all the currently running internal jobs to complete and locks the image for writing. Please note that this function does not wait for all the internal queues to process, so there might be some non-finished actions pending. It means that you just postpone these actions until you unlock() the image back. Until then, then image might easily be frozen in some inconsistent state.

The only sane usage for this function is to lock the image for emergency processing, when some internal action or scheduler got hung up, and you just want to fetch some data from the image without races.

In all other cases, please use barrierLock() instead!

Definition at line 793 of file kis_image.cc.

References KisUpdateScheduler::immediateLockForReadOnly(), KisBusyWaitBroker::instance(), KisImage::KisImagePrivate::lockCount, locked(), KisImage::KisImagePrivate::lockedForReadOnly, m_d, KisBusyWaitBroker::notifyWaitOnImageEnded(), KisBusyWaitBroker::notifyWaitOnImageStarted(), requestStrokeEnd(), and KisImage::KisImagePrivate::scheduler.

◆ initialRefreshGraph()

void KisImage::initialRefreshGraph ( )

Triggers synchronous recomposition of the projection on the document opening, i.e. with the cropRect set to null. Unlimited crop rect forces the clone layers to regenerate all its sources.

WARNING: If you are not loading a multilayered document, consider using refreshGraphAsync() instead, possibly coupled with waitForDone().

NOTE: Tricky part. We set crop rect to null, so the clones will not rely on precalculated projections of their sources

Definition at line 2155 of file kis_image.cc.

2156{
2162 refreshGraphAsync(0, bounds(), QRect());
2163 waitForDone();
2164}
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override

References bounds(), refreshGraphAsync(), and waitForDone().

◆ invalidateAllFrames()

void KisImage::invalidateAllFrames ( )
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 632 of file kis_image.cc.

633{
635}
void invalidateFrames(const KisTimeSpan &range, const QRect &rect) override
static KisTimeSpan infinite(int start)

References KisTimeSpan::infinite(), and invalidateFrames().

◆ invalidateFrames()

void KisImage::invalidateFrames ( const KisTimeSpan & range,
const QRect & rect )
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2416 of file kis_image.cc.

2417{
2419}
void invalidateFrames(const KisTimeSpan &range, const QRect &rect)

References KisImage::KisImagePrivate::animationInterface, KisImageAnimationInterface::invalidateFrames(), and m_d.

◆ isIdle()

bool KisImage::isIdle ( bool allowLocked = false)

Definition at line 788 of file kis_image.cc.

789{
790 return (allowLocked || !locked()) && m_d->scheduler.isIdle();
791}

References KisUpdateScheduler::isIdle(), locked(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ isIsolatingGroup()

bool KisImage::isIsolatingGroup ( ) const

Definition at line 2096 of file kis_image.cc.

2097{
2098 return m_d->isolateGroup;
2099}

References KisImage::KisImagePrivate::isolateGroup, and m_d.

◆ isIsolatingLayer()

bool KisImage::isIsolatingLayer ( ) const

Definition at line 2091 of file kis_image.cc.

2092{
2093 return m_d->isolateLayer;
2094}

References KisImage::KisImagePrivate::isolateLayer, and m_d.

◆ isolationRootNode()

KisNodeSP KisImage::isolationRootNode ( ) const

Definition at line 2087 of file kis_image.cc.

2087 {
2088 return m_d->isolationRootNode;
2089}

References KisImage::KisImagePrivate::isolationRootNode, and m_d.

◆ keyframeChannelAboutToBeRemoved()

void KisImage::keyframeChannelAboutToBeRemoved ( KisNode * node,
KisKeyframeChannel * channel )
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2439 of file kis_image.cc.

2440{
2441 Q_UNUSED(node);
2442
2443 channel->disconnect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)));
2444 channel->disconnect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)));
2445}

References KisImage::KisImagePrivate::animationInterface, and m_d.

◆ keyframeChannelHasBeenAdded()

void KisImage::keyframeChannelHasBeenAdded ( KisNode * node,
KisKeyframeChannel * channel )
overridevirtual

Inform the model that a keyframe channel has been added or removed.

Reimplemented from KisNodeGraphListener.

Definition at line 2431 of file kis_image.cc.

2432{
2433 Q_UNUSED(node);
2434
2435 channel->connect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2436 channel->connect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*,int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2437}

References KisImage::KisImagePrivate::animationInterface, and m_d.

◆ lastExecutedCommand()

const KUndo2Command * KisImage::lastExecutedCommand ( ) const
overridevirtual

Return the lastly executed LoD0 command. It is effectively the same as to call undoAdapter()->presentCommand();

Implements KisStrokeUndoFacade.

Definition at line 1768 of file kis_image.cc.

1769{
1770 return m_d->undoStore->presentCommand();
1771}
QScopedPointer< KisUndoStore > undoStore
Definition kis_image.cc:261

References m_d, and KisImage::KisImagePrivate::undoStore.

◆ locked()

bool KisImage::locked ( ) const
Returns
return true if the image is in a locked state, i.e. all the internal jobs are blocked from execution by calling either lock() or barrierLock().

When the image is locked, the user can do some modifications to the image contents safely without a perspective having race conditions with internal image jobs.

Definition at line 751 of file kis_image.cc.

752{
753 return m_d->lockCount != 0;
754}

References KisImage::KisImagePrivate::lockCount, and m_d.

◆ lodPreferences()

KisLodPreferences KisImage::lodPreferences ( ) const

Return current lod-preferences used by the strokes queue. They may differ from the preferences that has been assigned before due to multi-stage application process (due to multithreading considerations)

Definition at line 2568 of file kis_image.cc.

2569{
2570 return m_d->scheduler.lodPreferences();
2571}

References KisUpdateScheduler::lodPreferences(), m_d, and KisImage::KisImagePrivate::scheduler.

◆ mergeDown()

void KisImage::mergeDown ( KisLayerSP l,
const KisMetaData::MergeStrategy * strategy )

Merge the specified layer with the layer below this layer, remove the specified layer.

Definition at line 1663 of file kis_image.cc.

1664{
1665 KisLayerUtils::mergeDown(this, layer, strategy);
1666}
void mergeDown(KisImageSP image, KisLayerSP layer, const KisMetaData::MergeStrategy *strategy, MergeFlags flags)

References KisLayerUtils::mergeDown().

◆ mergeMultipleLayers()

void KisImage::mergeMultipleLayers ( QList< KisNodeSP > mergedLayers,
KisNodeSP putAfter )

Merges layers in mergedLayers and creates a new layer above putAfter

Definition at line 1658 of file kis_image.cc.

1659{
1660 KisLayerUtils::mergeMultipleNodes(this, mergedNodes, putAfter);
1661}
void mergeMultipleNodes(KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, MergeFlags flags)

References KisLayerUtils::mergeMultipleNodes().

◆ mirrorAxesCenter()

QPointF KisImage::mirrorAxesCenter ( ) const

Relative position of the mirror axis center 0,0 - topleft corner of the image 1,1 - bottomright corner of the image

Definition at line 2606 of file kis_image.cc.

2607{
2608 return m_d->axesCenter;
2609}

References KisImage::KisImagePrivate::axesCenter, and m_d.

◆ moveCompositionDown()

void KisImage::moveCompositionDown ( KisLayerCompositionSP composition)

Move a composition down in the composition list

Definition at line 2471 of file kis_image.cc.

2472{
2473 int index = m_d->compositions.indexOf(composition);
2474 if (index >= m_d->compositions.size() -1) {
2475 return;
2476 }
2477 m_d->compositions.move(index, index + 1);
2478}

References KisImage::KisImagePrivate::compositions, and m_d.

◆ moveCompositionUp()

void KisImage::moveCompositionUp ( KisLayerCompositionSP composition)

Move a composition up in the composition list

Definition at line 2462 of file kis_image.cc.

2463{
2464 int index = m_d->compositions.indexOf(composition);
2465 if (index <= 0) {
2466 return;
2467 }
2468 m_d->compositions.move(index, index - 1);
2469}

References KisImage::KisImagePrivate::compositions, and m_d.

◆ nChildLayers()

qint32 KisImage::nChildLayers ( ) const

Definition at line 1640 of file kis_image.cc.

1641{
1642 const QStringList list = {"KisLayer"};
1643
1644 KoProperties koProperties;
1645 KisCountVisitor visitor(list, koProperties);
1646 const QList<KisNodeSP> childNodes = m_d->rootLayer->childNodes(list, koProperties);
1647 for (KisNodeSP childNode: childNodes) {
1648 childNode->accept(visitor);
1649 }
1650 return visitor.count();
1651}
QList< KisNodeSP > childNodes(const QStringList &nodeTypes, const KoProperties &properties) const
Definition kis_node.cpp:439

References KisNode::childNodes(), KisCountVisitor::count(), m_d, and KisImage::KisImagePrivate::rootLayer.

◆ nextLayerName()

QString KisImage::nextLayerName ( const QString & baseName = "") const

Retrieve the next automatic layername (XXX: fix to add option to return Mask X)

Definition at line 715 of file kis_image.cc.

716{
717 QString baseName = _baseName;
718
719 int numLayers = 0;
720 int maxLayerIndex = 0;
721 QRegularExpression numberedLayerRegexp(".* (\\d+)$");
723 [&numLayers, &maxLayerIndex, &numberedLayerRegexp] (KisNodeSP node) {
724 if (node->inherits("KisLayer")) {
725 QRegularExpressionMatch match = numberedLayerRegexp.match(node->name());
726
727 if (match.hasMatch()) {
728 maxLayerIndex = qMax(maxLayerIndex, match.captured(1).toInt());
729 }
730 numLayers++;
731 }
732 });
733
734 // special case if there is only root node
735 if (numLayers == 1) {
736 return i18nc("Name for the bottom-most layer in the layerstack", "Background");
737 }
738
739 if (baseName.isEmpty()) {
740 baseName = i18n("Paint Layer");
741 }
742
743 return QString("%1 %2").arg(baseName).arg(maxLayerIndex + 1);
744}

References KisLayerUtils::recursiveApplyNodes(), and KisNodeFacade::root.

◆ nHiddenLayers()

qint32 KisImage::nHiddenLayers ( ) const

Return the number of layers (not other node types) that are in this image and that are hidden.

Definition at line 1628 of file kis_image.cc.

1629{
1630 QStringList list;
1631 list << "KisLayer";
1632 KoProperties properties;
1633 properties.setProperty("visible", false);
1634 KisCountVisitor visitor(list, properties);
1635 m_d->rootLayer->accept(visitor);
1636
1637 return visitor.count();
1638}
void setProperty(const QString &name, const QVariant &value)
bool accept(KisNodeVisitor &v) override

References KisGroupLayer::accept(), KisCountVisitor::count(), m_d, KisImage::KisImagePrivate::rootLayer, and KoProperties::setProperty().

◆ nlayers()

qint32 KisImage::nlayers ( ) const

Return the number of layers (not other nodes) that are in this image.

Definition at line 1618 of file kis_image.cc.

1619{
1620 QStringList list;
1621 list << "KisLayer";
1622
1623 KisCountVisitor visitor(list, KoProperties());
1624 m_d->rootLayer->accept(visitor);
1625 return visitor.count();
1626}

References KisGroupLayer::accept(), KisCountVisitor::count(), m_d, and KisImage::KisImagePrivate::rootLayer.

◆ nodeChanged()

void KisImage::nodeChanged ( KisNode * node)
overridevirtual

◆ nodeCollapsedChanged()

void KisImage::nodeCollapsedChanged ( KisNode * node)
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2573 of file kis_image.cc.

2574{
2575 Q_UNUSED(node);
2576 Q_EMIT sigNodeCollapsedChanged();
2577}
void sigNodeCollapsedChanged()

References sigNodeCollapsedChanged().

◆ nodeHasBeenAdded()

void KisImage::nodeHasBeenAdded ( KisNode * parent,
int index,
KisNodeAdditionFlags flags )
overridevirtual

Inform the model we're done adding a node.

Reimplemented from KisNodeGraphListener.

Definition at line 588 of file kis_image.cc.

589{
590 KisNodeGraphListener::nodeHasBeenAdded(parent, index, flags);
591
593 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
594 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
595 chan->setNode(node);
596 this->keyframeChannelHasBeenAdded(node.data(), chan);
597 }
598 });
599
600 SANITY_CHECK_LOCKED("nodeHasBeenAdded");
601 m_d->signalRouter.emitNodeHasBeenAdded(parent, index, flags);
602}
void emitNodeHasBeenAdded(KisNode *parent, int index, KisNodeAdditionFlags flags)
void keyframeChannelHasBeenAdded(KisNode *node, KisKeyframeChannel *channel) override
void setNode(KisNodeWSP node)
virtual void nodeHasBeenAdded(KisNode *parent, int index, KisNodeAdditionFlags flags)

References KisSharedPtr< T >::data(), KisImageSignalRouter::emitNodeHasBeenAdded(), keyframeChannelHasBeenAdded(), KisBaseNode::keyframeChannels, m_d, KisNodeGraphListener::nodeHasBeenAdded(), KisLayerUtils::recursiveApplyNodes(), SANITY_CHECK_LOCKED, KisKeyframeChannel::setNode(), and KisImage::KisImagePrivate::signalRouter.

◆ notifyAboutToBeDeleted()

void KisImage::notifyAboutToBeDeleted ( )

Called before the image is deleted and sends the sigAboutToBeDeleted signal

Definition at line 1888 of file kis_image.cc.

1889{
1890 Q_EMIT sigAboutToBeDeleted();
1891}
void sigAboutToBeDeleted()

References sigAboutToBeDeleted().

◆ notifyBatchUpdateEnded()

void KisImage::notifyBatchUpdateEnded ( )
overridevirtual

Notify GUI that batch update has been completed. Now GUI can start showing all of them on screen.

Implements KisUpdatesFacade.

Definition at line 2287 of file kis_image.cc.

References KisImageSignalRouter::emitNotifyBatchUpdateEnded(), m_d, and KisImage::KisImagePrivate::signalRouter.

◆ notifyBatchUpdateStarted()

void KisImage::notifyBatchUpdateStarted ( )
overridevirtual

Notify GUI about a bunch of updates planned. GUI is expected to wait until all the updates are completed, and render them on screen only in the very and of the batch.

Implements KisUpdatesFacade.

Definition at line 2282 of file kis_image.cc.

References KisImageSignalRouter::emitNotifyBatchUpdateStarted(), m_d, and KisImage::KisImagePrivate::signalRouter.

◆ notifyLayersChanged()

void KisImage::notifyLayersChanged ( )

use if the layers have changed completely (eg. when flattening)

Definition at line 1737 of file kis_image.cc.

1738{
1740}
@ LayersChangedSignal
void emitNotification(KisImageSignalType type)

References KisImageSignalRouter::emitNotification(), LayersChangedSignal, m_d, and KisImage::KisImagePrivate::signalRouter.

◆ notifyProjectionUpdated()

void KisImage::notifyProjectionUpdated ( const QRect & rc)
overridevirtual

Implements KisProjectionUpdateListener.

Definition at line 2311 of file kis_image.cc.

2312{
2314
2316 int lod = currentLevelOfDetail();
2317 QRect dirtyRect = !lod ? rc : KisLodTransform::upscaledRect(rc, lod);
2318
2319 if (dirtyRect.isEmpty()) return;
2320
2321 Q_EMIT sigImageUpdated(dirtyRect);
2322 } else {
2324 }
2325}
void sigImageUpdated(const QRect &)
static QRect upscaledRect(const QRect &srcRect, int lod)
void reportUpdateFinished(const QRect &rect)

References currentLevelOfDetail(), KisImage::KisImagePrivate::disableUIUpdateSignals, KisUpdateTimeMonitor::instance(), m_d, KisLocklessStack< T >::push(), KisUpdateTimeMonitor::reportUpdateFinished(), KisImage::KisImagePrivate::savedDisabledUIUpdates, sigImageUpdated(), and KisLodTransformBase::upscaledRect().

◆ notifySelectionChanged()

void KisImage::notifySelectionChanged ( )
overridevirtual

Inform the model that one of the selections in the graph is changed. The sender is not passed to the function (at least for now) because the UI should decide itself whether it needs to fetch new selection of not.

The selection is calculated asynchronously, so it is not handled by disableUIUpdates() and other special signals of KisImageSignalRouter

Editing of selection masks doesn't necessary produce a setDirty() call, so in the end of the stroke we need to request direct update of the UI's cache.

Reimplemented from KisNodeGraphListener.

Definition at line 2337 of file kis_image.cc.

2338{
2345
2351 if (m_d->isolationRootNode &&
2352 dynamic_cast<KisSelectionMask*>(m_d->isolationRootNode.data())) {
2353
2355 }
2356}
KisLegacyUndoAdapter legacyUndoAdapter
Definition kis_image.cc:262
void notifyProjectionUpdated(const QRect &rc) override

References bounds(), KisSharedPtr< T >::data(), KisUndoAdapter::emitSelectionChanged(), KisImage::KisImagePrivate::isolationRootNode, KisImage::KisImagePrivate::legacyUndoAdapter, m_d, and notifyProjectionUpdated().

◆ notifyUIUpdateCompleted()

void KisImage::notifyUIUpdateCompleted ( const QRect & rc)
overridevirtual

Notify GUI that rect rc is now prepared in the image and GUI can read data from it.

WARNING: GUI will read the data right in the handler of this signal, so exclusive access to the area must be guaranteed by the caller.

Implements KisUpdatesFacade.

Definition at line 2292 of file kis_image.cc.

2293{
2295}

References notifyProjectionUpdated().

◆ operator=()

KisImage & KisImage::operator= ( const KisImage & rhs)
private

◆ overlaySelectionMask()

KisSelectionMaskSP KisImage::overlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 685 of file kis_image.cc.

686{
688}

References m_d, and KisImage::KisImagePrivate::overlaySelectionMask.

◆ pixelToDocument() [1/3]

QPointF KisImage::pixelToDocument ( const QPoint & pixelCoord) const

Convert an integer pixel coordinate to a document coordinate. The document coordinate is at the centre of the pixel.

Parameters
pixelCoordpixel coordinate to convert.

Definition at line 1580 of file kis_image.cc.

1581{
1582 return QPointF((pixelCoord.x() + 0.5) / xRes(), (pixelCoord.y() + 0.5) / yRes());
1583}

References xRes(), and yRes().

◆ pixelToDocument() [2/3]

QPointF KisImage::pixelToDocument ( const QPointF & pixelCoord) const

Convert a pixel coordinate to a document coordinate.

Parameters
pixelCoordpixel coordinate to convert.

Definition at line 1575 of file kis_image.cc.

1576{
1577 return QPointF(pixelCoord.x() / xRes(), pixelCoord.y() / yRes());
1578}

References xRes(), and yRes().

◆ pixelToDocument() [3/3]

QRectF KisImage::pixelToDocument ( const QRectF & pixelCoord) const

Convert a document rectangle to an integer pixel rectangle.

Parameters
pixelCoordpixel coordinate to convert.

Definition at line 1585 of file kis_image.cc.

1586{
1587 return QRectF(pixelToDocument(pixelCoord.topLeft()), pixelToDocument(pixelCoord.bottomRight()));
1588}
QPointF pixelToDocument(const QPointF &pixelCoord) const

References pixelToDocument().

◆ postExecutionUndoAdapter()

KisPostExecutionUndoAdapter * KisImage::postExecutionUndoAdapter ( ) const
overridevirtual

This adapter is used by the strokes system. The commands are added to it after redo() is done (in the scheduler context). They are wrapped into a special command and added to the undo stack. redo() in not called.

Implements KisStrokeUndoFacade.

Definition at line 1760 of file kis_image.cc.

1761{
1762 const int lod = currentLevelOfDetail();
1763 return lod > 0 ?
1766}
KisPostExecutionUndoAdapter postExecutionUndoAdapter
Definition kis_image.cc:263
KisPostExecutionUndoAdapter * lodNPostExecutionUndoAdapter() const

References currentLevelOfDetail(), KisUpdateScheduler::lodNPostExecutionUndoAdapter(), m_d, KisImage::KisImagePrivate::postExecutionUndoAdapter, and KisImage::KisImagePrivate::scheduler.

◆ profile()

const KoColorProfile * KisImage::profile ( ) const

Definition at line 1529 of file kis_image.cc.

1530{
1531 return colorSpace()->profile();
1532}

References colorSpace(), and KoColorSpace::profile().

◆ projection()

KisPaintDeviceSP KisImage::projection ( ) const

Return the projection; that is, the complete, composited representation of this image.

Definition at line 1606 of file kis_image.cc.

1607{
1608 if (m_d->isolationRootNode) {
1609 return m_d->isolationRootNode->projection();
1610 }
1611
1612 Q_ASSERT(m_d->rootLayer);
1614 Q_ASSERT(projection);
1615 return projection;
1616}
virtual KisPaintDeviceSP projection() const =0
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:820

References KisImage::KisImagePrivate::isolationRootNode, m_d, projection(), KisBaseNode::projection(), KisLayer::projection(), and KisImage::KisImagePrivate::rootLayer.

◆ proofingConfiguration()

KisProofingConfigurationSP KisImage::proofingConfiguration ( ) const

proofingConfiguration

Returns
the proofing configuration of the image.

Definition at line 2598 of file kis_image.cc.

2599{
2600 if (m_d->proofingConfig) {
2601 return m_d->proofingConfig;
2602 }
2604}
QSharedPointer< KisProofingConfiguration > KisProofingConfigurationSP
Definition kis_types.h:311

References m_d, and KisImage::KisImagePrivate::proofingConfig.

◆ purgeUnusedData()

void KisImage::purgeUnusedData ( bool isCancellable)

purge all pixels that have default pixel to free up memory

Parameters
isCancellableif true, the scheduler is allower to stop and cancel purging operation as soon as the user starts any action. If isCancellable is false, then the user will not be allowed to do anything until purging operation is completed.

WARNING: don't use this function unless you know what you are doing!

It breaks undo on layers! Therefore, after calling it, KisImage is not undo-capable anymore!

make sure we deduplicate the list to avoid concurrent write access to the devices

Definition at line 875 of file kis_image.cc.

876{
884 struct PurgeUnusedDataStroke : public KisRunnableBasedStrokeStrategy {
885 PurgeUnusedDataStroke(KisImageSP image, bool isCancellable)
886 : KisRunnableBasedStrokeStrategy(QLatin1String("purge-unused-data"),
887 kundo2_noi18n("purge-unused-data")),
888 m_image(image)
889 {
890 this->enableJob(JOB_INIT, true, KisStrokeJobData::BARRIER, KisStrokeJobData::EXCLUSIVE);
891 this->enableJob(JOB_DOSTROKE, true);
892 setClearsRedoOnStart(false);
893 setRequestsOtherStrokesToEnd(!isCancellable);
894 setCanForgetAboutMe(isCancellable);
895 }
896
897 void initStrokeCallback() override
898 {
899 KisPaintDeviceList deviceList;
901
903 [&deviceList](KisNodeSP node) {
904 deviceList << node->getLodCapableDevices();
905 });
906
910
911 Q_FOREACH (KisPaintDeviceSP device, deviceList) {
912 if (!device) continue;
913
915 [device] () {
916 const_cast<KisPaintDevice*>(device.data())->purgeDefaultPixels();
917 });
918 }
919
920 addMutatedJobs(jobsData);
921 }
922
923 private:
924 KisImageSP m_image;
925 };
926
927 KisStrokeId id = startStroke(new PurgeUnusedDataStroke(this, isCancellable));
928 endStroke(id);
929}
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override
KUndo2MagicString kundo2_noi18n(const QString &text)
void addJobConcurrent(QVector< Job * > &jobs, Func func)
void makeContainerUnique(C &container)

References KritaUtils::addJobConcurrent(), KisStrokeJobData::BARRIER, KisSharedPtr< T >::data(), endStroke(), KisStrokeJobData::EXCLUSIVE, kundo2_noi18n(), KritaUtils::makeContainerUnique(), KisPaintDevice::purgeDefaultPixels(), KisLayerUtils::recursiveApplyNodes(), and startStroke().

◆ refreshGraphAsync() [1/5]

void KisUpdatesFacade::refreshGraphAsync ( KisNodeSP root,
const QRect & rc,
const QRect & cropRect,
KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None )

Definition at line 54 of file kis_image_interfaces.cpp.

31{
32 refreshGraphAsync(root, QVector<QRect>({rc}), cropRect, flags);
33}

◆ refreshGraphAsync() [2/5]

void KisUpdatesFacade::refreshGraphAsync ( KisNodeSP root,
const QRect & rc,
KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None )

Definition at line 53 of file kis_image_interfaces.cpp.

26{
27 refreshGraphAsync(root, rc, bounds(), flags);
28}

◆ refreshGraphAsync() [3/5]

virtual void KisUpdatesFacade::refreshGraphAsync ( KisNodeSP root,
const QVector< QRect > & rc,
const QRect & cropRect,
KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None )
virtual

Implements KisUpdatesFacade.

◆ refreshGraphAsync() [4/5]

void KisImage::refreshGraphAsync ( KisNodeSP root,
const QVector< QRect > & rects,
const QRect & cropRect,
KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None )
overridevirtual

We cannot regenerate a pass-through group, since it is not present in the layers stack. Instead we should delegate this regeneration pass to the parent group.

We should also take into account the change rect of all the layers that lay above the "dirty" pass-through group (i.e. convert the change rect of the child into a change rect of the parent). That is required for a case, when there are adjustment layers laying above the pass-through group.

We iterate through the filters in a reversed way. It makes the most nested filters to execute first.

Implements KisUpdatesFacade.

Definition at line 2166 of file kis_image.cc.

2167{
2168 if (!root) root = m_d->rootLayer;
2169
2170 QVector<QRect> requestedRects = rects;
2171
2172 KisGroupLayer *group = dynamic_cast<KisGroupLayer*>(root.data());
2173 if (group && group->passThroughMode()) {
2184 QVector<QRect> changeRects = requestedRects;
2185 KisProjectionLeafSP leaf = root->projectionLeaf()->nextSibling();
2186 while (leaf) {
2187 if (leaf->shouldBeRendered()) {
2188 for (auto it = changeRects.begin(); it != changeRects.end(); ++it) {
2189 *it = leaf->projectionPlane()->changeRect(*it, leaf->node() == root ? KisNode::N_FILTHY : KisNode::N_ABOVE_FILTHY);
2190 }
2191 }
2192
2193 leaf = leaf->nextSibling();
2194 }
2195
2196 std::swap(requestedRects, changeRects);
2197 root = group->parent();
2198
2200 }
2201
2206 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2207 it != m_d->projectionUpdatesFilters.rend();
2208 ++it) {
2209
2210 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2211
2212 if ((*it)->filterRefreshGraph(this, root.data(), requestedRects, cropRect, flags)) {
2213 return;
2214 }
2215 }
2216
2217 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2218 m_d->animationInterface->notifyNodeChanged(root.data(), requestedRects, true);
2219 }
2220
2221 m_d->scheduler.fullRefreshAsync(root, requestedRects, cropRect, flags);
2222}
void notifyNodeChanged(const KisNode *node, const QRect &rect, bool recursive)
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
@ N_ABOVE_FILTHY
Definition kis_node.h:59
@ N_FILTHY
Definition kis_node.h:61
KisNodeWSP parent
Definition kis_node.cpp:86
void fullRefreshAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)

References KisImage::KisImagePrivate::animationInterface, KisWeakSharedPtr< T >::data(), DontInvalidateFrames, KisUpdateScheduler::fullRefreshAsync(), KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KisNode::N_ABOVE_FILTHY, KisNode::N_FILTHY, KisImageAnimationInterface::notifyNodeChanged(), KisNode::parent, KisGroupLayer::passThroughMode, KisNode::projectionLeaf, KisImage::KisImagePrivate::projectionUpdatesFilters, KisNodeFacade::root, KisImage::KisImagePrivate::rootLayer, and KisImage::KisImagePrivate::scheduler.

◆ refreshGraphAsync() [5/5]

void KisUpdatesFacade::refreshGraphAsync ( KisNodeSP root = nullptr,
KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None )

Definition at line 52 of file kis_image_interfaces.cpp.

21{
22 refreshGraphAsync(root, bounds(), bounds(), flags);
23}

◆ refreshHiddenArea()

void KisImage::refreshHiddenArea ( KisNodeSP rootNode,
const QRect & preparedArea )
private

◆ removeAnnotation()

void KisImage::removeAnnotation ( const QString & type)

delete the annotation, if the image contains it

Definition at line 1865 of file kis_image.cc.

1866{
1867 vKisAnnotationSP_it it = m_d->annotations.begin();
1868 while (it != m_d->annotations.end()) {
1869 if ((*it)->type() == type) {
1870 m_d->annotations.erase(it);
1872 return;
1873 }
1874 ++it;
1875 }
1876}

References KisImage::KisImagePrivate::annotations, m_d, and setModifiedWithoutUndo().

◆ removeComposition()

void KisImage::removeComposition ( KisLayerCompositionSP composition)

Remove the layer composition

Definition at line 2457 of file kis_image.cc.

2458{
2459 m_d->compositions.removeAll(composition);
2460}

References KisImage::KisImagePrivate::compositions, and m_d.

◆ removeProjectionUpdatesFilter()

KisProjectionUpdatesFilterSP KisImage::removeProjectionUpdatesFilter ( KisProjectionUpdatesFilterCookie cookie)
overridevirtual

removes already installed filter from the stack of updates filers

Parameters
cookiea cookie object returned by addProjectionUpdatesFilter() on installation
Returns
the installed filter. If the cookie is invalid, or nesting rule has been broken, then removeProjectionUpdatesFilter() may safe-assert and return nullptr.

NOTE: some weird code (e.g. KisRegenerateFrameStrokeStrategy) needs to temporary remove all the filters and then install them back. Current implementation ensures that after removal and the following installation, cookies will be preserved. So this operation is considered safe.

See also
addProjectionUpdatesFilter()

Implements KisUpdatesFacade.

Definition at line 2243 of file kis_image.cc.

2244{
2247
2248 auto it = std::find(m_d->projectionUpdatesFilters.begin(), m_d->projectionUpdatesFilters.end(), cookie);
2250
2251 KisProjectionUpdatesFilterSP filter = *it;
2252
2253 m_d->projectionUpdatesFilters.erase(it);
2254
2255 return filter;
2256}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, and KisImage::KisImagePrivate::projectionUpdatesFilters.

◆ requestProjectionUpdate()

void KisImage::requestProjectionUpdate ( KisNode * node,
const QVector< QRect > & rects,
KisProjectionUpdateFlags flags )
overridevirtual

Inform the model that a node has been changed (setDirty)

We iterate through the filters in a reversed way. It makes the most nested filters to execute first.

Here we use 'permitted' instead of 'active' intentively, because the updates may come after the actual stroke has been finished. And having some more updates for the stroke not supporting the wrap-around mode will not make much harm.

TODO: Remove the no-filthy condition. I have no idea, why it is present. Or replace it with an assert. (DK)

Reimplemented from KisNodeGraphListener.

Definition at line 2369 of file kis_image.cc.

2370{
2375 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2376 it != m_d->projectionUpdatesFilters.rend();
2377 ++it) {
2378
2379 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2380
2381 if ((*it)->filter(this, node, rects, flags)) {
2382 return;
2383 }
2384 }
2385
2386 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2387 m_d->animationInterface->notifyNodeChanged(node, rects, false);
2388 }
2389
2399 QVector<QRect> allSplitRects;
2400
2401 const QRect boundRect = effectiveLodBounds();
2402 Q_FOREACH (const QRect &rc, rects) {
2403 KisWrappedRect splitRect(rc, boundRect, m_d->wrapAroundModeAxis);
2404 allSplitRects.append(splitRect);
2405 }
2406
2407 m_d->requestProjectionUpdateImpl(node, allSplitRects, boundRect, flags);
2408
2409 } else {
2410 m_d->requestProjectionUpdateImpl(node, rects, bounds(), flags);
2411 }
2412
2414}
void requestProjectionUpdateImpl(KisNode *node, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
WrapAroundAxis wrapAroundModeAxis
Definition kis_image.cc:259
QRect effectiveLodBounds() const
virtual void requestProjectionUpdate(KisNode *node, const QVector< QRect > &rects, KisProjectionUpdateFlags flags)

References KisImage::KisImagePrivate::animationInterface, bounds(), DontInvalidateFrames, effectiveLodBounds(), KIS_SAFE_ASSERT_RECOVER, m_d, NoFilthy, KisImageAnimationInterface::notifyNodeChanged(), KisImage::KisImagePrivate::projectionUpdatesFilters, KisNodeGraphListener::requestProjectionUpdate(), KisImage::KisImagePrivate::requestProjectionUpdateImpl(), KisImage::KisImagePrivate::wrapAroundModeAxis, and KisImage::KisImagePrivate::wrapAroundModePermitted.

◆ requestRedoDuringStroke

void KisImage::requestRedoDuringStroke ( )
slot

This method is called by the UI (not by the creator of the stroke) when it thinks the current stroke should redo its last undo, for example, when the user presses Ctrl+Shift+Z while some stroke is active.

If the creator of the stroke supports undoing/redoing of an intermediate actions, it will be notified about this request and can undo its last action.

Definition at line 2127 of file kis_image.cc.

2128{
2130}
void sigRedoDuringStrokeRequested()

References sigRedoDuringStrokeRequested().

◆ requestStrokeCancellation

void KisImage::requestStrokeCancellation ( )
slot

This method is called by the UI (not by the creator of the stroke) when it thinks current stroke should be cancelled. If there is a running stroke that has already been detached from its creator (ended or cancelled), it will be forcefully cancelled and reverted. If there is an open stroke present, and if its creator supports cancelling, it will be notified about the request and the stroke will be cancelled

Definition at line 2132 of file kis_image.cc.

2133{
2136 }
2137}
void sigStrokeCancellationRequested()

References m_d, sigStrokeCancellationRequested(), and KisImage::KisImagePrivate::tryCancelCurrentStrokeAsync().

◆ requestStrokeEnd

void KisImage::requestStrokeEnd ( )
slot

This method is called when image or some other part of Krita (not the creator of the stroke) decides that the stroke should be ended. If the creator of the stroke supports it, it will be notified and the stroke will be cancelled

Definition at line 2144 of file kis_image.cc.

2145{
2146 Q_EMIT sigStrokeEndRequested();
2148}
void sigStrokeEndRequested()
void sigStrokeEndRequestedActiveNodeFiltered()

References sigStrokeEndRequested(), and sigStrokeEndRequestedActiveNodeFiltered().

◆ requestStrokeEndActiveNode

void KisImage::requestStrokeEndActiveNode ( )
slot

Same as requestStrokeEnd() but is called by view manager when the current node is changed. Use to distinguish sigStrokeEndRequested() and sigStrokeEndRequestedActiveNodeFiltered() which are used by KisNodeJugglerCompressed

Definition at line 2150 of file kis_image.cc.

2151{
2152 Q_EMIT sigStrokeEndRequested();
2153}

References sigStrokeEndRequested().

◆ requestTimeSwitch()

void KisImage::requestTimeSwitch ( int time)
overridevirtual

◆ requestUndoDuringStroke

void KisImage::requestUndoDuringStroke ( )
slot

This method is called by the UI (not by the creator of the stroke) when it thinks the current stroke should undo its last action, for example, when the user presses Ctrl+Z while some stroke is active.

If the creator of the stroke supports undoing of intermediate actions, it will be notified about this request and can undo its last action.

Definition at line 2122 of file kis_image.cc.

2123{
2125}
void sigUndoDuringStrokeRequested()

References sigUndoDuringStrokeRequested().

◆ resizeImage()

void KisImage::resizeImage ( const QRect & newRect)

start asynchronous operation on resizing the image

The method will resize the image to fit the new size without dropping any pixel data. The GUI will get correct notification with old and new sizes, so it adjust canvas origin accordingly and avoid jumping of the canvas on screen

Parameters
newRectthe rectangle of the image which will be visible after operation is completed

Please note that the actual operation starts asynchronously in a background, so you cannot expect the image having new size right after this call.

Definition at line 865 of file kis_image.cc.

866{
867 resizeImageImpl(newRect, false);
868}

References resizeImageImpl().

◆ resizeImageImpl()

void KisImage::resizeImageImpl ( const QRect & newRect,
bool cropLayers )
private

Definition at line 834 of file kis_image.cc.

835{
836 if (newRect == bounds() && !cropLayers) return;
837
838 KUndo2MagicString actionName = cropLayers ?
839 kundo2_i18n("Crop Image") :
840 kundo2_i18n("Resize Image");
841
842 KisImageSignalVector emitSignals;
843 emitSignals << ComplexSizeChangedSignal(newRect, newRect.size());
844
845 KisCropSavedExtraData *extraData =
846 new KisCropSavedExtraData(cropLayers ?
848 KisCropSavedExtraData::RESIZE_IMAGE,
849 newRect);
850
851 KisProcessingApplicator applicator(this, m_d->rootLayer,
854 emitSignals, actionName, extraData);
855
856 if (cropLayers || !newRect.topLeft().isNull()) {
857 KisProcessingVisitorSP visitor =
858 new KisCropProcessingVisitor(newRect, cropLayers, true);
859 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
860 }
861 applicator.applyCommand(new KisImageResizeCommand(this, newRect.size()));
862 applicator.end();
863}
friend class KisImageResizeCommand
Definition kis_image.h:1266

References bounds(), KisStrokeJobData::CONCURRENT, KisCropSavedExtraData::CROP_IMAGE, KisImageResizeCommand, kundo2_i18n(), m_d, KisProcessingApplicator::NO_UI_UPDATES, KisProcessingApplicator::RECURSIVE, KisCropSavedExtraData::RESIZE_IMAGE, and KisImage::KisImagePrivate::rootLayer.

◆ rootLayer()

KisGroupLayerSP KisImage::rootLayer ( ) const
Returns
the root node of the image node graph

Definition at line 1600 of file kis_image.cc.

1601{
1602 Q_ASSERT(m_d->rootLayer);
1603 return m_d->rootLayer;
1604}

References m_d, and KisImage::KisImagePrivate::rootLayer.

◆ rotateImage()

void KisImage::rotateImage ( double radians)

start asynchronous operation on rotating the image

The image is resized to fit the rotated rectangle

Parameters
radiansrotation angle in radians

Please note that the actual operation starts asynchronously in a background, so you cannot expect the operation being completed right after the call

Definition at line 1161 of file kis_image.cc.

1162{
1163 rotateImpl(kundo2_i18n("Rotate Image"), root(), radians, true, 0);
1164}
void rotateImpl(const KUndo2MagicString &actionName, KisNodeSP rootNode, double radians, bool resizeImage, KisSelectionSP selection)

References kundo2_i18n(), KisNodeFacade::root, and rotateImpl().

◆ rotateImpl() [1/2]

void KisImage::rotateImpl ( const KUndo2MagicString & actionName,
KisNodeList nodes,
double radians,
bool resizeImage,
KisSelectionSP selection )
private

Definition at line 1069 of file kis_image.cc.

1074{
1075 // we can either transform (and resize) the whole image or
1076 // transform a selection, we cannot do both at the same time
1077 KIS_SAFE_ASSERT_RECOVER(!(bool(selection) && resizeImage)) {
1078 selection = 0;
1079 }
1080
1081 QRect baseBounds;
1082 if (resizeImage) {
1083 baseBounds = bounds();
1084 }
1085 else if (selection) {
1086 baseBounds = selection->selectedExactRect();
1087 }
1088 else {
1089 Q_FOREACH(KisNodeSP node, nodes) {
1090 baseBounds = baseBounds.united(node->exactBounds());
1091 }
1092 }
1093
1094 QPointF offset;
1095 QSize newSize;
1096
1097 {
1098 KisTransformWorker worker(0,
1099 1.0, 1.0,
1100 0, 0,
1101 radians,
1102 0, 0, 0, 0);
1103 QTransform transform = worker.transform();
1104
1105 if (resizeImage) {
1106 QRect newRect = transform.mapRect(baseBounds);
1107 newSize = newRect.size();
1108 offset = -newRect.topLeft();
1109 }
1110 else {
1111 QPointF origin = QRectF(baseBounds).center();
1112
1113 newSize = size();
1114 offset = -(transform.map(origin) - origin);
1115 }
1116 }
1117
1118 bool sizeChanged = resizeImage &&
1119 (newSize.width() != baseBounds.width() ||
1120 newSize.height() != baseBounds.height());
1121
1122 // These signals will be emitted after processing is done
1123 KisImageSignalVector emitSignals;
1124 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1125
1126 // These flags determine whether updates are transferred to the UI during processing
1127 KisProcessingApplicator::ProcessingFlags signalFlags =
1128 sizeChanged ?
1131
1132
1133 KisProcessingApplicator applicator(this, nodes,
1135 emitSignals, actionName);
1136
1138
1140 new KisTransformProcessingVisitor(1.0, 1.0, 0.0, 0.0,
1141 radians,
1142 offset.x(), offset.y(),
1143 filter);
1144 if (selection) {
1145 visitor->setSelection(selection);
1146 }
1147
1148 if (selection) {
1149 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1150 } else {
1151 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1152 }
1153
1154 if (sizeChanged) {
1155 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1156 }
1157 applicator.end();
1158}
void resizeImage(const QRect &newRect)
start asynchronous operation on resizing the image
Definition kis_image.cc:865
const T value(const QString &id) const
virtual QRect exactBounds() const
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.

References KisProcessingApplicator::applyCommand(), KisProcessingApplicator::applyVisitor(), KisProcessingApplicator::applyVisitorAllFrames(), bounds(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), KisBaseNode::exactBounds(), KisFilterStrategyRegistry::instance(), KIS_SAFE_ASSERT_RECOVER, KisImageResizeCommand, KisProcessingApplicator::NO_UI_UPDATES, KisProcessingApplicator::NONE, KisProcessingApplicator::RECURSIVE, resizeImage(), KisSelection::selectedExactRect(), KisTransformProcessingVisitor::setSelection(), size(), KisTransformWorker::transform(), and KoGenericRegistry< T >::value().

◆ rotateImpl() [2/2]

void KisImage::rotateImpl ( const KUndo2MagicString & actionName,
KisNodeSP rootNode,
double radians,
bool resizeImage,
KisSelectionSP selection )
private

Definition at line 1061 of file kis_image.cc.

1066{
1067 rotateImpl(actionName, KisNodeList{rootNode}, radians, resizeImage, selection);
1068}

References resizeImage(), and rotateImpl().

◆ rotateNode()

void KisImage::rotateNode ( KisNodeSP node,
double radians,
KisSelectionSP selection )

start asynchronous operation on rotating a subtree of nodes starting at node

The image is not resized!

Parameters
nodethe root of the subtree to rotate
radiansrotation angle in radians
selectionthe selection we based on

Please note that the actual operation starts asynchronously in a background, so you cannot expect the operation being completed right after the call

Definition at line 1166 of file kis_image.cc.

1167{
1168 rotateNodes(KisNodeList{node}, radians, selection);
1169}
void rotateNodes(KisNodeList nodes, double radians, KisSelectionSP selection)

References rotateNodes().

◆ rotateNodes()

void KisImage::rotateNodes ( KisNodeList nodes,
double radians,
KisSelectionSP selection )

Definition at line 1170 of file kis_image.cc.

1171{
1172 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1173 rotateImpl(kundo2_i18n("Rotate Mask"), nodes, radians, false, selection);
1174 }
1175 else {
1176 rotateImpl(kundo2_i18np("Rotate Layer", "Rotate %1 Layers", nodes.size()), nodes, radians, false, selection);
1177 }
1178}
KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1)

References kundo2_i18n(), kundo2_i18np(), and rotateImpl().

◆ safeRemoveTwoNodes()

void KisImage::safeRemoveTwoNodes ( KisNodeSP node1,
KisNodeSP node2 )
private

◆ scaleImage()

void KisImage::scaleImage ( const QSize & size,
qreal xres,
qreal yres,
KisFilterStrategy * filterStrategy )

start asynchronous operation on scaling the image

Parameters
sizenew image size in pixels
xresnew image x-resolution pixels-per-pt
yresnew image y-resolution pixels-per-pt
filterStrategyfiltering strategy

Please note that the actual operation starts asynchronously in a background, so you cannot expect the image having new size right after this call.

Definition at line 961 of file kis_image.cc.

962{
963 bool resolutionChanged = !qFuzzyCompare(xRes(), xres) || !qFuzzyCompare(yRes(), yres);
964 bool sizeChanged = size != this->size();
965
966 if (!resolutionChanged && !sizeChanged) return;
967
968 KisImageSignalVector emitSignals;
969 if (resolutionChanged) emitSignals << ResolutionChangedSignal;
970 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(bounds(), size);
971
972 KUndo2MagicString actionName = sizeChanged ?
973 kundo2_i18n("Scale Image") :
974 kundo2_i18n("Change Image Resolution");
975
976 KisProcessingApplicator::ProcessingFlags signalFlags =
977 (resolutionChanged || sizeChanged) ?
980
981 KisProcessingApplicator applicator(this, m_d->rootLayer,
983 emitSignals, actionName);
984
985 qreal sx = qreal(size.width()) / this->size().width();
986 qreal sy = qreal(size.height()) / this->size().height();
987
988 QTransform shapesCorrection;
989
990 if (resolutionChanged) {
991 shapesCorrection = QTransform::fromScale(xRes() / xres, yRes() / yres);
992 }
993
994 KisProcessingVisitorSP visitor =
996 0, 0,
997 0,
998 0, 0,
999 filterStrategy,
1000 shapesCorrection);
1001
1002 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1003
1004 if (resolutionChanged) {
1007 new KisImageSetResolutionCommand(this, xres, yres, parent);
1008 applicator.applyCommand(parent);
1009 }
1010
1011 if (sizeChanged) {
1012 applicator.applyCommand(new KisImageResizeCommand(this, size));
1013 }
1014
1015 applicator.end();
1016}
@ NONE
@ ResolutionChangedSignal
static bool qFuzzyCompare(half p1, half p2)

References KisProcessingApplicator::applyCommand(), KisProcessingApplicator::applyVisitorAllFrames(), bounds(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), KisImageResizeCommand, kundo2_i18n(), m_d, KisProcessingApplicator::NO_UI_UPDATES, KisProcessingApplicator::NONE, qFuzzyCompare(), KisProcessingApplicator::RECURSIVE, ResolutionChangedSignal, KisImage::KisImagePrivate::rootLayer, size(), xRes(), and yRes().

◆ scaleNode()

void KisImage::scaleNode ( KisNodeSP node,
const QPointF & center,
qreal scaleX,
qreal scaleY,
KisFilterStrategy * filterStrategy,
KisSelectionSP selection )

start asynchronous operation on scaling a subtree of nodes starting at node

Parameters
nodenode to scale
centerthe center of the scaling
scaleXx-scale coefficient to be applied to the node
scaleYy-scale coefficient to be applied to the node
filterStrategyfiltering strategy
selectionthe selection we based on

Please note that the actual operation starts asynchronously in a background, so you cannot expect the image having new size right after this call.

Definition at line 1018 of file kis_image.cc.

1019{
1020 scaleNodes(KisNodeList{node}, center, scaleX, scaleY, filterStrategy, selection);
1021}
void scaleNodes(KisNodeList nodes, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection)

References scaleNodes().

◆ scaleNodes()

void KisImage::scaleNodes ( KisNodeList nodes,
const QPointF & center,
qreal scaleX,
qreal scaleY,
KisFilterStrategy * filterStrategy,
KisSelectionSP selection )

Definition at line 1022 of file kis_image.cc.

1023{
1024 KUndo2MagicString actionName(kundo2_i18np("Scale Layer", "Scale %1 Layers", nodes.size()));
1025 KisImageSignalVector emitSignals;
1026
1027 QPointF offset;
1028 {
1029 KisTransformWorker worker(0,
1030 scaleX, scaleY,
1031 0, 0,
1032 0.0,
1033 0, 0, 0, 0);
1034 QTransform transform = worker.transform();
1035
1036 offset = center - transform.map(center);
1037 }
1038
1039 KisProcessingApplicator applicator(this, nodes,
1041 emitSignals, actionName);
1042
1044 new KisTransformProcessingVisitor(scaleX, scaleY,
1045 0, 0,
1046 0,
1047 offset.x(), offset.y(),
1048 filterStrategy);
1049
1050 visitor->setSelection(selection);
1051
1052 if (selection) {
1053 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1054 } else {
1055 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1056 }
1057
1058 applicator.end();
1059}

References KisProcessingApplicator::applyVisitor(), KisProcessingApplicator::applyVisitorAllFrames(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), kundo2_i18np(), KisProcessingApplicator::RECURSIVE, KisTransformProcessingVisitor::setSelection(), and KisTransformWorker::transform().

◆ setAllowMasksOnRootNode()

void KisImage::setAllowMasksOnRootNode ( bool value)

Configure the image to allow masks on the root not (as reported by root()->allowAsChild()). By default it is not allowed (because it looks weird from GUI point of view)

Definition at line 2616 of file kis_image.cc.

2617{
2619}

References KisImage::KisImagePrivate::allowMasksOnRootNode, m_d, and value().

◆ setDefaultProjectionColor()

void KisImage::setDefaultProjectionColor ( const KoColor & color)

Sets the default color of the root layer projection. All the layers will be merged on top of this very color

Definition at line 1795 of file kis_image.cc.

1796{
1799}
void setDefaultProjectionColor(KoColor color)

References KIS_ASSERT_RECOVER_RETURN, m_d, KisImage::KisImagePrivate::rootLayer, and KisGroupLayer::setDefaultProjectionColor().

◆ setLodPreferences()

void KisImage::setLodPreferences ( const KisLodPreferences & value)

Set preferences for the level-of-detail functionality. Due to multithreading considerations they may be applied not immediately, but some time later.

Definition at line 2563 of file kis_image.cc.

2564{
2566}
void setLodPreferences(const KisLodPreferences &value)

References m_d, KisImage::KisImagePrivate::scheduler, KisUpdateScheduler::setLodPreferences(), and value().

◆ setMirrorAxesCenter()

void KisImage::setMirrorAxesCenter ( const QPointF & value) const

Sets the relative position of the axes center

See also
mirrorAxesCenter() for details

Definition at line 2611 of file kis_image.cc.

2612{
2613 m_d->axesCenter = value;
2614}

References KisImage::KisImagePrivate::axesCenter, m_d, and value().

◆ setModifiedWithoutUndo()

void KisImage::setModifiedWithoutUndo ( )

Tell the image it's modified without creation of an undo command. It may happen when e.g. layer visibility has changed.

This function emits both, sigImageModified() and sigImageModifiedWithoutUndo()

For normal modifications with undo information the signal emission is triggered by the undo stack

Definition at line 1673 of file kis_image.cc.

1674{
1676 Q_EMIT sigImageModified();
1677}
@ ModifiedWithoutUndoSignal
void sigImageModified()

References KisImageSignalRouter::emitNotification(), m_d, ModifiedWithoutUndoSignal, sigImageModified(), and KisImage::KisImagePrivate::signalRouter.

◆ setOverlaySelectionMask()

void KisImage::setOverlaySelectionMask ( KisSelectionMaskSP mask)

Sets the mask (it must be a part of the node hierarchy already) to be painted on the top of all layers. This method does all the locking and syncing for you. It is executed asynchronously.

Definition at line 637 of file kis_image.cc.

638{
639 if (m_d->targetOverlaySelectionMask == mask) return;
640
642
643 struct UpdateOverlaySelectionStroke : public KisSimpleStrokeStrategy {
644 UpdateOverlaySelectionStroke(KisImageSP image)
645 : KisSimpleStrokeStrategy(QLatin1String("update-overlay-selection-mask"), kundo2_noi18n("update-overlay-selection-mask")),
646 m_image(image)
647 {
648 this->enableJob(JOB_INIT, true, KisStrokeJobData::BARRIER, KisStrokeJobData::EXCLUSIVE);
649 setClearsRedoOnStart(false);
650 }
651
652 void initStrokeCallback() override {
653 KisSelectionMaskSP oldMask = m_image->m_d->overlaySelectionMask;
654 KisSelectionMaskSP newMask = m_image->m_d->targetOverlaySelectionMask;
655 if (oldMask == newMask) return;
656
657 KIS_SAFE_ASSERT_RECOVER_RETURN(!newMask || static_cast<KisImage*>(newMask->graphListener()) == m_image);
658
659 m_image->m_d->overlaySelectionMask = newMask;
660
661 if (oldMask || newMask) {
662 m_image->m_d->rootLayer->notifyChildMaskChanged();
663 }
664
665 if (oldMask) {
666 const QRect oldMaskRect = oldMask->graphListener() ? oldMask->extent() : m_image->bounds();
667 m_image->m_d->rootLayer->setDirtyDontResetAnimationCache(oldMaskRect);
668 }
669
670 if (newMask) {
671 newMask->setDirty();
672 }
673
674 m_image->undoAdapter()->emitSelectionChanged();
675 }
676
677 private:
678 KisImageSP m_image;
679 };
680
681 KisStrokeId id = startStroke(new UpdateOverlaySelectionStroke(this));
682 endStroke(id);
683}
KisNodeGraphListener * graphListener
Definition kis_node.cpp:87
QRect extent() const override
void setDirty(const QVector< QRect > &rects) override

References KisStrokeJobData::BARRIER, endStroke(), KisStrokeJobData::EXCLUSIVE, KisSelectionMask::extent(), KisNode::graphListener, KIS_SAFE_ASSERT_RECOVER_RETURN, kundo2_noi18n(), m_d, KisSelectionMask::m_d, KisSelectionMask::setDirty(), startStroke(), and KisImage::KisImagePrivate::targetOverlaySelectionMask.

◆ setProjectionColorSpace()

void KisImage::setProjectionColorSpace ( const KoColorSpace * colorSpace)
private

Definition at line 1519 of file kis_image.cc.

1520{
1522}

References KisImage::KisImagePrivate::colorSpace, colorSpace(), and m_d.

◆ setProofingConfiguration()

void KisImage::setProofingConfiguration ( KisProofingConfigurationSP proofingConfig)

setProofingConfiguration, this sets the image's proofing configuration, and signals the proofingConfiguration has changed.

Parameters
proofingConfig- the kis proofing config that will be used instead.

Definition at line 2584 of file kis_image.cc.

2585{
2586 const bool changed = bool(m_d->proofingConfig) != bool(proofingConfig) ||
2587 (m_d->proofingConfig && proofingConfig && *m_d->proofingConfig != *proofingConfig);
2588
2589 // we still assign even when unchanged since they can be different
2590 // shared pointer objects
2591 m_d->proofingConfig = proofingConfig;
2592
2593 if (changed) {
2594 Q_EMIT sigProofingConfigChanged();
2595 }
2596}
void sigProofingConfigChanged()

References m_d, KisImage::KisImagePrivate::proofingConfig, and sigProofingConfigChanged().

◆ setResolution()

void KisImage::setResolution ( double xres,
double yres )

Set the resolution in pixels per pt.

Definition at line 1544 of file kis_image.cc.

1545{
1546 if (xres > 0) {
1547 m_d->xres = xres;
1548 } else {
1549 qWarning() << "WARNING: Ignoring attempt to set image x resolution <= 0 (" << xres << ")!";
1550 }
1551
1552 if (yres > 0) {
1553 m_d->yres = yres;
1554 } else {
1555 qWarning() << "WARNING: Ignoring attempt to set image y resolution <= 0 (" << yres << ")!";
1556 }
1557}

References m_d, KisImage::KisImagePrivate::xres, and KisImage::KisImagePrivate::yres.

◆ setRootLayer()

void KisImage::setRootLayer ( KisGroupLayerSP rootLayer)

Definition at line 1810 of file kis_image.cc.

1811{
1813
1815
1816 if (m_d->rootLayer) {
1818 m_d->rootLayer->setImage(0);
1819 m_d->rootLayer->disconnect();
1820
1821 KisPaintDeviceSP original = m_d->rootLayer->original();
1823 }
1824
1826 m_d->rootLayer->disconnect();
1828 m_d->rootLayer->setImage(this);
1829
1831 this->setDefaultProjectionColor(defaultProjectionColor);
1832}
void setDefaultProjectionColor(const KoColor &color)
KoColor defaultProjectionColor() const
KoColor defaultPixel() const
void setImage(KisImageWSP image) override
KisPaintDeviceSP original() const override

References KisImage::KisImagePrivate::colorSpace, KoColor::createTransparent(), KisSharedPtr< T >::data(), KisPaintDevice::defaultPixel(), defaultProjectionColor(), m_d, KisGroupLayer::original(), KisImage::KisImagePrivate::rootLayer, rootLayer(), setDefaultProjectionColor(), KisNode::setGraphListener(), KisGroupLayer::setImage(), KisNodeFacade::setRoot(), and sigInternalStopIsolatedModeRequested().

◆ setSize()

void KisImage::setSize ( const QSize & size)
private

Definition at line 828 of file kis_image.cc.

829{
830 m_d->width = size.width();
831 m_d->height = size.height();
832}

References KisImage::KisImagePrivate::height, m_d, size(), and KisImage::KisImagePrivate::width.

◆ setUndoStore()

void KisImage::setUndoStore ( KisUndoStore * undoStore)

Replace current undo store with the new one. The old store will be deleted. This method is used by KisDocument for dropping all the commands during file loading.

Definition at line 1773 of file kis_image.cc.

1774{
1775 disconnect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1776
1779 m_d->undoStore.reset(undoStore);
1780
1781 connect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1782
1783}
void setUndoStore(KisUndoStore *undoStore)
void setUndoStore(KisUndoStore *undoStore)

References connect(), KisImage::KisImagePrivate::legacyUndoAdapter, m_d, KisImage::KisImagePrivate::postExecutionUndoAdapter, KisPostExecutionUndoAdapter::setUndoStore(), KisUndoAdapter::setUndoStore(), KisImage::KisImagePrivate::signalRouter, KisImage::KisImagePrivate::undoStore, and undoStore().

◆ setWorkingThreadsLimit()

void KisImage::setWorkingThreadsLimit ( int value)

Set the number of threads used by the image's working threads

Definition at line 2327 of file kis_image.cc.

2328{
2330}
void setThreadsLimit(int value)

References m_d, KisImage::KisImagePrivate::scheduler, KisUpdateScheduler::setThreadsLimit(), and value().

◆ setWrapAroundModeAxis()

void KisImage::setWrapAroundModeAxis ( WrapAroundAxis value)

Set which axis to use for wraparound mode

Definition at line 2527 of file kis_image.cc.

2528{
2530}

References m_d, value(), and KisImage::KisImagePrivate::wrapAroundModeAxis.

◆ setWrapAroundModePermitted()

void KisImage::setWrapAroundModePermitted ( bool value)

Permit or deny the wrap-around mode for all the paint devices of the image. Note that permitting the wraparound mode will not necessarily activate it right now. To be activated the wrap around mode should be 1) permitted; 2) supported by the currently running stroke.

Definition at line 2503 of file kis_image.cc.

2504{
2507 }
2508
2510
2513
2514 KisProcessingApplicator applicator(this, root(),
2517 kundo2_i18n("Crop Selections"));
2518
2519 KisProcessingVisitorSP visitor =
2521
2522 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
2523 applicator.end();
2524 }
2525}
QVector< KisImageSignalType > KisImageSignalVector
bool checkMasksNeedConversion(KisNodeSP root, const QRect &bounds)

References KisProcessingApplicator::applyVisitor(), bounds(), checkMasksNeedConversion(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), kundo2_i18n(), m_d, KisProcessingApplicator::RECURSIVE, requestStrokeEnd(), KisNodeFacade::root, value(), and KisImage::KisImagePrivate::wrapAroundModePermitted.

◆ shear()

void KisImage::shear ( double angleX,
double angleY )

start asynchronous operation on shearing the image

The image is resized to fit the sheared polygon

angleX, angleY are given in degrees.

Please note that the actual operation starts asynchronously in a background, so you cannot expect the operation being completed right after the call

Definition at line 1286 of file kis_image.cc.

1287{
1288 shearImpl(kundo2_i18n("Shear Image"), m_d->rootLayer, true,
1289 angleX, angleY, 0);
1290}
void shearImpl(const KUndo2MagicString &actionName, KisNodeSP rootNode, bool resizeImage, double angleX, double angleY, KisSelectionSP selection)

References kundo2_i18n(), m_d, KisImage::KisImagePrivate::rootLayer, and shearImpl().

◆ shearImpl() [1/2]

void KisImage::shearImpl ( const KUndo2MagicString & actionName,
KisNodeList nodes,
bool resizeImage,
double angleX,
double angleY,
KisSelectionSP selection )
private

Definition at line 1188 of file kis_image.cc.

1193{
1194 QRect baseBounds;
1195 if (resizeImage) {
1196 baseBounds = bounds();
1197 }
1198 else if (selection) {
1199 baseBounds = selection->selectedExactRect();
1200 }
1201 else {
1202 Q_FOREACH(KisNodeSP node, nodes) {
1203 baseBounds = baseBounds.united(node->exactBounds());
1204 }
1205 }
1206 const QPointF origin = QRectF(baseBounds).center();
1207
1208 //angleX, angleY are in degrees
1209 const qreal pi = 3.1415926535897932385;
1210 const qreal deg2rad = pi / 180.0;
1211
1212 qreal tanX = tan(angleX * deg2rad);
1213 qreal tanY = tan(angleY * deg2rad);
1214
1215 QPointF offset;
1216 QSize newSize;
1217
1218 {
1219 KisTransformWorker worker(0,
1220 1.0, 1.0,
1221 tanX, tanY,
1222 0,
1223 0, 0, 0, 0);
1224
1225 QRect newRect = worker.transform().mapRect(baseBounds);
1226 newSize = newRect.size();
1227 if (resizeImage) offset = -newRect.topLeft();
1228 else offset = origin - worker.transform().map(origin);
1229 }
1230
1231 if (newSize == baseBounds.size()) return;
1232
1233 KisImageSignalVector emitSignals;
1234 if (resizeImage) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1235
1236 KisProcessingApplicator::ProcessingFlags signalFlags =
1239
1240 KisProcessingApplicator applicator(this, nodes,
1241 signalFlags,
1242 emitSignals, actionName);
1243
1245
1247 new KisTransformProcessingVisitor(1.0, 1.0,
1248 tanX, tanY,
1249 0,
1250 offset.x(), offset.y(),
1251 filter);
1252
1253 if (selection) {
1254 visitor->setSelection(selection);
1255 }
1256
1257 if (selection) {
1258 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1259 } else {
1260 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1261 }
1262
1263 if (resizeImage) {
1264 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1265 }
1266
1267 applicator.end();
1268}

References KisProcessingApplicator::applyCommand(), KisProcessingApplicator::applyVisitor(), KisProcessingApplicator::applyVisitorAllFrames(), bounds(), KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), KisBaseNode::exactBounds(), KisFilterStrategyRegistry::instance(), KisImageResizeCommand, KisProcessingApplicator::NO_UI_UPDATES, KisProcessingApplicator::RECURSIVE, resizeImage(), KisSelection::selectedExactRect(), KisTransformProcessingVisitor::setSelection(), KisTransformWorker::transform(), and KoGenericRegistry< T >::value().

◆ shearImpl() [2/2]

void KisImage::shearImpl ( const KUndo2MagicString & actionName,
KisNodeSP rootNode,
bool resizeImage,
double angleX,
double angleY,
KisSelectionSP selection )
private

Definition at line 1180 of file kis_image.cc.

1185{
1186 shearImpl(actionName, KisNodeList{rootNode}, resizeImage, angleX, angleY, selection);
1187}

References resizeImage(), and shearImpl().

◆ shearNode()

void KisImage::shearNode ( KisNodeSP node,
double angleX,
double angleY,
KisSelectionSP selection )

start asynchronous operation on shearing a subtree of nodes starting at node

The image is not resized!

Parameters
nodethe root of the subtree to rotate
angleXx-shear given in degrees.
angleYy-shear given in degrees.
selectionthe selection we based on

Please note that the actual operation starts asynchronously in a background, so you cannot expect the operation being completed right after the call

Definition at line 1270 of file kis_image.cc.

1271{
1272 shearNodes(KisNodeList{node}, angleX, angleY, selection);
1273}
void shearNodes(KisNodeList nodes, double angleX, double angleY, KisSelectionSP selection)

References shearNodes().

◆ shearNodes()

void KisImage::shearNodes ( KisNodeList nodes,
double angleX,
double angleY,
KisSelectionSP selection )

Definition at line 1274 of file kis_image.cc.

1275{
1276 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1277 shearImpl(kundo2_i18n("Shear Mask"), nodes, false,
1278 angleX, angleY, selection);
1279 }
1280 else {
1281 shearImpl(kundo2_i18np("Shear Layer", "Shear %1 Layers", nodes.size()), nodes, false,
1282 angleX, angleY, selection);
1283 }
1284}

References kundo2_i18n(), kundo2_i18np(), and shearImpl().

◆ sigAboutToBeDeleted

void KisImage::sigAboutToBeDeleted ( )
signal

Inform that the image is going to be deleted

◆ sigColorSpaceChanged

void KisImage::sigColorSpaceChanged ( const KoColorSpace * cs)
signal

◆ sigImageModified

void KisImage::sigImageModified ( )
signal

Emitted whenever the image has been modified, so that it doesn't match with the version saved on disk.

◆ sigImageModifiedWithoutUndo

void KisImage::sigImageModifiedWithoutUndo ( )
signal

Emitted whenever the image has been modified without creation of an undo command

◆ sigImageUpdated

void KisImage::sigImageUpdated ( const QRect & )
signal

Emitted whenever an action has caused the image to be recomposited. Parameter is the rect that has been recomposited.

◆ sigInternalStopIsolatedModeRequested

void KisImage::sigInternalStopIsolatedModeRequested ( )
signal

Internal signal for asynchronously requesting isolated mode to stop. Don't use it outside KisImage, use sigIsolatedModeChanged() instead.

◆ sigIsolatedModeChanged

void KisImage::sigIsolatedModeChanged ( )
signal

Emitted when the isolated mode status has changed.

Can be used by the receivers to catch a fact of forcefully stopping the isolated mode by the image when some complex action was requested

◆ sigLayersChangedAsync

void KisImage::sigLayersChangedAsync ( )
signal

Emitted when the root node of the image has changed. It happens, e.g. when we flatten the image. When this happens the receiver should reload information about the image

◆ signalRouter()

KisImageSignalRouter * KisImage::signalRouter ( )

Definition at line 1893 of file kis_image.cc.

1894{
1895 return &m_d->signalRouter;
1896}

References m_d, and KisImage::KisImagePrivate::signalRouter.

◆ sigNodeAddedAsync

void KisImage::sigNodeAddedAsync ( KisNodeSP node,
KisNodeAdditionFlags flags )
signal

The signal is emitted right after a node has been connected to the graph of the nodes.

WARNING: you must not request any graph-related information about the node being run in a not-scheduler thread. If you need information about the parent/siblings of the node connect with Qt::DirectConnection, get needed information and then Q_EMIT another Qt::AutoConnection signal to pass this information to your thread. See details of the implementation in KisDummiesfacadeBase.

◆ sigNodeChanged

void KisImage::sigNodeChanged ( KisNodeSP node)
signal

Inform the model that a node was changed

◆ sigNodeCollapsedChanged

void KisImage::sigNodeCollapsedChanged ( )
signal

Emitted when one or more nodes changed the collapsed state

◆ sigProfileChanged

void KisImage::sigProfileChanged ( const KoColorProfile * profile)
signal

◆ sigProofingConfigChanged

void KisImage::sigProofingConfigChanged ( )
signal

Emitted when the proofing configuration of the image is being changed.

◆ sigRedoDuringStrokeRequested

void KisImage::sigRedoDuringStrokeRequested ( )
signal

Emitted when the UI has requested the redo of the last undo operation.

If your tool supports undoing/redoing part of its work, just listen to this signal and undo when it comes

◆ sigRemoveNodeAsync

void KisImage::sigRemoveNodeAsync ( KisNodeSP node)
signal

This signal is emitted right before a node is going to removed from the graph of the nodes.

WARNING: you must not request any graph-related information about the node being run in a not-scheduler thread.

See also
comment in sigNodeAddedAsync()

◆ sigRequestNodeReselection

void KisImage::sigRequestNodeReselection ( KisNodeSP activeNode,
const KisNodeList & selectedNodes )
signal

◆ sigResolutionChanged

void KisImage::sigResolutionChanged ( double xRes,
double yRes )
signal

◆ sigSizeChanged

void KisImage::sigSizeChanged ( const QPointF & oldStillPoint,
const QPointF & newStillPoint )
signal

The signal is emitted when the size of the image is changed. oldStillPoint and newStillPoint give the receiver the hint about how the new and old rect of the image correspond to each other. They specify the point of the image around which the conversion was done. This point will stay still on the user's screen. That is the newStillPoint of the new image will be painted at the same screen position, where oldStillPoint of the old image was painted.

Parameters
oldStillPointis a still point represented in old image coordinates
newStillPointis a still point represented in new image coordinates

◆ sigStrokeCancellationRequested

void KisImage::sigStrokeCancellationRequested ( )
signal

Emitted when the UI has requested the cancellation of the stroke. The point is, we cannot cancel the stroke without its creator knowing about it (which most probably cause a crash), so we just forward this request from the UI to the creator of the stroke.

If your tool supports cancelling of its work in the middle of operation, just listen to this signal and cancel the stroke when it comes

◆ sigStrokeEndRequested

void KisImage::sigStrokeEndRequested ( )
signal

Emitted when the image decides that the stroke should better be ended. The point is, we cannot just end the stroke without its creator knowing about it (which most probably cause a crash), so we just forward this request from the UI to the creator of the stroke.

If your tool supports long strokes that may involve multiple mouse actions in one stroke, just listen to this signal and end the stroke when it comes.

◆ sigStrokeEndRequestedActiveNodeFiltered

void KisImage::sigStrokeEndRequestedActiveNodeFiltered ( )
signal

Same as sigStrokeEndRequested() but is not emitted when the active node is changed.

◆ sigUndoDuringStrokeRequested

void KisImage::sigUndoDuringStrokeRequested ( )
signal

Emitted when the UI has requested the undo of the last stroke's operation. The point is, we cannot deal with the internals of the stroke without its creator knowing about it (which most probably cause a crash), so we just forward this request from the UI to the creator of the stroke.

If your tool supports undoing part of its work, just listen to this signal and undo when it comes

◆ size()

QSize KisImage::size ( ) const
inline

Return the size of the image

Definition at line 547 of file kis_image.h.

547 {
548 return QSize(width(), height());
549 }

◆ startIsolatedMode()

bool KisImage::startIsolatedMode ( KisNodeSP node,
bool isolateLayer,
bool isolateGroup )

Isolation of transform masks is not possible, so we should not allow that

Definition at line 1938 of file kis_image.cc.

1939{
1940 m_d->isolateLayer = isolateLayer;
1941 m_d->isolateGroup = isolateGroup;
1942 if ((isolateLayer || isolateGroup) == false) return false;
1943
1948 if (!node->projection()) return false;
1949
1950 struct StartIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
1951 StartIsolatedModeStroke(KisNodeSP node, KisImageSP image, bool isolateLayer, bool isolateGroup)
1952 : KisRunnableBasedStrokeStrategy(QLatin1String("start-isolated-mode"),
1953 kundo2_noi18n("start-isolated-mode")),
1954 m_newRoot(node),
1955 m_image(image),
1956 m_isolateLayer(isolateLayer),
1957 m_isolateGroup(isolateGroup)
1958 {
1959 this->enableJob(JOB_INIT, true, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::EXCLUSIVE);
1960 this->enableJob(JOB_DOSTROKE, true);
1961 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
1962 setClearsRedoOnStart(false);
1963 }
1964
1965 void initStrokeCallback() override {
1966 if (m_isolateLayer == false && m_isolateGroup == true) {
1967 // Isolate parent node unless node is the root note.
1968 m_newRoot = m_newRoot->parent() ? m_newRoot->parent() : m_newRoot;
1969 }
1970 // pass-though node don't have any projection prepared, so we should
1971 // explicitly regenerate it before activating isolated mode.
1972 m_newRoot->projectionLeaf()->explicitlyRegeneratePassThroughProjection();
1973 m_prevRoot = m_image->m_d->isolationRootNode;
1974
1975 const bool beforeVisibility = m_newRoot->projectionLeaf()->visible();
1976 const bool prevRootBeforeVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
1977
1978 m_image->m_d->isolationRootNode = m_newRoot;
1979 Q_EMIT m_image->sigIsolatedModeChanged();
1980
1981 const bool afterVisibility = m_newRoot->projectionLeaf()->visible();
1982 const bool prevRootAfterVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
1983
1984 m_newRootNeedsFullRefresh = beforeVisibility != afterVisibility;
1985 m_prevRootNeedsFullRefresh = prevRootBeforeVisibility != prevRootAfterVisibility;
1986 }
1987
1988 void finishStrokeCallback() override {
1989 // the GUI uses our thread to do the color space conversion so we
1990 // need to Q_EMIT this signal in multiple threads
1991
1992 if (m_prevRoot && m_prevRootNeedsFullRefresh) {
1993 m_image->refreshGraphAsync(m_prevRoot);
1994 }
1995
1996 if (m_newRootNeedsFullRefresh) {
1997 m_image->refreshGraphAsync(m_newRoot);
1998 }
1999
2000 if (!m_prevRootNeedsFullRefresh && !m_newRootNeedsFullRefresh) {
2002 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2003 this->runnableJobsInterface()->addRunnableJobs(jobs);
2004 }
2005
2006 m_image->invalidateAllFrames();
2007 }
2008
2009 private:
2010 KisNodeSP m_newRoot;
2011 KisNodeSP m_prevRoot;
2012 KisImageSP m_image;
2013 bool m_newRootNeedsFullRefresh = false;
2014 bool m_prevRootNeedsFullRefresh = false;
2015
2016 bool m_isolateLayer;
2017 bool m_isolateGroup;
2018 };
2019
2020 KisStrokeId id = startStroke(new StartIsolatedModeStroke(node, this, isolateLayer, isolateGroup));
2021 endStroke(id);
2022
2023 return true;
2024}

References KisStrokeJobData::BARRIER, endStroke(), KisStrokeJobData::EXCLUSIVE, KisImage::KisImagePrivate::isolateGroup, KisImage::KisImagePrivate::isolateLayer, kundo2_noi18n(), m_d, KisBaseNode::projection(), KisStrokeJobData::SEQUENTIAL, and startStroke().

◆ startStroke()

KisStrokeId KisImage::startStroke ( KisStrokeStrategy * strokeStrategy)
overridevirtual

Ask open strokes to end gracefully. All the strokes clients (including the one calling this method right now) will get a notification that they should probably end their strokes. However this is purely their choice whether to end a stroke or not.

Implements KisStrokesFacade.

Definition at line 1906 of file kis_image.cc.

1907{
1915 if (strokeStrategy->requestsOtherStrokesToEnd()) {
1917 }
1918
1919 return m_d->scheduler.startStroke(strokeStrategy);
1920}
bool requestsOtherStrokesToEnd() const
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override

References m_d, KisStrokeStrategy::requestsOtherStrokesToEnd(), requestStrokeEnd(), KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::startStroke().

◆ stopIsolatedMode

void KisImage::stopIsolatedMode ( )
slot

Definition at line 2026 of file kis_image.cc.

2027{
2028 if (!m_d->isolationRootNode) return;
2029
2030 struct StopIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
2031 StopIsolatedModeStroke(KisImageSP image)
2032 : KisRunnableBasedStrokeStrategy(QLatin1String("stop-isolated-mode"), kundo2_noi18n("stop-isolated-mode")),
2033 m_image(image),
2034 m_oldRootNode(nullptr),
2035 m_oldNodeNeedsRefresh(false)
2036 {
2037 this->enableJob(JOB_INIT);
2038 this->enableJob(JOB_DOSTROKE, true);
2039 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
2040 setClearsRedoOnStart(false);
2041 }
2042
2043 void initStrokeCallback() override {
2044 if (!m_image->m_d->isolationRootNode) return;
2045
2046 m_oldRootNode = m_image->m_d->isolationRootNode;
2047
2048 const bool beforeVisibility = m_oldRootNode->projectionLeaf()->visible();
2049 m_image->m_d->isolationRootNode = 0;
2050 m_image->m_d->isolateLayer = false;
2051 m_image->m_d->isolateGroup = false;
2052 Q_EMIT m_image->sigIsolatedModeChanged();
2053 const bool afterVisibility = m_oldRootNode->projectionLeaf()->visible();
2054
2055 m_oldNodeNeedsRefresh = (beforeVisibility != afterVisibility);
2056 }
2057
2058 void finishStrokeCallback() override {
2059
2060 m_image->invalidateAllFrames();
2061
2062 if (m_oldNodeNeedsRefresh){
2063 m_oldRootNode->setDirty(m_image->bounds());
2064 } else {
2065 // TODO: Substitute notifyProjectionUpdated() with this code
2066 // when update optimization is implemented
2067 //
2068 // QRect updateRect = bounds() | oldRootNode->extent();
2069 //oldRootNode->setDirty(updateRect);
2070
2072 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2073 this->runnableJobsInterface()->addRunnableJobs(jobs);
2074 }
2075 }
2076
2077 private:
2078 KisImageSP m_image;
2079 KisNodeSP m_oldRootNode;
2080 bool m_oldNodeNeedsRefresh;
2081 };
2082
2083 KisStrokeId id = startStroke(new StopIsolatedModeStroke(this));
2084 endStroke(id);
2085}

References KisStrokeJobData::BARRIER, endStroke(), KisImage::KisImagePrivate::isolationRootNode, kundo2_noi18n(), m_d, and startStroke().

◆ tryBarrierLock()

bool KisImage::tryBarrierLock ( bool readOnly = false)

Tries to lock the image without waiting for the jobs to finish.

Same as barrierLock(), but doesn't block execution of the calling thread until all the background jobs are finished. Instead, in case of presence of unfinished jobs in the queue, it just returns false

Returns
whether the lock has been acquired
See also
barrierLock

Definition at line 771 of file kis_image.cc.

772{
773 bool result = true;
774
775 if (!locked()) {
776 result = m_d->scheduler.tryBarrierLock();
777 m_d->lockedForReadOnly = readOnly;
778 }
779
780 if (result) {
781 m_d->lockCount++;
782 m_d->lockedForReadOnly &= readOnly;
783 }
784
785 return result;
786}

References KisImage::KisImagePrivate::lockCount, locked(), KisImage::KisImagePrivate::lockedForReadOnly, m_d, KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::tryBarrierLock().

◆ tryUndoUnfinishedLod0Stroke

UndoResult KisImage::tryUndoUnfinishedLod0Stroke ( )
slot

This method requests the last stroke executed on the image to become undone. If the stroke is not ended, or if all the Lod0 strokes are completed, the method returns UNDO_FAIL. If the last Lod0 is going to be finished soon, then UNDO_WAIT is returned and the caller should just wait for its completion and call global undo instead. UNDO_OK means one unfinished stroke has been undone.

Definition at line 2139 of file kis_image.cc.

2140{
2142}

References m_d, KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::tryUndoLastStrokeAsync().

◆ unblockUpdates()

void KisImage::unblockUpdates ( )
overridevirtual

unblockUpdates unblock updating the image project. This only restarts the scheduler and does not schedule a full refresh.

Implements KisUpdatesFacade.

Definition at line 823 of file kis_image.cc.

References m_d, KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::unblockUpdates().

◆ undoAdapter()

KisUndoAdapter * KisImage::undoAdapter ( ) const

Returns the current undo adapter. You can add new commands to the undo stack using the adapter. This adapter is used for a backward compatibility for old commands created before strokes. It blocks all the processing at the scheduler, waits until it's finished and executes commands exclusively.

Definition at line 1790 of file kis_image.cc.

1791{
1792 return &m_d->legacyUndoAdapter;
1793}

References KisImage::KisImagePrivate::legacyUndoAdapter, and m_d.

◆ undoStore()

KisUndoStore * KisImage::undoStore ( )

Return current undo store of the image

Definition at line 1785 of file kis_image.cc.

1786{
1787 return m_d->undoStore.data();
1788}

References m_d, and KisImage::KisImagePrivate::undoStore.

◆ unifyLayersColorSpace()

void KisImage::unifyLayersColorSpace ( )

Unify layers color space

If any of the layers have color space different from the image color space, convert them into the image color space.

Definition at line 1408 of file kis_image.cc.

1409{
1410 const KUndo2MagicString actionName = kundo2_i18n("Unify Layers Color Space");
1411
1412 KisImageSignalVector emitSignals;
1413
1414 KisProcessingApplicator::ProcessingFlags flags =
1416
1417 KisProcessingApplicator applicator(this, m_d->rootLayer,
1418 flags,
1419 emitSignals, actionName);
1420
1421 // src and dst color spaces coincide, since we should just unify
1422 // all our layers
1423 applicator.applyVisitor(
1429
1430 applicator.end();
1431}

References KisProcessingApplicator::applyVisitor(), KisImage::KisImagePrivate::colorSpace, KisStrokeJobData::CONCURRENT, KisProcessingApplicator::end(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), kundo2_i18n(), m_d, KisProcessingApplicator::NO_UI_UPDATES, KisProcessingApplicator::RECURSIVE, and KisImage::KisImagePrivate::rootLayer.

◆ unlock()

void KisImage::unlock ( )

Unlocks the image and starts/resumes all the pending internal jobs. If the image has been locked for a non-readOnly access, then all the internal caches of the image (e.g. lod-planes) are reset and regeneration jobs are scheduled.

Definition at line 805 of file kis_image.cc.

806{
807 Q_ASSERT(locked());
808
809 if (locked()) {
810 m_d->lockCount--;
811
812 if (m_d->lockCount == 0) {
814 }
815 }
816}
void unlock(bool resetLodLevels=true)

References KisImage::KisImagePrivate::lockCount, locked(), KisImage::KisImagePrivate::lockedForReadOnly, m_d, KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::unlock().

◆ waitForDone()

void KisImage::waitForDone ( )

Wait for all the internal image jobs to complete and return without locking the image. This function is handy for tests or other synchronous actions, when one needs to wait for the result of his actions.

Definition at line 1898 of file kis_image.cc.

References KisBusyWaitBroker::instance(), m_d, KisBusyWaitBroker::notifyWaitOnImageEnded(), KisBusyWaitBroker::notifyWaitOnImageStarted(), requestStrokeEnd(), KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::waitForDone().

◆ width()

qint32 KisImage::width ( ) const

Return the width of the image

Definition at line 1590 of file kis_image.cc.

1591{
1592 return m_d->width;
1593}

References m_d, and KisImage::KisImagePrivate::width.

◆ workingThreadsLimit()

int KisImage::workingThreadsLimit ( ) const

Return the number of threads available to the image's working threads

Definition at line 2332 of file kis_image.cc.

2333{
2334 return m_d->scheduler.threadsLimit();
2335}

References m_d, KisImage::KisImagePrivate::scheduler, and KisUpdateScheduler::threadsLimit().

◆ wrapAroundModeActive()

bool KisImage::wrapAroundModeActive ( ) const
Returns
whether the wraparound mode is activated for all the devices of the image. The mode is activated when both factors are true: the user permitted it and the stroke supports it

Definition at line 2543 of file kis_image.cc.

2544{
2545 return m_d->wrapAroundModePermitted &&
2547}

References m_d, KisImage::KisImagePrivate::scheduler, KisImage::KisImagePrivate::wrapAroundModePermitted, and KisUpdateScheduler::wrapAroundModeSupported().

◆ wrapAroundModeAxis()

WrapAroundAxis KisImage::wrapAroundModeAxis ( ) const
Returns
the axis being used for wraparound mode
See also
setWrapAroundModeAxis

Definition at line 2532 of file kis_image.cc.

2533{
2534 return m_d->wrapAroundModeAxis;
2535}

References m_d, and KisImage::KisImagePrivate::wrapAroundModeAxis.

◆ wrapAroundModePermitted()

bool KisImage::wrapAroundModePermitted ( ) const
Returns
whether the wrap-around mode is permitted for this image. If the wrap around mode is permitted and the currently running stroke supports it, the mode will be activated for all paint devices of the image.
See also
setWrapAroundMode

Definition at line 2538 of file kis_image.cc.

2539{
2541}

References m_d, and KisImage::KisImagePrivate::wrapAroundModePermitted.

◆ xRes()

double KisImage::xRes ( ) const

X resolution in pixels per pt

Definition at line 1534 of file kis_image.cc.

1535{
1536 return m_d->xres;
1537}

References m_d, and KisImage::KisImagePrivate::xres.

◆ yRes()

double KisImage::yRes ( ) const

Y resolution in pixels per pt

Definition at line 1539 of file kis_image.cc.

1540{
1541 return m_d->yres;
1542}

References m_d, and KisImage::KisImagePrivate::yres.

Friends And Related Symbol Documentation

◆ KisImageGlobalSelectionManagementInterface

Definition at line 1271 of file kis_image.h.

◆ KisImageResizeCommand

friend class KisImageResizeCommand
friend

Definition at line 1266 of file kis_image.h.

Member Data Documentation

◆ m_d

KisImagePrivate* KisImage::m_d
private

Definition at line 1275 of file kis_image.h.


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