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

#include <kis_image.h>

+ Inheritance diagram for KisImage:

Classes

class  KisImagePrivate
 

Public Slots

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

Signals

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

Public Member Functions

void aboutToAddANode (KisNode *parent, int index) override
 
void aboutToRemoveANode (KisNode *parent, int index) override
 
void addAnnotation (KisAnnotationSP annotation)
 
void addComposition (KisLayerCompositionSP composition)
 
void addJob (KisStrokeId id, KisStrokeJobData *data) override
 
KisProjectionUpdatesFilterCookie addProjectionUpdatesFilter (KisProjectionUpdatesFilterSP filter) override
 
void addSpontaneousJob (KisSpontaneousJob *spontaneousJob)
 
bool allowMasksOnRootNode () const
 
KisImageAnimationInterfaceanimationInterface () const
 
KisAnnotationSP annotation (const QString &type)
 
bool assignImageProfile (const KoColorProfile *profile, bool blockAllUpdates=false)
 
bool assignLayerProfile (KisNodeSP node, const KoColorProfile *profile)
 
void barrierLock (bool readOnly=false)
 Wait until all the queued background jobs are completed and lock the image.
 
vKisAnnotationSP_it beginAnnotations ()
 
void blockUpdates () override
 blockUpdates block updating the image projection
 
QRect bounds () const override
 
bool cancelStroke (KisStrokeId id) override
 
bool canReselectGlobalSelection ()
 
KisImageclone (bool exactCopy=false)
 
const KoColorSpacecolorSpace () const
 
std::optional< KisColorVolumeInformationcolorVolumeInformation () const
 colorVolumeInformation
 
KisCompositeProgressProxycompositeProgressProxy ()
 
QList< KisLayerCompositionSPcompositions ()
 
