use a static initialization of the list of lensfun cameras and lenses
This commit is contained in:
parent
07dfda5d73
commit
376cb09f06
@ -29,6 +29,8 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
|
LensProfilePanel::LFDbHelper *LensProfilePanel::lf(nullptr);
|
||||||
|
|
||||||
LensProfilePanel::LensProfilePanel () :
|
LensProfilePanel::LensProfilePanel () :
|
||||||
FoldableToolPanel(this, "lensprof", M("TP_LENSPROFILE_LABEL")),
|
FoldableToolPanel(this, "lensprof", M("TP_LENSPROFILE_LABEL")),
|
||||||
lcpFileChanged(false),
|
lcpFileChanged(false),
|
||||||
@ -43,6 +45,10 @@ LensProfilePanel::LensProfilePanel () :
|
|||||||
lensfunCameraChanged(false),
|
lensfunCameraChanged(false),
|
||||||
lensfunLensChanged(false)
|
lensfunLensChanged(false)
|
||||||
{
|
{
|
||||||
|
if (!lf) {
|
||||||
|
lf = new LFDbHelper();
|
||||||
|
}
|
||||||
|
|
||||||
corrOff = Gtk::manage(new Gtk::RadioButton(M("LENSPROFILE_CORRECTION_OFF")));
|
corrOff = Gtk::manage(new Gtk::RadioButton(M("LENSPROFILE_CORRECTION_OFF")));
|
||||||
pack_start(*corrOff);
|
pack_start(*corrOff);
|
||||||
|
|
||||||
@ -54,30 +60,23 @@ LensProfilePanel::LensProfilePanel () :
|
|||||||
corrLensfunManual = Gtk::manage(new Gtk::RadioButton(corrGroup, M("LENSPROFILE_CORRECTION_MANUAL")));
|
corrLensfunManual = Gtk::manage(new Gtk::RadioButton(corrGroup, M("LENSPROFILE_CORRECTION_MANUAL")));
|
||||||
pack_start(*corrLensfunManual);
|
pack_start(*corrLensfunManual);
|
||||||
|
|
||||||
lensfunCameraModel = Gtk::TreeStore::create(lensfunModelCam);
|
|
||||||
lensfunLensModel = Gtk::TreeStore::create(lensfunModelLens);
|
|
||||||
|
|
||||||
lensfunCameras = Gtk::manage(new MyComboBox());
|
lensfunCameras = Gtk::manage(new MyComboBox());
|
||||||
lensfunCameras->set_model(lensfunCameraModel);
|
lensfunCameras->set_model(lf->lensfunCameraModel);
|
||||||
lensfunCameras->pack_start(lensfunModelCam.model);
|
lensfunCameras->pack_start(lf->lensfunModelCam.model);
|
||||||
lensfunLenses = Gtk::manage(new MyComboBox());
|
lensfunLenses = Gtk::manage(new MyComboBox());
|
||||||
lensfunLenses->set_model(lensfunLensModel);
|
lensfunLenses->set_model(lf->lensfunLensModel);
|
||||||
lensfunLenses->pack_start(lensfunModelLens.lens);
|
lensfunLenses->pack_start(lf->lensfunModelLens.prettylens);
|
||||||
|
|
||||||
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("EXIFFILTER_CAMERA"))), Gtk::PACK_SHRINK, 4);
|
hb->pack_start(*Gtk::manage(new Gtk::Label(M("EXIFFILTER_CAMERA"))), Gtk::PACK_SHRINK, 4);
|
||||||
hb->pack_start(*lensfunCameras);
|
hb->pack_start(*lensfunCameras);
|
||||||
pack_start(*hb);
|
pack_start(*hb);
|
||||||
|
|
||||||
fillLensfunCameras();
|
|
||||||
|
|
||||||
hb = Gtk::manage(new Gtk::HBox());
|
hb = Gtk::manage(new Gtk::HBox());
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("EXIFFILTER_LENS"))), Gtk::PACK_SHRINK, 4);
|
hb->pack_start(*Gtk::manage(new Gtk::Label(M("EXIFFILTER_LENS"))), Gtk::PACK_SHRINK, 4);
|
||||||
hb->pack_start(*lensfunLenses);
|
hb->pack_start(*lensfunLenses);
|
||||||
pack_start(*hb);
|
pack_start(*hb);
|
||||||
|
|
||||||
fillLensfunLenses();
|
|
||||||
|
|
||||||
corrLcpFile = Gtk::manage(new Gtk::RadioButton(corrGroup));
|
corrLcpFile = Gtk::manage(new Gtk::RadioButton(corrGroup));
|
||||||
hbLCPFile = Gtk::manage(new Gtk::HBox());
|
hbLCPFile = Gtk::manage(new Gtk::HBox());
|
||||||
hbLCPFile->pack_start(*corrLcpFile, Gtk::PACK_SHRINK);
|
hbLCPFile->pack_start(*corrLcpFile, Gtk::PACK_SHRINK);
|
||||||
@ -249,15 +248,15 @@ void LensProfilePanel::write( rtengine::procparams::ProcParams* pp, ParamsEdited
|
|||||||
pp->lensProf.lfAutoMatch = corrLensfunAuto->get_active();
|
pp->lensProf.lfAutoMatch = corrLensfunAuto->get_active();
|
||||||
auto itc = lensfunCameras->get_active();
|
auto itc = lensfunCameras->get_active();
|
||||||
if (itc) {
|
if (itc) {
|
||||||
pp->lensProf.lfCameraMake = (*itc)[lensfunModelCam.make];
|
pp->lensProf.lfCameraMake = (*itc)[lf->lensfunModelCam.make];
|
||||||
pp->lensProf.lfCameraModel = (*itc)[lensfunModelCam.model];
|
pp->lensProf.lfCameraModel = (*itc)[lf->lensfunModelCam.model];
|
||||||
} else {
|
} else {
|
||||||
pp->lensProf.lfCameraMake = "";
|
pp->lensProf.lfCameraMake = "";
|
||||||
pp->lensProf.lfCameraModel = "";
|
pp->lensProf.lfCameraModel = "";
|
||||||
}
|
}
|
||||||
auto itl = lensfunLenses->get_active();
|
auto itl = lensfunLenses->get_active();
|
||||||
if (itl) {
|
if (itl) {
|
||||||
pp->lensProf.lfLens = (*itl)[lensfunModelLens.lens];
|
pp->lensProf.lfLens = (*itl)[lf->lensfunModelLens.lens];
|
||||||
} else {
|
} else {
|
||||||
pp->lensProf.lfLens = "";
|
pp->lensProf.lfLens = "";
|
||||||
}
|
}
|
||||||
@ -335,61 +334,21 @@ void LensProfilePanel::setBatchMode(bool yes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LensProfilePanel::fillLensfunCameras()
|
|
||||||
{
|
|
||||||
std::map<Glib::ustring, std::set<Glib::ustring>> camnames;
|
|
||||||
auto camlist = LFDatabase::getInstance()->getCameras();
|
|
||||||
for (auto &c : camlist) {
|
|
||||||
camnames[c.getMake()].insert(c.getModel());
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
child[lensfunModelCam.model] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LensProfilePanel::fillLensfunLenses()
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
lenses[make].insert(name);
|
|
||||||
}
|
|
||||||
for (auto &p : lenses) {
|
|
||||||
Gtk::TreeModel::Row row = *(lensfunLensModel->append());
|
|
||||||
row[lensfunModelLens.lens] = p.first;
|
|
||||||
for (auto &c : p.second) {
|
|
||||||
Gtk::TreeModel::Row child = *(lensfunLensModel->append(row.children()));
|
|
||||||
child[lensfunModelLens.lens] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
auto it = lensfunCameras->get_active();
|
||||||
if (it && (*it)[lensfunModelCam.make] == make && (*it)[lensfunModelCam.model] == model) {
|
if (it && (*it)[lf->lensfunModelCam.make] == make && (*it)[lf->lensfunModelCam.model] == model) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search for the active row
|
// search for the active row
|
||||||
for (auto row : lensfunCameraModel->children()) {
|
for (auto row : lf->lensfunCameraModel->children()) {
|
||||||
if (row[lensfunModelCam.make] == make) {
|
if (row[lf->lensfunModelCam.make] == make) {
|
||||||
auto &c = row.children();
|
auto &c = row.children();
|
||||||
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
||||||
auto &childrow = *it;
|
auto &childrow = *it;
|
||||||
if (childrow[lensfunModelCam.model] == model) {
|
if (childrow[lf->lensfunModelCam.model] == model) {
|
||||||
lensfunCameras->set_active(it);
|
lensfunCameras->set_active(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -407,16 +366,16 @@ bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
|
|||||||
{
|
{
|
||||||
if (!lens.empty()) {
|
if (!lens.empty()) {
|
||||||
auto it = lensfunLenses->get_active();
|
auto it = lensfunLenses->get_active();
|
||||||
if (it && (*it)[lensfunModelLens.lens] == lens) {
|
if (it && (*it)[lf->lensfunModelLens.lens] == lens) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto row : lensfunLensModel->children()) {
|
for (auto row : lf->lensfunLensModel->children()) {
|
||||||
if (lens.find(row[lensfunModelLens.lens]) == 0) {
|
if (lens.find(row[lf->lensfunModelLens.lens]) == 0) {
|
||||||
auto &c = row.children();
|
auto &c = row.children();
|
||||||
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
|
||||||
auto &childrow = *it;
|
auto &childrow = *it;
|
||||||
if (childrow[lensfunModelLens.lens] == lens) {
|
if (childrow[lf->lensfunModelLens.lens] == lens) {
|
||||||
lensfunLenses->set_active(it);
|
lensfunLenses->set_active(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -439,7 +398,7 @@ void LensProfilePanel::onLensfunCameraChanged()
|
|||||||
lensfunCameraChanged = true;
|
lensfunCameraChanged = true;
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
Glib::ustring name = (*iter)[lensfunModelCam.model];
|
Glib::ustring name = (*iter)[lf->lensfunModelCam.model];
|
||||||
listener->panelChanged(EvLensCorrLensfunCamera, name);
|
listener->panelChanged(EvLensCorrLensfunCamera, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,7 +413,7 @@ void LensProfilePanel::onLensfunLensChanged()
|
|||||||
lensfunLensChanged = true;
|
lensfunLensChanged = true;
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
Glib::ustring name = (*iter)[lensfunModelLens.lens];
|
Glib::ustring name = (*iter)[lf->lensfunModelLens.lens];
|
||||||
listener->panelChanged(EvLensCorrLensfunLens, name);
|
listener->panelChanged(EvLensCorrLensfunLens, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,3 +509,62 @@ bool LensProfilePanel::checkLensfunCanCorrect(bool automatch)
|
|||||||
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
|
std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
|
||||||
return mod.get() != nullptr;
|
return mod.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// LFDbHelper
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LensProfilePanel::LFDbHelper::LFDbHelper()
|
||||||
|
{
|
||||||
|
lensfunCameraModel = Gtk::TreeStore::create(lensfunModelCam);
|
||||||
|
lensfunLensModel = Gtk::TreeStore::create(lensfunModelLens);
|
||||||
|
|
||||||
|
fillLensfunCameras();
|
||||||
|
fillLensfunLenses();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LensProfilePanel::LFDbHelper::fillLensfunCameras()
|
||||||
|
{
|
||||||
|
std::map<Glib::ustring, std::set<Glib::ustring>> camnames;
|
||||||
|
auto camlist = LFDatabase::getInstance()->getCameras();
|
||||||
|
for (auto &c : camlist) {
|
||||||
|
camnames[c.getMake()].insert(c.getModel());
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
child[lensfunModelCam.model] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LensProfilePanel::LFDbHelper::fillLensfunLenses()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
lenses[make].insert(name);
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
child[lensfunModelLens.prettylens] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -51,32 +51,39 @@ protected:
|
|||||||
MyComboBox *lensfunCameras;
|
MyComboBox *lensfunCameras;
|
||||||
MyComboBox *lensfunLenses;
|
MyComboBox *lensfunLenses;
|
||||||
|
|
||||||
class LFModelCam: public Gtk::TreeModel::ColumnRecord {
|
class LFDbHelper {
|
||||||
public:
|
public:
|
||||||
LFModelCam() { add(make); add(model); }
|
class LFModelCam: public Gtk::TreeModel::ColumnRecord {
|
||||||
Gtk::TreeModelColumn<Glib::ustring> make;
|
public:
|
||||||
Gtk::TreeModelColumn<Glib::ustring> 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:
|
public:
|
||||||
LFModelLens() { add(lens); }
|
LFModelLens() { add(lens); add(prettylens); }
|
||||||
Gtk::TreeModelColumn<Glib::ustring> lens;
|
Gtk::TreeModelColumn<Glib::ustring> lens;
|
||||||
};
|
Gtk::TreeModelColumn<Glib::ustring> prettylens;
|
||||||
|
};
|
||||||
|
|
||||||
LFModelCam lensfunModelCam;
|
LFModelCam lensfunModelCam;
|
||||||
LFModelLens lensfunModelLens;
|
LFModelLens lensfunModelLens;
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> lensfunCameraModel;
|
Glib::RefPtr<Gtk::TreeStore> lensfunCameraModel;
|
||||||
Glib::RefPtr<Gtk::TreeStore> lensfunLensModel;
|
Glib::RefPtr<Gtk::TreeStore> lensfunLensModel;
|
||||||
|
|
||||||
|
LFDbHelper();
|
||||||
|
void fillLensfunCameras();
|
||||||
|
void fillLensfunLenses();
|
||||||
|
};
|
||||||
|
static LFDbHelper *lf;
|
||||||
|
|
||||||
bool useLensfunChanged;
|
bool useLensfunChanged;
|
||||||
bool lensfunAutoChanged;
|
bool lensfunAutoChanged;
|
||||||
bool lensfunCameraChanged;
|
bool lensfunCameraChanged;
|
||||||
bool lensfunLensChanged;
|
bool lensfunLensChanged;
|
||||||
|
|
||||||
void fillLensfunCameras();
|
|
||||||
void fillLensfunLenses();
|
|
||||||
bool setLensfunCamera(const Glib::ustring &make, const Glib::ustring &model);
|
bool setLensfunCamera(const Glib::ustring &make, const Glib::ustring &model);
|
||||||
bool setLensfunLens(const Glib::ustring &lens);
|
bool setLensfunLens(const Glib::ustring &lens);
|
||||||
bool checkLensfunCanCorrect(bool automatch);
|
bool checkLensfunCanCorrect(bool automatch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user