digiKam
tagregion.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-08-26
7  * Description : Tag region formatting
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_TAG_REGION_H
26 #define DIGIKAM_TAG_REGION_H
27 
28 // Qt includes
29 
30 #include <QRect>
31 #include <QString>
32 #include <QVariant>
33 #include <QDebug>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
39 class QDebug;
40 
41 namespace Digikam
42 {
43 
44 class DImg;
45 
46 class DIGIKAM_EXPORT TagRegion
47 {
48 
49 public:
50 
51  enum Type
52  {
54  Rect
55  };
56 
57 public:
58 
68  TagRegion();
69 
73  explicit TagRegion(const QString& descriptor);
74 
78  explicit TagRegion(const QRect& rect);
79 
80  Type type() const;
81  bool isValid() const;
82 
83  bool operator==(const TagRegion& other) const;
84 
85  bool operator!=(const TagRegion& other) const;
86 
90  QString toXml() const;
91 
95  QRect toRect() const;
96 
100  QVariant toVariant() const;
101  static TagRegion fromVariant(const QVariant& var);
102 
112  bool intersects(const TagRegion& other, double fraction = 0);
113 
117  static QRect mapToOriginalSize(const QSize& fullImageSize, const QSize& reducedImageSize, const QRect& reducedSizeDetail);
118  static QRect mapFromOriginalSize(const QSize& fullImageSize, const QSize& reducedImageSize, const QRect& fullSizeDetail);
119 
123  static QRect mapToOriginalSize(const DImg& reducedSizeImage, const QRect& reducedSizeDetail);
124  static QRect mapFromOriginalSize(const DImg& reducedSizeImage, const QRect& fullSizeDetail);
125 
129  static QRect relativeToAbsolute(const QRectF& region, const QSize& fullSize);
130 
134  static QRect relativeToAbsolute(const QRectF& region, const DImg& reducedSizeImage);
135 
140  static QRectF absoluteToRelative(const QRect& region, const QSize& fullSize);
141 
146  static QSize adjustToOrientation(QRect& region, int orientation, const QSize& fullSize);
147 
152  static void reverseToOrientation(QRect& region, int orientation, const QSize& fullSize);
153 
154 protected:
155 
156  QVariant m_value;
158 };
159 
160 QDebug DIGIKAM_EXPORT operator<<(QDebug dbg, const TagRegion& r);
161 
162 } // namespace Digikam
163 
164 #endif // DIGIKAM_TAG_REGION_H
Definition: dimg.h:62
Definition: tagregion.h:47
QVariant m_value
Definition: tagregion.h:156
Type m_type
Definition: tagregion.h:157
Type
Definition: tagregion.h:52
@ Invalid
Definition: tagregion.h:53
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
Type
Definition: gpsitemcontainer.h:45