lensfun: further tweaks on the matching logic and the UI
This commit is contained in:
@@ -262,7 +262,7 @@ LFCamera LFDatabase::findCamera(const Glib::ustring &make, const Glib::ustring &
|
|||||||
{
|
{
|
||||||
LFCamera ret;
|
LFCamera ret;
|
||||||
if (data_) {
|
if (data_) {
|
||||||
auto found = data_->FindCamerasExt(make.c_str(), model.c_str(), LF_SEARCH_LOOSE);
|
auto found = data_->FindCamerasExt(make.c_str(), model.c_str());
|
||||||
if (found) {
|
if (found) {
|
||||||
ret.data_ = found[0];
|
ret.data_ = found[0];
|
||||||
lf_free(found);
|
lf_free(found);
|
||||||
@@ -276,12 +276,12 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c
|
|||||||
{
|
{
|
||||||
LFLens ret;
|
LFLens ret;
|
||||||
if (data_) {
|
if (data_) {
|
||||||
const char *lname = name.c_str();
|
Glib::ustring lname = name;
|
||||||
bool stdlens = camera.ok() && (name.empty() || name.find("Unknown ") == 0);
|
bool stdlens = camera.ok() && (name.empty() || name.find("Unknown ") == 0);
|
||||||
if (stdlens) {
|
if (stdlens) {
|
||||||
lname = "Standard";
|
lname = camera.getModel(); // "Standard"
|
||||||
}
|
}
|
||||||
auto found = data_->FindLenses(camera.data_, nullptr, lname, LF_SEARCH_LOOSE);
|
auto found = data_->FindLenses(camera.data_, nullptr, lname.c_str());
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// try to split the maker from the model of the lens
|
// try to split the maker from the model of the lens
|
||||||
Glib::ustring make, model;
|
Glib::ustring make, model;
|
||||||
@@ -289,7 +289,7 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c
|
|||||||
if (i != Glib::ustring::npos) {
|
if (i != Glib::ustring::npos) {
|
||||||
make = name.substr(0, i);
|
make = name.substr(0, i);
|
||||||
model = name.substr(i+1);
|
model = name.substr(i+1);
|
||||||
found = data_->FindLenses(camera.data_, make.c_str(), model.c_str(), LF_SEARCH_LOOSE);
|
found = data_->FindLenses(camera.data_, make.c_str(), model.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@@ -174,25 +174,31 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
|||||||
ckbUseVign->set_active (pp->lensProf.useVign && isRaw);
|
ckbUseVign->set_active (pp->lensProf.useVign && isRaw);
|
||||||
ckbUseCA->set_active (pp->lensProf.useCA && isRaw);
|
ckbUseCA->set_active (pp->lensProf.useCA && isRaw);
|
||||||
|
|
||||||
setLensfunCamera(pp->lensProf.lfCameraMake, pp->lensProf.lfCameraModel);
|
const LFDatabase *db = LFDatabase::getInstance();
|
||||||
setLensfunLens(pp->lensProf.lfLens);
|
LFCamera c;
|
||||||
|
LFLens l;
|
||||||
|
if (metadata) {
|
||||||
|
c = db->findCamera(metadata->getMake(), metadata->getModel());
|
||||||
|
l = db->findLens(c, metadata->getLens());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!setLensfunCamera(pp->lensProf.lfCameraMake, pp->lensProf.lfCameraModel) && pp->lensProf.lfAutoMatch) {
|
||||||
|
setLensfunCamera(c.getMake(), c.getModel());
|
||||||
|
}
|
||||||
|
if (!setLensfunLens(pp->lensProf.lfLens) && pp->lensProf.lfAutoMatch) {
|
||||||
|
setLensfunLens(l.getLens());
|
||||||
|
}
|
||||||
|
|
||||||
lcpFileChanged = useDistChanged = useVignChanged = useCAChanged = false;
|
lcpFileChanged = useDistChanged = useVignChanged = useCAChanged = false;
|
||||||
useLensfunChanged = lensfunAutoChanged = lensfunCameraChanged = lensfunLensChanged = false;
|
useLensfunChanged = lensfunAutoChanged = lensfunCameraChanged = lensfunLensChanged = false;
|
||||||
|
|
||||||
if (!batchMode && metadata && pp->lensProf.useLensfun) {
|
if (metadata) {
|
||||||
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(pp->lensProf, metadata, 100, 100, pp->coarse, -1));
|
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(pp->lensProf, metadata, 100, 100, pp->coarse, -1));
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
|
if (pp->lensProf.useLensfun) {
|
||||||
corrOff->set_active(true);
|
corrOff->set_active(true);
|
||||||
if (pp->lensProf.lfAutoMatch) {
|
|
||||||
corrLensfunAuto->set_sensitive(false);
|
|
||||||
}
|
}
|
||||||
} else if (pp->lensProf.lfAutoMatch) {
|
corrLensfunAuto->set_sensitive(false);
|
||||||
const LFDatabase *db = LFDatabase::getInstance();
|
|
||||||
LFCamera c = db->findCamera(metadata->getMake(), metadata->getModel());
|
|
||||||
LFLens l = db->findLens(c, metadata->getLens());
|
|
||||||
setLensfunCamera(c.getMake(), c.getModel());
|
|
||||||
setLensfunLens(l.getLens());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +372,11 @@ void LensProfilePanel::fillLensfunLenses()
|
|||||||
bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::ustring &model)
|
bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::ustring &model)
|
||||||
{
|
{
|
||||||
if (!make.empty() && !model.empty()) {
|
if (!make.empty() && !model.empty()) {
|
||||||
|
auto it = lensfunCameras->get_active();
|
||||||
|
if (it && (*it)[lensfunModelCam.make] == make && (*it)[lensfunModelCam.model] == model) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// search for the active row
|
// search for the active row
|
||||||
for (auto row : lensfunCameraModel->children()) {
|
for (auto row : lensfunCameraModel->children()) {
|
||||||
if (row[lensfunModelCam.make] == make) {
|
if (row[lensfunModelCam.make] == make) {
|
||||||
@@ -381,6 +392,7 @@ bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lensfunCameras->set_active(-1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,6 +400,11 @@ bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::u
|
|||||||
bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
||||||
{
|
{
|
||||||
if (!lens.empty()) {
|
if (!lens.empty()) {
|
||||||
|
auto it = lensfunLenses->get_active();
|
||||||
|
if (it && (*it)[lensfunModelLens.lens] == lens) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// search for the active row
|
// search for the active row
|
||||||
auto pos = lens.find_first_of(' ');
|
auto pos = lens.find_first_of(' ');
|
||||||
Glib::ustring make = "(Unknown)";
|
Glib::ustring make = "(Unknown)";
|
||||||
@@ -409,6 +426,7 @@ bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lensfunLenses->set_active(-1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user