dynamic profile: merge "make" and "model" into "camera", and allow to use regexps

This commit is contained in:
Alberto Griggio
2017-03-03 09:11:37 +01:00
parent 7d1bebf341
commit 6ae57cd556
5 changed files with 64 additions and 78 deletions

View File

@@ -1078,6 +1078,7 @@ PREFERENCES_TAB_GENERAL;General
PREFERENCES_TAB_IMPROC;Image Processing
PREFERENCES_TAB_PERFORMANCE;Performance & Quality
PREFERENCES_TAB_SOUND;Sounds
PREFERENCES_TAB_DYNAMICPROFILE;Dynamic Profile Rules
PREFERENCES_TIMAX;High
PREFERENCES_TINB;Number of tiles
PREFERENCES_TISTD;Standard
@@ -1105,6 +1106,7 @@ PROFILEPANEL_PCUSTOM;Custom
PROFILEPANEL_PFILE;From file
PROFILEPANEL_PINTERNAL;Neutral
PROFILEPANEL_PLASTSAVED;Last Saved
PROFILEPANEL_PDYNAMIC;Dynamic
PROFILEPANEL_SAVEDLGLABEL;Save Processing Parameters...
PROFILEPANEL_SAVEPPASTE;Parameters to save
PROFILEPANEL_TOOLTIPCOPY;Copy current processing profile to clipboard.\n<b>Ctrl-click</b> to select the parameters to copy.
@@ -2037,3 +2039,11 @@ ZOOMPANEL_ZOOMFITCROPSCREEN;Fit crop to screen\nShortcut: <b>Alt</b>-<b>f</b>
ZOOMPANEL_ZOOMFITSCREEN;Fit whole image to screen\nShortcut: <b>f</b>
ZOOMPANEL_ZOOMIN;Zoom In\nShortcut: <b>+</b>
ZOOMPANEL_ZOOMOUT;Zoom Out\nShortcut: <b>-</b>
DYNPROFILEEDITOR_PROFILE;Processing profile
DYNPROFILEEDITOR_MOVE_UP;Move up
DYNPROFILEEDITOR_MOVE_DOWN;Move down
DYNPROFILEEDITOR_NEW;New
DYNPROFILEEDITOR_EDIT;Edit
DYNPROFILEEDITOR_DELETE;Delete
DYNPROFILEEDITOR_NEW_RULE;New dynamic profile rule
DYNPROFILEEDITOR_EDIT_RULE;Edit dynamic profile rule

View File

