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 ()
 
KisImageGlobalSelectionManagementInterface * globalSelectionManagementInterface () 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
 
KisImageAnimationInterface * animationInterface () 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 ()
 
KisImage * clone (bool exactCopy=false)
 
const KoColorSpace * colorSpace () const
 
std::optional< KisColorVolumeInformation > colorVolumeInformation () const
 colorVolumeInformation
 
KisCompositeProgressProxy * compositeProgressProxy ()
 
QList< KisLayerCompositionSP > compositions ()
 
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
 
KisNode * graphOverlayNode () const override
 
bool hasOverlaySelectionMask () const
 
bool hasUpdatesRunning () const override
 
std::optional< double > hdrReferenceWhiteLightLevel () const
 HDR Reference White livel.
 
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 KUndo2Command * lastExecutedCommand () 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
 
KisPostExecutionUndoAdapter * postExecutionUndoAdapter () const override
 
const KoColorProfile * profile () 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)
 
std::optional< KisRelativeContentLightLevelInformation > relativeContentLightLevelInformation () const
 relativeContentLightLevelInformation This returns (optionally) a KisRelativeContentLightLevelInformation with the MaxCLL and MaxFALL of the image. Note that MaxCLL and MaxFALL will not be in cd/m², but rather in linear XYZ Y. To get the cd/m², multiply these values with diffuseWhiteLightLevel().
 
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 setColorVolumeInformation (const std::optional< KisColorVolumeInformation > cvi)
 Set the color volume information.
 
void setDefaultProjectionColor (const KoColor &color)
 
void setHdrReferenceWhiteLightLevel (const std::optional< double > value)
 Set the diffuse white light level, in cd/m²
 
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 setRelativeContentLightLevelInformation (const std::optional< KisRelativeContentLightLevelInformation > clli)
 
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)
 
KisImageSignalRouter * signalRouter ()
 
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.
 
KisUndoAdapter * undoAdapter () const
 
KisUndoStore * undoStore ()
 
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)
 
