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

317 : QObject(0)
318 , KisShared()
319 , m_d(new KisImagePrivate(this, width, height,
322{
323 // make sure KisImage belongs to the GUI thread
324 moveToThread(qApp->thread());
325 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
326
327 setObjectName(name);
328 setRootLayer(new KisGroupLayer(this, "root", OPACITY_OPAQUE_U8));
329}
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 331 of file kis_image.cc.

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

References m_d, and waitForDone().

◆ KisImage() [2/2]

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

Definition at line 566 of file kis_image.cc.

567 : KisNodeFacade(),
569 KisShared(),
570 m_d(new KisImagePrivate(this,
571 rhs.width(), rhs.height(),
572 rhs.colorSpace(),
575{
576 // make sure KisImage belongs to the GUI thread
577 moveToThread(qApp->thread());
578 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
579
580 copyFromImageImpl(rhs, CONSTRUCT | (exactCopy ? EXACT_COPY : 0));
581}
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:416

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

584{
586 SANITY_CHECK_LOCKED("aboutToAddANode");
587}
#define SANITY_CHECK_LOCKED(name)
Definition kis_image.cc:113
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 605 of file kis_image.cc.

606{
607 KisNodeSP deletedNode = parent->at(index);
608 if (!dynamic_cast<KisSelectionMask*>(deletedNode.data()) &&
609 deletedNode == m_d->isolationRootNode) {
610
612 }
613
615 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
616 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
617 this->keyframeChannelAboutToBeRemoved(node.data(), chan);
618 }
619 });
620
622
623 SANITY_CHECK_LOCKED("aboutToRemoveANode");
625}
void emitAboutToRemoveANode(KisNode *parent, int index)
KisImageSignalRouter signalRouter
Definition kis_image.cc:274
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 1890 of file kis_image.cc.

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

2509{
2510 m_d->compositions.append(composition);
2511}
QList< KisLayerCompositionSP > compositions
Definition kis_image.cc:253

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

◆ addJob()

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

Implements KisStrokesFacade.

Definition at line 2157 of file kis_image.cc.

2158{
2160 m_d->scheduler.addJob(id, data);
2161}
KisUpdateScheduler scheduler
Definition kis_image.cc:276
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 2290 of file kis_image.cc.

2291{
2293
2294 m_d->projectionUpdatesFilters.append(filter);
2295
2296 return KisProjectionUpdatesFilterCookie(filter.data());
2297}
QVector< KisProjectionUpdatesFilterSP > projectionUpdatesFilters
Definition kis_image.cc:272
#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 2280 of file kis_image.cc.

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

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

◆ allowMasksOnRootNode()

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

Definition at line 2677 of file kis_image.cc.

2678{
2679 return m_d->allowMasksOnRootNode;
2680}

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

◆ animationInterface()

KisImageAnimationInterface * KisImage::animationInterface ( ) const

Definition at line 2635 of file kis_image.cc.

2636{
2637 return m_d->animationInterface;
2638}
KisImageAnimationInterface * animationInterface
Definition kis_image.cc:275

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

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

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

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

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

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

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

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

◆ blockUpdates()

void KisImage::blockUpdates ( )
overridevirtual

blockUpdates block updating the image projection

Implements KisUpdatesFacade.

Definition at line 819 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 1798 of file kis_image.cc.

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

References height(), and width().

◆ cancelStroke()

bool KisImage::cancelStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2168 of file kis_image.cc.

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

707{
709}
KisSelectionMaskSP deselectedGlobalSelectionMask
Definition kis_image.cc:249

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

407{
408 return new KisImage(*this, 0, exactCopy);
409}
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:316

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

1581{
1582 return m_d->colorSpace;
1583}

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

◆ compositeProgressProxy()

KisCompositeProgressProxy * KisImage::compositeProgressProxy ( )

Definition at line 747 of file kis_image.cc.

748{
750}
KisCompositeProgressProxy compositeProgressProxy
Definition kis_image.cc:279

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

◆ compositions()

QList< KisLayerCompositionSP > KisImage::compositions ( )

Returns the layer compositions for the image

Definition at line 2503 of file kis_image.cc.

2504{
2505 return m_d->compositions;
2506}

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

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

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

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

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

References convertToQImage(), and profile().

◆ copyFromImage()

void KisImage::copyFromImage ( const KisImage & rhs)

Definition at line 411 of file kis_image.cc.

412{
414}

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

417{
418 // make sure we choose exactly one from REPLACE and CONSTRUCT
419 KIS_ASSERT_RECOVER_RETURN(bool(policy & REPLACE) != bool(policy & CONSTRUCT));
420
433 const bool sizeChanged = m_d->width != rhs.width() || m_d->height != rhs.height();
434 const bool colorSpaceChanged = *m_d->colorSpace != *rhs.colorSpace();
435 const bool resolutionChanged = m_d->xres != rhs.m_d->xres || m_d->yres != rhs.m_d->yres;
436
437 if (sizeChanged) {
438 m_d->width = rhs.width();
439 m_d->height = rhs.height();
440 }
441
442 if (colorSpaceChanged) {
443 m_d->colorSpace = rhs.colorSpace();
444 }
445
446 if (resolutionChanged) {
447 m_d->xres = rhs.m_d->xres;
448 m_d->yres = rhs.m_d->yres;
449 }
450
451 // from KisImage::KisImage(const KisImage &, KisUndoStore *, bool)
452 setObjectName(rhs.objectName());
453
454 KisNodeSP oldRoot = this->root();
455 KisNodeSP newRoot = rhs.root()->clone();
456 newRoot->setGraphListener(this);
457 newRoot->setImage(this);
458
459 m_d->rootLayer = dynamic_cast<KisGroupLayer*>(newRoot.data());
460 setRoot(newRoot);
461
462 if (oldRoot) {
463 oldRoot->setImage(0);
464 oldRoot->setGraphListener(0);
465 oldRoot->disconnect();
466 }
467
468 // only when replacing do we need to Q_EMIT signals
469#define EMIT_IF_NEEDED if (!(policy & REPLACE)) {} else emit
470
471 if (sizeChanged) {
472 EMIT_IF_NEEDED sigSizeChanged(QPointF(), QPointF());
473 }
474 if (colorSpaceChanged) {
476 }
477 if (resolutionChanged) {
479 }
480
482
483 if (rhs.m_d->proofingConfig) {
485 if (policy & REPLACE) {
486 setProofingConfiguration(proofingConfig);
487 } else {
488 m_d->proofingConfig = proofingConfig;
489 }
490 }
491
492 bool exactCopy = policy & EXACT_COPY;
493
494 if (exactCopy || rhs.m_d->isolationRootNode || rhs.m_d->overlaySelectionMask) {
497
498 QQueue<KisNodeSP> linearizedNodes;
500 [&linearizedNodes](KisNodeSP node) {
501 linearizedNodes.enqueue(node);
502 });
504 [&linearizedNodes, exactCopy, &rhs, this](KisNodeSP node) {
505 KisNodeSP refNode = linearizedNodes.dequeue();
506
507 if (exactCopy) {
508 node->setUuid(refNode->uuid());
509 }
510
511 if (rhs.m_d->isolationRootNode &&
512 rhs.m_d->isolationRootNode == refNode) {
513 m_d->isolationRootNode = node;
514 }
515
516 if (rhs.m_d->overlaySelectionMask &&
517 KisNodeSP(rhs.m_d->overlaySelectionMask) == refNode) {
518 m_d->targetOverlaySelectionMask = dynamic_cast<KisSelectionMask*>(node.data());
521 }
522
523
524 // Re-establish DefaultBounds Instances for Existing Nodes
525 // This is a workaround for copy-constructors failing to pass
526 // proper DefaultBounds due to either lacking image data on construction
527 // We should change the way "DefaultBounds" works to try to make it
528 // safer for threading races.
529 using KeyframeChannelContainer = QMap<QString, KisKeyframeChannel*>;
530 KeyframeChannelContainer keyframeChannels = node->keyframeChannels();
531 for (KeyframeChannelContainer::iterator i = keyframeChannels.begin();
532 i != keyframeChannels.end(); i++) {
533 keyframeChannels[i.key()]->setNode(node);
534 }
535 });
536 }
537
539 [](KisNodeSP node) {
540 dbgImage << "Node: " << (void *)node.data();
541 });
542
543
544
545 m_d->compositions.clear();
546
547 Q_FOREACH (KisLayerCompositionSP comp, rhs.m_d->compositions) {
548 m_d->compositions << toQShared(new KisLayerComposition(*comp, this));
549 }
550
552
553 vKisAnnotationSP newAnnotations;
554 Q_FOREACH (KisAnnotationSP annotation, rhs.m_d->annotations) {
555 newAnnotations << annotation->clone();
556 }
557 m_d->annotations = newAnnotations;
558
562
563#undef EMIT_IF_NEEDED
564}
KisProofingConfigurationSP proofingConfig
Definition kis_image.cc:246
KisSelectionMaskSP targetOverlaySelectionMask
Definition kis_image.cc:251
KisSelectionMaskSP overlaySelectionMask
Definition kis_image.cc:252
QAtomicInt disableUIUpdateSignals
Definition kis_image.cc:268
QAtomicInt disableDirtyRequests
Definition kis_image.cc:277
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 871 of file kis_image.cc.

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

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

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

