Add filter for Paths to dynamic profiles (#6284)

Work by @nicolas-t 
* Path filter in dynamic profile panel
* Pass filename as a function argument
* Removed unused include
* Clearer translation
This commit is contained in:
Nicolas Turlais 2022-12-31 10:51:30 +01:00 committed by GitHub
parent 22831866cd
commit 401727fba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 44 additions and 8 deletions

View File

@ -61,6 +61,7 @@ EXIFFILTER_IMAGETYPE;Image type
EXIFFILTER_ISO;ISO EXIFFILTER_ISO;ISO
EXIFFILTER_LENS;Lens EXIFFILTER_LENS;Lens
EXIFFILTER_METADATAFILTER;Enable metadata filters EXIFFILTER_METADATAFILTER;Enable metadata filters
EXIFFILTER_PATH;File path
EXIFFILTER_SHUTTER;Shutter EXIFFILTER_SHUTTER;Shutter
EXIFPANEL_ADDEDIT;Add/Edit EXIFPANEL_ADDEDIT;Add/Edit
EXIFPANEL_ADDEDITHINT;Add new tag or edit tag. EXIFPANEL_ADDEDITHINT;Add new tag or edit tag.

View File

@ -77,7 +77,7 @@ bool DynamicProfileRule::operator< (const DynamicProfileRule &other) const
} }
bool DynamicProfileRule::matches (const rtengine::FramesMetaData *im) const bool DynamicProfileRule::matches (const rtengine::FramesMetaData *im, const Glib::ustring& filename) const
{ {
return (iso (im->getISOSpeed()) return (iso (im->getISOSpeed())
&& fnumber (im->getFNumber()) && fnumber (im->getFNumber())
@ -86,6 +86,7 @@ bool DynamicProfileRule::matches (const rtengine::FramesMetaData *im) const
&& expcomp (im->getExpComp()) && expcomp (im->getExpComp())
&& camera (im->getCamera()) && camera (im->getCamera())
&& lens (im->getLens()) && lens (im->getLens())
&& path (filename)
&& imagetype(im->getImageType(0))); && imagetype(im->getImageType(0)));
} }
@ -214,6 +215,7 @@ bool DynamicProfileRules::loadRules()
get_double_range (rule.expcomp, kf, group, "expcomp"); get_double_range (rule.expcomp, kf, group, "expcomp");
get_optional (rule.camera, kf, group, "camera"); get_optional (rule.camera, kf, group, "camera");
get_optional (rule.lens, kf, group, "lens"); get_optional (rule.lens, kf, group, "lens");
get_optional (rule.path, kf, group, "path");
get_optional (rule.imagetype, kf, group, "imagetype"); get_optional (rule.imagetype, kf, group, "imagetype");
try { try {
@ -247,6 +249,7 @@ bool DynamicProfileRules::storeRules()
set_double_range (kf, group, "expcomp", rule.expcomp); set_double_range (kf, group, "expcomp", rule.expcomp);
set_optional (kf, group, "camera", rule.camera); set_optional (kf, group, "camera", rule.camera);
set_optional (kf, group, "lens", rule.lens); set_optional (kf, group, "lens", rule.lens);
set_optional (kf, group, "path", rule.path);
set_optional (kf, group, "imagetype", rule.imagetype); set_optional (kf, group, "imagetype", rule.imagetype);
kf.set_string (group, "profilepath", rule.profilepath); kf.set_string (group, "profilepath", rule.profilepath);
} }

View File

@ -51,7 +51,7 @@ public:
}; };
DynamicProfileRule(); DynamicProfileRule();
bool matches (const rtengine::FramesMetaData *im) const; bool matches (const rtengine::FramesMetaData *im, const Glib::ustring& filename) const;
bool operator< (const DynamicProfileRule &other) const; bool operator< (const DynamicProfileRule &other) const;
int serial_number; int serial_number;
@ -62,6 +62,7 @@ public:
Range<double> expcomp; Range<double> expcomp;
Optional camera; Optional camera;
Optional lens; Optional lens;
Optional path;
Optional imagetype; Optional imagetype;
Glib::ustring profilepath; Glib::ustring profilepath;
}; };

View File