void convertImageColorSpace (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
 
void convertImageProjectionColorSpace (const KoColorSpace *dstColorSpace)
 
void convertLayerColorSpace (KisNodeSP node, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
 
QImage convertToQImage (const QSize &scaledImageSize, const KoColorProfile *profile)
 
QImage convertToQImage (qint32 x1, qint32 y1, qint32 width, qint32 height, const KoColorProfile *profile)
 
QImage convertToQImage (QRect imageRect, const KoColorProfile *profile)
 
void copyFromImage (const KisImage &rhs)
 
void cropImage (const QRect &newRect)
 start asynchronous operation on cropping the image
 
void cropNode (KisNodeSP node, const QRect &newRect, const bool activeFrameOnly=false)
 start asynchronous operation on cropping a subtree of nodes starting at node
 
void cropNodes (KisNodeList nodes, const QRect &newRect, const bool activeFrameOnly=false)
 
int currentLevelOfDetail () const
 
KisProjectionUpdatesFilterCookie currentProjectionUpdatesFilter () const override
 
KoColor defaultProjectionColor () const
 
void disableDirtyRequests () override
 
void disableUIUpdates () override
 
QPoint documentToImagePixelFloored (const QPointF &documentCoord) const
 
QPointF documentToPixel (const QPointF &documentCoord) const
 
QRectF documentToPixel (const QRectF &documentRect) const
 
QRect effectiveLodBounds () const
 
void enableDirtyRequests () override
 
QVector< QRect > enableUIUpdates () override
 
vKisAnnotationSP_it endAnnotations ()
 
void endStroke (KisStrokeId id) override
 
void flatten (KisNodeSP activeNode)
 
void flattenLayer (KisLayerSP layer)
 
KisSelectionSP globalSelection () const
 
KisNodegraphOverlayNode () const override
 
bool hasOverlaySelectionMask () const
 
bool hasUpdatesRunning () const override
 
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 KUndo2CommandlastExecutedCommand () const override
 
bool locked () const
 
KisLodPreferences lodPreferences () const
 
void mergeDown (KisLayerSP l, const KisMetaData::MergeStrategy *strategy)
 
void mergeMultipleLayers (QList< KisNodeSP > mergedLayers, KisNodeSP putAfter)
 
QPointF mirrorAxesCenter () const
 
void moveCompositionDown (KisLayerCompositionSP composition)
 
void moveCompositionUp (KisLayerCompositionSP composition)
 
qint32 nChildLayers () const
 
QString nextLayerName (const QString &baseName="") const
 
qint32 nHiddenLayers () const
 
qint32 nlayers () const
 
void nodeChanged (KisNode *node) override
 
void nodeCollapsedChanged (KisNode *node) override
 
void nodeHasBeenAdded (KisNode *parent, int index, KisNodeAdditionFlags flags) override
 
void notifyAboutToBeDeleted ()
 
void notifyBatchUpdateEnded () override
 
void notifyBatchUpdateStarted () override
 
void notifyLayersChanged ()
 use if the layers have changed completely (eg. when flattening)
 
void notifyProjectionUpdated (const QRect &rc) override
 
void notifySelectionChanged () override
 
void notifyUIUpdateCompleted (const QRect &rc) override
 
KisSelectionMaskSP overlaySelectionMask () const
 
QPointF pixelToDocument (const QPoint &pixelCoord) const
 
QPointF pixelToDocument (const QPointF &pixelCoord) const
 
QRectF pixelToDocument (const QRectF &pixelCoord) const
 
KisPostExecutionUndoAdapterpostExecutionUndoAdapter () const override
 
const KoColorProfileprofile () const
 
KisPaintDeviceSP projection () const
 
KisProofingConfigurationSP proofingConfiguration () const
 proofingConfiguration
 
void purgeUnusedData (bool isCancellable)
 purge all pixels that have default pixel to free up memory
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
virtual void refreshGraphAsync (KisNodeSP root, const QVector< QRect > &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)=0
 
void refreshGraphAsync (KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
 
void refreshGraphAsync (KisNodeSP root=nullptr, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
std::optional< KisRelativeContentLightLevelInformationrelativeContentLightLevelInformation () 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)
 
KisImageSignalRoutersignalRouter ()
 
QSize size () const
 
bool startIsolatedMode (KisNodeSP node, bool isolateLayer, bool isolateGroup)
 
KisStrokeId startStroke (KisStrokeStrategy *strokeStrategy) override
 
bool tryBarrierLock (bool readOnly=false)
 Tries to lock the image without waiting for the jobs to finish.
 
void unblockUpdates () override
 unblockUpdates unblock updating the image project. This only restarts the scheduler and does not schedule a full refresh.
 
KisUndoAdapterundoAdapter () const
 
KisUndoStoreundoStore ()
 
void unifyLayersColorSpace ()
 
void unlock ()
 
void waitForDone ()
 
qint32 width () const
 
int workingThreadsLimit () const
 
bool wrapAroundModeActive () const
 
WrapAroundAxis wrapAroundModeAxis () const
 
bool wrapAroundModePermitted () const
 
double xRes () const
 
double yRes () const
 
 ~KisImage () override
 
- Public Member Functions inherited from KisStrokesFacade
virtual ~KisStrokesFacade ()
 
- Public Member Functions inherited from KisStrokeUndoFacade
virtual ~KisStrokeUndoFacade ()
 
- Public Member Functions inherited from KisUpdatesFacade
void refreshGraphAsync (KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
void refreshGraphAsync (KisNodeSP root=nullptr, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None)
 
virtual ~KisUpdatesFacade ()
 
- Public Member Functions inherited from KisProjectionUpdateListener
virtual ~KisProjectionUpdateListener ()
 
- Public Member Functions inherited from KisNodeFacade
bool addNode (KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis, KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
bool addNode (KisNodeSP node, KisNodeSP parent, quint32 index, KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
bool addNode (KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
 KisNodeFacade ()
 
 KisNodeFacade (KisNodeSP root)
 
bool moveNode (KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis)
 
bool moveNode (KisNodeSP node, KisNodeSP parent, quint32 index)
 
bool removeNode (KisNodeSP node)
 
const KisNodeSP root () const
 
void setRoot (KisNodeSP root)
 
virtual ~KisNodeFacade ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisNodeGraphListener
virtual void aboutToMoveNode (KisNode *node, int oldIndex, int newIndex)
 
int graphSequenceNumber () const
 
 KisNodeGraphListener ()
 
virtual void nodeHasBeenMoved (KisNode *node, int oldIndex, int newIndex)
 
virtual void nodeHasBeenRemoved (KisNode *parent, int index)
 
 Private ()
 
virtual ~KisNodeGraphListener ()
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

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

Private Types

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

Private Member Functions

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

Private Attributes

KisImagePrivatem_d
 

Friends

class KisImageGlobalSelectionManagementInterface
 
class KisImageResizeCommand
 

Additional Inherited Members

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

Detailed Description

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

Definition at line 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 disconnect(); // in case Qt gets confused
362}
void waitForDone()

References m_d, and waitForDone().

◆ KisImage() [2/2]

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

Definition at line 592 of file kis_image.cc.

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

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

610{
612 SANITY_CHECK_LOCKED("aboutToAddANode");
613}
#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 631 of file kis_image.cc.

632{
633 KisNodeSP deletedNode = parent->at(index);
634 if (!dynamic_cast<KisSelectionMask*>(deletedNode.data()) &&
635 deletedNode == m_d->isolationRootNode) {
636
638 }
639
641 QMap<QString, KisKeyframeChannel*> chans = node->keyframeChannels();
642 Q_FOREACH(KisKeyframeChannel* chan, chans.values()) {
643 this->keyframeChannelAboutToBeRemoved(node.data(), chan);
644 }
645 });
646
648
649 SANITY_CHECK_LOCKED("aboutToRemoveANode");
651}
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 1917 of file kis_image.cc.

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

2571{
2572 m_d->compositions.append(composition);
2573}
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 2219 of file kis_image.cc.

2220{
2222 m_d->scheduler.addJob(id, data);
2223}
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 2352 of file kis_image.cc.

2353{
2355
2356 m_d->projectionUpdatesFilters.append(filter);
2357
2358 return KisProjectionUpdatesFilterCookie(filter.data());
2359}
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 2342 of file kis_image.cc.

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

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

◆ allowMasksOnRootNode()

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

Definition at line 2739 of file kis_image.cc.

2740{
2741 return m_d->allowMasksOnRootNode;
2742}

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

◆ animationInterface()

KisImageAnimationInterface * KisImage::animationInterface ( ) const

Definition at line 2697 of file kis_image.cc.

2698{
2699 return m_d->animationInterface;
2700}
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 1933 of file kis_image.cc.

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

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

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

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

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

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

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

◆ blockUpdates()

void KisImage::blockUpdates ( )
overridevirtual

blockUpdates block updating the image projection

Implements KisUpdatesFacade.

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

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

References height(), and width().

◆ cancelStroke()

bool KisImage::cancelStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2230 of file kis_image.cc.

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

733{
735}
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 428 of file kis_image.cc.

429{
430 return new KisImage(*this, 0, exactCopy);
431}
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 1607 of file kis_image.cc.

1608{
1609 return m_d->colorSpace;
1610}

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

2120{
2122}
std::optional< KisColorVolumeInformation > colorVolumeInformation
Definition kis_image.cc:285

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

◆ compositeProgressProxy()

KisCompositeProgressProxy * KisImage::compositeProgressProxy ( )

Definition at line 773 of file kis_image.cc.

774{
776}
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 2565 of file kis_image.cc.

2566{
2567 return m_d->compositions;
2568}

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

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

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

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

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

References convertToQImage(), and profile().

◆ copyFromImage()

void KisImage::copyFromImage ( const KisImage & rhs)

Definition at line 433 of file kis_image.cc.

434{
436}

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

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

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

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

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

2668{
2670}

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

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

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

◆ defaultProjectionColor()

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

Definition at line 1884 of file kis_image.cc.

1885{
1888 }
1889
1891}
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 2383 of file kis_image.cc.

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

2396{
2398}

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

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

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

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

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

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

2390{
2393}
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 2415 of file kis_image.cc.

2416{
2417 m_d->disableUIUpdateSignals.deref();
2418
2419 QRect rect;
2420 QVector<QRect> postponedUpdates;
2421
2422 while (m_d->savedDisabledUIUpdates.pop(rect)) {
2423 postponedUpdates.append(rect);
2424 }
2425
2426 return postponedUpdates;
2427}
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 1966 of file kis_image.cc.

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

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

◆ endStroke()

void KisImage::endStroke ( KisStrokeId id)
overridevirtual

Implements KisStrokesFacade.

Definition at line 2225 of file kis_image.cc.

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

2673{
2675
2676 if (pref.lodSupported() && pref.lodPreferred()) {
2678 }
2679}
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 1736 of file kis_image.cc.

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

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

References KisLayerUtils::flattenLayer().

◆ fromQImage()

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

Definition at line 364 of file kis_image.cc.

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

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

738{
740}
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 2544 of file kis_image.cc.

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

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

◆ hasOverlaySelectionMask()

bool KisImage::hasOverlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 717 of file kis_image.cc.

718{
720}

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

2348{
2350}

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

2130{
2132}

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

◆ height()

qint32 KisImage::height ( ) const

Return the height of the image

Definition at line 1678 of file kis_image.cc.

1679{
1680 return m_d->height;
1681}

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

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

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

2535{
2537}
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 815 of file kis_image.cc.

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

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

◆ isIsolatingGroup()

bool KisImage::isIsolatingGroup ( ) const

Definition at line 2214 of file kis_image.cc.

2215{
2216 return m_d->isolateGroup;
2217}

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

◆ isIsolatingLayer()

bool KisImage::isIsolatingLayer ( ) const

Definition at line 2209 of file kis_image.cc.

2210{
2211 return m_d->isolateLayer;
2212}

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

◆ isolationRootNode()

KisNodeSP KisImage::isolationRootNode ( ) const

Definition at line 2205 of file kis_image.cc.

2205 {
2206 return m_d->isolationRootNode;
2207}

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

◆ keyframeChannelAboutToBeRemoved()

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

Reimplemented from KisNodeGraphListener.

Definition at line 2557 of file kis_image.cc.

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

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

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

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

1852{
1853 return m_d->undoStore->presentCommand();
1854}
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 778 of file kis_image.cc.

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

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

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

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

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

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

2725{
2726 return m_d->axesCenter;
2727}

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

◆ moveCompositionDown()

void KisImage::moveCompositionDown ( KisLayerCompositionSP composition)

Move a composition down in the composition list

Definition at line 2589 of file kis_image.cc.

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

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

◆ moveCompositionUp()

void KisImage::moveCompositionUp ( KisLayerCompositionSP composition)

Move a composition up in the composition list

Definition at line 2580 of file kis_image.cc.

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

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

◆ nChildLayers()

qint32 KisImage::nChildLayers ( ) const

Definition at line 1723 of file kis_image.cc.

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

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

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

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

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

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

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

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

1972{
1973 Q_EMIT sigAboutToBeDeleted();
1974}
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 2405 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 2400 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 1820 of file kis_image.cc.

1821{
1823}
@ 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 2429 of file kis_image.cc.

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

2456{
2463
2469 if (m_d->isolationRootNode &&
2470 dynamic_cast<KisSelectionMask*>(m_d->isolationRootNode.data())) {
2471
2473 }
2474}
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 2410 of file kis_image.cc.

2411{
2413}

References notifyProjectionUpdated().

◆ operator=()

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

◆ overlaySelectionMask()

KisSelectionMaskSP KisImage::overlaySelectionMask ( ) const
See also
setOverlaySelectionMask

Definition at line 712 of file kis_image.cc.

713{
715}

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

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

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

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

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

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

1844{
1845 const int lod = currentLevelOfDetail();
1846 return lod > 0 ?
1849}
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 1612 of file kis_image.cc.

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

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

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

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

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

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

2110{
2112}

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

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

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

◆ removeComposition()

void KisImage::removeComposition ( KisLayerCompositionSP composition)

Remove the layer composition

Definition at line 2575 of file kis_image.cc.

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

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

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

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

2246{
2248}
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 2250 of file kis_image.cc.

2251{
2254 }
2255}
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 2262 of file kis_image.cc.

2263{
2264 Q_EMIT sigStrokeEndRequested();
2266}
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 2268 of file kis_image.cc.

2269{
2270 Q_EMIT sigStrokeEndRequested();
2271}

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

2241{
2243}
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 892 of file kis_image.cc.

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

References resizeImageImpl().

◆ resizeImageImpl()

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

Definition at line 861 of file kis_image.cc.

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

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

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

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

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

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

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

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

References rotateNodes().

◆ rotateNodes()

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

Definition at line 1252 of file kis_image.cc.

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

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

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

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

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

2735{
2737}

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

2125{
2127}

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

1879{
1882}
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 2134 of file kis_image.cc.

2135{
2137 qWarning() << "Cannot set the diffuse white metadata on the image: profile provides a different inconsistent value";
2138 return;
2139 }
2140
2142}
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 2681 of file kis_image.cc.

2682{
2684}
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 2729 of file kis_image.cc.

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

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

1757{
1759 Q_EMIT sigImageModified();
1760}
@ 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 664 of file kis_image.cc.

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

2703{
2704 const bool changed = bool(m_d->proofingConfig) != bool(proofingConfig) ||
2705 (m_d->proofingConfig && proofingConfig && *m_d->proofingConfig != *proofingConfig);
2706
2707 // we still assign even when unchanged since they can be different
2708 // shared pointer objects
2709 m_d->proofingConfig = proofingConfig;
2710
2711 if (changed) {
2712 Q_EMIT sigProofingConfigChanged();
2713 }
2714}
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 1627 of file kis_image.cc.

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

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

◆ setRootLayer()

void KisImage::setRootLayer ( KisGroupLayerSP rootLayer)

Definition at line 1893 of file kis_image.cc.

1894{
1896
1898
1899 if (m_d->rootLayer) {
1901 m_d->rootLayer->setImage(0);
1902 m_d->rootLayer->disconnect();
1903
1904 KisPaintDeviceSP original = m_d->rootLayer->original();
1906 }
1907
1909 m_d->rootLayer->disconnect();
1911 m_d->rootLayer->setImage(this);
1912
1914 this->setDefaultProjectionColor(defaultProjectionColor);
1915}
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 855 of file kis_image.cc.

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

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

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

2446{
2448}
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 2645 of file kis_image.cc.

2646{
2648}

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

2622{
2625 }
2626
2628
2631
2632 KisProcessingApplicator applicator(this, root(),
2635 kundo2_i18n("Crop Selections"));
2636
2637 KisProcessingVisitorSP visitor =
2639
2640 applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT);
2641 applicator.end();
2642 }
2643}
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 1368 of file kis_image.cc.

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

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

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

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

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

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

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

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

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

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

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

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

1990{
1998 if (strokeStrategy->requestsOtherStrokesToEnd()) {
2000 }
2001
2002 return m_d->scheduler.startStroke(strokeStrategy);
2003}
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 2144 of file kis_image.cc.

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

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

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

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

2258{
2260}

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

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

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

◆ undoStore()

KisUndoStore * KisImage::undoStore ( )

Return current undo store of the image

Definition at line 1868 of file kis_image.cc.

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

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

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

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

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

1674{
1675 return m_d->width;
1676}

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

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

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

2662{
2663 return m_d->wrapAroundModePermitted &&
2665}

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

2651{
2652 return m_d->wrapAroundModeAxis;
2653}

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

2657{
2659}

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

◆ xRes()

double KisImage::xRes ( ) const

X resolution in pixels per pt

Definition at line 1617 of file kis_image.cc.

1618{
1619 return m_d->xres;
1620}

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

◆ yRes()

double KisImage::yRes ( ) const

Y resolution in pixels per pt

Definition at line 1622 of file kis_image.cc.

1623{
1624 return m_d->yres;
1625}

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: