digiKam
Loading...
Searching...
No Matches
imagezoomsettings.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2010-04-30
7 * Description : Image zoom settings
8 *
9 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15#pragma once
16
17// Qt includes
18
19#include <QSizeF>
20#include <QRectF>
21#include <QPointF>
22#include <QWidget>
23
24// Local includes
25
26#include "digikam_export.h"
27
28namespace Digikam
29{
30
31class DIGIKAM_EXPORT ImageZoomSettings
32{
33
34public:
35
37 {
39 OnlyScaleDown
40 };
41
42public:
43
44 ImageZoomSettings() = default;
45 explicit ImageZoomSettings(const QSize& imageSize, const QSize& originalSize = QSize());
46
54 void setImageSize(const QSize& size, const QSize& originalSize = QSize());
55
59 void setDisplayWidget(QWidget* const widget);
60
64 double zoomFactor() const;
65
69 double realZoomFactor() const;
70
74 QSizeF imageSize() const;
75
79 QSizeF originalImageSize() const;
80
85 QSizeF zoomedSize() const;
86
87 bool isFitToSize(const QSizeF& frameSize) const;
88
92 void setZoomFactor(double zoom);
93
101 void fitToSize(const QSizeF& frameSize, FitToSizeMode = AlwaysFit);
102
107 QRectF sourceRect(const QRectF& imageRect) const;
108
109 QRectF mapZoomToImage(const QRectF& imageRect) const;
110
115 QRectF mapImageToZoom(const QRectF& imagePoint) const;
116
121 QPointF mapZoomToImage(const QPointF& zoomedPoint) const;
122
127 QPointF mapImageToZoom(const QPointF& imagePoint) const;
128
133 double fitToSizeZoomFactor(const QSizeF& frameSize, FitToSizeMode = AlwaysFit) const;
134
140 double snappedZoomStep(double nextZoom, const QSizeF& frameSize) const;
141
147 double snappedZoomFactor(double newZoom, const QSizeF& frameSize) const;
148
152 static void setImageSmoothScale(bool enable);
153 static bool getImageSmoothScale();
154
155private:
156
157 double displayRatio() const;
158
159protected:
160
161 QSizeF m_size;
162 double m_zoom = 1.0;
163 double m_zoomConst = 1.0;
164
165 QWidget* m_displayWidget = nullptr;
166};
167
168} // namespace Digikam
Definition imagezoomsettings.h:32
FitToSizeMode
Definition imagezoomsettings.h:37
@ AlwaysFit
Definition imagezoomsettings.h:38
QSizeF m_size
Definition imagezoomsettings.h:161
Definition datefolderview.cpp:34