digiKam
imageguidewidget.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 : 2004-08-20
7  * Description : a widget to display an image with guides
8  *
9  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
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_GUIDE_WIDGET_H
25 #define DIGIKAM_IMAGE_GUIDE_WIDGET_H
26 
27 // Qt includes
28 
29 #include <QWidget>
30 #include <QColor>
31 #include <QPixmap>
32 #include <QResizeEvent>
33 #include <QMouseEvent>
34 #include <QPaintEvent>
35 #include <QPoint>
36 #include <QEvent>
37 #include <QTimerEvent>
38 
39 // Local includes
40 
41 #include "imageiface.h"
42 #include "dcolor.h"
43 #include "digikam_export.h"
44 
45 namespace Digikam
46 {
47 
48 class DColor;
49 
50 class DIGIKAM_EXPORT ImageGuideWidget : public QWidget
51 {
52  Q_OBJECT
53 
54 public:
55 
57  {
58  HVGuideMode = 0,
59  PickColorMode
60  };
61 
63  {
64  OriginalImage = 0,
66  TargetPreviewImage
67  };
68 
69 public:
70 
71  explicit ImageGuideWidget(QWidget* const parent = nullptr,
72  bool spotVisible = true,
73  int guideMode = PickColorMode,
74  const QColor& guideColor = Qt::red,
75  int guideSize = 1,
76  bool blink = false,
78  ~ImageGuideWidget() override;
79 
80  ImageIface* imageIface() const;
81  QImage getMask() const;
82  QPoint getSpotPosition() const;
83  DColor getSpotColor(int getColorFrom) const;
84  int previewMode() const;
85 
86  void setSpotVisible(bool spotVisible, bool blink = false);
87  void setSpotVisibleNoUpdate(bool spotVisible);
88  void resetSpotPosition();
89  void updatePreview();
90  void setPoints(const QPolygon& p, bool drawLine = false);
91  void resetPoints();
92 
93  void setPaintColor(const QColor& color);
94  void setEraseMode(bool erase);
95  void setMaskEnabled(bool enabled);
96  void setMaskPenSize(int size);
97  void setMaskCursor();
98 
99  void setBackgroundColor(const QColor&);
100  void ICCSettingsChanged();
101  void exposureSettingsChanged();
102 
103 public Q_SLOTS:
104 
105  void slotChangeGuideColor(const QColor& color);
106  void slotChangeGuideSize(int size);
107  void slotPreviewModeChanged(int mode);
108 
109 Q_SIGNALS:
110 
111  void spotPositionChangedFromOriginal(const Digikam::DColor& color, const QPoint& position);
112  void spotPositionChangedFromTarget(const Digikam::DColor& color, const QPoint& position);
114 
115 protected:
116 
117  void paintEvent(QPaintEvent*) override;
118  void resizeEvent(QResizeEvent*) override;
119  void timerEvent(QTimerEvent*) override;
120  void mousePressEvent(QMouseEvent*) override;
121  void mouseReleaseEvent(QMouseEvent*) override;
122  void mouseMoveEvent(QMouseEvent*) override;
123 
124 #if (QT_VERSION > QT_VERSION_CHECK(5, 99, 0))
125  void enterEvent(QEnterEvent*) override;
126 #else
127  void enterEvent(QEvent*) override;
128 #endif
129 
130  void leaveEvent(QEvent*) override;
131  void updatePixmap();
132  void drawLineTo(const QPoint& endPoint);
133  void drawLineTo(int width, bool erase, const QColor& color, const QPoint& start, const QPoint& end);
134  QPoint translatePointPosition(const QPoint& point) const;
135  void drawText(QPainter* const p, const QPoint& corner, const QString& text);
136  void updateMaskCursor();
137  void setSpotPosition(const QPoint& point);
138  void updateSpotPosition(int x, int y);
139  QPoint translateItemPosition(const QPoint& point, bool src) const;
140 
141 private:
142 
143  class Private;
144  Private* const d;
145 };
146 
147 } // namespace Digikam
148 
149 #endif // DIGIKAM_IMAGE_GUIDE_WIDGET_H
Definition: dcolor.h:43
Definition: imageguidewidget.h:51
void spotPositionChangedFromOriginal(const Digikam::DColor &color, const QPoint &position)
ColorPointSrc
Definition: imageguidewidget.h:63
@ PreviewImage
Definition: imageguidewidget.h:65
void spotPositionChangedFromTarget(const Digikam::DColor &color, const QPoint &position)
GuideToolMode
Definition: imageguidewidget.h:57
Definition: imageiface.h:47
PreviewType
Definition: imageiface.h:52
@ FullImage
Preview will be rendered using full image.
Definition: imageiface.h:53
Definition: datefolderview.cpp:43
Definition: scan.h:26