2606{
2608}

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

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

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

◆ defaultProjectionColor()

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

Definition at line 1857 of file kis_image.cc.

1858{
1861 }
1862
1864}
static KoColor createTransparent(const KoColorSpace *cs)
Definition KoColor.cpp:682
#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 2321 of file kis_image.cc.

2322{
2325}
QStack< KisProjectionUpdatesFilterCookie > disabledUpdatesCookies
Definition kis_image.cc:273
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 2333 of file kis_image.cc.

2334{
2336}

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

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

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

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

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

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

2328{
2331}
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 2353 of file kis_image.cc.

2354{
2355 m_d->disableUIUpdateSignals.deref();
2356
2357 QRect rect;
2358 QVector<QRect> postponedUpdates;
2359
2361 postponedUpdates.append(rect);
2362 }
2363
2364 return postponedUpdates;
2365}
KisLocklessStack< QRect > savedDisabledUIUpdates
Definition kis_image.cc:269

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

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

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

◆ endStroke()

void KisImage::endStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2163 of file kis_image.cc.

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

2611{
2613
2614 if (pref.lodSupported() && pref.lodPreferred()) {
2616 }
2617}
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 1709 of file kis_image.cc.

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

1725{
1726 KisLayerUtils::flattenLayer(this, layer);
1727}
void flattenLayer(KisImageSP image, KisLayerSP layer, MergeFlags flags)

References KisLayerUtils::flattenLayer().

◆ fromQImage()

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

Definition at line 342 of file kis_image.cc.

343{
344 const KoColorSpace *colorSpace = 0;
345
346 switch (image.format()) {
347 case QImage::Format_Invalid:
348 case QImage::Format_Mono:
349 case QImage::Format_MonoLSB:
351 break;
352 case QImage::Format_Indexed8:
353 case QImage::Format_RGB32:
354 case QImage::Format_ARGB32:
355 case QImage::Format_ARGB32_Premultiplied:
357 break;
358 case QImage::Format_RGB16:
360 break;
361 case QImage::Format_ARGB8565_Premultiplied:
362 case QImage::Format_RGB666:
363 case QImage::Format_ARGB6666_Premultiplied:
364 case QImage::Format_RGB555:
365 case QImage::Format_ARGB8555_Premultiplied:
366 case QImage::Format_RGB888:
367 case QImage::Format_RGB444:
368 case QImage::Format_ARGB4444_Premultiplied:
369 case QImage::Format_RGBX8888:
370 case QImage::Format_RGBA8888:
371 case QImage::Format_RGBA8888_Premultiplied:
373 break;
374 case QImage::Format_BGR30:
375 case QImage::Format_A2BGR30_Premultiplied:
376 case QImage::Format_RGB30:
377 case QImage::Format_A2RGB30_Premultiplied:
379 break;
380 case QImage::Format_Alpha8:
382 break;
383 case QImage::Format_Grayscale8:
385 break;
386 case QImage::Format_Grayscale16:
388 break;
389 case QImage::Format_RGBX64:
390 case QImage::Format_RGBA64:
391 case QImage::Format_RGBA64_Premultiplied:
393 break;
394 default:
395 colorSpace = 0;
396 }
397
398 KisImageSP img = new KisImage(undoStore, image.width(), image.height(), colorSpace, i18n("Imported Image"));
399 KisPaintLayerSP layer = new KisPaintLayer(img, img->nextLayerName(), 255);
400 layer->paintDevice()->convertFromQImage(image, 0, 0, 0);
401 img->addNode(layer.data(), img->rootLayer().data());
402
403 return img;
404}
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:716
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 696 of file kis_image.cc.

