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());
324 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
325
326 setObjectName(name);
327 setRootLayer(new KisGroupLayer(this, "root", OPACITY_OPAQUE_U8));
328}
const quint8 OPACITY_OPAQUE_U8
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 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());
577 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
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 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 1889 of file kis_image.cc.

1890{
1891 // Find the icc annotation, if there is one
1892 vKisAnnotationSP_it it = m_d->annotations.begin();
1893 while (it != m_d->annotations.end()) {
1894 if ((*it)->type() == annotation->type()) {
1895 *it = annotation;
1897 return;
1898 }
1899 ++it;
1900 }
1901 m_d->annotations.push_back(annotation);
1903}
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 2507 of file kis_image.cc.

2508{
2509 m_d->compositions.append(composition);
2510}
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 2156 of file kis_image.cc.

2157{
2159 m_d->scheduler.addJob(id, data);
2160}
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 2289 of file kis_image.cc.

2290{
2292
2293 m_d->projectionUpdatesFilters.append(filter);
2294
2295 return KisProjectionUpdatesFilterCookie(filter.data());
2296}
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 2279 of file kis_image.cc.

2280{
2281 m_d->scheduler.addSpontaneousJob(spontaneousJob);
2282}
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)

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

◆ allowMasksOnRootNode()

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

Definition at line 2676 of file kis_image.cc.

2677{
2678 return m_d->allowMasksOnRootNode;
2679}

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

◆ animationInterface()

KisImageAnimationInterface * KisImage::animationInterface ( ) const

Definition at line 2634 of file kis_image.cc.

2635{
2636 return m_d->animationInterface;
2637}
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 1905 of file kis_image.cc.

1906{
1907 vKisAnnotationSP_it it = m_d->annotations.begin();
1908 while (it != m_d->annotations.end()) {
1909 if ((*it) && (*it)->type() == type) {
1910 return *it;
1911 }
1912 else if (!*it) {
1913 qWarning() << "Skipping deleted annotation";
1914 }
1915 ++it;
1916 }
1917 return KisAnnotationSP(0);
1918}
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 1518 of file kis_image.cc.

