digiKam
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  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_IMAGE_ZOOM_SETTINGS_H
25 #define DIGIKAM_IMAGE_ZOOM_SETTINGS_H
26 
27 // Qt includes
28 
29 #include <QSizeF>
30 #include <QRectF>
31 #include <QPointF>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class DIGIKAM_EXPORT ImageZoomSettings
41 {
42 
43 public:
44 
46  {
48  OnlyScaleDown
49  };
50 
51 public:
52 
54  explicit ImageZoomSettings(const QSize& imageSize, const QSize& originalSize = QSize());
55 
63  void setImageSize(const QSize& size, const QSize& originalSize = QSize());
64 
68  double zoomFactor() const;
69 
73  double realZoomFactor() const;
74 
78  QSizeF imageSize() const;
79 
83  QSizeF originalImageSize() const;
84 
89  QSizeF zoomedSize() const;
90 
91  bool isFitToSize(const QSizeF& frameSize) const;
92 
96  void setZoomFactor(double zoom);
97 
105  void fitToSize(const QSizeF& frameSize, FitToSizeMode = AlwaysFit);
106 
111  QRectF sourceRect(const QRectF& imageRect) const;
112 
113  QRectF mapZoomToImage(const QRectF& imageRect) const;
114 
119  QRectF mapImageToZoom(const QRectF& imagePoint) const;
120 
125  QPointF mapZoomToImage(const QPointF& zoomedPoint) const;
126 
131  QPointF mapImageToZoom(const QPointF& imagePoint) const;
132 
137  double fitToSizeZoomFactor(const QSizeF& frameSize, FitToSizeMode = AlwaysFit) const;
138 
144  double snappedZoomStep(double nextZoom, const QSizeF& frameSize) const;
145 
151  double snappedZoomFactor(double newZoom, const QSizeF& frameSize) const;
152 
153 protected:
154 
155  QSizeF m_size;
156  double m_zoom;
157  double m_zoomConst;
158  double m_zoomRatio;
159 };
160 
161 } // namespace Digikam
162 
163 #endif // DIGIKAM_IMAGE_ZOOM_SETTINGS_H
Definition: imagezoomsettings.h:41
double m_zoomConst
Definition: imagezoomsettings.h:157
FitToSizeMode
Definition: imagezoomsettings.h:46
@ AlwaysFit
Definition: imagezoomsettings.h:47
QSizeF m_size
Definition: imagezoomsettings.h:155
double m_zoom
Definition: imagezoomsettings.h:156
double m_zoomRatio
Definition: imagezoomsettings.h:158
Definition: datefolderview.cpp:43