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

#include <KisImageResolutionProxy.h>

+ Inheritance diagram for KisImageResolutionProxy:

Classes

struct  Private
 

Public Member Functions

KisImageResolutionProxySP cloneDetached () const
 
bool compareResolution (const KisImageResolutionProxy &rhs) const
 
KisImageResolutionProxySP createOrCloneDetached (KisImageWSP image) const
 
 KisImageResolutionProxy ()
 
 KisImageResolutionProxy (const KisImageResolutionProxy &rhs)
 
 KisImageResolutionProxy (KisImageWSP image)
 
qreal xRes () const
 
qreal yRes () const
 
 ~KisImageResolutionProxy ()
 

Static Public Member Functions

static KisImageResolutionProxySP identity ()
 

Private Attributes

QScopedPointer< Private > m_d
 

Detailed Description

KisImageResolutionProxy is a simple interface class that keeps a link to the resolution of KisImage. When KisImage is destroyed, the proxy still stores the "last known" image resolution and returns that to the user.

The proxy may also be in a detached state, that is, unconnected to any image. Then is stored the "last known image resolution value".

Definition at line 29 of file KisImageResolutionProxy.h.

Constructor & Destructor Documentation

◆ KisImageResolutionProxy() [1/3]

KisImageResolutionProxy::KisImageResolutionProxy ( )

Definition at line 66 of file KisImageResolutionProxy.cpp.

◆ KisImageResolutionProxy() [2/3]

KisImageResolutionProxy::KisImageResolutionProxy ( KisImageWSP image)

Definition at line 71 of file KisImageResolutionProxy.cpp.

72 : m_d(new Private(image, this))
73{
74}
QScopedPointer< Private > m_d

◆ KisImageResolutionProxy() [3/3]

KisImageResolutionProxy::KisImageResolutionProxy ( const KisImageResolutionProxy & rhs)

Definition at line 76 of file KisImageResolutionProxy.cpp.

77 : QObject(nullptr)
78 , m_d(new Private(*rhs.m_d, this))
79{
80}

◆ ~KisImageResolutionProxy()

KisImageResolutionProxy::~KisImageResolutionProxy ( )

Definition at line 82 of file KisImageResolutionProxy.cpp.

83{
84}

Member Function Documentation

◆ cloneDetached()

KisImageResolutionProxySP KisImageResolutionProxy::cloneDetached ( ) const

Returns a copy of this proxy that stores the same resolution, but is detached from the image. That is, when the image changes its resolution any time in the future, this proxy will no react on that.

Definition at line 103 of file KisImageResolutionProxy.cpp.

104{
106 proxy->m_d->setImage(nullptr);
107 return proxy;
108}

References KisImageResolutionProxy().

◆ compareResolution()

bool KisImageResolutionProxy::compareResolution ( const KisImageResolutionProxy & rhs) const

Compare resolution of (*this) and rhs

Definition at line 96 of file KisImageResolutionProxy.cpp.

97{
98 return qFuzzyCompare(xRes(), rhs.xRes()) &&
99 qFuzzyCompare(yRes(), rhs.yRes());
100
101}
static bool qFuzzyCompare(half p1, half p2)

References qFuzzyCompare(), xRes(), and yRes().

◆ createOrCloneDetached()

KisImageResolutionProxySP KisImageResolutionProxy::createOrCloneDetached ( KisImageWSP image) const

Helper function that checks if the passed image is not null and creates a resolution proxy for that. If the passed image is null, then a detached clone of (*this) is returned.

The function is used in layers, when they are detached from the image (layer->setImage(nullptr)). In such a case it is useful to keep the old resolution stored in a detached proxy, other than resetting it to default. It allows avoiding unnecessary updates.

Definition at line 110 of file KisImageResolutionProxy.cpp.

111{
112 return image ? toQShared(new KisImageResolutionProxy(image)) : cloneDetached();
113}
KisImageResolutionProxySP cloneDetached() const
QSharedPointer< T > toQShared(T *ptr)

References cloneDetached(), KisImageResolutionProxy(), and toQShared().

◆ identity()

KisImageResolutionProxySP KisImageResolutionProxy::identity ( )
static

Return an identity resolution proxy that returns 1.0 for both, xRes() and yRes(). Used as a fallback proxy mostly.

Definition at line 115 of file KisImageResolutionProxy.cpp.

116{
117 return s_holder->identity;
118}
QScopedPointer< AutoKeyFrameStateHolder > s_holder

◆ xRes()

qreal KisImageResolutionProxy::xRes ( ) const

Definition at line 86 of file KisImageResolutionProxy.cpp.

87{
88 return m_d->image ? m_d->image->xRes() : m_d->lastKnownXRes;
89}

References m_d.

◆ yRes()

qreal KisImageResolutionProxy::yRes ( ) const

Definition at line 91 of file KisImageResolutionProxy.cpp.

92{
93 return m_d->image ? m_d->image->yRes() : m_d->lastKnownYRes;
94}

References m_d.

Member Data Documentation

◆ m_d

QScopedPointer<Private> KisImageResolutionProxy::m_d
private

Definition at line 77 of file KisImageResolutionProxy.h.


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