1519{
1520 if (!profile) return false;
1521
1522 const KoColorSpace *srcColorSpace = m_d->colorSpace;
1523 bool imageProfileIsSame = *srcColorSpace->profile() == *profile;
1524
1525 imageProfileIsSame &=
1527 [profile] (KisNodeSP node) {
1528 return *node->colorSpace()->profile() != *profile;
1529 });
1530
1531 if (imageProfileIsSame) {
1532 dbgImage << "Trying to set the same image profile again" << ppVar(srcColorSpace->profile()->name()) << ppVar(profile->name());
1533 return true;
1534 }
1535
1536 KUndo2MagicString actionName = kundo2_i18n("Assign Profile");
1537
1538 KisImageSignalVector emitSignals;
1539 emitSignals << ProfileChangedSignal;
1540
1541 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1542 if (!dstColorSpace) return false;
1543
1544 KisProcessingApplicator applicator(this, m_d->rootLayer,
1546 (!blockAllUpdates ?
1548 KisProcessingApplicator::NO_IMAGE_UPDATES),
1549 emitSignals, actionName);
1550
1551 applicator.applyCommand(
1552 new KisImagePrivate::SetImageProjectionColorSpace(dstColorSpace,
1553 KisImageWSP(this),
1556
1557 applicator.applyVisitor(
1559 srcColorSpace, dstColorSpace),
1561
1562 applicator.applyCommand(
1563 new KisImagePrivate::SetImageProjectionColorSpace(srcColorSpace,
1564 KisImageWSP(this),
1567
1568
1569 applicator.end();
1570
1571 return true;
1572}
@ 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 1488 of file kis_image.cc.

1489{
1490 const KoColorSpace *srcColorSpace = node->colorSpace();
1491
1492 if (!node->projectionLeaf()->isLayer()) return false;
1493 if (!profile || *srcColorSpace->profile() == *profile) return false;
1494
1495 KUndo2MagicString actionName = kundo2_i18n("Assign Profile to Layer");
1496
1497 KisImageSignalVector emitSignals;
1498
1499 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1500 if (!dstColorSpace) return false;
1501
1502 KisProcessingApplicator applicator(this, node,
1505 emitSignals, actionName);
1506
1507 applicator.applyVisitor(
1509 srcColorSpace, dstColorSpace),
1511
1512 applicator.end();
1513
1514 return true;
1515}
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 1933 of file kis_image.cc.

1934{
1935 return m_d->annotations.begin();
1936}

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 1797 of file kis_image.cc.

1798{
1799 return QRect(0, 0, width(), height());
1800}

References height(), and width().

◆ cancelStroke()

bool KisImage::cancelStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2167 of file kis_image.cc.

2168{
2169 return m_d->scheduler.cancelStroke(id);
2170}
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 1579 of file kis_image.cc.

1580{
1581 return m_d->colorSpace;
1582}

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 2502 of file kis_image.cc.

2503{
2504 return m_d->compositions;
2505}

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 1449 of file kis_image.cc.

1452{
1453 m_d->convertImageColorSpaceImpl(dstColorSpace, true, renderingIntent, conversionFlags);
1454}
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 1347 of file kis_image.cc.

1351{
1352 if (!node->projectionLeaf()->isLayer()) return;
1353 // must not be an image root, use convertImageColorSpace() for that:
1354 KIS_SAFE_ASSERT_RECOVER_RETURN(!node->image() || (node.data() != node->image()->rootLayer().data()));
1355
1356 const KoColorSpace *srcColorSpace = node->colorSpace();
1357
1358 if (!dstColorSpace || *srcColorSpace == *dstColorSpace) return;
1359
1360 KUndo2MagicString actionName =
1361 kundo2_i18n("Convert Layer Color Space");
1362
1363 KisImageSignalVector emitSignals;
1364
1365 KisProcessingApplicator applicator(this, node,
1367 emitSignals, actionName);
1368
1369 applicator.applyVisitor(
1371 srcColorSpace, dstColorSpace,
1372 renderingIntent, conversionFlags),
1374
1375 applicator.end();
1376}
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 1762 of file kis_image.cc.

1763{
1764 if (scaledImageSize.isEmpty()) {
1765 return QImage();
1766 }
1767
1769 KisPainter gc;
1770 gc.copyAreaOptimized(QPoint(0, 0), projection(), dev, bounds());
1771 gc.end();
1772 double scaleX = qreal(scaledImageSize.width()) / width();
1773 double scaleY = qreal(scaledImageSize.height()) / height();
1774
1775
1776 if (scaleX < 1.0/256 || scaleY < 1.0/256) {
1777 // quick checking if we're not trying to scale too much
1778 // convertToQImage uses KisFixedPoint values, which means that the scale cannot be smaller than 1/2^8
1779 // BUG:432182
1780 // FIXME: would be best to extend KisFixedPoint instead
1781 return convertToQImage(size(), profile).scaled(scaledImageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
1782 }
1783
1784 KoDummyUpdaterHolder updaterHolder;
1785 QPointer<KoUpdater> updater = updaterHolder.updater();
1786
1787 KisTransformWorker worker(dev, scaleX, scaleY, 0.0, 0.0, 0.0, 0.0, 0.0, updater, KisFilterStrategyRegistry::instance()->value("Bicubic"));
1788 worker.run();
1789
1790 return dev->convertToQImage(profile);
1791}
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 1734 of file kis_image.cc.

1736{
1737 qint32 x;
1738 qint32 y;
1739 qint32 w;
1740 qint32 h;
1741 imageRect.getRect(&x, &y, &w, &h);
1742 return convertToQImage(x, y, w, h, profile);
1743}

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:499
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 986 of file kis_image.cc.

987{
988 const bool isLayer = qobject_cast<KisLayer*>(node.data());
989 KUndo2MagicString actionName = isLayer ?
990 kundo2_i18n("Crop Layer") :
991 kundo2_i18n("Crop Mask");
992
993 KisImageSignalVector emitSignals;
994
995 KisCropSavedExtraData *extraData =
997 newRect, node);
998
999 KisProcessingApplicator applicator(this, node,
1001 emitSignals, actionName, extraData);
1002
1003 KisProcessingVisitorSP visitor =
1004 new KisCropProcessingVisitor(newRect, true, false);
1005
1006 if (node->isAnimated() && activeFrameOnly) {
1007 // Crop active frame..
1008 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1009 } else {
1010 // Crop all frames..
1011 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1012 }
1013 applicator.end();
1014}
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 2604 of file kis_image.cc.

2605{
2607}

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 2313 of file kis_image.cc.

2314{
2315 return !m_d->projectionUpdatesFilters.isEmpty() ?
2316 m_d->projectionUpdatesFilters.last().data() :
2318}

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

◆ defaultProjectionColor()

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

Definition at line 1856 of file kis_image.cc.

1857{
1860 }
1861
1863}
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 2320 of file kis_image.cc.

2321{
2324}
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 2332 of file kis_image.cc.

2333{
2335}

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 1619 of file kis_image.cc.

1620{
1621 QPointF pixelCoord = documentToPixel(documentCoord);
1622 return QPoint(qFloor(pixelCoord.x()), qFloor(pixelCoord.y()));
1623}
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 1614 of file kis_image.cc.

1615{
1616 return QPointF(documentCoord.x() * xRes(), documentCoord.y() * yRes());
1617}
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 1625 of file kis_image.cc.

1626{
1627 return QRectF(documentToPixel(documentRect.topLeft()), documentToPixel(documentRect.bottomRight()));
1628}

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 1802 of file kis_image.cc.

1803{
1804 QRect boundRect = bounds();
1805
1806 const int lod = currentLevelOfDetail();
1807 if (lod > 0) {
1808 KisLodTransform t(lod);
1809 boundRect = t.map(boundRect);
1810 }
1811
1812 return boundRect;
1813}
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 2326 of file kis_image.cc.

2327{
2330}
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 2352 of file kis_image.cc.

2353{
2354 m_d->disableUIUpdateSignals.deref();
2355
2356 QRect rect;
2357 QVector<QRect> postponedUpdates;
2358
2360 postponedUpdates.append(rect);
2361 }
2362
2363 return postponedUpdates;
2364}
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 1938 of file kis_image.cc.

1939{
1940 return m_d->annotations.end();
1941}

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

◆ endStroke()

void KisImage::endStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2162 of file kis_image.cc.

2163{
2164 m_d->scheduler.endStroke(id);
2165}
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 2609 of file kis_image.cc.

2610{
2612
2613 if (pref.lodSupported() && pref.lodPreferred()) {
2615 }
2616}
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 1708 of file kis_image.cc.

1709{
1710 KisLayerUtils::flattenImage(this, activeNode);
1711}
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 1723 of file kis_image.cc.

1724{
1725 KisLayerUtils::flattenLayer(this, layer);
1726}
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:504
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 2481 of file kis_image.cc.

2482{
2483 return m_d->overlaySelectionMask.data();
2484}

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 2284 of file kis_image.cc.

2285{
2287}

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

◆ height()

qint32 KisImage::height ( ) const

Return the height of the image

Definition at line 1650 of file kis_image.cc.

1651{
1652 return m_d->height;
1653}

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 2210 of file kis_image.cc.

2211{
2217 refreshGraphAsync(0, bounds(), QRect());
2218 waitForDone();
2219}
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 2471 of file kis_image.cc.

2472{
2474}
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 2151 of file kis_image.cc.

2152{
2153 return m_d->isolateGroup;
2154}

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

◆ isIsolatingLayer()

bool KisImage::isIsolatingLayer ( ) const

Definition at line 2146 of file kis_image.cc.

2147{
2148 return m_d->isolateLayer;
2149}

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

◆ isolationRootNode()

KisNodeSP KisImage::isolationRootNode ( ) const

Definition at line 2142 of file kis_image.cc.

2142 {
2143 return m_d->isolationRootNode;
2144}

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

◆ keyframeChannelAboutToBeRemoved()

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

Reimplemented from KisNodeGraphListener.

Definition at line 2494 of file kis_image.cc.

2495{
2496 Q_UNUSED(node);
2497
2498 channel->disconnect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)));
2499 channel->disconnect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)));
2500}

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 2486 of file kis_image.cc.