697{
698 KisSelectionMaskSP selectionMask = m_d->rootLayer->selectionMask();
699 if (selectionMask) {
700 return selectionMask->selection();
701 } else {
702 return 0;
703 }
704}
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 711 of file kis_image.cc.

712{
714}
KisImageGlobalSelectionManagementInterface globalSelectionInterface
Definition kis_image.cc:248

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

◆ graphOverlayNode()

KisNode * KisImage::graphOverlayNode ( ) const
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2482 of file kis_image.cc.

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

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

◆ hasOverlaySelectionMask()

bool KisImage::hasOverlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 691 of file kis_image.cc.

692{
694}

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

2286{
2288}

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

◆ height()

qint32 KisImage::height ( ) const

Return the height of the image

Definition at line 1651 of file kis_image.cc.

1652{
1653 return m_d->height;
1654}

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

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

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

2473{
2475}
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 789 of file kis_image.cc.

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

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

◆ isIsolatingGroup()

bool KisImage::isIsolatingGroup ( ) const

Definition at line 2152 of file kis_image.cc.

2153{
2154 return m_d->isolateGroup;
2155}

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

◆ isIsolatingLayer()

bool KisImage::isIsolatingLayer ( ) const

Definition at line 2147 of file kis_image.cc.

2148{
2149 return m_d->isolateLayer;
2150}

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

◆ isolationRootNode()

KisNodeSP KisImage::isolationRootNode ( ) const

Definition at line 2143 of file kis_image.cc.

2143 {
2144 return m_d->isolationRootNode;
2145}

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

◆ keyframeChannelAboutToBeRemoved()

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

Reimplemented from KisNodeGraphListener.

Definition at line 2495 of file kis_image.cc.

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

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

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

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

1825{
1826 return m_d->undoStore->presentCommand();
1827}
QScopedPointer< KisUndoStore > undoStore
Definition kis_image.cc:262

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

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

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

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

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

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

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

2663{
2664 return m_d->axesCenter;
2665}

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

◆ moveCompositionDown()

void KisImage::moveCompositionDown ( KisLayerCompositionSP composition)

Move a composition down in the composition list

Definition at line 2527 of file kis_image.cc.

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

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

◆ moveCompositionUp()

void KisImage::moveCompositionUp ( KisLayerCompositionSP composition)

Move a composition up in the composition list

Definition at line 2518 of file kis_image.cc.

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

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

◆ nChildLayers()

qint32 KisImage::nChildLayers ( ) const

Definition at line 1696 of file kis_image.cc.

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

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

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

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

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

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

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

590{
591 KisNodeGraphListener::nodeHasBeenAdded(parent, index, flags);
592
594 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
595 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
596 chan->setNode(node);
597 this->keyframeChannelHasBeenAdded(node.data(), chan);
598 }
599 });
600
601 SANITY_CHECK_LOCKED("nodeHasBeenAdded");
602 m_d->signalRouter.emitNodeHasBeenAdded(parent, index, flags);
603}
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 1944 of file kis_image.cc.

1945{
1946 Q_EMIT sigAboutToBeDeleted();
1947}
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 2343 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 2338 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 1793 of file kis_image.cc.

1794{
1796}
@ 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 2367 of file kis_image.cc.

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

2394{
2401
2407 if (m_d->isolationRootNode &&
2408 dynamic_cast<KisSelectionMask*>(m_d->isolationRootNode.data())) {
2409
2411 }
2412}
KisLegacyUndoAdapter legacyUndoAdapter
Definition kis_image.cc:263
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 2348 of file kis_image.cc.

2349{
2351}

References notifyProjectionUpdated().

◆ operator=()

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

◆ overlaySelectionMask()

KisSelectionMaskSP KisImage::overlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 686 of file kis_image.cc.

687{
689}

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

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

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

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

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

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

1817{
1818 const int lod = currentLevelOfDetail();
1819 return lod > 0 ?
1822}
KisPostExecutionUndoAdapter postExecutionUndoAdapter
Definition kis_image.cc:264
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 1585 of file kis_image.cc.

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

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