KisImage & operator= (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

KisImagePrivate * m_d
 

Friends

class KisImageGlobalSelectionManagementInterface
 
class KisImageResizeCommand
 

Additional Inherited Members

- Public Attributes inherited from KisNodeFacade
KisNodeWSP root
 
- Public Attributes inherited from Private
KisCanvas2 * canvas
 
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 59 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 127 of file kis_image.h.

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

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

339 : QObject(0)
340 , KisShared()
341 , m_d(new KisImagePrivate(this, width, height,
344{
345 // make sure KisImage belongs to the GUI thread
346 moveToThread(qApp->thread());
347 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
348
349 setObjectName(name);
350 setRootLayer(new KisGroupLayer(this, "root", OPACITY_OPAQUE_U8));
351}
const quint8 OPACITY_OPAQUE_U8
KisImagePrivate * m_d
Definition kis_image.h:1312
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 353 of file kis_image.cc.

354{
358 waitForDone();
359
360 delete m_d;
361}
void waitForDone()

References m_d, and waitForDone().

◆ KisImage() [2/2]

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

Definition at line 591 of file kis_image.cc.

592 : KisNodeFacade(),
594 KisShared(),
595 m_d(new KisImagePrivate(this,
596 rhs.width(), rhs.height(),
597 rhs.colorSpace(),
600{
601 // make sure KisImage belongs to the GUI thread
602 moveToThread(qApp->thread());
603 connect(this, SIGNAL(sigInternalStopIsolatedModeRequested()), SLOT(stopIsolatedMode()));
604
605 copyFromImageImpl(rhs, CONSTRUCT | (exactCopy ? EXACT_COPY : 0));
606}
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:437

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

609{
611 SANITY_CHECK_LOCKED("aboutToAddANode");
612}
#define SANITY_CHECK_LOCKED(name)
Definition kis_image.cc:114
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 630 of file kis_image.cc.

631{
632 KisNodeSP deletedNode = parent->at(index);
633 if (!dynamic_cast<KisSelectionMask*>(deletedNode.data()) &&
634 deletedNode == m_d->isolationRootNode) {
635
637 }
638
640 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
641 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
642 this->keyframeChannelAboutToBeRemoved(node.data(), chan);
643 }
644 });
645
647
648 SANITY_CHECK_LOCKED("aboutToRemoveANode");
650}
void emitAboutToRemoveANode(KisNode *parent, int index)
KisImageSignalRouter signalRouter
Definition kis_image.cc:277
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 1916 of file kis_image.cc.

1917{
1918 // Find the icc annotation, if there is one
1919 vKisAnnotationSP_it it = m_d->annotations.begin();
1920 while (it != m_d->annotations.end()) {
1921 if ((*it)->type() == annotation->type()) {
1922 *it = annotation;
1924 return;
1925 }
1926 ++it;
1927 }
1928 m_d->annotations.push_back(annotation);
1930}
vKisAnnotationSP annotations
Definition kis_image.cc:269
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 2569 of file kis_image.cc.

2570{
2571 m_d->compositions.append(composition);
2572}
QList< KisLayerCompositionSP > compositions
Definition kis_image.cc:256

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

◆ addJob()

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

Implements KisStrokesFacade.

Definition at line 2218 of file kis_image.cc.

2219{
2221 m_d->scheduler.addJob(id, data);
2222}
KisUpdateScheduler scheduler
Definition kis_image.cc:279
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 2351 of file kis_image.cc.

2352{
2354
2355 m_d->projectionUpdatesFilters.append(filter);
2356
2357 return KisProjectionUpdatesFilterCookie(filter.data());
2358}
QVector< KisProjectionUpdatesFilterSP > projectionUpdatesFilters
Definition kis_image.cc:275
#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 2341 of file kis_image.cc.

2342{
2343 m_d->scheduler.addSpontaneousJob(spontaneousJob);
2344}
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)

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

◆ allowMasksOnRootNode()

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

Definition at line 2738 of file kis_image.cc.

2739{
2740 return m_d->allowMasksOnRootNode;
2741}

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

◆ animationInterface()

KisImageAnimationInterface * KisImage::animationInterface ( ) const

Definition at line 2696 of file kis_image.cc.

2697{
2698 return m_d->animationInterface;
2699}
KisImageAnimationInterface * animationInterface
Definition kis_image.cc:278

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

1933{
1934 vKisAnnotationSP_it it = m_d->annotations.begin();
1935 while (it != m_d->annotations.end()) {
1936 if ((*it) && (*it)->type() == type) {
1937 return *it;
1938 }
1939 else if (!*it) {
1940 qWarning() << "Skipping deleted annotation";
1941 }
1942 ++it;
1943 }
1944 return KisAnnotationSP(0);
1945}
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 1544 of file kis_image.cc.

1545{
1546 if (!profile) return false;
1547
1548 const KoColorSpace *srcColorSpace = m_d->colorSpace;
1549 bool imageProfileIsSame = *srcColorSpace->profile() == *profile;
1550
1551 imageProfileIsSame &=
1553 [profile] (KisNodeSP node) {
1554 return *node->colorSpace()->profile() != *profile;
1555 });
1556
1557 if (imageProfileIsSame) {
1558 dbgImage << "Trying to set the same image profile again" << ppVar(srcColorSpace->profile()->name()) << ppVar(profile->name());
1559 return true;
1560 }
1561
1562 KUndo2MagicString actionName = kundo2_i18n("Assign Profile");
1563
1564 KisImageSignalVector emitSignals;
1565 emitSignals << ProfileChangedSignal;
1566
1567 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1568 if (!dstColorSpace) return false;
1569
1570 KisProcessingApplicator applicator(this, m_d->rootLayer,
1572 (!blockAllUpdates ?
1574 KisProcessingApplicator::NO_IMAGE_UPDATES),
1575 emitSignals, actionName);
1576
1577 applicator.applyCommand(
1578 new KisImagePrivate::SetImageProjectionColorSpace(dstColorSpace,
1579 KisImageWSP(this),
1582
1583 applicator.applyVisitor(
1585 srcColorSpace, dstColorSpace),
1587
1588 applicator.applyCommand(
1589 new KisImagePrivate::SetImageProjectionColorSpace(srcColorSpace,
1590 KisImageWSP(this),
1593
1594
1595 applicator.end();
1596
1597 return true;
1598}
@ ProfileChangedSignal
const KoColorSpace * colorSpace
Definition kis_image.cc:248
KisGroupLayerSP rootLayer
Definition kis_image.cc:253
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:163
#define dbgImage
Definition kis_debug.h:50
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 1514 of file kis_image.cc.

1515{
1516 const KoColorSpace *srcColorSpace = node->colorSpace();
1517
1518 if (!node->projectionLeaf()->isLayer()) return false;
1519 if (!profile || *srcColorSpace->profile() == *profile) return false;
1520
1521 KUndo2MagicString actionName = kundo2_i18n("Assign Profile to Layer");
1522
1523 KisImageSignalVector emitSignals;
1524
1525 const KoColorSpace *dstColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1526 if (!dstColorSpace) return false;
1527
1528 KisProcessingApplicator applicator(this, node,
1531 emitSignals, actionName);
1532
1533 applicator.applyVisitor(
1535 srcColorSpace, dstColorSpace),
1537
1538 applicator.end();
1539
1540 return true;
1541}
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 782 of file kis_image.cc.

783{
784 if (!locked()) {
789 m_d->lockedForReadOnly = readOnly;
790 } else {
791 m_d->lockedForReadOnly &= readOnly;
792 }
793
794 m_d->lockCount++;
795}
void notifyWaitOnImageStarted(KisImage *image)
void notifyWaitOnImageEnded(KisImage *image)
static KisBusyWaitBroker * instance()
void requestStrokeEnd()
bool locked() const
Definition kis_image.cc:777

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

1961{
1962 return m_d->annotations.begin();
1963}

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

◆ blockUpdates()

void KisImage::blockUpdates ( )
overridevirtual

blockUpdates block updating the image projection

Implements KisUpdatesFacade.

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

1825{
1826 return QRect(0, 0, width(), height());
1827}

References height(), and width().

◆ cancelStroke()

bool KisImage::cancelStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2229 of file kis_image.cc.

2230{
2231 return m_d->scheduler.cancelStroke(id);
2232}
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 731 of file kis_image.cc.

732{
734}
KisSelectionMaskSP deselectedGlobalSelectionMask
Definition kis_image.cc:252

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

428{
429 return new KisImage(*this, 0, exactCopy);
430}
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:338

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

1607{
1608 return m_d->colorSpace;
1609}

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

◆ colorVolumeInformation()

std::optional< KisColorVolumeInformation > KisImage::colorVolumeInformation ( ) const

colorVolumeInformation

Returns
the KisColorVolumeInformation of the image. When this is missing, the image color space is assumed, with 0 as the minimum luminance and 10K as the max luminance.

Definition at line 2118 of file kis_image.cc.

2119{
2121}
std::optional< KisColorVolumeInformation > colorVolumeInformation
Definition kis_image.cc:285

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

◆ compositeProgressProxy()

KisCompositeProgressProxy * KisImage::compositeProgressProxy ( )

Definition at line 772 of file kis_image.cc.

773{
775}
KisCompositeProgressProxy compositeProgressProxy
Definition kis_image.cc:282

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

◆ compositions()

QList< KisLayerCompositionSP > KisImage::compositions ( )

Returns the layer compositions for the image

Definition at line 2564 of file kis_image.cc.

2565{
2566 return m_d->compositions;
2567}

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

1478{
1479 m_d->convertImageColorSpaceImpl(dstColorSpace, true, renderingIntent, conversionFlags);
1480}
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 1373 of file kis_image.cc.

1377{
1378 if (!node->projectionLeaf()->isLayer()) return;
1379 // must not be an image root, use convertImageColorSpace() for that:
1380 KIS_SAFE_ASSERT_RECOVER_RETURN(!node->image() || (node.data() != node->image()->rootLayer().data()));
1381
1382 const KoColorSpace *srcColorSpace = node->colorSpace();
1383
1384 if (!dstColorSpace || *srcColorSpace == *dstColorSpace) return;
1385
1386 KUndo2MagicString actionName =
1387 kundo2_i18n("Convert Layer Color Space");
1388
1389 KisImageSignalVector emitSignals;
1390
1391 KisProcessingApplicator applicator(this, node,
1393 emitSignals, actionName);
1394
1395 applicator.applyVisitor(
1397 srcColorSpace, dstColorSpace,
1398 renderingIntent, conversionFlags),
1400
1401 applicator.end();
1402}
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 1789 of file kis_image.cc.

1790{
1791 if (scaledImageSize.isEmpty()) {
1792 return QImage();
1793 }
1794
1796 KisPainter gc;
1797 gc.copyAreaOptimized(QPoint(0, 0), projection(), dev, bounds());
1798 gc.end();
1799 double scaleX = qreal(scaledImageSize.width()) / width();
1800 double scaleY = qreal(scaledImageSize.height()) / height();
1801
1802
1803 if (scaleX < 1.0/256 || scaleY < 1.0/256) {
1804 // quick checking if we're not trying to scale too much
1805 // convertToQImage uses KisFixedPoint values, which means that the scale cannot be smaller than 1/2^8
1806 // BUG:432182
1807 // FIXME: would be best to extend KisFixedPoint instead
1808 return convertToQImage(size(), profile).scaled(scaledImageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
1809 }
1810
1811 KoDummyUpdaterHolder updaterHolder;
1812 QPointer<KoUpdater> updater = updaterHolder.updater();
1813
1814 KisTransformWorker worker(dev, scaleX, scaleY, 0.0, 0.0, 0.0, 0.0, 0.0, updater, KisFilterStrategyRegistry::instance()->value("Bicubic"));
1815 worker.run();
1816
1817 return dev->convertToQImage(profile);
1818}
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:550
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 1761 of file kis_image.cc.

1763{
1764 qint32 x;
1765 qint32 y;
1766 qint32 w;
1767 qint32 h;
1768 imageRect.getRect(&x, &y, &w, &h);
1769 return convertToQImage(x, y, w, h, profile);
1770}

References convertToQImage(), and profile().

◆ copyFromImage()

void KisImage::copyFromImage ( const KisImage & rhs)

Definition at line 432 of file kis_image.cc.

433{
435}

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

438{
439 // make sure we choose exactly one from REPLACE and CONSTRUCT
440 KIS_ASSERT_RECOVER_RETURN(bool(policy & REPLACE) != bool(policy & CONSTRUCT));
441
454 const bool sizeChanged = m_d->width != rhs.width() || m_d->height != rhs.height();
455 const bool colorSpaceChanged = *m_d->colorSpace != *rhs.colorSpace();
456 const bool resolutionChanged = m_d->xres != rhs.m_d->xres || m_d->yres != rhs.m_d->yres;
457
458 if (sizeChanged) {
459 m_d->width = rhs.width();
460 m_d->height = rhs.height();
461 }
462
463 if (colorSpaceChanged) {
464 m_d->colorSpace = rhs.colorSpace();
465 }
466
467 if (resolutionChanged) {
468 m_d->xres = rhs.m_d->xres;
469 m_d->yres = rhs.m_d->yres;
470 }
471
472 // from KisImage::KisImage(const KisImage &, KisUndoStore *, bool)
473 setObjectName(rhs.objectName());
474
475 KisNodeSP oldRoot = this->root();
476 KisNodeSP newRoot = rhs.root()->clone();
477 newRoot->setGraphListener(this);
478 newRoot->setImage(this);
479
480 m_d->rootLayer = dynamic_cast<KisGroupLayer*>(newRoot.data());
481 setRoot(newRoot);
482
483 if (oldRoot) {
484 oldRoot->setImage(0);
485 oldRoot->setGraphListener(0);
486 oldRoot->disconnect();
487 }
488
489 // only when replacing do we need to Q_EMIT signals
490#define EMIT_IF_NEEDED if (!(policy & REPLACE)) {} else emit
491
492 if (sizeChanged) {
493 EMIT_IF_NEEDED sigSizeChanged(QPointF(), QPointF());
494 }
495 if (colorSpaceChanged) {
497 }
498 if (resolutionChanged) {
500 }
501
503
504 if (rhs.m_d->proofingConfig) {
506 if (policy & REPLACE) {
507 setProofingConfiguration(proofingConfig);
508 } else {
509 m_d->proofingConfig = proofingConfig;
510 }
511 }
512
516
517 bool exactCopy = policy & EXACT_COPY;
518
519 if (exactCopy || rhs.m_d->isolationRootNode || rhs.m_d->overlaySelectionMask) {
522
523 QQueue<KisNodeSP> linearizedNodes;
525 [&linearizedNodes](KisNodeSP node) {
526 linearizedNodes.enqueue(node);
527 });
529 [&linearizedNodes, exactCopy, &rhs, this](KisNodeSP node) {
530 KisNodeSP refNode = linearizedNodes.dequeue();
531
532 if (exactCopy) {
533 node->setUuid(refNode->uuid());
534 }
535
536 if (rhs.m_d->isolationRootNode &&
537 rhs.m_d->isolationRootNode == refNode) {
538 m_d->isolationRootNode = node;
539 }
540
541 if (rhs.m_d->overlaySelectionMask &&
542 KisNodeSP(rhs.m_d->overlaySelectionMask) == refNode) {
543 m_d->targetOverlaySelectionMask = dynamic_cast<KisSelectionMask*>(node.data());
546 }
547
548
549 // Re-establish DefaultBounds Instances for Existing Nodes
550 // This is a workaround for copy-constructors failing to pass
551 // proper DefaultBounds due to either lacking image data on construction
552 // We should change the way "DefaultBounds" works to try to make it
553 // safer for threading races.
554 using KeyframeChannelContainer = QMap<QString, KisKeyframeChannel*>;
555 KeyframeChannelContainer keyframeChannels = node->keyframeChannels();
556 for (KeyframeChannelContainer::iterator i = keyframeChannels.begin();
557 i != keyframeChannels.end(); i++) {
558 keyframeChannels[i.key()]->setNode(node);
559 }
560 });
561 }
562
564 [](KisNodeSP node) {
565 dbgImage << "Node: " << (void *)node.data();
566 });
567
568
569
570 m_d->compositions.clear();
571
572 Q_FOREACH (KisLayerCompositionSP comp, rhs.m_d->compositions) {
573 m_d->compositions << toQShared(new KisLayerComposition(*comp, this));
574 }
575
577
578 vKisAnnotationSP newAnnotations;
579 Q_FOREACH (KisAnnotationSP annotation, rhs.m_d->annotations) {
580 newAnnotations << annotation->clone();
581 }
582 m_d->annotations = newAnnotations;
583
587
588#undef EMIT_IF_NEEDED
589}
std::optional< KisRelativeContentLightLevelInformation > relativeContentLightLevelInformation
Definition kis_image.cc:284
KisProofingConfigurationSP proofingConfig
Definition kis_image.cc:249
KisSelectionMaskSP targetOverlaySelectionMask
Definition kis_image.cc:254
KisSelectionMaskSP overlaySelectionMask
Definition kis_image.cc:255
std::optional< double > diffuseWhiteLightLevel
Definition kis_image.cc:286
QAtomicInt disableUIUpdateSignals
Definition kis_image.cc:271
QAtomicInt disableDirtyRequests
Definition kis_image.cc:280
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::colorVolumeInformation, KisImage::KisImagePrivate::compositions, CONSTRUCT, KisSharedPtr< T >::data(), dbgImage, KisImage::KisImagePrivate::diffuseWhiteLightLevel, 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(), KisImage::KisImagePrivate::relativeContentLightLevelInformation, 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 896 of file kis_image.cc.

897{
898 resizeImageImpl(newRect, true);
899}
void resizeImageImpl(const QRect &newRect, bool cropLayers)
Definition kis_image.cc:860

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

1013{
1014 const bool isLayer = qobject_cast<KisLayer*>(node.data());
1015 KUndo2MagicString actionName = isLayer ?
1016 kundo2_i18n("Crop Layer") :
1017 kundo2_i18n("Crop Mask");
1018
1019 KisImageSignalVector emitSignals;
1020
1021 KisCropSavedExtraData *extraData =
1023 newRect, node);
1024
1025 KisProcessingApplicator applicator(this, node,
1027 emitSignals, actionName, extraData);
1028
1029 KisProcessingVisitorSP visitor =
1030 new KisCropProcessingVisitor(newRect, true, false);
1031
1032 if (node->isAnimated() && activeFrameOnly) {
1033 // Crop active frame..
1034 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1035 } else {
1036 // Crop all frames..
1037 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1038 }
1039 applicator.end();
1040}
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 2666 of file kis_image.cc.

2667{
2669}

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

2376{
2377 return !m_d->projectionUpdatesFilters.isEmpty() ?
2378 m_d->projectionUpdatesFilters.last().data() :
2380}

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

◆ defaultProjectionColor()

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

Definition at line 1883 of file kis_image.cc.

1884{
1887 }
1888
1890}
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 2382 of file kis_image.cc.