@@ -19,6 +19,7 @@
#include "dynamicprofile.h"
#include <stdlib.h>
#include <glibmm/regex.h>
using namespace rtengine;
using namespace rtengine::procparams;
@@ -36,6 +37,22 @@ const double EXPCOMP_MAX = 20.0;
} // namespace
bool DynamicProfileEntry::Optional::operator()(const Glib::ustring &val) const
{
if (!enabled) {
return true;
}
if (value.find("re:") == 0) {
// this is a regexp
return Glib::Regex::match_simple(value.substr(3), val,
Glib::REGEX_CASELESS);
} else {
// normal string comparison
return value.casefold() == val.casefold();
}
}
DynamicProfileEntry::DynamicProfileEntry():
serial_number(0),
iso(0, ISO_MAX),
@@ -60,8 +77,7 @@ bool DynamicProfileEntry::matches(const rtengine::ImageMetaData *im)
&& focallen(im->getFocalLen())
&& shutterspeed(im->getShutterSpeed())
&& expcomp(im->getExpComp())
&& make(im->getMake())
&& model(im->getModel())
&& camera(im->getCamera())
&& lens(im->getLens()));
}
@@ -99,7 +115,7 @@ void get_double_range(DynamicProfileEntry::Range<double> &dest,
}
void get_optional(DynamicProfileEntry::Optional<Glib::ustring> &dest,
void get_optional(DynamicProfileEntry::Optional &dest,
const Glib::KeyFile &kf, const Glib::ustring &group,
const Glib::ustring &key)
{
@@ -132,7 +148,7 @@ void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
const Glib::ustring &key,
const DynamicProfileEntry::Optional<Glib::ustring> &val)
const DynamicProfileEntry::Optional &val)
{
kf.set_boolean(group, key + "_enabled", val.enabled);
kf.set_string(group, key + "_value", val.value);
@@ -175,8 +191,7 @@ bool loadDynamicProfileEntries(std::vector<DynamicProfileEntry> &out)
get_double_range(entry.focallen, kf, group, "focallen");
get_double_range(entry.shutterspeed, kf, group, "shutterspeed");
get_double_range(entry.expcomp, kf, group, "expcomp");
get_optional(entry.make, kf, group, "make");
get_optional(entry.model, kf, group, "model");
get_optional(entry.camera, kf, group, "camera");
get_optional(entry.lens, kf, group, "lens");
try {
entry.profilepath = kf.get_string(group, "profilepath");
@@ -202,8 +217,7 @@ bool storeDynamicProfileEntries(const std::vector<DynamicProfileEntry> &entries)
set_double_range(kf, group, "focallen", entry.focallen);
set_double_range(kf, group, "shutterspeed", entry.shutterspeed);
set_double_range(kf, group, "expcomp", entry.expcomp);
set_optional(kf, group, "make", entry.make);
set_optional(kf, group, "model", entry.model);
set_optional(kf, group, "camera", entry.camera);
set_optional(kf, group, "lens", entry.lens);
kf.set_string(group, "profilepath", entry.profilepath);
}

View File

@@ -38,16 +38,13 @@ public:
}
};
template <class T>
struct Optional {
T value;
Glib::ustring value;
bool enabled;
explicit Optional(T v=T(), bool e=false): value(v), enabled(e) {}
explicit Optional(const Glib::ustring v="", bool e=false):
value(v), enabled(e) {}
bool operator()(const T &val) const
{
return !enabled || value == val;
}
bool operator()(const Glib::ustring &val) const;
};
DynamicProfileEntry();
@@ -60,9 +57,8 @@ public:
Range<double> focallen;
Range<double> shutterspeed;
Range<double> expcomp;
Optional<Glib::ustring> make;
Optional<Glib::ustring> model;
Optional<Glib::ustring> lens;
Optional camera;
Optional lens;
Glib::ustring profilepath;
};

View File

@@ -68,9 +68,8 @@ DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
hb->pack_start(*profilepath_, true, true, 2);
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
add_optional(M("DYNPROFILEEDITOR_CAMERA_MAKE"), has_make, make);
add_optional(M("DYNPROFILEEDITOR_CAMERA_MODEL"), has_model, model);
add_optional(M("EXIFFILTER_LENS"), has_lens, lens);
add_optional(M("EXIFFILTER_CAMERA"), has_camera_, camera_);
add_optional(M("EXIFFILTER_LENS"), has_lens_, lens_);
add_range(M("EXIFFILTER_ISO"), iso_min_, iso_max_);
add_range(M("EXIFFILTER_APERTURE"), fnumber_min_, fnumber_max_);
@@ -105,14 +104,11 @@ void DynamicProfilePanel::EditDialog::set_entry(
expcomp_min_->set_value(entry.expcomp.min);
expcomp_max_->set_value(entry.expcomp.max);
has_make->set_active(entry.make.enabled);
make->set_text(entry.make.value);
has_camera_->set_active(entry.camera.enabled);
camera_->set_text(entry.camera.value);
has_model->set_active(entry.model.enabled);
model->set_text(entry.model.value);
has_lens->set_active(entry.lens.enabled);
lens->set_text(entry.lens.value);
has_lens_->set_active(entry.lens.enabled);
lens_->set_text(entry.lens.value);
profilepath_->updateProfileList();
if (!profilepath_->setActiveRowFromFullPath(entry.profilepath)) {
@@ -139,14 +135,11 @@ DynamicProfileEntry DynamicProfilePanel::EditDialog::get_entry()
ret.expcomp.min = expcomp_min_->get_value();
ret.expcomp.max = expcomp_max_->get_value();
ret.make.enabled = has_make->get_active();
ret.make.value = make->get_text();
ret.camera.enabled = has_camera_->get_active();
ret.camera.value = camera_->get_text();
ret.model.enabled = has_model->get_active();
ret.model.value = model->get_text();
ret.lens.enabled = has_lens->get_active();
ret.lens.value = lens->get_text();
ret.lens.enabled = has_lens_->get_active();
ret.lens.value = lens_->get_text();
ret.profilepath = profilepath_->getFullPathFromActiveRow();
@@ -273,21 +266,12 @@ DynamicProfilePanel::DynamicProfilePanel():
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(
M("DYNPROFILEEDITOR_CAMERA_MAKE"), *cell);
M("EXIFFILTER_CAMERA"), *cell);
col = treeview_.get_column(cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
*this, &DynamicProfilePanel::render_make));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(
M("DYNPROFILEEDITOR_CAMERA_MODEL"), *cell);
col = treeview_.get_column(cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
*this, &DynamicProfilePanel::render_model));
*this, &DynamicProfilePanel::render_camera));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_LENS"), *cell);
@@ -358,8 +342,7 @@ void DynamicProfilePanel::update_entry(Gtk::TreeModel::Row row,
row[columns_.focallen] = entry.focallen;
row[columns_.shutterspeed] = entry.shutterspeed;
row[columns_.expcomp] = entry.expcomp;
row[columns_.make] = entry.make;
row[columns_.model] = entry.model;
row[columns_.camera] = entry.camera;
row[columns_.lens] = entry.lens;
row[columns_.profilepath] = entry.profilepath;
}
@@ -381,8 +364,7 @@ DynamicProfileEntry DynamicProfilePanel::to_entry(Gtk::TreeModel::Row row,
ret.focallen = row[columns_.focallen];
ret.shutterspeed = row[columns_.shutterspeed];
ret.expcomp = row[columns_.expcomp];
ret.make = row[columns_.make];
ret.model = row[columns_.model];
ret.camera = row[columns_.camera];
ret.lens = row[columns_.lens];
ret.profilepath = row[columns_.profilepath];
return ret;
@@ -445,24 +427,17 @@ void DynamicProfilePanel::render_expcomp(
#define RENDER_OPTIONAL_(name) \
auto row = *iter; \
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell); \
DynamicProfileEntry::Optional<Glib::ustring> o = row[columns_. name]; \
DynamicProfileEntry::Optional o = row[columns_. name]; \
if (o.enabled) { \
ct->property_text() = o.value; \
} else { \
ct->property_text() = ""; \
}
void DynamicProfilePanel::render_make(
void DynamicProfilePanel::render_camera(
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
{
RENDER_OPTIONAL_(make);
}
void DynamicProfilePanel::render_model(
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
{
RENDER_OPTIONAL_(model);
RENDER_OPTIONAL_(camera);
}

View File

@@ -34,7 +34,6 @@ private:
void add_entry(const DynamicProfileEntry &entry);
DynamicProfileEntry to_entry(Gtk::TreeModel::Row row, int serial=0);
//Signal handlers:
void on_button_quit();
void on_button_up();
void on_button_down();
@@ -42,7 +41,6 @@ private:
void on_button_edit();
void on_button_delete();
//Tree model columns:
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord {
public:
DynamicProfileColumns()
@@ -52,8 +50,7 @@ private:
add(focallen);
add(shutterspeed);
add(expcomp);
add(make);
add(model);
add(camera);
add(lens);
add(profilepath);
}
@@ -63,9 +60,8 @@ private:
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> focallen;
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> shutterspeed;
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> expcomp;
Gtk::TreeModelColumn<DynamicProfileEntry::Optional<Glib::ustring>> make;
Gtk::TreeModelColumn<DynamicProfileEntry::Optional<Glib::ustring>> model;
Gtk::TreeModelColumn<DynamicProfileEntry::Optional<Glib::ustring>> lens;
Gtk::TreeModelColumn<DynamicProfileEntry::Optional> camera;
Gtk::TreeModelColumn<DynamicProfileEntry::Optional> lens;
Gtk::TreeModelColumn<Glib::ustring> profilepath;
};
@@ -80,10 +76,8 @@ private:
const Gtk::TreeModel::iterator& iter);
void render_expcomp(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter);
void render_make(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter);
void render_model(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_profilepath(Gtk::CellRenderer* cell,
@@ -117,14 +111,11 @@ private:
Gtk::SpinButton *expcomp_min_;
Gtk::SpinButton *expcomp_max_;
Gtk::CheckButton *has_make;
Gtk::Entry *make;
Gtk::CheckButton *has_model;
Gtk::Entry *model;
Gtk::CheckButton *has_camera_;
Gtk::Entry *camera_;
Gtk::CheckButton *has_lens;
Gtk::Entry *lens;
Gtk::CheckButton *has_lens_;
Gtk::Entry *lens_;
ProfileStoreComboBox *profilepath_;
};