File indexing completed on 2025-01-05 03:53:10

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-03-15
0007  * Description : a tool to create panorama by fusion of several images.
0008  *
0009  * SPDX-FileCopyrightText: 2012-2016 by Benjamin Girault <benjamin dot girault at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "cpcleantask.h"
0016 
0017 // Qt includes
0018 
0019 #include <QFile>
0020 
0021 namespace DigikamGenericPanoramaPlugin
0022 {
0023 
0024 CpCleanTask::CpCleanTask(const QString& workDirPath, const QUrl& input,
0025                          QUrl& cpCleanPtoUrl, const QString& cpCleanPath)
0026     : CommandTask(PANO_CPCLEAN, workDirPath, cpCleanPath),
0027       cpCleanPtoUrl(cpCleanPtoUrl),
0028       cpFindPtoUrl(input)
0029 {
0030 }
0031 
0032 void CpCleanTask::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread*)
0033 {
0034     cpCleanPtoUrl = tmpDir;
0035     cpCleanPtoUrl.setPath(cpCleanPtoUrl.path()+ QLatin1String("cp_pano_clean.pto"));
0036 
0037     QStringList args;
0038     args << QLatin1String("-o");
0039     args << cpCleanPtoUrl.toLocalFile();
0040     args << cpFindPtoUrl.toLocalFile();
0041 
0042     runProcess(args);
0043 
0044     // CPClean does not return an error code when something went wrong...
0045 
0046     QFile ptoOutput(cpCleanPtoUrl.toLocalFile());
0047 
0048     if (!ptoOutput.exists())
0049     {
0050         successFlag = false;
0051         errString   = getProcessError();
0052     }
0053 
0054     printDebug(QLatin1String("cpclean"));
0055 }
0056 
0057 } // namespace DigikamGenericPanoramaPlugin