File indexing completed on 2025-03-09 03:50:51

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-11-13
0007  * Description : a tool to blend bracketed images.
0008  *
0009  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2009-2011 by Johannes Wienke <languitar at semipol dot de>
0011  * SPDX-FileCopyrightText: 2012-2015 by Benjamin Girault <benjamin dot girault at gmail dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_EXPO_BLENDING_THREAD_H
0018 #define DIGIKAM_EXPO_BLENDING_THREAD_H
0019 
0020 // Qt includes
0021 
0022 #include <QThread>
0023 
0024 // Local includes
0025 
0026 #include "metaengine.h"
0027 #include "enfusesettings.h"
0028 #include "expoblendingactions.h"
0029 
0030 class QProcess;
0031 
0032 using namespace Digikam;
0033 
0034 namespace DigikamGenericExpoBlendingPlugin
0035 {
0036 
0037 class ExpoBlendingActionData;
0038 
0039 class ExpoBlendingThread : public QThread
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044 
0045     explicit ExpoBlendingThread(QObject* const parent);
0046     ~ExpoBlendingThread() override;
0047 
0048     void setEnfuseVersion(const double version);
0049     void setPreProcessingSettings(bool align);
0050     void loadProcessed(const QUrl& url);
0051     void identifyFiles(const QList<QUrl>& urlList);
0052     void convertRawFiles(const QList<QUrl>& urlList);
0053     void preProcessFiles(const QList<QUrl>& urlList, const QString& alignPath);
0054     void enfusePreview(const QList<QUrl>& alignedUrls, const QUrl& outputUrl,
0055                        const EnfuseSettings& settings, const QString& enfusePath);
0056     void enfuseFinal(const QList<QUrl>& alignedUrls, const QUrl& outputUrl,
0057                      const EnfuseSettings& settings, const QString& enfusePath);
0058 
0059     void cancel();
0060 
0061     /**
0062      * Clean up all temporary results produced so far.
0063      */
0064     void cleanUpResultFiles();
0065 
0066 Q_SIGNALS:
0067 
0068     void starting(const DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData& ad);
0069     void finished(const DigikamGenericExpoBlendingPlugin::ExpoBlendingActionData& ad);
0070 
0071 private:
0072 
0073     void    run() override;
0074 
0075     bool    preProcessingMultithreaded(const QUrl& url);
0076     bool    startPreProcessing(const QList<QUrl>& inUrls, bool  align, const QString& alignPath, QString& errors);
0077     bool    computePreview(const QUrl& inUrl, QUrl& outUrl);
0078     bool    convertRaw(const QUrl& inUrl, QUrl& outUrl);
0079 
0080     bool    startEnfuse(const QList<QUrl>& inUrls, QUrl& outUrl,
0081                         const EnfuseSettings& settings,
0082                         const QString& enfusePath, QString& errors);
0083 
0084     QString getProcessError(QProcess& proc) const;
0085 
0086     float   getAverageSceneLuminance(const QUrl& url);
0087     bool    getXmpRational(const char* xmpTagName, long& num, long& den, MetaEngine* const meta);
0088 
0089 public:
0090 
0091     class Private;
0092 
0093 private:
0094 
0095     Private* const d;
0096 };
0097 
0098 } // namespace DigikamGenericExpoBlendingPlugin
0099 
0100 #endif // DIGIKAM_EXPO_BLENDING_THREAD_H