@ -508,7 +508,7 @@ void ProfileStore::dumpFolderList()
printf ("\n"); printf ("\n");
} }
PartialProfile *ProfileStore::loadDynamicProfile (const FramesMetaData *im) PartialProfile *ProfileStore::loadDynamicProfile (const FramesMetaData *im, const Glib::ustring& filename)
{ {
if (storeState == STORESTATE_NOTINITIALIZED) { if (storeState == STORESTATE_NOTINITIALIZED) {
parseProfilesOnce(); parseProfilesOnce();
@ -521,7 +521,7 @@ PartialProfile *ProfileStore::loadDynamicProfile (const FramesMetaData *im)
} }
for (auto rule : dynamicRules) { for (auto rule : dynamicRules) {
if (rule.matches (im)) { if (rule.matches (im, filename)) {
if (settings->verbose) { if (settings->verbose) {
printf ("found matching profile %s\n", rule.profilepath.c_str()); printf ("found matching profile %s\n", rule.profilepath.c_str());
} }

View File

@ -209,7 +209,7 @@ public:
void addListener (ProfileStoreListener *listener); void addListener (ProfileStoreListener *listener);
void removeListener (ProfileStoreListener *listener); void removeListener (ProfileStoreListener *listener);
rtengine::procparams::PartialProfile* loadDynamicProfile (const rtengine::FramesMetaData *im); rtengine::procparams::PartialProfile* loadDynamicProfile (const rtengine::FramesMetaData *im, const Glib::ustring& filename);
void dumpFolderList(); void dumpFolderList();
}; };

View File

@ -42,6 +42,7 @@ DynamicProfilePanel::EditDialog::EditDialog (const Glib::ustring &title, Gtk::Wi
add_optional (M ("EXIFFILTER_CAMERA"), has_camera_, camera_); add_optional (M ("EXIFFILTER_CAMERA"), has_camera_, camera_);
add_optional (M ("EXIFFILTER_LENS"), has_lens_, lens_); add_optional (M ("EXIFFILTER_LENS"), has_lens_, lens_);
add_optional (M ("EXIFFILTER_PATH"), has_path_, path_);
imagetype_ = Gtk::manage (new MyComboBoxText()); imagetype_ = Gtk::manage (new MyComboBoxText());
imagetype_->append(Glib::ustring("(") + M("DYNPROFILEEDITOR_IMGTYPE_ANY") + ")"); imagetype_->append(Glib::ustring("(") + M("DYNPROFILEEDITOR_IMGTYPE_ANY") + ")");
@ -93,6 +94,9 @@ void DynamicProfilePanel::EditDialog::set_rule (
has_lens_->set_active (rule.lens.enabled); has_lens_->set_active (rule.lens.enabled);
lens_->set_text (rule.lens.value); lens_->set_text (rule.lens.value);
has_path_->set_active (rule.path.enabled);
path_->set_text (rule.path.value);
if (!rule.imagetype.enabled) { if (!rule.imagetype.enabled) {
imagetype_->set_active(0); imagetype_->set_active(0);
} else if (rule.imagetype.value == "STD") { } else if (rule.imagetype.value == "STD") {
@ -136,6 +140,9 @@ DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
ret.lens.enabled = has_lens_->get_active(); ret.lens.enabled = has_lens_->get_active();
ret.lens.value = lens_->get_text(); ret.lens.value = lens_->get_text();
ret.path.enabled = has_path_->get_active();
ret.path.value = path_->get_text();
ret.imagetype.enabled = imagetype_->get_active_row_number() > 0; ret.imagetype.enabled = imagetype_->get_active_row_number() > 0;
switch (imagetype_->get_active_row_number()) { switch (imagetype_->get_active_row_number()) {
case 1: case 1:
@ -296,6 +303,16 @@ DynamicProfilePanel::DynamicProfilePanel():
*this, &DynamicProfilePanel::render_lens)); *this, &DynamicProfilePanel::render_lens));
} }
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_PATH"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_path));
}
cell = Gtk::manage (new Gtk::CellRendererText()); cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_IMAGETYPE"), *cell); cols_count = treeview_.append_column (M ("EXIFFILTER_IMAGETYPE"), *cell);
col = treeview_.get_column (cols_count - 1); col = treeview_.get_column (cols_count - 1);
@ -375,6 +392,7 @@ void DynamicProfilePanel::update_rule (Gtk::TreeModel::Row row,
row[columns_.expcomp] = rule.expcomp; row[columns_.expcomp] = rule.expcomp;
row[columns_.camera] = rule.camera; row[columns_.camera] = rule.camera;
row[columns_.lens] = rule.lens; row[columns_.lens] = rule.lens;
row[columns_.path] = rule.path;
row[columns_.imagetype] = rule.imagetype; row[columns_.imagetype] = rule.imagetype;
row[columns_.profilepath] = rule.profilepath; row[columns_.profilepath] = rule.profilepath;
} }
@ -398,6 +416,7 @@ DynamicProfileRule DynamicProfilePanel::to_rule (Gtk::TreeModel::Row row,
ret.expcomp = row[columns_.expcomp]; ret.expcomp = row[columns_.expcomp];
ret.camera = row[columns_.camera]; ret.camera = row[columns_.camera];
ret.lens = row[columns_.lens]; ret.lens = row[columns_.lens];
ret.path = row[columns_.path];
ret.profilepath = row[columns_.profilepath]; ret.profilepath = row[columns_.profilepath];
ret.imagetype = row[columns_.imagetype]; ret.imagetype = row[columns_.imagetype];
return ret; return ret;
@ -510,6 +529,12 @@ void DynamicProfilePanel::render_lens (
RENDER_OPTIONAL_ (lens); RENDER_OPTIONAL_ (lens);
} }
void DynamicProfilePanel::render_path (
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
{
RENDER_OPTIONAL_ (path);
}
void DynamicProfilePanel::render_imagetype ( void DynamicProfilePanel::render_imagetype (
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
{ {

View File

@ -55,6 +55,7 @@ private:
add (expcomp); add (expcomp);
add (camera); add (camera);
add (lens); add (lens);
add (path);
add (profilepath); add (profilepath);
add (imagetype); add (imagetype);
} }
@ -66,6 +67,7 @@ private:
Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> expcomp; Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> expcomp;
Gtk::TreeModelColumn<DynamicProfileRule::Optional> camera; Gtk::TreeModelColumn<DynamicProfileRule::Optional> camera;
Gtk::TreeModelColumn<DynamicProfileRule::Optional> lens; Gtk::TreeModelColumn<DynamicProfileRule::Optional> lens;
Gtk::TreeModelColumn<DynamicProfileRule::Optional> path;
Gtk::TreeModelColumn<DynamicProfileRule::Optional> imagetype; Gtk::TreeModelColumn<DynamicProfileRule::Optional> imagetype;
Gtk::TreeModelColumn<Glib::ustring> profilepath; Gtk::TreeModelColumn<Glib::ustring> profilepath;
}; };
@ -78,6 +80,7 @@ private:
void render_expcomp (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void render_expcomp (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_camera (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void render_camera (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_lens (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void render_lens (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_path (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_imagetype (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void render_imagetype (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_profilepath (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter); void render_profilepath (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
@ -114,6 +117,9 @@ private:
Gtk::CheckButton *has_lens_; Gtk::CheckButton *has_lens_;
Gtk::Entry *lens_; Gtk::Entry *lens_;
Gtk::CheckButton *has_path_;
Gtk::Entry *path_;
MyComboBoxText *imagetype_; MyComboBoxText *imagetype_;
ProfileStoreComboBox *profilepath_; ProfileStoreComboBox *profilepath_;

View File

@ -743,7 +743,7 @@ int processLineParams ( int argc, char **argv )
if (options.defProfRaw == DEFPROFILE_DYNAMIC) { if (options.defProfRaw == DEFPROFILE_DYNAMIC) {
rawParams->deleteInstance(); rawParams->deleteInstance();
delete rawParams; delete rawParams;
rawParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData()); rawParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData(), inputFile);
} }
std::cout << " Merging default raw processing profile." << std::endl; std::cout << " Merging default raw processing profile." << std::endl;
@ -752,7 +752,7 @@ int processLineParams ( int argc, char **argv )
if (options.defProfImg == DEFPROFILE_DYNAMIC) { if (options.defProfImg == DEFPROFILE_DYNAMIC) {
imgParams->deleteInstance(); imgParams->deleteInstance();
delete imgParams; delete imgParams;
imgParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData()); imgParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData(), inputFile);
} }
std::cout << " Merging default non-raw processing profile." << std::endl; std::cout << " Merging default non-raw processing profile." << std::endl;

View File

@ -266,7 +266,7 @@ rtengine::procparams::ProcParams* Thumbnail::createProcParamsForUpdate(bool retu
// Should we ask all frame's MetaData ? // Should we ask all frame's MetaData ?
imageMetaData = rtengine::FramesMetaData::fromFile (fname, nullptr, true); imageMetaData = rtengine::FramesMetaData::fromFile (fname, nullptr, true);
} }
PartialProfile *pp = ProfileStore::getInstance()->loadDynamicProfile(imageMetaData); PartialProfile *pp = ProfileStore::getInstance()->loadDynamicProfile(imageMetaData, fname);
delete imageMetaData; delete imageMetaData;
int err = pp->pparams->save(outFName); int err = pp->pparams->save(outFName);
pp->deleteInstance(); pp->deleteInstance();