1663{
1664 if (m_d->isolationRootNode) {
1665 return m_d->isolationRootNode->projection();
1666 }
1667
1668 Q_ASSERT(m_d->rootLayer);
1670 Q_ASSERT(projection);
1671 return projection;
1672}
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 2654 of file kis_image.cc.

2655{
2656 if (m_d->proofingConfig) {
2657 return m_d->proofingConfig;
2658 }
2660}
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 876 of file kis_image.cc.

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

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

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

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

◆ removeComposition()

void KisImage::removeComposition ( KisLayerCompositionSP composition)

Remove the layer composition

Definition at line 2513 of file kis_image.cc.

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

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

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

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

2184{
2186}
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 2188 of file kis_image.cc.

2189{
2192 }
2193}
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 2200 of file kis_image.cc.

2201{
2202 Q_EMIT sigStrokeEndRequested();
2204}
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 2206 of file kis_image.cc.

2207{
2208 Q_EMIT sigStrokeEndRequested();
2209}

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

2179{
2181}
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 866 of file kis_image.cc.

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

References resizeImageImpl().

◆ resizeImageImpl()

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

Definition at line 835 of file kis_image.cc.

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

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

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

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

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

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

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

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

References rotateNodes().

◆ rotateNodes()

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

Definition at line 1226 of file kis_image.cc.

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

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

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

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

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

2673{
2675}

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

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

2620{
2622}
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 2667 of file kis_image.cc.

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

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

1730{
1732 Q_EMIT sigImageModified();
1733}
@ 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 638 of file kis_image.cc.

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

1576{
1578}

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

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

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

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

◆ setRootLayer()

void KisImage::setRootLayer ( KisGroupLayerSP rootLayer)

Definition at line 1866 of file kis_image.cc.

1867{
1869
1871
1872 if (m_d->rootLayer) {
1874 m_d->rootLayer->setImage(0);
1875 m_d->rootLayer->disconnect();
1876
1877 KisPaintDeviceSP original = m_d->rootLayer->original();
1879 }
1880
1882 m_d->rootLayer->disconnect();
1884 m_d->rootLayer->setImage(this);
1885
1887 this->setDefaultProjectionColor(defaultProjectionColor);
1888}
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 829 of file kis_image.cc.

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

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

1830{
1831 disconnect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1832
1835 m_d->undoStore.reset(undoStore);
1836
1837 connect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1838
1839}
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 2383 of file kis_image.cc.

2384{
2386}
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 2583 of file kis_image.cc.

2584{
2586}

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

2560{
2563 }
2564
2566
2569
2570 KisProcessingApplicator applicator(this, root(),
2573 kundo2_i18n("Crop Selections"));
2574
2575 KisProcessingVisitorSP visitor =
2577
2578 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
2579 applicator.end();
2580 }
2581}
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 1342 of file kis_image.cc.

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

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

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

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

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

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

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

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

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

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

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

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

1963{
1971 if (strokeStrategy->requestsOtherStrokesToEnd()) {
1973 }
1974
1975 return m_d->scheduler.startStroke(strokeStrategy);
1976}
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 2082 of file kis_image.cc.

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

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

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

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

2196{
2198}

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

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

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

◆ undoStore()

KisUndoStore * KisImage::undoStore ( )

Return current undo store of the image

Definition at line 1841 of file kis_image.cc.

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

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

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

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

807{
808 Q_ASSERT(locked());
809
810 if (locked()) {
811 m_d->lockCount--;
812
813 if (m_d->lockCount == 0) {
815 }
816 }
817}
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 1954 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 1646 of file kis_image.cc.

1647{
1648 return m_d->width;
1649}

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

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

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

2600{
2601 return m_d->wrapAroundModePermitted &&
2603}

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

2589{
2590 return m_d->wrapAroundModeAxis;
2591}

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

2595{
2597}

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

◆ xRes()

double KisImage::xRes ( ) const

X resolution in pixels per pt

Definition at line 1590 of file kis_image.cc.

1591{
1592 return m_d->xres;
1593}

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

◆ yRes()

double KisImage::yRes ( ) const

Y resolution in pixels per pt

Definition at line 1595 of file kis_image.cc.

1596{
1597 return m_d->yres;
1598}

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: