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