digiKam
Digikam::ImageZoomSettings Class Reference

Public Types

enum  FitToSizeMode { AlwaysFit , OnlyScaleDown }
 

Public Member Functions

void fitToSize (const QSizeF &frameSize, FitToSizeMode=AlwaysFit)
 
double fitToSizeZoomFactor (const QSizeF &frameSize, FitToSizeMode=AlwaysFit) const
 
QSizeF imageSize () const
 
 ImageZoomSettings ()
 
 ImageZoomSettings (const QSize &imageSize, const QSize &originalSize=QSize())
 
bool isFitToSize (const QSizeF &frameSize) const
 
QPointF mapImageToZoom (const QPointF &imagePoint) const
 
QRectF mapImageToZoom (const QRectF &imagePoint) const
 
QPointF mapZoomToImage (const QPointF &zoomedPoint) const
 
QRectF mapZoomToImage (const QRectF &imageRect) const
 
QSizeF originalImageSize () const
 
double realZoomFactor () const
 
void setImageSize (const QSize &size, const QSize &originalSize=QSize())
 
void setZoomFactor (double zoom)
 
double snappedZoomFactor (double newZoom, const QSizeF &frameSize) const
 
double snappedZoomStep (double nextZoom, const QSizeF &frameSize) const
 
QRectF sourceRect (const QRectF &imageRect) const
 
QSizeF zoomedSize () const
 
double zoomFactor () const
 

Protected Attributes

QSizeF m_size
 
double m_zoom
 
double m_zoomConst
 
double m_zoomRatio
 

Member Enumeration Documentation

◆ FitToSizeMode

Enumerator
AlwaysFit 
OnlyScaleDown 

Constructor & Destructor Documentation

◆ ImageZoomSettings() [1/2]

Digikam::ImageZoomSettings::ImageZoomSettings ( )

◆ ImageZoomSettings() [2/2]

Digikam::ImageZoomSettings::ImageZoomSettings ( const QSize &  imageSize,
const QSize &  originalSize = QSize() 
)
explicit

References imageSize(), and setImageSize().

Member Function Documentation

◆ fitToSize()

void Digikam::ImageZoomSettings::fitToSize ( const QSizeF &  frameSize,
FitToSizeMode  mode = AlwaysFit 
)

Sets the current zoom factor to the factor needed to fit the current (original) image size into the given view size. Aspect ratio will be respected, that means the frameSize may not be completely filled in one dimension, and zoomedSize() can differ from frameSize in one dimension.

References fitToSizeZoomFactor(), and setZoomFactor().

◆ fitToSizeZoomFactor()

double Digikam::ImageZoomSettings::fitToSizeZoomFactor ( const QSizeF &  frameSize,
FitToSizeMode  mode = AlwaysFit 
) const

Returns the zoom factor that would be used by fitToSize() called with the given frameSize.

References m_size, m_zoomConst, m_zoomRatio, OnlyScaleDown, and originalImageSize().

Referenced by fitToSize(), isFitToSize(), snappedZoomFactor(), and snappedZoomStep().

◆ imageSize()

QSizeF Digikam::ImageZoomSettings::imageSize ( ) const

Returns the (available) image size

References m_size.

Referenced by ImageZoomSettings().

◆ isFitToSize()

bool Digikam::ImageZoomSettings::isFitToSize ( const QSizeF &  frameSize) const

◆ mapImageToZoom() [1/2]

QPointF Digikam::ImageZoomSettings::mapImageToZoom ( const QPointF &  imagePoint) const

For a given point (in (0,0), imageSize()) returns the corresponding point in (0,0),zoomedSize().

References m_zoom, m_zoomConst, and m_zoomRatio.

◆ mapImageToZoom() [2/2]

QRectF Digikam::ImageZoomSettings::mapImageToZoom ( const QRectF &  imagePoint) const

For a given rect contained in ((0,0), imageSize()) returns the corresponding rectangle in (0,0),zoomedSize().

References m_zoom, m_zoomConst, and m_zoomRatio.

Referenced by DigikamEditorHealingCloneToolPlugin::HealingCloneToolWidget::mapFromImageCoordinates(), and Digikam::GraphicsDImgView::slotPanIconSelectionMoved().

◆ mapZoomToImage() [1/2]

QPointF Digikam::ImageZoomSettings::mapZoomToImage ( const QPointF &  zoomedPoint) const

For a given point (in (0,0), zoomedSize()) returns the corresponding point in (0,0),imageSize().

References m_zoom, m_zoomConst, and m_zoomRatio.

◆ mapZoomToImage() [2/2]

QRectF Digikam::ImageZoomSettings::mapZoomToImage ( const QRectF &  imageRect) const

◆ originalImageSize()

QSizeF Digikam::ImageZoomSettings::originalImageSize ( ) const

◆ realZoomFactor()

double Digikam::ImageZoomSettings::realZoomFactor ( ) const

Return the real zoom factor dependent on device pixel ratio

References m_zoom, and m_zoomRatio.

Referenced by Digikam::ImageRegionItem::paintExtraData().

◆ setImageSize()

void Digikam::ImageZoomSettings::setImageSize ( const QSize &  size,
const QSize &  originalSize = QSize() 
)

Sets the size of the (available) image data. Optionally, you can specify an original size, if the available image data is a scaled-down version. In this case, zoom factors will refer to the original size. The zoom factor is unchanged, you need to call fitToSize again.

References m_size, and m_zoomConst.

Referenced by ImageZoomSettings().

◆ setZoomFactor()

void Digikam::ImageZoomSettings::setZoomFactor ( double  zoom)

Sets the current zoom factor, relative to (original) size.

References m_zoom.

Referenced by fitToSize().

◆ snappedZoomFactor()

double Digikam::ImageZoomSettings::snappedZoomFactor ( double  newZoom,
const QSizeF &  frameSize 
) const

When setting a new zoom factor (absolute value), the new value may be very close to a special value. Returns this special value if this is the case, returns newZoom if not applicable.

References fitToSizeZoomFactor().

◆ snappedZoomStep()

double Digikam::ImageZoomSettings::snappedZoomStep ( double  nextZoom,
const QSizeF &  frameSize 
) const

When changing the zoom from current zoom to given nextZoom, sometimes a special value may be crossed, and this could then be used instead of nextZoom. Returns this special zoom, or nextZoom if not applicable.

References fitToSizeZoomFactor(), and zoomFactor().

◆ sourceRect()

QRectF Digikam::ImageZoomSettings::sourceRect ( const QRectF &  imageRect) const

For a given rectangle contained in ((0,0), zoomedSize()) returns the corresponding rectangle in (0,0),imageSize().

References mapZoomToImage().

◆ zoomedSize()

QSizeF Digikam::ImageZoomSettings::zoomedSize ( ) const

Return the size of the image when the current zoom factor is applied. This is the size the image should be displayed at.

References m_size, m_zoom, m_zoomConst, and m_zoomRatio.

◆ zoomFactor()

double Digikam::ImageZoomSettings::zoomFactor ( ) const

Return the currently set zoom factor

References m_zoom.

Referenced by isFitToSize(), and snappedZoomStep().

Member Data Documentation

◆ m_size

QSizeF Digikam::ImageZoomSettings::m_size
protected

◆ m_zoom

double Digikam::ImageZoomSettings::m_zoom
protected

◆ m_zoomConst

double Digikam::ImageZoomSettings::m_zoomConst
protected

◆ m_zoomRatio

double Digikam::ImageZoomSettings::m_zoomRatio
protected

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