2383{
2386}
QStack< KisProjectionUpdatesFilterCookie > disabledUpdatesCookies
Definition kis_image.cc:276
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 2394 of file kis_image.cc.

2395{
2397}

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

1647{
1648 QPointF pixelCoord = documentToPixel(documentCoord);
1649 return QPoint(qFloor(pixelCoord.x()), qFloor(pixelCoord.y()));
1650}
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 1641 of file kis_image.cc.

1642{
1643 return QPointF(documentCoord.x() * xRes(), documentCoord.y() * yRes());
1644}
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 1652 of file kis_image.cc.

1653{
1654 return QRectF(documentToPixel(documentRect.topLeft()), documentToPixel(documentRect.bottomRight()));
1655}

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

1830{
1831 QRect boundRect = bounds();
1832
1833 const int lod = currentLevelOfDetail();
1834 if (lod > 0) {
1835 KisLodTransform t(lod);
1836 boundRect = t.map(boundRect);
1837 }
1838
1839 return boundRect;
1840}
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 2388 of file kis_image.cc.

2389{
2392}
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 2414 of file kis_image.cc.

2415{
2416 m_d->disableUIUpdateSignals.deref();
2417
2418 QRect rect;
2419 QVector<QRect> postponedUpdates;
2420
2421 while (m_d->savedDisabledUIUpdates.pop(rect)) {
2422 postponedUpdates.append(rect);
2423 }
2424
2425 return postponedUpdates;
2426}
KisLocklessStack< QRect > savedDisabledUIUpdates
Definition kis_image.cc:272

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

1966{
1967 return m_d->annotations.end();
1968}

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

◆ endStroke()

void KisImage::endStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2224 of file kis_image.cc.

2225{
2226 m_d->scheduler.endStroke(id);
2227}
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 2671 of file kis_image.cc.

2672{
2674
2675 if (pref.lodSupported() && pref.lodPreferred()) {
2677 }
2678}
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 1735 of file kis_image.cc.

1736{
1737 KisLayerUtils::flattenImage(this, activeNode);
1738}
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 1750 of file kis_image.cc.

1751{
1752 KisLayerUtils::flattenLayer(this, layer);
1753}
void flattenLayer(KisImageSP image, KisLayerSP layer, MergeFlags flags)

References KisLayerUtils::flattenLayer().

◆ fromQImage()

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

Definition at line 363 of file kis_image.cc.

364{
365 const KoColorSpace *colorSpace = 0;
366
367 switch (image.format()) {
368 case QImage::Format_Invalid:
369 case QImage::Format_Mono:
370 case QImage::Format_MonoLSB:
372 break;
373 case QImage::Format_Indexed8:
374 case QImage::Format_RGB32:
375 case QImage::Format_ARGB32:
376 case QImage::Format_ARGB32_Premultiplied:
378 break;
379 case QImage::Format_RGB16:
381 break;
382 case QImage::Format_ARGB8565_Premultiplied:
383 case QImage::Format_RGB666:
384 case QImage::Format_ARGB6666_Premultiplied:
385 case QImage::Format_RGB555:
386 case QImage::Format_ARGB8555_Premultiplied:
387 case QImage::Format_RGB888:
388 case QImage::Format_RGB444:
389 case QImage::Format_ARGB4444_Premultiplied:
390 case QImage::Format_RGBX8888:
391 case QImage::Format_RGBA8888:
392 case QImage::Format_RGBA8888_Premultiplied:
394 break;
395 case QImage::Format_BGR30:
396 case QImage::Format_A2BGR30_Premultiplied:
397 case QImage::Format_RGB30:
398 case QImage::Format_A2RGB30_Premultiplied:
400 break;
401 case QImage::Format_Alpha8:
403 break;
404 case QImage::Format_Grayscale8:
406 break;
407 case QImage::Format_Grayscale16:
409 break;
410 case QImage::Format_RGBX64:
411 case QImage::Format_RGBA64:
412 case QImage::Format_RGBA64_Premultiplied:
414 break;
415 default:
416 colorSpace = 0;
417 }
418
419 KisImageSP img = new KisImage(undoStore, image.width(), image.height(), colorSpace, i18n("Imported Image"));
420 KisPaintLayerSP layer = new KisPaintLayer(img, img->nextLayerName(), 255);
421 layer->paintDevice()->convertFromQImage(image, 0, 0, 0);
422 img->addNode(layer.data(), img->rootLayer().data());
423
424 return img;
425}
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:741
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 721 of file kis_image.cc.

722{
723 KisSelectionMaskSP selectionMask = m_d->rootLayer->selectionMask();
724 if (selectionMask) {
725 return selectionMask->selection();
726 } else {
727 return 0;
728 }
729}
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 736 of file kis_image.cc.

737{
739}
KisImageGlobalSelectionManagementInterface globalSelectionInterface
Definition kis_image.cc:251

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

◆ graphOverlayNode()

KisNode * KisImage::graphOverlayNode ( ) const
overridevirtual

Reimplemented from KisNodeGraphListener.

Definition at line 2543 of file kis_image.cc.

2544{
2545 return m_d->overlaySelectionMask.data();
2546}

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

◆ hasOverlaySelectionMask()

bool KisImage::hasOverlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 716 of file kis_image.cc.

717{
719}

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

2347{
2349}

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

◆ hdrReferenceWhiteLightLevel()

std::optional< double > KisImage::hdrReferenceWhiteLightLevel ( ) const

HDR Reference White livel.

Returns
the cd/m² value Defines at what brightness level the SDR content is supposed to be converted to this image. When this is missing, 80cd/m² is assumed.

Definition at line 2128 of file kis_image.cc.

2129{
2131}

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

◆ height()

qint32 KisImage::height ( ) const

Return the height of the image

Definition at line 1677 of file kis_image.cc.

1678{
1679 return m_d->height;
1680}

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

2273{
2279 refreshGraphAsync(0, bounds(), QRect());
2280 waitForDone();
2281}
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 658 of file kis_image.cc.

659{
661}
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 2533 of file kis_image.cc.

2534{
2536}
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 814 of file kis_image.cc.

815{
816 return (allowLocked || !locked()) && m_d->scheduler.isIdle();
817}

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

◆ isIsolatingGroup()

bool KisImage::isIsolatingGroup ( ) const

Definition at line 2213 of file kis_image.cc.

2214{
2215 return m_d->isolateGroup;
2216}

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

◆ isIsolatingLayer()

bool KisImage::isIsolatingLayer ( ) const

Definition at line 2208 of file kis_image.cc.

2209{
2210 return m_d->isolateLayer;
2211}

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

◆ isolationRootNode()

KisNodeSP KisImage::isolationRootNode ( ) const

Definition at line 2204 of file kis_image.cc.

2204 {
2205 return m_d->isolationRootNode;
2206}

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

◆ keyframeChannelAboutToBeRemoved()

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

Reimplemented from KisNodeGraphListener.

Definition at line 2556 of file kis_image.cc.

2557{
2558 Q_UNUSED(node);
2559
2560 channel->disconnect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)));
2561 channel->disconnect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)));
2562}

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

2549{
2550 Q_UNUSED(node);
2551
2552 channel->connect(channel, SIGNAL(sigAddedKeyframe(const KisKeyframeChannel*, int)), m_d->animationInterface, SIGNAL(sigKeyframeAdded(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2553 channel->connect(channel, SIGNAL(sigKeyframeHasBeenRemoved(const KisKeyframeChannel*,int)), m_d->animationInterface, SIGNAL(sigKeyframeRemoved(const KisKeyframeChannel*, int)), Qt::UniqueConnection);
2554}

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

1851{
1852 return m_d->undoStore->presentCommand();
1853}
QScopedPointer< KisUndoStore > undoStore
Definition kis_image.cc:265

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

778{
779 return m_d->lockCount != 0;
780}

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

2686{
2687 return m_d->scheduler.lodPreferences();
2688}

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

1746{
1747 KisLayerUtils::mergeDown(this, layer, strategy);
1748}
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 1740 of file kis_image.cc.

1741{
1742 KisLayerUtils::mergeMultipleNodes(this, mergedNodes, putAfter);
1743}
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 2723 of file kis_image.cc.

2724{
2725 return m_d->axesCenter;
2726}

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

◆ moveCompositionDown()

void KisImage::moveCompositionDown ( KisLayerCompositionSP composition)

Move a composition down in the composition list

Definition at line 2588 of file kis_image.cc.

2589{
2590 int index = m_d->compositions.indexOf(composition);
2591 if (index >= m_d->compositions.size() -1) {
2592 return;
2593 }
2594 m_d->compositions.move(index, index + 1);
2595}

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

◆ moveCompositionUp()

void KisImage::moveCompositionUp ( KisLayerCompositionSP composition)

Move a composition up in the composition list

Definition at line 2579 of file kis_image.cc.

2580{
2581 int index = m_d->compositions.indexOf(composition);
2582 if (index <= 0) {
2583 return;
2584 }
2585 m_d->compositions.move(index, index - 1);
2586}

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

◆ nChildLayers()

qint32 KisImage::nChildLayers ( ) const

Definition at line 1722 of file kis_image.cc.

1723{
1724 const QStringList list = {"KisLayer"};
1725
1726 KoProperties koProperties;
1727 KisCountVisitor visitor(list, koProperties);
1728 const QList<KisNodeSP> childNodes = m_d->rootLayer->childNodes(list, koProperties);
1729 for (KisNodeSP childNode: childNodes) {
1730 childNode->accept(visitor);
1731 }
1732 return visitor.count();
1733}
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 741 of file kis_image.cc.

742{
743 QString baseName = _baseName;
744
745 int numLayers = 0;
746 int maxLayerIndex = 0;
747 QRegularExpression numberedLayerRegexp(".* (\\d+)$");
749 [&numLayers, &maxLayerIndex, &numberedLayerRegexp] (KisNodeSP node) {
750 if (node->inherits("KisLayer")) {
751 QRegularExpressionMatch match = numberedLayerRegexp.match(node->name());
752
753 if (match.hasMatch()) {
754 maxLayerIndex = qMax(maxLayerIndex, match.captured(1).toInt());
755 }
756 numLayers++;
757 }
758 });
759
760 // special case if there is only root node
761 if (numLayers == 1) {
762 return i18nc("Name for the bottom-most layer in the layerstack", "Background");
763 }
764
765 if (baseName.isEmpty()) {
766 baseName = i18n("Paint Layer");
767 }
768
769 return QString("%1 %2").arg(baseName).arg(maxLayerIndex + 1);
770}

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

1711{
1712 QStringList list;
1713 list << "KisLayer";
1714 KoProperties properties;
1715 properties.setProperty("visible", false);
1716 KisCountVisitor visitor(list, properties);
1717 m_d->rootLayer->accept(visitor);
1718
1719 return visitor.count();
1720}
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 1700 of file kis_image.cc.

1701{
1702 QStringList list;
1703 list << "KisLayer";
1704
1705 KisCountVisitor visitor(list, KoProperties());
1706 m_d->rootLayer->accept(visitor);
1707 return visitor.count();
1708}

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

2691{
2692 Q_UNUSED(node);
2693 Q_EMIT sigNodeCollapsedChanged();
2694}
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 614 of file kis_image.cc.

615{
616 KisNodeGraphListener::nodeHasBeenAdded(parent, index, flags);
617
619 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
620 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
621 chan->setNode(node);
622 this->keyframeChannelHasBeenAdded(node.data(), chan);
623 }
624 });
625
626 SANITY_CHECK_LOCKED("nodeHasBeenAdded");
627 m_d->signalRouter.emitNodeHasBeenAdded(parent, index, flags);
628}
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 1970 of file kis_image.cc.