2487{
2488 Q_UNUSED(node);
2489
2490 channel->connect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2491 channel->connect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*,int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2492}

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 1823 of file kis_image.cc.

1824{
1825 return m_d->undoStore->presentCommand();
1826}
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 2623 of file kis_image.cc.

2624{
2625 return m_d->scheduler.lodPreferences();
2626}

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 1718 of file kis_image.cc.

1719{
1720 KisLayerUtils::mergeDown(this, layer, strategy);
1721}
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 1713 of file kis_image.cc.

1714{
1715 KisLayerUtils::mergeMultipleNodes(this, mergedNodes, putAfter);
1716}
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 2661 of file kis_image.cc.

2662{
2663 return m_d->axesCenter;
2664}

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

◆ moveCompositionDown()

void KisImage::moveCompositionDown ( KisLayerCompositionSP composition)

Move a composition down in the composition list

Definition at line 2526 of file kis_image.cc.

2527{
2528 int index = m_d->compositions.indexOf(composition);
2529 if (index >= m_d->compositions.size() -1) {
2530 return;
2531 }
2532 m_d->compositions.move(index, index + 1);
2533}

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

◆ moveCompositionUp()

void KisImage::moveCompositionUp ( KisLayerCompositionSP composition)

Move a composition up in the composition list

Definition at line 2517 of file kis_image.cc.

2518{
2519 int index = m_d->compositions.indexOf(composition);
2520 if (index <= 0) {
2521 return;
2522 }
2523 m_d->compositions.move(index, index - 1);
2524}

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

◆ nChildLayers()

qint32 KisImage::nChildLayers ( ) const

Definition at line 1695 of file kis_image.cc.

1696{
1697 const QStringList list = {"KisLayer"};
1698
1699 KoProperties koProperties;
1700 KisCountVisitor visitor(list, koProperties);
1701 const QList<KisNodeSP> childNodes = m_d->rootLayer->childNodes(list, koProperties);
1702 for (KisNodeSP childNode: childNodes) {
1703 childNode->accept(visitor);
1704 }
1705 return visitor.count();
1706}
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 1683 of file kis_image.cc.

1684{
1685 QStringList list;
1686 list << "KisLayer";
1687 KoProperties properties;
1688 properties.setProperty("visible", false);
1689 KisCountVisitor visitor(list, properties);
1690 m_d->rootLayer->accept(visitor);
1691
1692 return visitor.count();
1693}
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 1673 of file kis_image.cc.

1674{
1675 QStringList list;
1676 list << "KisLayer";
1677
1678 KisCountVisitor visitor(list, KoProperties());
1679 m_d->rootLayer->accept(visitor);
1680 return visitor.count();
1681}

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 2628 of file kis_image.cc.

2629{
2630 Q_UNUSED(node);
2631 Q_EMIT sigNodeCollapsedChanged();
2632}
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 1943 of file kis_image.cc.

1944{
1945 Q_EMIT sigAboutToBeDeleted();
1946}
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 2342 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 2337 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 1792 of file kis_image.cc.

1793{
1795}
@ 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 2366 of file kis_image.cc.

2367{
2369
2371 int lod = currentLevelOfDetail();
2372 QRect dirtyRect = !lod ? rc : KisLodTransform::upscaledRect(rc, lod);
2373
2374 if (dirtyRect.isEmpty()) return;
2375
2376 Q_EMIT sigImageUpdated(dirtyRect);
2377 } else {
2379 }
2380}
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 2392 of file kis_image.cc.

2393{
2400
2406 if (m_d->isolationRootNode &&
2407 dynamic_cast<KisSelectionMask*>(m_d->isolationRootNode.data())) {
2408
2410 }
2411}
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 2347 of file kis_image.cc.

2348{
2350}

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 1635 of file kis_image.cc.

1636{
1637 return QPointF((pixelCoord.x() + 0.5) / xRes(), (pixelCoord.y() + 0.5) / yRes());
1638}

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 1630 of file kis_image.cc.

1631{
1632 return QPointF(pixelCoord.x() / xRes(), pixelCoord.y() / yRes());
1633}

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 1640 of file kis_image.cc.

1641{
1642 return QRectF(pixelToDocument(pixelCoord.topLeft()), pixelToDocument(pixelCoord.bottomRight()));
1643}
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 1815 of file kis_image.cc.

1816{
1817 const int lod = currentLevelOfDetail();
1818 return lod > 0 ?
1821}
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 1584 of file kis_image.cc.

1585{
1586 return colorSpace()->profile();
1587}

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 1661 of file kis_image.cc.

1662{
1663 if (m_d->isolationRootNode) {
1664 return m_d->isolationRootNode->projection();
1665 }
1666
1667 Q_ASSERT(m_d->rootLayer);
1669 Q_ASSERT(projection);
1670 return projection;
1671}
virtual KisPaintDeviceSP projection() const =0
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:826

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 2653 of file kis_image.cc.

