Add initial metadata lens correction handling
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "../rtengine/lcp.h"
|
||||
#include "../rtengine/procparams.h"
|
||||
#include "../rtengine/rtlensfun.h"
|
||||
#include "../rtengine/lensmetadata.h"
|
||||
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
@@ -56,6 +57,7 @@ LensProfilePanel::LensProfilePanel() :
|
||||
distGrid(Gtk::manage((new Gtk::Grid()))),
|
||||
corrUnchangedRB(Gtk::manage((new Gtk::RadioButton(M("GENERAL_UNCHANGED"))))),
|
||||
corrOffRB(Gtk::manage((new Gtk::RadioButton(corrGroup, M("GENERAL_NONE"))))),
|
||||
corrMetadata(Gtk::manage((new Gtk::RadioButton(corrGroup, M("TP_LENSPROFILE_CORRECTION_METADATA"))))),
|
||||
corrLensfunAutoRB(Gtk::manage((new Gtk::RadioButton(corrGroup, M("TP_LENSPROFILE_CORRECTION_AUTOMATCH"))))),
|
||||
corrLensfunManualRB(Gtk::manage((new Gtk::RadioButton(corrGroup, M("TP_LENSPROFILE_CORRECTION_MANUAL"))))),
|
||||
corrLcpFileRB(Gtk::manage((new Gtk::RadioButton(corrGroup, M("TP_LENSPROFILE_CORRECTION_LCPFILE"))))),
|
||||
@@ -144,17 +146,18 @@ LensProfilePanel::LensProfilePanel() :
|
||||
// Populate modes grid:
|
||||
|
||||
modesGrid->attach(*corrOffRB, 0, 0, 3, 1);
|
||||
modesGrid->attach(*corrLensfunAutoRB, 0, 1, 3, 1);
|
||||
modesGrid->attach(*corrLensfunManualRB, 0, 2, 3, 1);
|
||||
modesGrid->attach(*corrMetadata, 0, 1, 3, 1);
|
||||
modesGrid->attach(*corrLensfunAutoRB, 0, 2, 3, 1);
|
||||
modesGrid->attach(*corrLensfunManualRB, 0, 3, 3, 1);
|
||||
|
||||
modesGrid->attach(*lensfunCamerasLbl, 0, 3, 1, 1);
|
||||
modesGrid->attach(*lensfunCameras, 1, 3, 1, 1);
|
||||
modesGrid->attach(*lensfunLensesLbl, 0, 4, 1, 1);
|
||||
modesGrid->attach(*lensfunLenses, 1, 4, 1, 1);
|
||||
modesGrid->attach(*warning, 2, 3, 1, 2);
|
||||
modesGrid->attach(*lensfunCamerasLbl, 0, 4, 1, 1);
|
||||
modesGrid->attach(*lensfunCameras, 1, 4, 1, 1);
|
||||
modesGrid->attach(*lensfunLensesLbl, 0, 5, 1, 1);
|
||||
modesGrid->attach(*lensfunLenses, 1, 5, 1, 1);
|
||||
modesGrid->attach(*warning, 2, 4, 1, 2);
|
||||
|
||||
modesGrid->attach(*corrLcpFileRB, 0, 5, 1, 1);
|
||||
modesGrid->attach(*corrLcpFileChooser, 1, 5, 1, 1);
|
||||
modesGrid->attach(*corrLcpFileRB, 0, 6, 1, 1);
|
||||
modesGrid->attach(*corrLcpFileChooser, 1, 6, 1, 1);
|
||||
|
||||
// Populate distortions grid:
|
||||
|
||||
@@ -179,6 +182,7 @@ LensProfilePanel::LensProfilePanel() :
|
||||
lensfunCameras->signal_changed().connect(sigc::mem_fun(*this, &LensProfilePanel::onLensfunCameraChanged));
|
||||
lensfunLenses->signal_changed().connect(sigc::mem_fun(*this, &LensProfilePanel::onLensfunLensChanged));
|
||||
corrOffRB->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &LensProfilePanel::onCorrModeChanged), corrOffRB));
|
||||
corrMetadata->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &LensProfilePanel::onCorrModeChanged), corrMetadata));
|
||||
corrLensfunAutoRB->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &LensProfilePanel::onCorrModeChanged), corrLensfunAutoRB));
|
||||
corrLensfunManualRB->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &LensProfilePanel::onCorrModeChanged), corrLensfunManualRB));
|
||||
corrLcpFileRB->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &LensProfilePanel::onCorrModeChanged), corrLcpFileRB));
|
||||
@@ -211,30 +215,52 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
break;
|
||||
}
|
||||
|
||||
case procparams::LensProfParams::LcMode::METADATA: {
|
||||
if (metadata) {
|
||||
auto metadataCorrection= rtengine::MetadataLensCorrectionFinder::findCorrection(metadata);
|
||||
if (metadataCorrection) {
|
||||
corrMetadata->set_active(true);
|
||||
corrMetadata->set_sensitive(true);
|
||||
} else {
|
||||
corrMetadata->set_sensitive(false);
|
||||
corrOffRB->set_active(true);
|
||||
}
|
||||
} else {
|
||||
corrMetadata->set_sensitive(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case procparams::LensProfParams::LcMode::NONE: {
|
||||
corrOffRB->set_active(true);
|
||||
setManualParamsVisibility(false);
|
||||
|
||||
ckbUseDist->set_sensitive(false);
|
||||
ckbUseVign->set_sensitive(false);
|
||||
ckbUseCA->set_sensitive(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp->lensProf.lcpFile.empty()) {
|
||||
const Glib::ustring lastFolder = corrLcpFileChooser->get_current_folder();
|
||||
corrLcpFileChooser->set_current_folder(lastFolder);
|
||||
corrLcpFileChooser->unselect_all();
|
||||
bindCurrentFolder(*corrLcpFileChooser, options.lastLensProfileDir);
|
||||
updateDisabled(false);
|
||||
}
|
||||
else if (LCPStore::getInstance()->isValidLCPFileName(pp->lensProf.lcpFile)) {
|
||||
corrLcpFileChooser->set_filename(pp->lensProf.lcpFile);
|
||||
|
||||
if (corrLcpFileRB->get_active()) {
|
||||
updateDisabled(true);
|
||||
if (pp->lensProf.lcMode == procparams::LensProfParams::LcMode::LCP) {
|
||||
if (pp->lensProf.lcpFile.empty()) {
|
||||
const Glib::ustring lastFolder = corrLcpFileChooser->get_current_folder();
|
||||
corrLcpFileChooser->set_current_folder(lastFolder);
|
||||
corrLcpFileChooser->unselect_all();
|
||||
bindCurrentFolder(*corrLcpFileChooser, options.lastLensProfileDir);
|
||||
updateLCPDisabled(false);
|
||||
}
|
||||
else if (LCPStore::getInstance()->isValidLCPFileName(pp->lensProf.lcpFile)) {
|
||||
corrLcpFileChooser->set_filename(pp->lensProf.lcpFile);
|
||||
|
||||
if (corrLcpFileRB->get_active()) {
|
||||
updateLCPDisabled(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
corrLcpFileChooser->unselect_filename(corrLcpFileChooser->get_filename());
|
||||
updateLCPDisabled(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
corrLcpFileChooser->unselect_filename(corrLcpFileChooser->get_filename());
|
||||
updateDisabled(false);
|
||||
}
|
||||
|
||||
const LFDatabase* const db = LFDatabase::getInstance();
|
||||
@@ -308,6 +334,9 @@ void LensProfilePanel::write(rtengine::procparams::ProcParams* pp, ParamsEdited*
|
||||
if (corrLcpFileRB->get_active()) {
|
||||
pp->lensProf.lcMode = procparams::LensProfParams::LcMode::LCP;
|
||||
}
|
||||
else if (corrMetadata->get_active()) {
|
||||
pp->lensProf.lcMode = procparams::LensProfParams::LcMode::METADATA;
|
||||
}
|
||||
else if (corrLensfunManualRB->get_active()) {
|
||||
pp->lensProf.lcMode = procparams::LensProfParams::LcMode::LENSFUNMANUAL;
|
||||
}
|
||||
@@ -367,12 +396,18 @@ void LensProfilePanel::setRawMeta(bool raw, const rtengine::FramesMetaData* pMet
|
||||
|
||||
// CA is very focus layer dependent, otherwise it might even worsen things
|
||||
allowFocusDep = false;
|
||||
ckbUseCA->set_active(false);
|
||||
ckbUseCA->set_sensitive(false);
|
||||
|
||||
enableListener();
|
||||
}
|
||||
|
||||
corrMetadata->set_sensitive(false);
|
||||
if (pMeta) {
|
||||
metadataCorrection = MetadataLensCorrectionFinder::findCorrection(pMeta);
|
||||
if (metadataCorrection) {
|
||||
corrMetadata->set_sensitive(true);
|
||||
}
|
||||
}
|
||||
|
||||
isRaw = raw;
|
||||
metadata = pMeta;
|
||||
}
|
||||
@@ -381,7 +416,7 @@ void LensProfilePanel::onLCPFileChanged()
|
||||
{
|
||||
lcpFileChanged = true;
|
||||
const bool valid = LCPStore::getInstance()->isValidLCPFileName(corrLcpFileChooser->get_filename());
|
||||
updateDisabled(valid);
|
||||
updateLCPDisabled(valid);
|
||||
|
||||
if (listener) {
|
||||
if (valid) {
|
||||
@@ -552,10 +587,20 @@ void LensProfilePanel::onCorrModeChanged(const Gtk::RadioButton* rbChanged)
|
||||
lensfunAutoChanged = true;
|
||||
lcpFileChanged = true;
|
||||
|
||||
updateDisabled(true);
|
||||
updateLCPDisabled(true);
|
||||
|
||||
mode = M("TP_LENSPROFILE_CORRECTION_LCPFILE");
|
||||
|
||||
} else if (rbChanged == corrMetadata) {
|
||||
lcModeChanged = true;
|
||||
useLensfunChanged = true;
|
||||
lensfunAutoChanged = true;
|
||||
lcpFileChanged = true;
|
||||
|
||||
updateMetadataDisabled();
|
||||
|
||||
mode = M("TP_LENSPROFILE_CORRECTION_METADATA");
|
||||
|
||||
} else if (rbChanged == corrUnchangedRB) {
|
||||
lcModeChanged = false;
|
||||
useLensfunChanged = false;
|
||||
@@ -680,7 +725,7 @@ void LensProfilePanel::LFDbHelper::fillLensfunLenses()
|
||||
}
|
||||
}
|
||||
|
||||
void LensProfilePanel::updateDisabled(bool enable)
|
||||
void LensProfilePanel::updateLCPDisabled(bool enable)
|
||||
{
|
||||
if (!batchMode) {
|
||||
ckbUseDist->set_sensitive(enable);
|
||||
@@ -689,6 +734,21 @@ void LensProfilePanel::updateDisabled(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
void LensProfilePanel::updateMetadataDisabled()
|
||||
{
|
||||
if (!batchMode) {
|
||||
if (metadataCorrection) {
|
||||
ckbUseDist->set_sensitive(metadataCorrection->hasDistortionCorrection());
|
||||
ckbUseVign->set_sensitive(metadataCorrection->hasVignettingCorrection());
|
||||
ckbUseCA->set_sensitive(metadataCorrection->hasCACorrection());
|
||||
} else {
|
||||
ckbUseDist->set_sensitive(false);
|
||||
ckbUseVign->set_sensitive(false);
|
||||
ckbUseCA->set_sensitive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LensProfilePanel::setLensfunCamera(const Glib::ustring& make, const Glib::ustring& model)
|
||||
{
|
||||
if (!make.empty() && !model.empty()) {
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "guiutils.h"
|
||||
#include "toolpanel.h"
|
||||
#include "../rtengine/lensmetadata.h"
|
||||
|
||||
class LensProfilePanel final :
|
||||
public ToolParamBlock,
|
||||
@@ -89,7 +90,8 @@ private:
|
||||
void fillLensfunLenses();
|
||||
};
|
||||
|
||||
void updateDisabled(bool enable);
|
||||
void updateLCPDisabled(bool enable);
|
||||
void updateMetadataDisabled();
|
||||
|
||||
bool setLensfunCamera(const Glib::ustring& make, const Glib::ustring& model);
|
||||
bool setLensfunLens(const Glib::ustring& lens);
|
||||
@@ -113,12 +115,14 @@ private:
|
||||
bool allowFocusDep;
|
||||
bool isRaw;
|
||||
const rtengine::FramesMetaData* metadata;
|
||||
std::unique_ptr<rtengine::MetadataLensCorrection> metadataCorrection;
|
||||
|
||||
Gtk::Grid* const modesGrid;
|
||||
Gtk::Grid* const distGrid;
|
||||
Gtk::RadioButton* const corrUnchangedRB;
|
||||
Gtk::RadioButton::Group corrGroup;
|
||||
Gtk::RadioButton* const corrOffRB;
|
||||
Gtk::RadioButton* const corrMetadata;
|
||||
Gtk::RadioButton* const corrLensfunAutoRB;
|
||||
Gtk::RadioButton* const corrLensfunManualRB;
|
||||
Gtk::RadioButton* const corrLcpFileRB;
|
||||
|
Reference in New Issue
Block a user