1971{
1972 Q_EMIT sigAboutToBeDeleted();
1973}
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 2404 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 2399 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 1819 of file kis_image.cc.

1820{
1822}
@ 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 2428 of file kis_image.cc.

2429{
2431
2433 int lod = currentLevelOfDetail();
2434 QRect dirtyRect = !lod ? rc : KisLodTransform::upscaledRect(rc, lod);
2435
2436 if (dirtyRect.isEmpty()) return;
2437
2438 Q_EMIT sigImageUpdated(dirtyRect);
2439 } else {
2441 }
2442}
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 2454 of file kis_image.cc.

2455{
2462
2468 if (m_d->isolationRootNode &&
2469 dynamic_cast<KisSelectionMask*>(m_d->isolationRootNode.data())) {
2470
2472 }
2473}
KisLegacyUndoAdapter legacyUndoAdapter
Definition kis_image.cc:266
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 2409 of file kis_image.cc.

2410{
2412}

References notifyProjectionUpdated().

◆ operator=()

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

◆ overlaySelectionMask()

KisSelectionMaskSP KisImage::overlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 711 of file kis_image.cc.

712{
714}

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

1663{
1664 return QPointF((pixelCoord.x() + 0.5) / xRes(), (pixelCoord.y() + 0.5) / yRes());
1665}

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

1658{
1659 return QPointF(pixelCoord.x() / xRes(), pixelCoord.y() / yRes());
1660}

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

1668{
1669 return QRectF(pixelToDocument(pixelCoord.topLeft()), pixelToDocument(pixelCoord.bottomRight()));
1670}
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 1842 of file kis_image.cc.

1843{
1844 const int lod = currentLevelOfDetail();
1845 return lod > 0 ?
1848}
KisPostExecutionUndoAdapter postExecutionUndoAdapter
Definition kis_image.cc:267
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 1611 of file kis_image.cc.

1612{
1613 return colorSpace()->profile();
1614}

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

1689{
1690 if (m_d->isolationRootNode) {
1691 return m_d->isolationRootNode->projection();
1692 }
1693
1694 Q_ASSERT(m_d->rootLayer);
1696 Q_ASSERT(projection);
1697 return projection;
1698}
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 2715 of file kis_image.cc.

2716{
2717 if (m_d->proofingConfig) {
2718 return m_d->proofingConfig;
2719 }
2721}
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 901 of file kis_image.cc.

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

2284{
2285 if (!root) root = m_d->rootLayer;
2286
2287 QVector<QRect> requestedRects = rects;
2288
2289 KisGroupLayer *group = dynamic_cast<KisGroupLayer*>(root.data());
2290 if (group && group->passThroughMode()) {
2301 QVector<QRect> changeRects = requestedRects;
2302 KisProjectionLeafSP leaf = root->projectionLeaf()->nextSibling();
2303 while (leaf) {
2304 if (leaf->shouldBeRendered()) {
2305 for (auto it = changeRects.begin(); it != changeRects.end(); ++it) {
2306 *it = leaf->projectionPlane()->changeRect(*it, leaf->node() == root ? KisNode::N_FILTHY : KisNode::N_ABOVE_FILTHY);
2307 }
2308 }
2309
2310 leaf = leaf->nextSibling();
2311 }
2312
2313 std::swap(requestedRects, changeRects);
2314 root = group->parent();
2315
2317 }
2318
2323 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2324 it != m_d->projectionUpdatesFilters.rend();
2325 ++it) {
2326
2327 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2328
2329 if ((*it)->filterRefreshGraph(this, root.data(), requestedRects, cropRect, flags)) {
2330 return;
2331 }
2332 }
2333
2334 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2335 m_d->animationInterface->notifyNodeChanged(root.data(), requestedRects, true);
2336 }
2337
2338 m_d->scheduler.fullRefreshAsync(root, requestedRects, cropRect, flags);
2339}
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

◆ relativeContentLightLevelInformation()

std::optional< KisRelativeContentLightLevelInformation > KisImage::relativeContentLightLevelInformation ( ) const

relativeContentLightLevelInformation This returns (optionally) a KisRelativeContentLightLevelInformation with the MaxCLL and MaxFALL of the image. Note that MaxCLL and MaxFALL will not be in cd/m², but rather in linear XYZ Y. To get the cd/m², multiply these values with diffuseWhiteLightLevel().

Definition at line 2108 of file kis_image.cc.

2109{
2111}

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

◆ removeAnnotation()

void KisImage::removeAnnotation ( const QString & type)

delete the annotation, if the image contains it

Definition at line 1947 of file kis_image.cc.

1948{
1949 vKisAnnotationSP_it it = m_d->annotations.begin();
1950 while (it != m_d->annotations.end()) {
1951 if ((*it)->type() == type) {
1952 m_d->annotations.erase(it);
1954 return;
1955 }
1956 ++it;
1957 }
1958}

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

◆ removeComposition()

void KisImage::removeComposition ( KisLayerCompositionSP composition)

Remove the layer composition

Definition at line 2574 of file kis_image.cc.

2575{
2576 m_d->compositions.removeAll(composition);
2577}

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

2361{
2364
2365 auto it = std::find(m_d->projectionUpdatesFilters.begin(), m_d->projectionUpdatesFilters.end(), cookie);
2367
2368 KisProjectionUpdatesFilterSP filter = *it;
2369
2370 m_d->projectionUpdatesFilters.erase(it);
2371
2372 return filter;
2373}
#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 2486 of file kis_image.cc.

2487{
2492 for (auto it = m_d->projectionUpdatesFilters.rbegin();
2493 it != m_d->projectionUpdatesFilters.rend();
2494 ++it) {
2495
2496 KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
2497
2498 if ((*it)->filter(this, node, rects, flags)) {
2499 return;
2500 }
2501 }
2502
2503 if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
2504 m_d->animationInterface->notifyNodeChanged(node, rects, false);
2505 }
2506
2516 QVector<QRect> allSplitRects;
2517
2518 const QRect boundRect = effectiveLodBounds();
2519 Q_FOREACH (const QRect &rc, rects) {
2520 KisWrappedRect splitRect(rc, boundRect, m_d->wrapAroundModeAxis);
2521 allSplitRects.append(splitRect);
2522 }
2523
2524 m_d->requestProjectionUpdateImpl(node, allSplitRects, boundRect, flags);
2525
2526 } else {
2527 m_d->requestProjectionUpdateImpl(node, rects, bounds(), flags);
2528 }
2529
2531}
void requestProjectionUpdateImpl(KisNode *node, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
WrapAroundAxis wrapAroundModeAxis
Definition kis_image.cc:263
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 2244 of file kis_image.cc.

2245{
2247}
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 2249 of file kis_image.cc.

2250{
2253 }
2254}
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 2261 of file kis_image.cc.

2262{
2263 Q_EMIT sigStrokeEndRequested();
2265}
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 2267 of file kis_image.cc.

2268{
2269 Q_EMIT sigStrokeEndRequested();
2270}

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

2240{
2242}
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 891 of file kis_image.cc.

892{
893 resizeImageImpl(newRect, false);
894}

References resizeImageImpl().

◆ resizeImageImpl()

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

Definition at line 860 of file kis_image.cc.

861{
862 if (newRect == bounds() && !cropLayers) return;
863
864 KUndo2MagicString actionName = cropLayers ?
865 kundo2_i18n("Crop Image") :
866 kundo2_i18n("Resize Image");
867
868 KisImageSignalVector emitSignals;
869 emitSignals << ComplexSizeChangedSignal(newRect, newRect.size());
870
871 KisCropSavedExtraData *extraData =
872 new KisCropSavedExtraData(cropLayers ?
874 KisCropSavedExtraData::RESIZE_IMAGE,
875 newRect);
876
877 KisProcessingApplicator applicator(this, m_d->rootLayer,
880 emitSignals, actionName, extraData);
881
882 if (cropLayers || !newRect.topLeft().isNull()) {
883 KisProcessingVisitorSP visitor =
884 new KisCropProcessingVisitor(newRect, cropLayers, true);
885 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
886 }
887 applicator.applyCommand(new KisImageResizeCommand(this, newRect.size()));
888 applicator.end();
889}
friend class KisImageResizeCommand
Definition kis_image.h:1303

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