2654{
2655 if (m_d->proofingConfig) {
2656 return m_d->proofingConfig;
2657 }
2659}
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.

In cancellable mode, the action does not touch the paint devices of the image, only projections, because it can break undo/redo.

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

Definition at line 875 of file kis_image.cc.

876{
883 struct PurgeUnusedDataStroke : public KisRunnableBasedStrokeStrategy {
884 PurgeUnusedDataStroke(KisImageSP image, bool isCancellable)
885 : KisRunnableBasedStrokeStrategy(QLatin1String("purge-unused-data"),
886 kundo2_i18n("Purge Unused Data")),
887 m_image(image),
888 m_finalCommand(new KUndo2Command(this->name()))
889
890 {
891 this->enableJob(JOB_INIT, true, KisStrokeJobData::BARRIER, KisStrokeJobData::EXCLUSIVE);
892 this->enableJob(JOB_DOSTROKE, true);
893 this->enableJob(JOB_FINISH, true, KisStrokeJobData::SEQUENTIAL);
894
895 setClearsRedoOnStart(!isCancellable);
896 setRequestsOtherStrokesToEnd(!isCancellable);
897 setCanForgetAboutMe(isCancellable);
898 }
899
900 void initStrokeCallback() override
901 {
902 KisPaintDeviceList paintDevicesList;
903 KisPaintDeviceList projectionsList;
905
907 [&paintDevicesList, &projectionsList, this](KisNodeSP node) {
908 KisPaintDeviceList deviceList = node->getLodCapableDevices();
909
910 Q_FOREACH (KisPaintDeviceSP dev, deviceList) {
911 if (!dev) continue;
912
913 // we do **not** strip paint devices in the forgettable
914 // mode, since we should handle transactions for them
915 if (dev == node->paintDevice() && !canForgetAboutMe()) {
916 paintDevicesList << dev;
917 } else {
918 projectionsList << dev;
919 }
920 }
921 });
922
925 KritaUtils::makeContainerUnique(paintDevicesList);
926 KritaUtils::makeContainerUnique(projectionsList);
927
928 Q_FOREACH(KisPaintDeviceSP dev, paintDevicesList) {
929 projectionsList.removeAll(dev);
930
931 // all transactions will be linked to the final command via the
932 // parent-child relationship
933 m_transactions.emplace_back(dev, m_finalCommand.data(), -1, nullptr, KisTransaction::None);
934 }
935
936 // now, when the transactions are started, we can merge the two lists
937 paintDevicesList << projectionsList;
938 projectionsList.clear();
939
940 Q_FOREACH (KisPaintDeviceSP device, paintDevicesList) {
942 [device] () {
943 const_cast<KisPaintDevice*>(device.data())->purgeDefaultPixels();
944 });
945 }
946
947 addMutatedJobs(jobsData);
948 }
949
950 void finishStrokeCallback() override {
951 for (auto it = m_transactions.begin(); it != m_transactions.end(); ++it) {
952 QScopedPointer<KUndo2Command> cmd(it->endAndTake());
953
954 // verify the transaction command is linked to m_finalCommand,
955 // if not, just delete on return
956 KIS_SAFE_ASSERT_RECOVER(cmd->hasParent()) { continue; }
957
958 // if has a parent, release...
959 (void)cmd.take();
960 }
961
962 m_transactions.clear();
963
964 m_finalCommand->redo();
965 m_image->postExecutionUndoAdapter()->addCommand(toQShared(m_finalCommand.take()));
966
967 // now reset the thumbnail generation limitation
969 [](KisNodeSP node) {
970 if (node->preferredThumbnailBoundsMode() != KisThumbnailBoundsMode::Precise) {
971 node->setPreferredThumbnailBoundsMode(KisThumbnailBoundsMode::Precise);
972 }
973 });
974 }
975
976 private:
977 KisImageSP m_image;
978 QScopedPointer<KUndo2Command> m_finalCommand;
979 std::vector<KisTransaction> m_transactions;
980 };
981
982 KisStrokeId id = startStroke(new PurgeUnusedDataStroke(this, isCancellable));
983 endStroke(id);
984}
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
const char * name(StandardAction id)
void addJobConcurrent(QVector< Job * > &jobs, Func func)
void makeContainerUnique(C &container)

References KritaUtils::addJobConcurrent(), KisStrokeJobData::BARRIER, KisSharedPtr< T >::data(), KisStrokeJobData::EXCLUSIVE, KIS_SAFE_ASSERT_RECOVER, kundo2_i18n(), KritaUtils::makeContainerUnique(), KisTransaction::None, KisPaintDevice::purgeDefaultPixels(), KisLayerUtils::recursiveApplyNodes(), KisStrokeJobData::SEQUENTIAL, toQShared(), and void().

◆ 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 2221 of file kis_image.cc.

2222{
2223 if (!root) root = m_d->rootLayer;
2224
2225 QVector<QRect> requestedRects = rects;
2226
2227 KisGroupLayer *group = dynamic_cast<KisGroupLayer*>(root.data());
2228 if (group && group->passThroughMode()) {
2239 QVector<QRect> changeRects = requestedRects;
2240 KisProjectionLeafSP leaf = root->projectionLeaf()->nextSibling();
2241 while (leaf) {
2242 if (leaf->shouldBeRendered()) {
2243 for (auto it = changeRects.begin(); it != changeRects.end(); ++it) {
2244 *it = leaf->projectionPlane()->changeRect(*it, leaf->node() == root ? KisNode::N_FILTHY : KisNode::N_ABOVE_FILTHY);
2245 }
2246 }
2247
2248 leaf = leaf->nextSibling();
2249 }
2250
2251 std::swap(requestedRects, changeRects);
2252 root = group->parent();
2253
2255 }
2256
2261 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2262 it != m_d->projectionUpdatesFilters.rend();
2263 ++it) {
2264
2265 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2266
2267 if ((*it)->filterRefreshGraph(this, root.data(), requestedRects, cropRect, flags)) {
2268 return;
2269 }
2270 }
2271
2272 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2273 m_d->animationInterface->notifyNodeChanged(root.data(), requestedRects, true);
2274 }
2275
2276 m_d->scheduler.fullRefreshAsync(root, requestedRects, cropRect, flags);
2277}
void notifyNodeChanged(const KisNode *node, const QRect &rect, bool recursive)
@ 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 1920 of file kis_image.cc.

