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< Privatem_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 63 of file KisImageResolutionProxy.cpp.

◆ KisImageResolutionProxy() [2/3]

KisImageResolutionProxy::KisImageResolutionProxy ( KisImageWSP image)

Definition at line 68 of file KisImageResolutionProxy.cpp.

69 : m_d(new Private(image))
70{
71}
QScopedPointer< Private > m_d

◆ KisImageResolutionProxy() [3/3]

KisImageResolutionProxy::KisImageResolutionProxy ( const KisImageResolutionProxy & rhs)

Definition at line 73 of file KisImageResolutionProxy.cpp.

74 : QObject(nullptr)
75 , m_d(new Private(*rhs.m_d))
76{
77}

◆ ~KisImageResolutionProxy()

KisImageResolutionProxy::~KisImageResolutionProxy ( )

Definition at line 79 of file KisImageResolutionProxy.cpp.

80{
81}

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 100 of file KisImageResolutionProxy.cpp.

101{
103 proxy->m_d->setImage(nullptr);
104 return proxy;
105}

References KisImageResolutionProxy().

◆ compareResolution()

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

Compare resolution of (*this) and rhs

Definition at line 93 of file KisImageResolutionProxy.cpp.

94{
95 return qFuzzyCompare(xRes(), rhs.xRes()) &&
96 qFuzzyCompare(yRes(), rhs.yRes());
97
98}
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 107 of file KisImageResolutionProxy.cpp.

108{
109 return image ? toQShared(new KisImageResolutionProxy(image)) : cloneDetached();
110}
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 112 of file KisImageResolutionProxy.cpp.

113{
114 return s_holder->identity;
115}
QScopedPointer< AutoKeyFrameStateHolder > s_holder

◆ xRes()

qreal KisImageResolutionProxy::xRes ( ) const

Definition at line 83 of file KisImageResolutionProxy.cpp.

84{
85 return m_d->image ? m_d->image->xRes() : m_d->lastKnownXRes;
86}

References m_d.

◆ yRes()

qreal KisImageResolutionProxy::yRes ( ) const

Definition at line 88 of file KisImageResolutionProxy.cpp.

89{
90 return m_d->image ? m_d->image->yRes() : m_d->lastKnownYRes;
91}

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: