File indexing completed on 2025-01-05 03:59:44

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2013-07-15
0007  * Description : a widget to draw an image clip region.
0008  *
0009  * SPDX-FileCopyrightText: 2013-2014 by Yiou Wang <geow812 at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0011  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_IMAGE_REGION_WIDGET_H
0018 #define DIGIKAM_IMAGE_REGION_WIDGET_H
0019 
0020 // Qt includes
0021 
0022 #include <QPoint>
0023 #include <QRect>
0024 #include <QEvent>
0025 #include <QPolygon>
0026 #include <QPixmap>
0027 #include <QResizeEvent>
0028 #include <QWheelEvent>
0029 
0030 // Local includes
0031 
0032 #include "dimg.h"
0033 #include "graphicsdimgview.h"
0034 #include "imagezoomsettings.h"
0035 #include "digikam_export.h"
0036 
0037 namespace Digikam
0038 {
0039 
0040 class DIGIKAM_EXPORT ImageRegionWidget : public GraphicsDImgView
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045 
0046     explicit ImageRegionWidget(QWidget* const parent = nullptr, bool paintExtras = true);
0047     ~ImageRegionWidget() override;
0048 
0049     /**
0050      * To get target image region area to render.
0051      */
0052     QRect  getOriginalImageRegionToRender() const;
0053 
0054     /**
0055      * To get target image region image to use for render operations
0056      * If the bool parameter is true a downscaled version of the image
0057      * region at screen resolution will be sent.
0058      * Should be use to increase preview speed for the effects whose
0059      * behaviour is a function of each pixel.
0060      */
0061     DImg   getOriginalRegionImage(bool useDownscaledImage = false) const;
0062 
0063     DImg   getOriginalImage() const;
0064 
0065     void   setPreviewImage(const DImg& img);
0066     void   updateImage(const DImg& img);
0067 
0068     void   setCapturePointMode(bool b);
0069     bool   capturePointMode() const;
0070 
0071     void   setHighLightPoints(const QPolygon& pointsList);
0072 
0073     void   ICCSettingsChanged();
0074     void   exposureSettingsChanged();
0075 
0076 Q_SIGNALS:
0077 
0078     void signalOriginalClipFocusChanged();
0079     void signalCapturedPointFromOriginal(const Digikam::DColor&, const QPoint&);
0080 
0081 public Q_SLOTS:
0082 
0083     void slotPreviewModeChanged(int mode);
0084     void slotOriginalImageRegionChanged(bool targetDone=true);
0085 
0086 protected:
0087 
0088     void mousePressEvent(QMouseEvent*) override;
0089     void mouseReleaseEvent(QMouseEvent*) override;
0090 
0091 private:
0092 
0093     void emitCapturedPointFromOriginal(const QPointF&);
0094 
0095 private Q_SLOTS:
0096 
0097     void slotOriginalImageRegionChangedDelayed();
0098 
0099 private:
0100 
0101     class Private;
0102     Private* const d_ptr;
0103 };
0104 
0105 } // namespace Digikam
0106 
0107 #endif // DIGIKAM_IMAGE_REGION_WIDGET_H