1683{
1684 Q_ASSERT(m_d->rootLayer);
1685 return m_d->rootLayer;
1686}

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

1243{
1244 rotateImpl(kundo2_i18n("Rotate Image"), root(), radians, true, 0);
1245}
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 1150 of file kis_image.cc.

1155{
1156 // we can either transform (and resize) the whole image or
1157 // transform a selection, we cannot do both at the same time
1158 KIS_SAFE_ASSERT_RECOVER(!(bool(selection) && resizeImage)) {
1159 selection = 0;
1160 }
1161
1162 QRect baseBounds;
1163 if (resizeImage) {
1164 baseBounds = bounds();
1165 }
1166 else if (selection) {
1167 baseBounds = selection->selectedExactRect();
1168 }
1169 else {
1170 Q_FOREACH(KisNodeSP node, nodes) {
1171 baseBounds = baseBounds.united(node->exactBounds());
1172 }
1173 }
1174
1175 QPointF offset;
1176 QSize newSize;
1177
1178 {
1179 KisTransformWorker worker(0,
1180 1.0, 1.0,
1181 0, 0,
1182 radians,
1183 0, 0, 0, 0);
1184 QTransform transform = worker.transform();
1185
1186 if (resizeImage) {
1187 QRect newRect = transform.mapRect(baseBounds);
1188 newSize = newRect.size();
1189 offset = -newRect.topLeft();
1190 }
1191 else {
1192 QPointF origin = QRectF(baseBounds).center();
1193
1194 newSize = size();
1195 offset = -(transform.map(origin) - origin);
1196 }
1197 }
1198
1199 bool sizeChanged = resizeImage &&
1200 (newSize.width() != baseBounds.width() ||
1201 newSize.height() != baseBounds.height());
1202
1203 // These signals will be emitted after processing is done
1204 KisImageSignalVector emitSignals;
1205 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1206
1207 // These flags determine whether updates are transferred to the UI during processing
1208 KisProcessingApplicator::ProcessingFlags signalFlags =
1209 sizeChanged ?
1212
1213
1214 KisProcessingApplicator applicator(this, nodes,
1216 emitSignals, actionName);
1217
1219
1221 new KisTransformProcessingVisitor(1.0, 1.0, 0.0, 0.0,
1222 radians,
1223 offset.x(), offset.y(),
1224 filter);
1225 if (selection) {
1226 visitor->setSelection(selection);
1227 }
1228
1229 if (selection) {
1230 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1231 } else {
1232 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1233 }
1234
1235 if (sizeChanged) {
1236 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1237 }
1238 applicator.end();
1239}
void resizeImage(const QRect &newRect)
start asynchronous operation on resizing the image
Definition kis_image.cc:891
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 1142 of file kis_image.cc.

1147{
1148 rotateImpl(actionName, KisNodeList{rootNode}, radians, resizeImage, selection);
1149}

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

1248{
1249 rotateNodes(KisNodeList{node}, radians, selection);
1250}
void rotateNodes(KisNodeList nodes, double radians, KisSelectionSP selection)

References rotateNodes().

◆ rotateNodes()

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

Definition at line 1251 of file kis_image.cc.

1252{
1253 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1254 rotateImpl(kundo2_i18n("Rotate Mask"), nodes, radians, false, selection);
1255 }
1256 else {
1257 rotateImpl(kundo2_i18np("Rotate Layer", "Rotate %1 Layers", nodes.size()), nodes, radians, false, selection);
1258 }
1259}
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 1042 of file kis_image.cc.

1043{
1044 bool resolutionChanged = !qFuzzyCompare(xRes(), xres) || !qFuzzyCompare(yRes(), yres);
1045 bool sizeChanged = size != this->size();
1046
1047 if (!resolutionChanged && !sizeChanged) return;
1048
1049 KisImageSignalVector emitSignals;
1050 if (resolutionChanged) emitSignals << ResolutionChangedSignal;
1051 if (sizeChanged) emitSignals << ComplexSizeChangedSignal(bounds(), size);
1052
1053 KUndo2MagicString actionName = sizeChanged ?
1054 kundo2_i18n("Scale Image") :
1055 kundo2_i18n("Change Image Resolution");
1056
1057 KisProcessingApplicator::ProcessingFlags signalFlags =
1058 (resolutionChanged || sizeChanged) ?
1061
1062 KisProcessingApplicator applicator(this, m_d->rootLayer,
1064 emitSignals, actionName);
1065
1066 qreal sx = qreal(size.width()) / this->size().width();
1067 qreal sy = qreal(size.height()) / this->size().height();
1068
1069 QTransform shapesCorrection;
1070
1071 if (resolutionChanged) {
1072 shapesCorrection = QTransform::fromScale(xRes() / xres, yRes() / yres);
1073 }
1074
1075 KisProcessingVisitorSP visitor =
1077 0, 0,
1078 0,
1079 0, 0,
1080 filterStrategy,
1081 shapesCorrection);
1082
1083 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1084
1085 if (resolutionChanged) {
1088 new KisImageSetResolutionCommand(this, xres, yres, parent);
1089 applicator.applyCommand(parent);
1090 }
1091
1092 if (sizeChanged) {
1093 applicator.applyCommand(new KisImageResizeCommand(this, size));
1094 }
1095
1096 applicator.end();
1097}
@ 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 1099 of file kis_image.cc.

1100{
1101 scaleNodes(KisNodeList{node}, center, scaleX, scaleY, filterStrategy, selection);
1102}
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 1103 of file kis_image.cc.

1104{
1105 KUndo2MagicString actionName(kundo2_i18np("Scale Layer", "Scale %1 Layers", nodes.size()));
1106 KisImageSignalVector emitSignals;
1107
1108 QPointF offset;
1109 {
1110 KisTransformWorker worker(0,
1111 scaleX, scaleY,
1112 0, 0,
1113 0.0,
1114 0, 0, 0, 0);
1115 QTransform transform = worker.transform();
1116
1117 offset = center - transform.map(center);
1118 }
1119
1120 KisProcessingApplicator applicator(this, nodes,
1122 emitSignals, actionName);
1123
1125 new KisTransformProcessingVisitor(scaleX, scaleY,
1126 0, 0,
1127 0,
1128 offset.x(), offset.y(),
1129 filterStrategy);
1130
1131 visitor->setSelection(selection);
1132
1133 if (selection) {
1134 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1135 } else {
1136 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1137 }
1138
1139 applicator.end();
1140}

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

2734{
2736}

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

◆ setColorVolumeInformation()

void KisImage::setColorVolumeInformation ( const std::optional< KisColorVolumeInformation > cvi)

Set the color volume information.

Definition at line 2123 of file kis_image.cc.

2124{
2126}

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

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

1878{
1881}
void setDefaultProjectionColor(KoColor color)

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

◆ setHdrReferenceWhiteLightLevel()

void KisImage::setHdrReferenceWhiteLightLevel ( const std::optional< double > value)

Set the diffuse white light level, in cd/m²

Definition at line 2133 of file kis_image.cc.

2134{
2136 qWarning() << "Cannot set the diffuse white metadata on the image: profile provides a different inconsistent value";
2137 return;
2138 }
2139
2141}
virtual std::optional< double > hdrReferenceWhite() const =0
hdrReferenceWhite HDR reference white is only available for Perceptual Quantizer profiles that save t...

References KisImage::KisImagePrivate::colorSpace, KisImage::KisImagePrivate::diffuseWhiteLightLevel, KoColorProfile::hdrReferenceWhite(), m_d, KoColorSpace::profile(), and value().

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

2681{
2683}
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 2728 of file kis_image.cc.

2729{
2730 m_d->axesCenter = value;
2731}

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

1756{
1758 Q_EMIT sigImageModified();
1759}
@ 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 663 of file kis_image.cc.