1921{
1922 vKisAnnotationSP_it it = m_d->annotations.begin();
1923 while (it != m_d->annotations.end()) {
1924 if ((*it)->type() == type) {
1925 m_d->annotations.erase(it);
1927 return;
1928 }
1929 ++it;
1930 }
1931}

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

◆ removeComposition()

void KisImage::removeComposition ( KisLayerCompositionSP composition)

Remove the layer composition

Definition at line 2512 of file kis_image.cc.

2513{
2514 m_d->compositions.removeAll(composition);
2515}

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 2298 of file kis_image.cc.

2299{
2302
2303 auto it = std::find(m_d->projectionUpdatesFilters.begin(), m_d->projectionUpdatesFilters.end(), cookie);
2305
2306 KisProjectionUpdatesFilterSP filter = *it;
2307
2308 m_d->projectionUpdatesFilters.erase(it);
2309
2310 return filter;
2311}
#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 2424 of file kis_image.cc.

2425{
2430 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2431 it != m_d->projectionUpdatesFilters.rend();
2432 ++it) {
2433
2434 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2435
2436 if ((*it)->filter(this, node, rects, flags)) {
2437 return;
2438 }
2439 }
2440
2441 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2442 m_d->animationInterface->notifyNodeChanged(node, rects, false);
2443 }
2444
2454 QVector<QRect> allSplitRects;
2455
2456 const QRect boundRect = effectiveLodBounds();
2457 Q_FOREACH (const QRect &rc, rects) {
2458 KisWrappedRect splitRect(rc, boundRect, m_d->wrapAroundModeAxis);
2459 allSplitRects.append(splitRect);
2460 }
2461
2462 m_d->requestProjectionUpdateImpl(node, allSplitRects, boundRect, flags);
2463
2464 } else {
2465 m_d->requestProjectionUpdateImpl(node, rects, bounds(), flags);
2466 }
2467
2469}
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 2182 of file kis_image.cc.

2183{
2185}
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 2187 of file kis_image.cc.

2188{
2191 }
2192}
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 2199 of file kis_image.cc.

2200{
2201 Q_EMIT sigStrokeEndRequested();
2203}
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 2205 of file kis_image.cc.

2206{
2207 Q_EMIT sigStrokeEndRequested();
2208}

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 2177 of file kis_image.cc.

2178{
2180}
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 1655 of file kis_image.cc.

1656{
1657 Q_ASSERT(m_d->rootLayer);
1658 return m_d->rootLayer;
1659}

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 1216 of file kis_image.cc.

1217{
1218 rotateImpl(kundo2_i18n("Rotate Image"), root(), radians, true, 0);
1219}
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 1124 of file kis_image.cc.

1129{
1130 // we can either transform (and resize) the whole image or
1131 // transform a selection, we cannot do both at the same time
1132 KIS_SAFE_ASSERT_RECOVER(!(bool(selection) && resizeImage)) {
1133 selection = 0;
1134 }
1135
1136 QRect baseBounds;
1137 if (resizeImage) {
1138 baseBounds = bounds();
1139 }
1140 else if (selection) {
1141 baseBounds = selection->selectedExactRect();
1142 }
1143 else {
1144 Q_FOREACH(KisNodeSP node, nodes) {
1145 baseBounds = baseBounds.united(node->exactBounds());
1146 }
1147 }
1148
1149 QPointF offset;
1150 QSize newSize;
1151
1152 {
1153 KisTransformWorker worker(0,
1154 1.0, 1.0,
1155 0, 0,
1156 radians,
1157 0, 0, 0, 0);
1158 QTransform transform = worker.transform();
1159
1160 if (resizeImage) {
1161 QRect newRect = transform.mapRect(baseBounds);
1162 newSize = newRect.size();
1163 offset = -newRect.topLeft();
1164 }
1165 else {
1166 QPointF origin = QRectF(baseBounds).center();
1167
1168 newSize = size();
1169 offset = -(transform.map(origin) - origin);
1170 }
1171 }
1172
1173 bool sizeChanged = resizeImage &&
1174 (newSize.width() != baseBounds.width() ||
1175 newSize.height() != baseBounds.height());
1176
1177 // These signals will be emitted after processing is done
1178 KisImageSignalVector emitSignals;
1179 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1180
1181 // These flags determine whether updates are transferred to the UI during processing
1182 KisProcessingApplicator::ProcessingFlags signalFlags =
1183 sizeChanged ?
1186
1187
1188 KisProcessingApplicator applicator(this, nodes,
1190 emitSignals, actionName);
1191
1193
1195 new KisTransformProcessingVisitor(1.0, 1.0, 0.0, 0.0,
1196 radians,
1197 offset.x(), offset.y(),
1198 filter);
1199 if (selection) {
1200 visitor->setSelection(selection);
1201 }
1202
1203 if (selection) {
1204 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1205 } else {
1206 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1207 }
1208
1209 if (sizeChanged) {
1210 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1211 }
1212 applicator.end();
1213}
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 1116 of file kis_image.cc.

1121{
1122 rotateImpl(actionName, KisNodeList{rootNode}, radians, resizeImage, selection);
1123}

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 1221 of file kis_image.cc.

1222{
1223 rotateNodes(KisNodeList{node}, radians, selection);
1224}
void rotateNodes(KisNodeList nodes, double radians, KisSelectionSP selection)

References rotateNodes().

◆ rotateNodes()

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

Definition at line 1225 of file kis_image.cc.

1226{
1227 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1228 rotateImpl(kundo2_i18n("Rotate Mask"), nodes, radians, false, selection);
1229 }
1230 else {
1231 rotateImpl(kundo2_i18np("Rotate Layer", "Rotate %1 Layers", nodes.size()), nodes, radians, false, selection);
1232 }
1233}
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 1016 of file kis_image.cc.

1017{
1018 bool resolutionChanged = !qFuzzyCompare(xRes(), xres) || !qFuzzyCompare(yRes(), yres);
1019 bool sizeChanged = size != this->size();
1020
1021 if (!resolutionChanged && !sizeChanged) return;
1022
1023 KisImageSignalVector emitSignals;
1024 if (resolutionChanged) emitSignals << ResolutionChangedSignal;
1025 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(bounds(), size);
1026
1027 KUndo2MagicString actionName = sizeChanged ?
1028 kundo2_i18n("Scale Image") :
1029 kundo2_i18n("Change Image Resolution");
1030
1031 KisProcessingApplicator::ProcessingFlags signalFlags =
1032 (resolutionChanged || sizeChanged) ?
1035
1036 KisProcessingApplicator applicator(this, m_d->rootLayer,
1038 emitSignals, actionName);
1039
1040 qreal sx = qreal(size.width()) / this->size().width();
1041 qreal sy = qreal(size.height()) / this->size().height();
1042
1043 QTransform shapesCorrection;
1044
1045 if (resolutionChanged) {
1046 shapesCorrection = QTransform::fromScale(xRes() / xres, yRes() / yres);
1047 }
1048
1049 KisProcessingVisitorSP visitor =
1051 0, 0,
1052 0,
1053 0, 0,
1054 filterStrategy,
1055 shapesCorrection);
1056
1057 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1058
1059 if (resolutionChanged) {
1062 new KisImageSetResolutionCommand(this, xres, yres, parent);
1063 applicator.applyCommand(parent);
1064 }
1065
1066 if (sizeChanged) {
1067 applicator.applyCommand(new KisImageResizeCommand(this, size));
1068 }
1069
1070 applicator.end();
1071}
@ 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 1073 of file kis_image.cc.

1074{
1075 scaleNodes(KisNodeList{node}, center, scaleX, scaleY, filterStrategy, selection);
1076}
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 1077 of file kis_image.cc.

1078{
1079 KUndo2MagicString actionName(kundo2_i18np("Scale Layer", "Scale %1 Layers", nodes.size()));
1080 KisImageSignalVector emitSignals;
1081
1082 QPointF offset;
1083 {
1084 KisTransformWorker worker(0,
1085 scaleX, scaleY,
1086 0, 0,
1087 0.0,
1088 0, 0, 0, 0);
1089 QTransform transform = worker.transform();
1090
1091 offset = center - transform.map(center);
1092 }
1093
1094 KisProcessingApplicator applicator(this, nodes,
1096 emitSignals, actionName);
1097
1099 new KisTransformProcessingVisitor(scaleX, scaleY,
1100 0, 0,
1101 0,
1102 offset.x(), offset.y(),
1103 filterStrategy);
1104
1105 visitor->setSelection(selection);
1106
1107 if (selection) {
1108 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1109 } else {
1110 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1111 }
1112
1113 applicator.end();
1114}

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 2671 of file kis_image.cc.

2672{
2674}

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 1850 of file kis_image.cc.

1851{
1854}
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 2618 of file kis_image.cc.

2619{
2621}
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 2666 of file kis_image.cc.

2667{
2668 m_d->axesCenter = value;
2669}

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 1728 of file kis_image.cc.

1729{
1731 Q_EMIT sigImageModified();
1732}
@ 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}
KUndo2MagicString kundo2_noi18n(const QString &text)
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 1574 of file kis_image.cc.

1575{
1577}

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 2639 of file kis_image.cc.

2640{
2641 const bool changed = bool(m_d->proofingConfig) != bool(proofingConfig) ||
2642 (m_d->proofingConfig && proofingConfig && *m_d->proofingConfig != *proofingConfig);
2643
2644 // we still assign even when unchanged since they can be different
2645 // shared pointer objects
2646 m_d->proofingConfig = proofingConfig;
2647
2648 if (changed) {
2649 Q_EMIT sigProofingConfigChanged();
2650 }
2651}
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 1599 of file kis_image.cc.

1600{
1601 if (xres > 0) {
1602 m_d->xres = xres;
1603 } else {
1604 qWarning() << "WARNING: Ignoring attempt to set image x resolution <= 0 (" << xres << ")!";
1605 }
1606
1607 if (yres > 0) {
1608 m_d->yres = yres;
1609 } else {
1610 qWarning() << "WARNING: Ignoring attempt to set image y resolution <= 0 (" << yres << ")!";
1611 }
1612}

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

◆ setRootLayer()

void KisImage::setRootLayer ( KisGroupLayerSP rootLayer)

Definition at line 1865 of file kis_image.cc.

1866{
1868
1870
1871 if (m_d->rootLayer) {
1873 m_d->rootLayer->setImage(0);
1874 m_d->rootLayer->disconnect();
1875
1876 KisPaintDeviceSP original = m_d->rootLayer->original();
1878 }
1879
1881 m_d->rootLayer->disconnect();
1883 m_d->rootLayer->setImage(this);
1884
1886 this->setDefaultProjectionColor(defaultProjectionColor);
1887}
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 1828 of file kis_image.cc.

