Formatted lensprofile.*
This commit is contained in:
@@ -119,6 +119,7 @@ LensProfilePanel::LensProfilePanel () :
|
||||
} else if (!options.lastLensProfileDir.empty()) {
|
||||
fcbLCPFile->set_current_folder(options.lastLensProfileDir);
|
||||
}
|
||||
|
||||
bindCurrentFolder(*fcbLCPFile, options.lastLensProfileDir);
|
||||
|
||||
hbLCPFile->pack_start(*fcbLCPFile);
|
||||
@@ -164,12 +165,15 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
case procparams::LensProfParams::LcMode::LCP :
|
||||
corrLcpFile->set_active(true);
|
||||
break;
|
||||
|
||||
case procparams::LensProfParams::LcMode::LENSFUNAUTOMATCH :
|
||||
corrLensfunAuto->set_active(true);
|
||||
break;
|
||||
|
||||
case procparams::LensProfParams::LcMode::LENSFUNMANUAL :
|
||||
corrLensfunManual->set_active(true);
|
||||
break;
|
||||
|
||||
case procparams::LensProfParams::LcMode::NONE :
|
||||
corrOff->set_active(true);
|
||||
}
|
||||
@@ -182,6 +186,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
updateDisabled(false);
|
||||
} else if (LCPStore::getInstance()->isValidLCPFileName(pp->lensProf.lcpFile)) {
|
||||
fcbLCPFile->set_filename(pp->lensProf.lcpFile);
|
||||
|
||||
if (corrLcpFile->get_active()) {
|
||||
updateDisabled(true);
|
||||
}
|
||||
@@ -199,6 +204,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
setLensfunCamera(c.getMake(), c.getModel());
|
||||
}
|
||||
}
|
||||
|
||||
if (!setLensfunLens(pp->lensProf.lfLens) && !pp->lensProf.lfManual()) {
|
||||
if (metadata) {
|
||||
LFLens l = db->findLens(c, metadata->getLens());
|
||||
@@ -213,6 +219,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
if (corrLensfunAuto->get_active()) {
|
||||
corrOff->set_active(true);
|
||||
}
|
||||
|
||||
corrLensfunAuto->set_sensitive(false);
|
||||
}
|
||||
|
||||
@@ -234,33 +241,43 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
|
||||
void LensProfilePanel::updateLensfunWarning()
|
||||
{
|
||||
warning->hide();
|
||||
|
||||
if (corrLensfunManual->get_active() || corrLensfunAuto->get_active()) {
|
||||
const LFDatabase *db = LFDatabase::getInstance();
|
||||
|
||||
auto itc = lensfunCameras->get_active();
|
||||
|
||||
if (!itc) {
|
||||
return;
|
||||
}
|
||||
|
||||
LFCamera c = db->findCamera((*itc)[lf->lensfunModelCam.make], (*itc)[lf->lensfunModelCam.model]);
|
||||
auto itl = lensfunLenses->get_active();
|
||||
|
||||
if (!itl) {
|
||||
return;
|
||||
}
|
||||
|
||||
LFLens l = db->findLens(LFCamera(), (*itl)[lf->lensfunModelLens.lens]);
|
||||
float lenscrop = l.getCropFactor();
|
||||
float camcrop = c.getCropFactor();
|
||||
|
||||
if (lenscrop <= 0 || camcrop <= 0 || lenscrop / camcrop >= 1.01f) {
|
||||
warning->show();
|
||||
}
|
||||
|
||||
ckbUseVign->set_sensitive(l.hasVignettingCorrection());
|
||||
ckbUseDist->set_sensitive(l.hasDistortionCorrection());
|
||||
ckbUseCA->set_sensitive(l.hasCACorrection());
|
||||
|
||||
if (!isRaw || !l.hasVignettingCorrection()) {
|
||||
ckbUseVign->set_active(false);
|
||||
}
|
||||
|
||||
if (!l.hasDistortionCorrection()) {
|
||||
ckbUseDist->set_active(false);
|
||||
}
|
||||
|
||||
if (!l.hasCACorrection()) {
|
||||
ckbUseCA->set_active(false);
|
||||
}
|
||||
@@ -307,6 +324,7 @@ void LensProfilePanel::write( rtengine::procparams::ProcParams* pp, ParamsEdited
|
||||
pp->lensProf.useCA = ckbUseCA->get_active();
|
||||
|
||||
auto itc = lensfunCameras->get_active();
|
||||
|
||||
if (itc) {
|
||||
pp->lensProf.lfCameraMake = (*itc)[lf->lensfunModelCam.make];
|
||||
pp->lensProf.lfCameraModel = (*itc)[lf->lensfunModelCam.model];
|
||||
@@ -314,7 +332,9 @@ void LensProfilePanel::write( rtengine::procparams::ProcParams* pp, ParamsEdited
|
||||
pp->lensProf.lfCameraMake = "";
|
||||
pp->lensProf.lfCameraModel = "";
|
||||
}
|
||||
|
||||
auto itl = lensfunLenses->get_active();
|
||||
|
||||
if (itl) {
|
||||
pp->lensProf.lfLens = (*itl)[lf->lensfunModelLens.lens];
|
||||
} else {
|
||||
@@ -347,6 +367,7 @@ void LensProfilePanel::onLCPFileChanged()
|
||||
corrLcpFile->set_active(true);
|
||||
enableListener();
|
||||
}
|
||||
|
||||
listener->panelChanged(EvLCPFile, Glib::path_get_basename(fcbLCPFile->get_filename()));
|
||||
}
|
||||
}
|
||||
@@ -386,6 +407,7 @@ void LensProfilePanel::updateDisabled(bool enable)
|
||||
void LensProfilePanel::setBatchMode(bool yes)
|
||||
{
|
||||
FoldableToolPanel::setBatchMode(yes);
|
||||
|
||||
if (yes) {
|
||||
corrUnchanged->show();
|
||||
corrUnchanged->set_active(true);
|
||||
@@ -399,6 +421,7 @@ bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::u
|
||||
{
|
||||
if (!make.empty() && !model.empty()) {
|
||||
auto it = lensfunCameras->get_active();
|
||||
|
||||
if (it && (*it)[lf->lensfunModelCam.make] == make && (*it)[lf->lensfunModelCam.model] == model) {
|
||||
return true;
|
||||
}
|
||||
@@ -407,17 +430,21 @@ bool LensProfilePanel::setLensfunCamera(const Glib::ustring &make, const Glib::u
|
||||
for (auto row : lf->lensfunCameraModel->children()) {
|
||||
if (row[lf->lensfunModelCam.make] == make) {
|
||||
auto &c = row.children();
|
||||
|
||||
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
||||
auto &childrow = *it;
|
||||
|
||||
if (childrow[lf->lensfunModelCam.model] == model) {
|
||||
lensfunCameras->set_active(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lensfunCameras->set_active(-1);
|
||||
return false;
|
||||
}
|
||||
@@ -427,21 +454,26 @@ bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
||||
{
|
||||
if (!lens.empty()) {
|
||||
auto it = lensfunLenses->get_active();
|
||||
|
||||
if (it && (*it)[lf->lensfunModelLens.lens] == lens) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool first_maker_found = false;
|
||||
|
||||
for (auto row : lf->lensfunLensModel->children()) {
|
||||
if (lens.find(row[lf->lensfunModelLens.lens]) == 0) {
|
||||
auto &c = row.children();
|
||||
|
||||
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
||||
auto &childrow = *it;
|
||||
|
||||
if (childrow[lf->lensfunModelLens.lens] == lens) {
|
||||
lensfunLenses->set_active(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// we do not break immediately here, because there might be multiple makers
|
||||
// sharing the same prefix (e.g. "Leica" and "Leica Camera AG").
|
||||
// therefore, we break below when the lens doesn't match any of them
|
||||
@@ -451,6 +483,7 @@ bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lensfunLenses->set_active(-1);
|
||||
return false;
|
||||
}
|
||||
@@ -533,6 +566,7 @@ void LensProfilePanel::onCorrModeChanged(const Gtk::RadioButton *rbChanged)
|
||||
LFLens l = db->findLens(c, metadata->getLens());
|
||||
setLensfunCamera(c.getMake(), c.getModel());
|
||||
setLensfunLens(l.getLens());
|
||||
|
||||
if (b) {
|
||||
enableListener();
|
||||
}
|
||||
@@ -590,6 +624,7 @@ bool LensProfilePanel::checkLensfunCanCorrect(bool automatch)
|
||||
if (!metadata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rtengine::procparams::ProcParams lpp;
|
||||
write(&lpp);
|
||||
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
|
||||
@@ -629,8 +664,10 @@ void LensProfilePanel::LFDbHelper::fillLensfunCameras()
|
||||
if (options.rtSettings.verbose) {
|
||||
std::cout << "LENSFUN, scanning cameras:" << std::endl;
|
||||
}
|
||||
|
||||
std::map<Glib::ustring, std::set<Glib::ustring>> camnames;
|
||||
auto camlist = LFDatabase::getInstance()->getCameras();
|
||||
|
||||
for (auto &c : camlist) {
|
||||
camnames[c.getMake()].insert(c.getModel());
|
||||
|
||||
@@ -638,10 +675,12 @@ void LensProfilePanel::LFDbHelper::fillLensfunCameras()
|
||||
std::cout << " found: " << c.getDisplayString().c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &p : camnames) {
|
||||
Gtk::TreeModel::Row row = *(lensfunCameraModel->append());
|
||||
row[lensfunModelCam.make] = p.first;
|
||||
row[lensfunModelCam.model] = p.first;
|
||||
|
||||
for (auto &c : p.second) {
|
||||
Gtk::TreeModel::Row child = *(lensfunCameraModel->append(row.children()));
|
||||
child[lensfunModelCam.make] = p.first;
|
||||
@@ -656,8 +695,10 @@ void LensProfilePanel::LFDbHelper::fillLensfunLenses()
|
||||
if (options.rtSettings.verbose) {
|
||||
std::cout << "LENSFUN, scanning lenses:" << std::endl;
|
||||
}
|
||||
|
||||
std::map<Glib::ustring, std::set<Glib::ustring>> lenses;
|
||||
auto lenslist = LFDatabase::getInstance()->getLenses();
|
||||
|
||||
for (auto &l : lenslist) {
|
||||
auto name = l.getLens();
|
||||
auto make = l.getMake();
|
||||
@@ -667,13 +708,16 @@ void LensProfilePanel::LFDbHelper::fillLensfunLenses()
|
||||
std::cout << " found: " << l.getDisplayString().c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &p : lenses) {
|
||||
Gtk::TreeModel::Row row = *(lensfunLensModel->append());
|
||||
row[lensfunModelLens.lens] = p.first;
|
||||
row[lensfunModelLens.prettylens] = p.first;
|
||||
|
||||
for (auto &c : p.second) {
|
||||
Gtk::TreeModel::Row child = *(lensfunLensModel->append(row.children()));
|
||||
child[lensfunModelLens.lens] = c;
|
||||
|
||||
if (c.find(p.first, p.first.size() + 1) == p.first.size() + 1) {
|
||||
child[lensfunModelLens.prettylens] = c.substr(p.first.size() + 1);
|
||||
} else {
|
||||
|
@@ -50,18 +50,29 @@ protected:
|
||||
MyComboBox *lensfunLenses;
|
||||
Gtk::Image *warning;
|
||||
|
||||
class LFDbHelper {
|
||||
class LFDbHelper
|
||||
{
|
||||
public:
|
||||
class LFModelCam: public Gtk::TreeModel::ColumnRecord {
|
||||
class LFModelCam: public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
LFModelCam() { add(make); add(model); }
|
||||
LFModelCam()
|
||||
{
|
||||
add(make);
|
||||
add(model);
|
||||
}
|
||||
Gtk::TreeModelColumn<Glib::ustring> make;
|
||||
Gtk::TreeModelColumn<Glib::ustring> model;
|
||||
};
|
||||
|
||||
class LFModelLens: public Gtk::TreeModel::ColumnRecord {
|
||||
class LFModelLens: public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
LFModelLens() { add(lens); add(prettylens); }
|
||||
LFModelLens()
|
||||
{
|
||||
add(lens);
|
||||
add(prettylens);
|
||||
}
|
||||
Gtk::TreeModelColumn<Glib::ustring> lens;
|
||||
Gtk::TreeModelColumn<Glib::ustring> prettylens;
|
||||
};
|
||||
|
Reference in New Issue
Block a user