void PanoLastPage::slotPanoAction(const DigikamGenericPanoramaPlugin::PanoActionData& ad) { qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "SlotPanoAction (lastPage)"; qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "starting, success, action:" << ad.starting << ad.success << ad.action; if (!ad.starting) // Something is complete... { if (!ad.success) // Something is failed... { switch (ad.action) { case PANO_COPY: { disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); d->errorLabel->setText(i18n("<qt><p><font color=\"red\"><b>Error:</b> " "%1</font></p></qt>", ad.message)); d->errorLabel->show(); break; } default: { qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (last) " << ad.action; break; } } } else // Something is done... { switch (ad.action) { case PANO_COPY: { disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); d->copyDone = true; emit signalCopyFinished(); break; } default: { qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (last) " << ad.action; break; } } } } }
void PanoOptimizePage::process() { QMutexLocker lock(&d->progressMutex); d->title->setText(i18n("<qt>" "<p>Optimization is in progress, please wait.</p>" "<p>This can take a while...</p>" "</qt>")); d->horizonCheckbox->hide(); // d->projectionAndSizeCheckbox->hide(); d->progressTimer->start(300); connect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); d->mngr->resetAutoOptimisePto(); d->mngr->resetViewAndCropOptimisePto(); d->mngr->thread()->optimizeProject(d->mngr->cpCleanPtoUrl(), d->mngr->autoOptimisePtoUrl(), d->mngr->viewAndCropOptimisePtoUrl(), d->horizonCheckbox->isChecked(), d->mngr->gPano(), d->mngr->autoOptimiserBinary().path(), d->mngr->panoModifyBinary().path()); }
void PanoLastPage::copyFiles() { connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); QUrl panoUrl = d->mngr->preProcessedMap().begin().key().adjusted(QUrl::RemoveFilename); panoUrl.setPath(panoUrl.path() + panoFileName(d->fileTemplateQLineEdit->text())); d->mngr->thread()->copyFiles(d->mngr->panoPtoUrl(), d->mngr->panoUrl(), panoUrl, d->mngr->preProcessedMap(), d->savePtoCheckBox->isChecked(), d->mngr->gPano() ); }
void PanoOptimizePage::cleanupPage() { d->canceled = true; disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); d->mngr->thread()->cancel(); QMutexLocker lock(&d->progressMutex); if (d->progressTimer->isActive()) { d->progressTimer->stop(); d->progressLabel->clear(); } }
void PanoPreviewPage::computePreview() { // Cancel any stitching being processed if (d->stitchingBusy) { cleanupPage(); } QMutexLocker lock(&d->previewBusyMutex); connect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->canceled = false; d->previewWidget->setBusy(true, i18n("Processing Panorama Preview...")); d->previewDone = false; d->previewBusy = true; d->mngr->resetPreviewPto(); d->mngr->resetPreviewUrl(); d->mngr->resetPreviewMkUrl(); d->mngr->thread()->generatePanoramaPreview(d->mngr->viewAndCropOptimisePtoData(), d->mngr->previewPtoUrl(), d->mngr->previewMkUrl(), d->mngr->previewUrl(), d->mngr->preProcessedMap(), d->mngr->makeBinary().path(), d->mngr->pto2MkBinary().path(), d->mngr->huginExecutorBinary().path(), d->mngr->hugin2015(), d->mngr->enblendBinary().path(), d->mngr->nonaBinary().path()); }
void PanoOptimizePage::slotPanoAction(const DigikamGenericPanoramaPlugin::PanoActionData& ad) { qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "SlotPanoAction (optimize)"; qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "starting, success, canceled, action: " << ad.starting << ad.success << d->canceled << ad.action; QString text; QMutexLocker lock(&d->progressMutex); if (!ad.starting) // Something is complete... { if (!ad.success) // Something is failed... { if (d->canceled) // In that case, the error is expected { return; } switch (ad.action) { case PANO_OPTIMIZE: case PANO_AUTOCROP: { disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Job failed (optimize): " << ad.action; if (d->detailsText->isHidden()) { d->title->setText(i18n("<qt>" "<h1>Optimization has failed.</h1>" "<p>See processing messages below.</p>" "</qt>")); d->progressTimer->stop(); d->horizonCheckbox->hide(); // d->projectionAndSizeCheckbox->hide(); d->detailsText->show(); d->progressLabel->clear(); d->detailsText->setText(ad.message); setComplete(false); emit completeChanged(); } break; } default: { qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (optimize) " << ad.action; break; } } } else // Something is done... { switch (ad.action) { case PANO_OPTIMIZE: { return; } case PANO_AUTOCROP: { disconnect(d->mngr->thread(), SIGNAL(stepFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(DigikamGenericPanoramaPlugin::PanoActionData)), this, SLOT(slotPanoAction(DigikamGenericPanoramaPlugin::PanoActionData))); d->progressTimer->stop(); d->progressLabel->clear(); d->optimisationDone = true; emit signalOptimized(); initializePage(); break; } default: { qCWarning(DIGIKAM_DPLUGIN_GENERIC_LOG) << "Unknown action (optimize) " << ad.action; break; } } } } }
void PanoPreviewPage::slotPanoAction(const Digikam::PanoActionData& ad) { qCDebug(DIGIKAM_GENERAL_LOG) << "SlotPanoAction (preview)"; qCDebug(DIGIKAM_GENERAL_LOG) << "\tstarting, success, canceled, action: " << ad.starting << ad.success << d->canceled << ad.action; QString text; QMutexLocker lock(&d->previewBusyMutex); qCDebug(DIGIKAM_GENERAL_LOG) << "\tbusy (preview / stitch):" << d->previewBusy << d->stitchingBusy; if (!ad.starting) // Something is complete... { if (!ad.success) // Something is failed... { switch (ad.action) { case PANO_CREATEPREVIEWPTO: case PANO_NONAFILEPREVIEW: case PANO_STITCHPREVIEW: case PANO_CREATEMKPREVIEW: case PANO_HUGINEXECUTORPREVIEW: { if (!d->previewBusy) { lock.unlock(); emit signalPreviewFinished(); return; } disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->output = ad.message; d->previewWidget->setBusy(false); d->previewBusy = false; qCWarning(DIGIKAM_GENERAL_LOG) << "Preview compilation failed: " << ad.message; QString errorString(i18n("<h1><b>Error</b></h1><p>%1</p>", ad.message)); d->previewWidget->setText(errorString); d->previewWidget->setSelectionAreaPossible(false); setComplete(false); emit completeChanged(); lock.unlock(); emit signalPreviewFinished(); break; } case PANO_CREATEMK: { if (!d->stitchingBusy) { return; } disconnect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->stitchingBusy = false; QString message = i18nc("Here a makefile is a script for GNU Make", "<p><b>Cannot create makefile: </b></p><p>%1</p>", ad.message); qCWarning(DIGIKAM_GENERAL_LOG) << "pto2mk call failed"; d->postProcessing->addEntry(message, DHistoryView::ErrorEntry); setComplete(false); emit completeChanged(); break; } case PANO_CREATEFINALPTO: { if (!d->stitchingBusy) { return; } disconnect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->stitchingBusy = false; QString message = i18nc("a project file is a .pto file, as given to hugin to build a panorama", "<p><b>Cannot create project file: </b></p><p>%1</p>", ad.message); qCWarning(DIGIKAM_GENERAL_LOG) << "pto creation failed"; d->postProcessing->addEntry(message, DHistoryView::ErrorEntry); setComplete(false); emit completeChanged(); break; } case PANO_NONAFILE: { if (!d->stitchingBusy) { return; } disconnect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->stitchingBusy = false; QString message = i18nc("Error message for image file number %1 out of %2", "<p><b>Processing file %1 / %2: </b></p><p>%3</p>", QString::number(ad.id + 1), QString::number(d->totalProgress - 1), ad.message); qCWarning(DIGIKAM_GENERAL_LOG) << "Nona call failed for file #" << ad.id; d->postProcessing->addEntry(message, DHistoryView::ErrorEntry); setComplete(false); emit completeChanged(); break; } case PANO_STITCH: case PANO_HUGINEXECUTOR: { if (!d->stitchingBusy) { return; } disconnect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->stitchingBusy = false; d->postProcessing->addEntry(i18nc("Error message for panorama compilation", "<p><b>Panorama compilation: </b></p><p>%1</p>", ad.message.toHtmlEscaped()), DHistoryView::ErrorEntry); qCWarning(DIGIKAM_GENERAL_LOG) << "Enblend call failed"; setComplete(false); emit completeChanged(); break; } default: { qCWarning(DIGIKAM_GENERAL_LOG) << "Unknown action (preview) " << ad.action; break; } } } else // Something is done... { switch (ad.action) { case PANO_CREATEPREVIEWPTO: case PANO_CREATEMKPREVIEW: case PANO_NONAFILEPREVIEW: case PANO_CREATEFINALPTO: case PANO_CREATEMK: { // Nothing to do yet, a step is finished, that's all break; } case PANO_STITCHPREVIEW: case PANO_HUGINEXECUTORPREVIEW: { if (d->previewBusy) { disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); } d->previewBusy = false; d->previewDone = true; lock.unlock(); emit signalPreviewFinished(); d->title->setText(i18n("<qt>" "<h1>Panorama Preview</h1>" "<p>Draw a rectangle if you want to crop the image.</p>" "<p>Pressing the <i>Next</i> button will then launch the final " "stitching process.</p>" "</qt>")); d->previewWidget->setSelectionAreaPossible(true); // d->previewWidget->load(QUrl::fromLocalFile(d->mngr->previewUrl().toLocalFile()), true); d->previewWidget->load(d->mngr->previewUrl(), true); QSize panoSize = d->mngr->viewAndCropOptimisePtoData()->project.size; QRect panoCrop = d->mngr->viewAndCropOptimisePtoData()->project.crop; QSize previewSize = d->mngr->previewPtoData()->project.size; d->previewWidget->setSelectionArea(QRectF( ((double) panoCrop.left()) / panoSize.width() * previewSize.width(), ((double) panoCrop.top()) / panoSize.height() * previewSize.height(), ((double) panoCrop.width()) / panoSize.width() * previewSize.width(), ((double) panoCrop.height()) / panoSize.height() * previewSize.height() )); break; } case PANO_NONAFILE: { QString message = i18nc("Success for image file number %1 out of %2", "Processing file %1 / %2", QString::number(ad.id + 1), QString::number(d->totalProgress - 1)); d->postProcessing->addEntry(message, DHistoryView::SuccessEntry); d->curProgress++; d->progressBar->setValue(d->curProgress); d->progressBar->setMaximum(d->totalProgress); break; } case PANO_STITCH: case PANO_HUGINEXECUTOR: { if (!d->stitchingBusy) { return; } disconnect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); disconnect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->stitchingBusy = false; d->postProcessing->addEntry(i18nc("Success for panorama compilation", "Panorama compilation"), DHistoryView::SuccessEntry); d->curProgress++; d->progressBar->setValue(d->curProgress); d->progressBar->setMaximum(d->totalProgress); d->progressBar->progressCompleted(); d->progressBar->hide(); d->postProcessing->hide(); d->stitchingDone = true; emit signalStitchingFinished(); preInitializePage(); break; } default: { qCWarning(DIGIKAM_GENERAL_LOG) << "Unknown action (preview) " << ad.action; break; } } } } else // Some step is started... { switch (ad.action) { case PANO_CREATEPREVIEWPTO: case PANO_CREATEMKPREVIEW: case PANO_NONAFILEPREVIEW: case PANO_STITCHPREVIEW: case PANO_CREATEFINALPTO: case PANO_CREATEMK: case PANO_HUGINEXECUTORPREVIEW: { // Nothing to do... break; } case PANO_NONAFILE: { QString message = i18nc("Compilation started for image file number %1 out of %2", "Processing file %1 / %2", QString::number(ad.id + 1), QString::number(d->totalProgress - 1)); d->postProcessing->addEntry(message, DHistoryView::StartingEntry); break; } case PANO_STITCH: case PANO_HUGINEXECUTOR: { d->postProcessing->addEntry(i18nc("Panorama compilation started", "Panorama compilation"), DHistoryView::StartingEntry); break; } default: { qCWarning(DIGIKAM_GENERAL_LOG) << "Unknown starting action (preview) " << ad.action; break; } } } }
void PanoPreviewPage::startStitching() { QMutexLocker lock(&d->previewBusyMutex); if (d->previewBusy) { // The real beginning of the stitching starts after preview has finished / failed connect(this, SIGNAL(signalPreviewFinished()), this, SLOT(slotStartStitching())); cleanupPage(lock); return; } connect(d->mngr->thread(), SIGNAL(starting(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); connect(d->mngr->thread(), SIGNAL(stepFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); connect(d->mngr->thread(), SIGNAL(jobCollectionFinished(Digikam::PanoActionData)), this, SLOT(slotPanoAction(Digikam::PanoActionData))); d->canceled = false; d->stitchingBusy = true; d->curProgress = 0; if (d->mngr->hugin2015()) { d->totalProgress = 1; } else { d->totalProgress = d->mngr->preProcessedMap().size() + 1; } d->previewWidget->hide(); QSize panoSize = d->mngr->viewAndCropOptimisePtoData()->project.size; QRect panoSelection = d->mngr->viewAndCropOptimisePtoData()->project.crop; if (d->previewDone) { QSize previewSize = d->mngr->previewPtoData()->project.size; QRectF selection = d->previewWidget->getSelectionArea(); QRectF proportionSelection(selection.x() / previewSize.width(), selection.y() / previewSize.height(), selection.width() / previewSize.width(), selection.height() / previewSize.height()); // At this point, if no selection area was created, proportionSelection is null, // hence panoSelection becomes a null rectangle panoSelection = QRect(proportionSelection.x() * panoSize.width(), proportionSelection.y() * panoSize.height(), proportionSelection.width() * panoSize.width(), proportionSelection.height() * panoSize.height()); } d->title->setText(i18n("<qt>" "<p><h1>Panorama Post-Processing</h1></p>" "</qt>")); d->progressBar->reset(); d->progressBar->setMaximum(d->totalProgress); d->progressBar->progressScheduled(i18nc("@title:group", "Panorama Post-Processing"), true, true); d->progressBar->progressThumbnailChanged(QIcon::fromTheme(QLatin1String("panorama")).pixmap(22, 22)); d->progressBar->show(); d->postProcessing->show(); d->mngr->resetPanoPto(); d->mngr->resetMkUrl(); d->mngr->resetPanoUrl(); d->mngr->thread()->compileProject(d->mngr->viewAndCropOptimisePtoData(), d->mngr->panoPtoUrl(), d->mngr->mkUrl(), d->mngr->panoUrl(), d->mngr->preProcessedMap(), d->mngr->format(), panoSelection, d->mngr->makeBinary().path(), d->mngr->pto2MkBinary().path(), d->mngr->huginExecutorBinary().path(), d->mngr->hugin2015(), d->mngr->enblendBinary().path(), d->mngr->nonaBinary().path()); }