digiKam
freerotationfilter.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 : 2005-07-18
7  * Description : Free rotation threaded image filter.
8  *
9  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com>
11  * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_FREE_ROTATION_FILTER_H
27 #define DIGIKAM_FREE_ROTATION_FILTER_H
28 
29 // Qt includes
30 
31 #include <QSize>
32 #include <QColor>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 #include "dimgthreadedfilter.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT FreeRotationContainer
43 {
44 public:
45 
47  {
48  NoAutoCrop = 0,
50  LargestArea
51  };
52 
53 public:
54 
56  : antiAlias(true),
57  autoCrop(NoAutoCrop),
58  orgW(0),
59  orgH(0),
60  angle(0.0),
61  backgroundColor(Qt::black)
62  {
63  };
64 
66  {
67  };
68 
69 public:
70 
71  bool antiAlias;
72 
73  int autoCrop;
74  int orgW;
75  int orgH;
76 
77  double angle;
78 
79  QSize newSize;
80 
82 };
83 
84 // -----------------------------------------------------------------------------------------
85 
86 class DIGIKAM_EXPORT FreeRotationFilter : public DImgThreadedFilter
87 {
88  Q_OBJECT
89 
90 public:
91 
92  explicit FreeRotationFilter(QObject* const parent = nullptr);
93  explicit FreeRotationFilter(DImg* const orgImage, QObject* const parent = nullptr,
95 
96  ~FreeRotationFilter() override;
97 
98  QSize getNewSize() const;
99 
100  static double calculateAngle(int x1, int y1, int x2, int y2);
101  static double calculateAngle(const QPoint& p1, const QPoint& p2);
102 
103  static QString FilterIdentifier()
104  {
105  return QLatin1String("digikam:FreeRotationFilter");
106  }
107 
108  static QString DisplayableName();
109 
111  {
112  return QList<int>() << 1;
113  }
114 
115  static int CurrentVersion()
116  {
117  return 1;
118  }
119 
120  QString filterIdentifier() const override
121  {
122  return FilterIdentifier();
123  }
124 
125  FilterAction filterAction() override;
126  void readParameters(const FilterAction& action) override;
127 
128 private:
129 
130  void filterImage() override;
131  inline int setPosition (int Width, int X, int Y);
132  inline bool isInside (int Width, int Height, int X, int Y);
133 
134 private:
135 
136  class Private;
137  Private* const d;
138 };
139 
140 } // namespace Digikam
141 
142 #endif // DIGIKAM_FREE_ROTATION_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: freerotationfilter.h:43
int orgW
Definition: freerotationfilter.h:74
double angle
Definition: freerotationfilter.h:77
int orgH
Definition: freerotationfilter.h:75
~FreeRotationContainer()
Definition: freerotationfilter.h:65
QSize newSize
Definition: freerotationfilter.h:79
QColor backgroundColor
Definition: freerotationfilter.h:81
bool antiAlias
Definition: freerotationfilter.h:67
AutoCropTypes
Definition: freerotationfilter.h:47
@ WidestArea
Definition: freerotationfilter.h:49
int autoCrop
Definition: freerotationfilter.h:73
FreeRotationContainer()
Definition: freerotationfilter.h:55
Definition: freerotationfilter.h:87
static QString FilterIdentifier()
Definition: freerotationfilter.h:103
QString filterIdentifier() const override
Definition: freerotationfilter.h:120
static QList< int > SupportedVersions()
Definition: freerotationfilter.h:110
static int CurrentVersion()
Definition: freerotationfilter.h:115
#define X
@ Width
Definition: coredbfields.h:87
@ Height
Definition: coredbfields.h:88
Definition: datefolderview.cpp:43