1829{
1830 disconnect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1831
1834 m_d->undoStore.reset(undoStore);
1835
1836 connect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1837
1838}
void setUndoStore(KisUndoStore *undoStore)
void setUndoStore(KisUndoStore *undoStore)

References 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 2382 of file kis_image.cc.

2383{
2385}
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 2582 of file kis_image.cc.

2583{
2585}

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 2558 of file kis_image.cc.

2559{
2562 }
2563
2565
2568
2569 KisProcessingApplicator applicator(this, root(),
2572 kundo2_i18n("Crop Selections"));
2573
2574 KisProcessingVisitorSP visitor =
2576
2577 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
2578 applicator.end();
2579 }
2580}
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 1341 of file kis_image.cc.

1342{
1343 shearImpl(kundo2_i18n("Shear Image"), m_d->rootLayer, true,
1344 angleX, angleY, 0);
1345}
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 1243 of file kis_image.cc.

1248{
1249 QRect baseBounds;
1250 if (resizeImage) {
1251 baseBounds = bounds();
1252 }
1253 else if (selection) {
1254 baseBounds = selection->selectedExactRect();
1255 }
1256 else {
1257 Q_FOREACH(KisNodeSP node, nodes) {
1258 baseBounds = baseBounds.united(node->exactBounds());
1259 }
1260 }
1261 const QPointF origin = QRectF(baseBounds).center();
1262
1263 //angleX, angleY are in degrees
1264 const qreal pi = 3.1415926535897932385;
1265 const qreal deg2rad = pi / 180.0;
1266
1267 qreal tanX = tan(angleX * deg2rad);
1268 qreal tanY = tan(angleY * deg2rad);
1269
1270 QPointF offset;
1271 QSize newSize;
1272
1273 {
1274 KisTransformWorker worker(0,
1275 1.0, 1.0,
1276 tanX, tanY,
1277 0,
1278 0, 0, 0, 0);
1279
1280 QRect newRect = worker.transform().mapRect(baseBounds);
1281 newSize = newRect.size();
1282 if (resizeImage) offset = -newRect.topLeft();
1283 else offset = origin - worker.transform().map(origin);
1284 }
1285
1286 if (newSize == baseBounds.size()) return;
1287
1288 KisImageSignalVector emitSignals;
1289 if (resizeImage) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1290
1291 KisProcessingApplicator::ProcessingFlags signalFlags =
1294
1295 KisProcessingApplicator applicator(this, nodes,
1296 signalFlags,
1297 emitSignals, actionName);
1298
1300
1302 new KisTransformProcessingVisitor(1.0, 1.0,
1303 tanX, tanY,
1304 0,
1305 offset.x(), offset.y(),
1306 filter);
1307
1308 if (selection) {
1309 visitor->setSelection(selection);
1310 }
1311
1312 if (selection) {
1313 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1314 } else {
1315 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1316 }
1317
1318 if (resizeImage) {
1319 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1320 }
1321
1322 applicator.end();
1323}

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 1235 of file kis_image.cc.

1240{
1241 shearImpl(actionName, KisNodeList{rootNode}, resizeImage, angleX, angleY, selection);
1242}

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 1325 of file kis_image.cc.

1326{
1327 shearNodes(KisNodeList{node}, angleX, angleY, selection);
1328}
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 1329 of file kis_image.cc.

1330{
1331 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1332 shearImpl(kundo2_i18n("Shear Mask"), nodes, false,
1333 angleX, angleY, selection);
1334 }
1335 else {
1336 shearImpl(kundo2_i18np("Shear Layer", "Shear %1 Layers", nodes.size()), nodes, false,
1337 angleX, angleY, selection);
1338 }
1339}

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 1948 of file kis_image.cc.

1949{
1950 return &m_d->signalRouter;
1951}

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 1993 of file kis_image.cc.

1994{
1995 m_d->isolateLayer = isolateLayer;
1996 m_d->isolateGroup = isolateGroup;
1997 if ((isolateLayer || isolateGroup) == false) return false;
1998
2003 if (!node->projection()) return false;
2004
2005 struct StartIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
2006 StartIsolatedModeStroke(KisNodeSP node, KisImageSP image, bool isolateLayer, bool isolateGroup)
2007 : KisRunnableBasedStrokeStrategy(QLatin1String("start-isolated-mode"),
2008 kundo2_noi18n("start-isolated-mode")),
2009 m_newRoot(node),
2010 m_image(image),
2011 m_isolateLayer(isolateLayer),
2012 m_isolateGroup(isolateGroup)
2013 {
2014 this->enableJob(JOB_INIT, true, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::EXCLUSIVE);
2015 this->enableJob(JOB_DOSTROKE, true);
2016 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
2017 setClearsRedoOnStart(false);
2018 }
2019
2020 void initStrokeCallback() override {
2021 if (m_isolateLayer == false && m_isolateGroup == true) {
2022 // Isolate parent node unless node is the root note.
2023 m_newRoot = m_newRoot->parent() ? m_newRoot->parent() : m_newRoot;
2024 }
2025 // pass-though node don't have any projection prepared, so we should
2026 // explicitly regenerate it before activating isolated mode.
2027 m_newRoot->projectionLeaf()->explicitlyRegeneratePassThroughProjection();
2028 m_prevRoot = m_image->m_d->isolationRootNode;
2029
2030 const bool beforeVisibility = m_newRoot->projectionLeaf()->visible();
2031 const bool prevRootBeforeVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
2032
2033 m_image->m_d->isolationRootNode = m_newRoot;
2034 Q_EMIT m_image->sigIsolatedModeChanged();
2035
2036 const bool afterVisibility = m_newRoot->projectionLeaf()->visible();
2037 const bool prevRootAfterVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
2038
2039 m_newRootNeedsFullRefresh = beforeVisibility != afterVisibility;
2040 m_prevRootNeedsFullRefresh = prevRootBeforeVisibility != prevRootAfterVisibility;
2041 }
2042
2043 void finishStrokeCallback() override {
2044 // the GUI uses our thread to do the color space conversion so we
2045 // need to Q_EMIT this signal in multiple threads
2046
2047 if (m_prevRoot && m_prevRootNeedsFullRefresh) {
2048 m_image->refreshGraphAsync(m_prevRoot);
2049 }
2050
2051 if (m_newRootNeedsFullRefresh) {
2052 m_image->refreshGraphAsync(m_newRoot);
2053 }
2054
2055 if (!m_prevRootNeedsFullRefresh && !m_newRootNeedsFullRefresh) {
2057 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2058 this->runnableJobsInterface()->addRunnableJobs(jobs);
2059 }
2060
2061 m_image->invalidateAllFrames();
2062 }
2063
2064 private:
2065 KisNodeSP m_newRoot;
2066 KisNodeSP m_prevRoot;
2067 KisImageSP m_image;
2068 bool m_newRootNeedsFullRefresh = false;
2069 bool m_prevRootNeedsFullRefresh = false;
2070
2071 bool m_isolateLayer;
2072 bool m_isolateGroup;
2073 };
2074
2075 KisStrokeId id = startStroke(new StartIsolatedModeStroke(node, this, isolateLayer, isolateGroup));
2076 endStroke(id);
2077
2078 return true;
2079}

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 1961 of file kis_image.cc.