664{
665 if (m_d->targetOverlaySelectionMask == mask) return;
666
668
669 struct UpdateOverlaySelectionStroke : public KisSimpleStrokeStrategy {
670 UpdateOverlaySelectionStroke(KisImageSP image)
671 : KisSimpleStrokeStrategy(QLatin1String("update-overlay-selection-mask"), kundo2_noi18n("update-overlay-selection-mask")),
672 m_image(image)
673 {
674 this->enableJob(JOB_INIT, true, KisStrokeJobData::BARRIER, KisStrokeJobData::EXCLUSIVE);
675 setClearsRedoOnStart(false);
676 }
677
678 void initStrokeCallback() override {
679 KisSelectionMaskSP oldMask = m_image->m_d->overlaySelectionMask;
680 KisSelectionMaskSP newMask = m_image->m_d->targetOverlaySelectionMask;
681 if (oldMask == newMask) return;
682
683 KIS_SAFE_ASSERT_RECOVER_RETURN(!newMask || static_cast<KisImage*>(newMask->graphListener()) == m_image);
684
685 m_image->m_d->overlaySelectionMask = newMask;
686
687 if (oldMask || newMask) {
688 m_image->m_d->rootLayer->notifyChildMaskChanged();
689 }
690
691 if (oldMask) {
692 const QRect oldMaskRect = oldMask->graphListener() ? oldMask->extent() : m_image->bounds();
693 m_image->m_d->rootLayer->setDirtyDontResetAnimationCache(oldMaskRect);
694 }
695
696 if (newMask) {
697 newMask->setDirty();
698 }
699
700 m_image->undoAdapter()->emitSelectionChanged();
701 }
702
703 private:
704 KisImageSP m_image;
705 };
706
707 KisStrokeId id = startStroke(new UpdateOverlaySelectionStroke(this));
708 endStroke(id);
709}
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

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

2702{
2703 const bool changed = bool(m_d->proofingConfig) != bool(proofingConfig) ||
2704 (m_d->proofingConfig && proofingConfig && *m_d->proofingConfig != *proofingConfig);
2705
2706 // we still assign even when unchanged since they can be different
2707 // shared pointer objects
2708 m_d->proofingConfig = proofingConfig;
2709
2710 if (changed) {
2711 Q_EMIT sigProofingConfigChanged();
2712 }
2713}
void sigProofingConfigChanged()

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

◆ setRelativeContentLightLevelInformation()

void KisImage::setRelativeContentLightLevelInformation ( const std::optional< KisRelativeContentLightLevelInformation > clli)

◆ setResolution()

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

Set the resolution in pixels per pt.

Definition at line 1626 of file kis_image.cc.

1627{
1628 if (xres > 0) {
1629 m_d->xres = xres;
1630 } else {
1631 qWarning() << "WARNING: Ignoring attempt to set image x resolution <= 0 (" << xres << ")!";
1632 }
1633
1634 if (yres > 0) {
1635 m_d->yres = yres;
1636 } else {
1637 qWarning() << "WARNING: Ignoring attempt to set image y resolution <= 0 (" << yres << ")!";
1638 }
1639}

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

◆ setRootLayer()

void KisImage::setRootLayer ( KisGroupLayerSP rootLayer)

Definition at line 1892 of file kis_image.cc.

1893{
1895
1897
1898 if (m_d->rootLayer) {
1900 m_d->rootLayer->setImage(0);
1901 m_d->rootLayer->disconnect();
1902
1903 KisPaintDeviceSP original = m_d->rootLayer->original();
1905 }
1906
1908 m_d->rootLayer->disconnect();
1910 m_d->rootLayer->setImage(this);
1911
1913 this->setDefaultProjectionColor(defaultProjectionColor);
1914}
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 854 of file kis_image.cc.

855{
856 m_d->width = size.width();
857 m_d->height = size.height();
858}

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

1856{
1857 disconnect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1858
1861 m_d->undoStore.reset(undoStore);
1862
1863 connect(m_d->undoStore.data(), SIGNAL(historyStateChanged()), &m_d->signalRouter, SLOT(emitImageModifiedNotification()));
1864
1865}
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 2444 of file kis_image.cc.

2445{
2447}
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 2644 of file kis_image.cc.

2645{
2647}

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

2621{
2624 }
2625
2627
2630
2631 KisProcessingApplicator applicator(this, root(),
2634 kundo2_i18n("Crop Selections"));
2635
2636 KisProcessingVisitorSP visitor =
2638
2639 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
2640 applicator.end();
2641 }
2642}
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 1367 of file kis_image.cc.

1368{
1369 shearImpl(kundo2_i18n("Shear Image"), m_d->rootLayer, true,
1370 angleX, angleY, 0);
1371}
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 1269 of file kis_image.cc.

1274{
1275 QRect baseBounds;
1276 if (resizeImage) {
1277 baseBounds = bounds();
1278 }
1279 else if (selection) {
1280 baseBounds = selection->selectedExactRect();
1281 }
1282 else {
1283 Q_FOREACH(KisNodeSP node, nodes) {
1284 baseBounds = baseBounds.united(node->exactBounds());
1285 }
1286 }
1287 const QPointF origin = QRectF(baseBounds).center();
1288
1289 //angleX, angleY are in degrees
1290 const qreal pi = 3.1415926535897932385;
1291 const qreal deg2rad = pi / 180.0;
1292
1293 qreal tanX = tan(angleX * deg2rad);
1294 qreal tanY = tan(angleY * deg2rad);
1295
1296 QPointF offset;
1297 QSize newSize;
1298
1299 {
1300 KisTransformWorker worker(0,
1301 1.0, 1.0,
1302 tanX, tanY,
1303 0,
1304 0, 0, 0, 0);
1305
1306 QRect newRect = worker.transform().mapRect(baseBounds);
1307 newSize = newRect.size();
1308 if (resizeImage) offset = -newRect.topLeft();
1309 else offset = origin - worker.transform().map(origin);
1310 }
1311
1312 if (newSize == baseBounds.size()) return;
1313
1314 KisImageSignalVector emitSignals;
1315 if (resizeImage) emitSignals << ComplexSizeChangedSignal(baseBounds, newSize);
1316
1317 KisProcessingApplicator::ProcessingFlags signalFlags =
1320
1321 KisProcessingApplicator applicator(this, nodes,
1322 signalFlags,
1323 emitSignals, actionName);
1324
1326
1328 new KisTransformProcessingVisitor(1.0, 1.0,
1329 tanX, tanY,
1330 0,
1331 offset.x(), offset.y(),
1332 filter);
1333
1334 if (selection) {
1335 visitor->setSelection(selection);
1336 }
1337
1338 if (selection) {
1339 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
1340 } else {
1341 applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::CONCURRENT);
1342 }
1343
1344 if (resizeImage) {
1345 applicator.applyCommand(new KisImageResizeCommand(this, newSize));
1346 }
1347
1348 applicator.end();
1349}

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

1266{
1267 shearImpl(actionName, KisNodeList{rootNode}, resizeImage, angleX, angleY, selection);
1268}

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

1352{
1353 shearNodes(KisNodeList{node}, angleX, angleY, selection);
1354}
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 1355 of file kis_image.cc.

1356{
1357 if (nodes.size() == 1 && nodes[0]->inherits("KisMask")) {
1358 shearImpl(kundo2_i18n("Shear Mask"), nodes, false,
1359 angleX, angleY, selection);
1360 }
1361 else {
1362 shearImpl(kundo2_i18np("Shear Layer", "Shear %1 Layers", nodes.size()), nodes, false,
1363 angleX, angleY, selection);
1364 }
1365}

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

1976{
1977 return &m_d->signalRouter;
1978}

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 550 of file kis_image.h.

550 {
551 return QSize(width(), height());
552 }

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

