![]() |
digiKam
|
#include <imagezoomsettings.h>
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 ()=default | |
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 | setDisplayWidget (QWidget *const widget) |
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 |
Static Public Member Functions | |
static bool | getImageSmoothScale () |
static void | setImageSmoothScale (bool enable) |
Protected Attributes | |
QWidget * | m_displayWidget = nullptr |
QSizeF | m_size |
double | m_zoom = 1.0 |
double | m_zoomConst = 1.0 |
|
default |
|
explicit |
References imageSize(), and setImageSize().
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().
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, OnlyScaleDown, and originalImageSize().
Referenced by fitToSize(), isFitToSize(), snappedZoomFactor(), and snappedZoomStep().
|
static |
QSizeF Digikam::ImageZoomSettings::imageSize | ( | ) | const |
bool Digikam::ImageZoomSettings::isFitToSize | ( | const QSizeF & | frameSize | ) | const |
References fitToSizeZoomFactor(), and zoomFactor().
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, and m_zoomConst.
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, and m_zoomConst.
Referenced by Digikam::GraphicsDImgView::slotPanIconSelectionMoved().
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, and m_zoomConst.
QRectF Digikam::ImageZoomSettings::mapZoomToImage | ( | const QRectF & | imageRect | ) | const |
References m_zoom, and m_zoomConst.
Referenced by sourceRect().
QSizeF Digikam::ImageZoomSettings::originalImageSize | ( | ) | const |
Return the original image size. Can be identical to size().
References m_size, and m_zoomConst.
Referenced by fitToSizeZoomFactor(), Digikam::DImgChildItem::originalPos(), Digikam::DImgChildItem::originalSize(), Digikam::DImgChildItem::setOriginalPos(), and Digikam::DImgChildItem::setOriginalSize().
double Digikam::ImageZoomSettings::realZoomFactor | ( | ) | const |
Return the real zoom factor dependent on device pixel ratio
References m_zoom.
Referenced by Digikam::ImageRegionItem::paintExtraData().
void Digikam::ImageZoomSettings::setDisplayWidget | ( | QWidget *const | widget | ) |
Set the graphics view widget to track the device pixel ratio.
References m_displayWidget.
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().
|
static |
Static functions to define the smooth scaling of the image.
Referenced by Digikam::ApplicationSettings::setPreviewSmoothScaled().
void Digikam::ImageZoomSettings::setZoomFactor | ( | double | zoom | ) |
Sets the current zoom factor, relative to (original) size.
References m_zoom.
Referenced by fitToSize().
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().
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().
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().
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, and m_zoomConst.
double Digikam::ImageZoomSettings::zoomFactor | ( | ) | const |
Return the currently set zoom factor
References m_zoom.
Referenced by isFitToSize(), and snappedZoomStep().
|
protected |
Referenced by setDisplayWidget().
|
protected |
Referenced by fitToSizeZoomFactor(), imageSize(), originalImageSize(), setImageSize(), and zoomedSize().
|
protected |
Referenced by mapImageToZoom(), mapImageToZoom(), mapZoomToImage(), mapZoomToImage(), realZoomFactor(), setZoomFactor(), zoomedSize(), and zoomFactor().
|
protected |
Referenced by fitToSizeZoomFactor(), mapImageToZoom(), mapImageToZoom(), mapZoomToImage(), mapZoomToImage(), originalImageSize(), setImageSize(), and zoomedSize().