properly disable auto-matched lens correction when not available

This commit is contained in:
Alberto Griggio
2017-09-09 18:42:16 +02:00
parent 0c0f3d146d
commit 03ec1abca8
2 changed files with 32 additions and 8 deletions

View File

@@ -183,7 +183,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
}
if (!setLensfunCamera(pp->lensProf.lfCameraMake, pp->lensProf.lfCameraModel) && pp->lensProf.lfAutoMatch) {
setLensfunCamera(c.getMake(), c.getModel());
setLensfunCamera(c.getMake(), c.getModel());
}
if (!setLensfunLens(pp->lensProf.lfLens) && pp->lensProf.lfAutoMatch) {
setLensfunLens(l.getLens());
@@ -192,16 +192,26 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
lcpFileChanged = useDistChanged = useVignChanged = useCAChanged = false;
useLensfunChanged = lensfunAutoChanged = lensfunCameraChanged = lensfunLensChanged = false;
if (metadata) {
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(pp->lensProf, metadata, 100, 100, pp->coarse, -1));
if (!mod) {
if (pp->lensProf.useLensfun) {
corrOff->set_active(true);
}
corrLensfunAuto->set_sensitive(false);
if (!checkLensfunCanCorrect(true)) {
if (corrLensfunAuto->get_active()) {
corrOff->set_active(true);
}
corrLensfunAuto->set_sensitive(false);
}
if (corrLensfunManual->get_active() && !checkLensfunCanCorrect(false)) {
corrOff->set_active(true);
}
// if (metadata) {
// std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(pp->lensProf, metadata, 100, 100, pp->coarse, -1));
// if (!mod) {
// if (pp->lensProf.useLensfun) {
// corrOff->set_active(true);
// }
// corrLensfunAuto->set_sensitive(false);
// }
// }
enableListener ();
conUseDist.block(false);
}
@@ -526,3 +536,16 @@ void LensProfilePanel::onCorrModeChanged()
listener->panelChanged(EvLensCorrMode, mode);
}
}
bool LensProfilePanel::checkLensfunCanCorrect(bool automatch)
{
if (!metadata) {
return false;
}
rtengine::procparams::ProcParams lpp;
write(&lpp);
lpp.lensProf.lfAutoMatch = automatch;
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
return mod.get() != nullptr;
}