2021{
2022 m_d->isolateLayer = isolateLayer;
2023 m_d->isolateGroup = isolateGroup;
2024 if ((isolateLayer || isolateGroup) == false) return false;
2025
2030 if (!node->projection()) return false;
2031
2032 struct StartIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
2033 StartIsolatedModeStroke(KisNodeSP node, KisImageSP image, bool isolateLayer, bool isolateGroup)
2034 : KisRunnableBasedStrokeStrategy(QLatin1String("start-isolated-mode"),
2035 kundo2_noi18n("start-isolated-mode")),
2036 m_newRoot(node),
2037 m_image(image),
2038 m_isolateLayer(isolateLayer),
2039 m_isolateGroup(isolateGroup)
2040 {
2041 this->enableJob(JOB_INIT, true, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::EXCLUSIVE);
2042 this->enableJob(JOB_DOSTROKE, true);
2043 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
2044 setClearsRedoOnStart(false);
2045 }
2046
2047 void initStrokeCallback() override {
2048 if (m_isolateLayer == false && m_isolateGroup == true) {
2049 // Isolate parent node unless node is the root note.
2050 m_newRoot = m_newRoot->parent() ? m_newRoot->parent() : m_newRoot;
2051 }
2052 // pass-though node don't have any projection prepared, so we should
2053 // explicitly regenerate it before activating isolated mode.
2054 m_newRoot->projectionLeaf()->explicitlyRegeneratePassThroughProjection();
2055 m_prevRoot = m_image->m_d->isolationRootNode;
2056
2057 const bool beforeVisibility = m_newRoot->projectionLeaf()->visible();
2058 const bool prevRootBeforeVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
2059
2060 m_image->m_d->isolationRootNode = m_newRoot;
2061 Q_EMIT m_image->sigIsolatedModeChanged();
2062
2063 const bool afterVisibility = m_newRoot->projectionLeaf()->visible();
2064 const bool prevRootAfterVisibility = m_prevRoot ? m_prevRoot->projectionLeaf()->visible() : false;
2065
2066 m_newRootNeedsFullRefresh = beforeVisibility != afterVisibility;
2067 m_prevRootNeedsFullRefresh = prevRootBeforeVisibility != prevRootAfterVisibility;
2068 }
2069
2070 void finishStrokeCallback() override {
2071 // the GUI uses our thread to do the color space conversion so we
2072 // need to Q_EMIT this signal in multiple threads
2073
2074 if (m_prevRoot && m_prevRootNeedsFullRefresh) {
2075 m_image->refreshGraphAsync(m_prevRoot);
2076 }
2077
2078 if (m_newRootNeedsFullRefresh) {
2079 m_image->refreshGraphAsync(m_newRoot);
2080 }
2081
2082 if (!m_prevRootNeedsFullRefresh && !m_newRootNeedsFullRefresh) {
2084 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2085 this->runnableJobsInterface()->addRunnableJobs(jobs);
2086 }
2087
2088 m_image->invalidateAllFrames();
2089 }
2090
2091 private:
2092 KisNodeSP m_newRoot;
2093 KisNodeSP m_prevRoot;
2094 KisImageSP m_image;
2095 bool m_newRootNeedsFullRefresh = false;
2096 bool m_prevRootNeedsFullRefresh = false;
2097
2098 bool m_isolateLayer;
2099 bool m_isolateGroup;
2100 };
2101
2102 KisStrokeId id = startStroke(new StartIsolatedModeStroke(node, this, isolateLayer, isolateGroup));
2103 endStroke(id);
2104
2105 return true;
2106}

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

1989{
1997 if (strokeStrategy->requestsOtherStrokesToEnd()) {
1999 }
2000
2001 return m_d->scheduler.startStroke(strokeStrategy);
2002}
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 2143 of file kis_image.cc.

2144{
2145 if (!m_d->isolationRootNode) return;
2146
2147 struct StopIsolatedModeStroke : public KisRunnableBasedStrokeStrategy {
2148 StopIsolatedModeStroke(KisImageSP image)
2149 : KisRunnableBasedStrokeStrategy(QLatin1String("stop-isolated-mode"), kundo2_noi18n("stop-isolated-mode")),
2150 m_image(image),
2151 m_oldRootNode(nullptr),
2152 m_oldNodeNeedsRefresh(false)
2153 {
2154 this->enableJob(JOB_INIT);
2155 this->enableJob(JOB_DOSTROKE, true);
2156 this->enableJob(JOB_FINISH, true, KisStrokeJobData::BARRIER);
2157 setClearsRedoOnStart(false);
2158 }
2159
2160 void initStrokeCallback() override {
2161 if (!m_image->m_d->isolationRootNode) return;
2162
2163 m_oldRootNode = m_image->m_d->isolationRootNode;
2164
2165 const bool beforeVisibility = m_oldRootNode->projectionLeaf()->visible();
2166 m_image->m_d->isolationRootNode = 0;
2167 m_image->m_d->isolateLayer = false;
2168 m_image->m_d->isolateGroup = false;
2169 Q_EMIT m_image->sigIsolatedModeChanged();
2170 const bool afterVisibility = m_oldRootNode->projectionLeaf()->visible();
2171
2172 m_oldNodeNeedsRefresh = (beforeVisibility != afterVisibility);
2173 }
2174
2175 void finishStrokeCallback() override {
2176
2177 m_image->invalidateAllFrames();
2178
2179 if (m_oldNodeNeedsRefresh){
2180 m_oldRootNode->setDirty(m_image->bounds());
2181 } else {
2182 // TODO: Substitute notifyProjectionUpdated() with this code
2183 // when update optimization is implemented
2184 //
2185 // QRect updateRect = bounds() | oldRootNode->extent();
2186 //oldRootNode->setDirty(updateRect);
2187
2189 m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds(), jobs);
2190 this->runnableJobsInterface()->addRunnableJobs(jobs);
2191 }
2192 }
2193
2194 private:
2195 KisImageSP m_image;
2196 KisNodeSP m_oldRootNode;
2197 bool m_oldNodeNeedsRefresh;
2198 };
2199
2200 KisStrokeId id = startStroke(new StopIsolatedModeStroke(this));
2201 endStroke(id);
2202}

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

798{
799 bool result = true;
800
801 if (!locked()) {
802 result = m_d->scheduler.tryBarrierLock();
803 m_d->lockedForReadOnly = readOnly;
804 }
805
806 if (result) {
807 m_d->lockCount++;
808 m_d->lockedForReadOnly &= readOnly;
809 }
810
811 return result;
812}

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

2257{
2259}

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

1873{
1874 return &m_d->legacyUndoAdapter;
1875}

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

◆ undoStore()

KisUndoStore * KisImage::undoStore ( )

Return current undo store of the image

Definition at line 1867 of file kis_image.cc.

1868{
1869 return m_d->undoStore.data();
1870}

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

1490{
1491 const KUndo2MagicString actionName = kundo2_i18n("Unify Layers Color Space");
1492
1493 KisImageSignalVector emitSignals;
1494
1495 KisProcessingApplicator::ProcessingFlags flags =
1497
1498 KisProcessingApplicator applicator(this, m_d->rootLayer,
1499 flags,
1500 emitSignals, actionName);
1501
1502 // src and dst color spaces coincide, since we should just unify
1503 // all our layers
1504 applicator.applyVisitor(
1510
1511 applicator.end();
1512}

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

832{
833 Q_ASSERT(locked());
834
835 if (locked()) {
836 m_d->lockCount--;
837
838 if (m_d->lockCount == 0) {
840 }
841 }
842}
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 1980 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 1672 of file kis_image.cc.

1673{
1674 return m_d->width;
1675}

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

2450{
2451 return m_d->scheduler.threadsLimit();
2452}

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

2661{
2662 return m_d->wrapAroundModePermitted &&
2664}

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

2650{
2651 return m_d->wrapAroundModeAxis;
2652}

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

2656{
2658}

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

◆ xRes()

double KisImage::xRes ( ) const

X resolution in pixels per pt

Definition at line 1616 of file kis_image.cc.

1617{
1618 return m_d->xres;
1619}

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

◆ yRes()

double KisImage::yRes ( ) const

Y resolution in pixels per pt

Definition at line 1621 of file kis_image.cc.

1622{
1623 return m_d->yres;
1624}

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

Friends And Related Symbol Documentation

◆ KisImageGlobalSelectionManagementInterface

Definition at line 1308 of file kis_image.h.

◆ KisImageResizeCommand

friend class KisImageResizeCommand
friend

Definition at line 1303 of file kis_image.h.

Member Data Documentation

◆ m_d

KisImagePrivate* KisImage::m_d
private

Definition at line 1312 of file kis_image.h.


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