1962{
1970 if (strokeStrategy->requestsOtherStrokesToEnd()) {
1972 }
1973
1974 return m_d->scheduler.startStroke(strokeStrategy);
1975}
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 2081 of file kis_image.cc.

2082{
2083 if (!m_d->isolationRootNode) return;
2084
2085 struct StopIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
2086 StopIsolatedModeStroke(KisImageSP image)
2087 : KisRunnableBasedStrokeStrategy(QLatin1String("stop-isolated-mode"), kundo2_noi18n("stop-isolated-mode")),
2088 m_image(image),
2089 m_oldRootNode(nullptr),
2090 m_oldNodeNeedsRefresh(false)
2091 {
2092 this->enableJob(JOB_INIT);
2093 this->enableJob(JOB_DOSTROKE, true);
2094 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
2095 setClearsRedoOnStart(false);
2096 }
2097
2098 void initStrokeCallback() override {
2099 if (!m_image->m_d->isolationRootNode) return;
2100
2101 m_oldRootNode = m_image->m_d->isolationRootNode;
2102
2103 const bool beforeVisibility = m_oldRootNode->projectionLeaf()->visible();
2104 m_image->m_d->isolationRootNode = 0;
2105 m_image->m_d->isolateLayer = false;
2106 m_image->m_d->isolateGroup = false;
2107 Q_EMIT m_image->sigIsolatedModeChanged();
2108 const bool afterVisibility = m_oldRootNode->projectionLeaf()->visible();
2109
2110 m_oldNodeNeedsRefresh = (beforeVisibility != afterVisibility);
2111 }
2112
2113 void finishStrokeCallback() override {
2114
2115 m_image->invalidateAllFrames();
2116
2117 if (m_oldNodeNeedsRefresh){
2118 m_oldRootNode->setDirty(m_image->bounds());
2119 } else {
2120 // TODO: Substitute notifyProjectionUpdated() with this code
2121 // when update optimization is implemented
2122 //
2123 // QRect updateRect = bounds() | oldRootNode->extent();
2124 //oldRootNode->setDirty(updateRect);
2125
2127 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2128 this->runnableJobsInterface()->addRunnableJobs(jobs);
2129 }
2130 }
2131
2132 private:
2133 KisImageSP m_image;
2134 KisNodeSP m_oldRootNode;
2135 bool m_oldNodeNeedsRefresh;
2136 };
2137
2138 KisStrokeId id = startStroke(new StopIsolatedModeStroke(this));
2139 endStroke(id);
2140}

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 2194 of file kis_image.cc.

2195{
2197}

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 1845 of file kis_image.cc.

1846{
1847 return &m_d->legacyUndoAdapter;
1848}

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

◆ undoStore()

KisUndoStore * KisImage::undoStore ( )

Return current undo store of the image

Definition at line 1840 of file kis_image.cc.

1841{
1842 return m_d->undoStore.data();
1843}

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 1463 of file kis_image.cc.

1464{
1465 const KUndo2MagicString actionName = kundo2_i18n("Unify Layers Color Space");
1466
1467 KisImageSignalVector emitSignals;
1468
1469 KisProcessingApplicator::ProcessingFlags flags =
1471
1472 KisProcessingApplicator applicator(this, m_d->rootLayer,
1473 flags,
1474 emitSignals, actionName);
1475
1476 // src and dst color spaces coincide, since we should just unify
1477 // all our layers
1478 applicator.applyVisitor(
1484
1485 applicator.end();
1486}

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 1953 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 1645 of file kis_image.cc.

1646{
1647 return m_d->width;
1648}

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 2387 of file kis_image.cc.

2388{
2389 return m_d->scheduler.threadsLimit();
2390}

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 2598 of file kis_image.cc.

2599{
2600 return m_d->wrapAroundModePermitted &&
2602}

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 2587 of file kis_image.cc.

2588{
2589 return m_d->wrapAroundModeAxis;
2590}

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 2593 of file kis_image.cc.

2594{
2596}

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

◆ xRes()

double KisImage::xRes ( ) const

X resolution in pixels per pt

Definition at line 1589 of file kis_image.cc.

1590{
1591 return m_d->xres;
1592}

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

◆ yRes()

double KisImage::yRes ( ) const

Y resolution in pixels per pt

Definition at line 1594 of file kis_image.cc.

1595{
1596 return m_d->yres;
1597}

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: