renamed DynamicProfileEntry to DynamicProfileRule
This commit is contained in:
parent
0720659627
commit
bc5a6fc7c3
@ -37,7 +37,7 @@ const double EXPCOMP_MAX = 20.0;
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
bool DynamicProfileEntry::Optional::operator()(const Glib::ustring &val) const
|
bool DynamicProfileRule::Optional::operator()(const Glib::ustring &val) const
|
||||||
{
|
{
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return true;
|
return true;
|
||||||
@ -53,7 +53,7 @@ bool DynamicProfileEntry::Optional::operator()(const Glib::ustring &val) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProfileEntry::DynamicProfileEntry():
|
DynamicProfileRule::DynamicProfileRule():
|
||||||
serial_number(0),
|
serial_number(0),
|
||||||
iso(0, ISO_MAX),
|
iso(0, ISO_MAX),
|
||||||
fnumber(0, FNUMBER_MAX),
|
fnumber(0, FNUMBER_MAX),
|
||||||
@ -64,13 +64,13 @@ DynamicProfileEntry::DynamicProfileEntry():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DynamicProfileEntry::operator<(const DynamicProfileEntry &other) const
|
bool DynamicProfileRule::operator<(const DynamicProfileRule &other) const
|
||||||
{
|
{
|
||||||
return serial_number < other.serial_number;
|
return serial_number < other.serial_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DynamicProfileEntry::matches(const rtengine::ImageMetaData *im)
|
bool DynamicProfileRule::matches(const rtengine::ImageMetaData *im)
|
||||||
{
|
{
|
||||||
return (iso(im->getISOSpeed())
|
return (iso(im->getISOSpeed())
|
||||||
&& fnumber(im->getFNumber())
|
&& fnumber(im->getFNumber())
|
||||||
@ -83,7 +83,7 @@ bool DynamicProfileEntry::matches(const rtengine::ImageMetaData *im)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void get_int_range(DynamicProfileEntry::Range<int> &dest,
|
void get_int_range(DynamicProfileRule::Range<int> &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ void get_int_range(DynamicProfileEntry::Range<int> &dest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_double_range(DynamicProfileEntry::Range<double> &dest,
|
void get_double_range(DynamicProfileRule::Range<double> &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ void get_double_range(DynamicProfileEntry::Range<double> &dest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_optional(DynamicProfileEntry::Optional &dest,
|
void get_optional(DynamicProfileRule::Optional &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ void get_optional(DynamicProfileEntry::Optional &dest,
|
|||||||
|
|
||||||
void set_int_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_int_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileEntry::Range<int> &val)
|
const DynamicProfileRule::Range<int> &val)
|
||||||
{
|
{
|
||||||
kf.set_integer(group, key + "_min", val.min);
|
kf.set_integer(group, key + "_min", val.min);
|
||||||
kf.set_integer(group, key + "_max", val.max);
|
kf.set_integer(group, key + "_max", val.max);
|
||||||
@ -140,7 +140,7 @@ void set_int_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
|||||||
|
|
||||||
void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileEntry::Range<double> &val)
|
const DynamicProfileRule::Range<double> &val)
|
||||||
{
|
{
|
||||||
kf.set_double(group, key + "_min", val.min);
|
kf.set_double(group, key + "_min", val.min);
|
||||||
kf.set_double(group, key + "_max", val.max);
|
kf.set_double(group, key + "_max", val.max);
|
||||||
@ -148,7 +148,7 @@ void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
|||||||
|
|
||||||
void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileEntry::Optional &val)
|
const DynamicProfileRule::Optional &val)
|
||||||
{
|
{
|
||||||
kf.set_boolean(group, key + "_enabled", val.enabled);
|
kf.set_boolean(group, key + "_enabled", val.enabled);
|
||||||
kf.set_string(group, key + "_value", val.value);
|
kf.set_string(group, key + "_value", val.value);
|
||||||
@ -157,7 +157,7 @@ void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
bool loadDynamicProfileEntries(std::vector<DynamicProfileEntry> &out)
|
bool loadDynamicProfileRules(std::vector<DynamicProfileRule> &out)
|
||||||
{
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
Glib::KeyFile kf;
|
Glib::KeyFile kf;
|
||||||
@ -172,29 +172,29 @@ bool loadDynamicProfileEntries(std::vector<DynamicProfileEntry> &out)
|
|||||||
printf("loading dynamic profiles...\n");
|
printf("loading dynamic profiles...\n");
|
||||||
auto groups = kf.get_groups();
|
auto groups = kf.get_groups();
|
||||||
for (auto group : groups) {
|
for (auto group : groups) {
|
||||||
// groups are of the form "entry N", where N is a positive integer
|
// groups are of the form "rule N", where N is a positive integer
|
||||||
if (group.find("entry ") != 0) {
|
if (group.find("rule ") != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::istringstream buf(group.c_str() + 6);
|
std::istringstream buf(group.c_str() + 5);
|
||||||
int serial = 0;
|
int serial = 0;
|
||||||
if (!(buf >> serial) || !buf.eof()) {
|
if (!(buf >> serial) || !buf.eof()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
printf(" loading entry %d\n", serial);
|
printf(" loading rule %d\n", serial);
|
||||||
|
|
||||||
out.emplace_back(DynamicProfileEntry());
|
out.emplace_back(DynamicProfileRule());
|
||||||
DynamicProfileEntry &entry = out.back();
|
DynamicProfileRule &rule = out.back();
|
||||||
entry.serial_number = serial;
|
rule.serial_number = serial;
|
||||||
get_int_range(entry.iso, kf, group, "iso");
|
get_int_range(rule.iso, kf, group, "iso");
|
||||||
get_double_range(entry.fnumber, kf, group, "fnumber");
|
get_double_range(rule.fnumber, kf, group, "fnumber");
|
||||||
get_double_range(entry.focallen, kf, group, "focallen");
|
get_double_range(rule.focallen, kf, group, "focallen");
|
||||||
get_double_range(entry.shutterspeed, kf, group, "shutterspeed");
|
get_double_range(rule.shutterspeed, kf, group, "shutterspeed");
|
||||||
get_double_range(entry.expcomp, kf, group, "expcomp");
|
get_double_range(rule.expcomp, kf, group, "expcomp");
|
||||||
get_optional(entry.camera, kf, group, "camera");
|
get_optional(rule.camera, kf, group, "camera");
|
||||||
get_optional(entry.lens, kf, group, "lens");
|
get_optional(rule.lens, kf, group, "lens");
|
||||||
try {
|
try {
|
||||||
entry.profilepath = kf.get_string(group, "profilepath");
|
rule.profilepath = kf.get_string(group, "profilepath");
|
||||||
} catch (Glib::KeyFileError &) {
|
} catch (Glib::KeyFileError &) {
|
||||||
out.pop_back();
|
out.pop_back();
|
||||||
}
|
}
|
||||||
@ -204,22 +204,22 @@ bool loadDynamicProfileEntries(std::vector<DynamicProfileEntry> &out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool storeDynamicProfileEntries(const std::vector<DynamicProfileEntry> &entries)
|
bool storeDynamicProfileRules(const std::vector<DynamicProfileRule> &rules)
|
||||||
{
|
{
|
||||||
printf("saving dynamic profiles...\n");
|
printf("saving dynamic profiles...\n");
|
||||||
Glib::KeyFile kf;
|
Glib::KeyFile kf;
|
||||||
for (auto &entry : entries) {
|
for (auto &rule : rules) {
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
buf << "entry " << entry.serial_number;
|
buf << "rule " << rule.serial_number;
|
||||||
Glib::ustring group = buf.str();
|
Glib::ustring group = buf.str();
|
||||||
set_int_range(kf, group, "iso", entry.iso);
|
set_int_range(kf, group, "iso", rule.iso);
|
||||||
set_double_range(kf, group, "fnumber", entry.fnumber);
|
set_double_range(kf, group, "fnumber", rule.fnumber);
|
||||||
set_double_range(kf, group, "focallen", entry.focallen);
|
set_double_range(kf, group, "focallen", rule.focallen);
|
||||||
set_double_range(kf, group, "shutterspeed", entry.shutterspeed);
|
set_double_range(kf, group, "shutterspeed", rule.shutterspeed);
|
||||||
set_double_range(kf, group, "expcomp", entry.expcomp);
|
set_double_range(kf, group, "expcomp", rule.expcomp);
|
||||||
set_optional(kf, group, "camera", entry.camera);
|
set_optional(kf, group, "camera", rule.camera);
|
||||||
set_optional(kf, group, "lens", entry.lens);
|
set_optional(kf, group, "lens", rule.lens);
|
||||||
kf.set_string(group, "profilepath", entry.profilepath);
|
kf.set_string(group, "profilepath", rule.profilepath);
|
||||||
}
|
}
|
||||||
return kf.save_to_file(
|
return kf.save_to_file(
|
||||||
Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"));
|
Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"));
|
||||||
@ -229,14 +229,14 @@ bool storeDynamicProfileEntries(const std::vector<DynamicProfileEntry> &entries)
|
|||||||
PartialProfile *loadDynamicProfile(const ImageMetaData *im)
|
PartialProfile *loadDynamicProfile(const ImageMetaData *im)
|
||||||
{
|
{
|
||||||
PartialProfile *ret = new PartialProfile(true, true);
|
PartialProfile *ret = new PartialProfile(true, true);
|
||||||
std::vector<DynamicProfileEntry> entries;
|
std::vector<DynamicProfileRule> rules;
|
||||||
if (loadDynamicProfileEntries(entries)) {
|
if (loadDynamicProfileRules(rules)) {
|
||||||
for (auto &entry : entries) {
|
for (auto &rule : rules) {
|
||||||
if (entry.matches(im)) {
|
if (rule.matches(im)) {
|
||||||
printf("found matching profile %s\n",
|
printf("found matching profile %s\n",
|
||||||
entry.profilepath.c_str());
|
rule.profilepath.c_str());
|
||||||
const PartialProfile *p =
|
const PartialProfile *p =
|
||||||
profileStore.getProfile(entry.profilepath);
|
profileStore.getProfile(rule.profilepath);
|
||||||
if (p != nullptr) {
|
if (p != nullptr) {
|
||||||
p->applyTo(ret->pparams);
|
p->applyTo(ret->pparams);
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
|
||||||
class DynamicProfileEntry {
|
class DynamicProfileRule {
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <class T>
|
||||||
struct Range {
|
struct Range {
|
||||||
@ -47,9 +47,9 @@ public:
|
|||||||
bool operator()(const Glib::ustring &val) const;
|
bool operator()(const Glib::ustring &val) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicProfileEntry();
|
DynamicProfileRule();
|
||||||
bool matches(const rtengine::ImageMetaData *im);
|
bool matches(const rtengine::ImageMetaData *im);
|
||||||
bool operator<(const DynamicProfileEntry &other) const;
|
bool operator<(const DynamicProfileRule &other) const;
|
||||||
|
|
||||||
int serial_number;
|
int serial_number;
|
||||||
Range<int> iso;
|
Range<int> iso;
|
||||||
@ -63,9 +63,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool loadDynamicProfileEntries(std::vector<DynamicProfileEntry> &out);
|
bool loadDynamicProfileRules(std::vector<DynamicProfileRule> &out);
|
||||||
bool storeDynamicProfileEntries(
|
bool storeDynamicProfileRules(
|
||||||
const std::vector<DynamicProfileEntry> &entries);
|
const std::vector<DynamicProfileRule> &rules);
|
||||||
|
|
||||||
rtengine::procparams::PartialProfile *loadDynamicProfile(
|
rtengine::procparams::PartialProfile *loadDynamicProfile(
|
||||||
const rtengine::ImageMetaData *im);
|
const rtengine::ImageMetaData *im);
|
||||||
|
@ -69,40 +69,40 @@ DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::EditDialog::set_entry(
|
void DynamicProfilePanel::EditDialog::set_rule(
|
||||||
const DynamicProfileEntry &entry)
|
const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
iso_min_->set_value(entry.iso.min);
|
iso_min_->set_value(rule.iso.min);
|
||||||
iso_max_->set_value(entry.iso.max);
|
iso_max_->set_value(rule.iso.max);
|
||||||
|
|
||||||
fnumber_min_->set_value(entry.fnumber.min);
|
fnumber_min_->set_value(rule.fnumber.min);
|
||||||
fnumber_max_->set_value(entry.fnumber.max);
|
fnumber_max_->set_value(rule.fnumber.max);
|
||||||
|
|
||||||
focallen_min_->set_value(entry.focallen.min);
|
focallen_min_->set_value(rule.focallen.min);
|
||||||
focallen_max_->set_value(entry.focallen.max);
|
focallen_max_->set_value(rule.focallen.max);
|
||||||
|
|
||||||
shutterspeed_min_->set_value(entry.shutterspeed.min);
|
shutterspeed_min_->set_value(rule.shutterspeed.min);
|
||||||
shutterspeed_max_->set_value(entry.shutterspeed.max);
|
shutterspeed_max_->set_value(rule.shutterspeed.max);
|
||||||
|
|
||||||
expcomp_min_->set_value(entry.expcomp.min);
|
expcomp_min_->set_value(rule.expcomp.min);
|
||||||
expcomp_max_->set_value(entry.expcomp.max);
|
expcomp_max_->set_value(rule.expcomp.max);
|
||||||
|
|
||||||
has_camera_->set_active(entry.camera.enabled);
|
has_camera_->set_active(rule.camera.enabled);
|
||||||
camera_->set_text(entry.camera.value);
|
camera_->set_text(rule.camera.value);
|
||||||
|
|
||||||
has_lens_->set_active(entry.lens.enabled);
|
has_lens_->set_active(rule.lens.enabled);
|
||||||
lens_->set_text(entry.lens.value);
|
lens_->set_text(rule.lens.value);
|
||||||
|
|
||||||
profilepath_->updateProfileList();
|
profilepath_->updateProfileList();
|
||||||
if (!profilepath_->setActiveRowFromFullPath(entry.profilepath)) {
|
if (!profilepath_->setActiveRowFromFullPath(rule.profilepath)) {
|
||||||
profilepath_->setInternalEntry();
|
profilepath_->setInternalEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProfileEntry DynamicProfilePanel::EditDialog::get_entry()
|
DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
|
||||||
{
|
{
|
||||||
DynamicProfileEntry ret;
|
DynamicProfileRule ret;
|
||||||
ret.iso.min = iso_min_->get_value_as_int();
|
ret.iso.min = iso_min_->get_value_as_int();
|
||||||
ret.iso.max = iso_max_->get_value_as_int();
|
ret.iso.max = iso_max_->get_value_as_int();
|
||||||
|
|
||||||
@ -131,27 +131,27 @@ DynamicProfileEntry DynamicProfilePanel::EditDialog::get_entry()
|
|||||||
|
|
||||||
void DynamicProfilePanel::EditDialog::set_ranges()
|
void DynamicProfilePanel::EditDialog::set_ranges()
|
||||||
{
|
{
|
||||||
DynamicProfileEntry default_entry;
|
DynamicProfileRule default_rule;
|
||||||
iso_min_->set_digits(0);
|
iso_min_->set_digits(0);
|
||||||
iso_max_->set_digits(0);
|
iso_max_->set_digits(0);
|
||||||
iso_min_->set_increments(1, 10);
|
iso_min_->set_increments(1, 10);
|
||||||
iso_max_->set_increments(1, 10);
|
iso_max_->set_increments(1, 10);
|
||||||
iso_min_->set_range(default_entry.iso.min, default_entry.iso.max);
|
iso_min_->set_range(default_rule.iso.min, default_rule.iso.max);
|
||||||
iso_max_->set_range(default_entry.iso.min, default_entry.iso.max);
|
iso_max_->set_range(default_rule.iso.min, default_rule.iso.max);
|
||||||
iso_min_->set_value(default_entry.iso.min);
|
iso_min_->set_value(default_rule.iso.min);
|
||||||
iso_max_->set_value(default_entry.iso.max);
|
iso_max_->set_value(default_rule.iso.max);
|
||||||
|
|
||||||
#define DOIT_(name) \
|
#define DOIT_(name) \
|
||||||
name ## _min_->set_digits(1); \
|
name ## _min_->set_digits(1); \
|
||||||
name ## _max_->set_digits(1); \
|
name ## _max_->set_digits(1); \
|
||||||
name ## _min_->set_increments(0.1, 1); \
|
name ## _min_->set_increments(0.1, 1); \
|
||||||
name ## _max_->set_increments(0.1, 1); \
|
name ## _max_->set_increments(0.1, 1); \
|
||||||
name ## _min_->set_range(default_entry. name .min, \
|
name ## _min_->set_range(default_rule. name .min, \
|
||||||
default_entry. name .max); \
|
default_rule. name .max); \
|
||||||
name ## _max_->set_range(default_entry. name .min, \
|
name ## _max_->set_range(default_rule. name .min, \
|
||||||
default_entry. name .max); \
|
default_rule. name .max); \
|
||||||
name ## _min_->set_value(default_entry. name .min); \
|
name ## _min_->set_value(default_rule. name .min); \
|
||||||
name ## _max_->set_value(default_entry. name .max)
|
name ## _max_->set_value(default_rule. name .max)
|
||||||
|
|
||||||
DOIT_(fnumber);
|
DOIT_(fnumber);
|
||||||
DOIT_(focallen);
|
DOIT_(focallen);
|
||||||
@ -308,39 +308,39 @@ DynamicProfilePanel::DynamicProfilePanel():
|
|||||||
|
|
||||||
show_all_children();
|
show_all_children();
|
||||||
|
|
||||||
std::vector<DynamicProfileEntry> entries;
|
std::vector<DynamicProfileRule> rules;
|
||||||
if (loadDynamicProfileEntries(entries)) {
|
if (loadDynamicProfileRules(rules)) {
|
||||||
for (auto &e : entries) {
|
for (auto &r : rules) {
|
||||||
add_entry(e);
|
add_rule(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::update_entry(Gtk::TreeModel::Row row,
|
void DynamicProfilePanel::update_rule(Gtk::TreeModel::Row row,
|
||||||
const DynamicProfileEntry &entry)
|
const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
row[columns_.iso] = entry.iso;
|
row[columns_.iso] = rule.iso;
|
||||||
row[columns_.fnumber] = entry.fnumber;
|
row[columns_.fnumber] = rule.fnumber;
|
||||||
row[columns_.focallen] = entry.focallen;
|
row[columns_.focallen] = rule.focallen;
|
||||||
row[columns_.shutterspeed] = entry.shutterspeed;
|
row[columns_.shutterspeed] = rule.shutterspeed;
|
||||||
row[columns_.expcomp] = entry.expcomp;
|
row[columns_.expcomp] = rule.expcomp;
|
||||||
row[columns_.camera] = entry.camera;
|
row[columns_.camera] = rule.camera;
|
||||||
row[columns_.lens] = entry.lens;
|
row[columns_.lens] = rule.lens;
|
||||||
row[columns_.profilepath] = entry.profilepath;
|
row[columns_.profilepath] = rule.profilepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicProfilePanel::add_entry(const DynamicProfileEntry &entry)
|
void DynamicProfilePanel::add_rule(const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
auto row = *(treemodel_->append());
|
auto row = *(treemodel_->append());
|
||||||
update_entry(row, entry);
|
update_rule(row, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProfileEntry DynamicProfilePanel::to_entry(Gtk::TreeModel::Row row,
|
DynamicProfileRule DynamicProfilePanel::to_rule(Gtk::TreeModel::Row row,
|
||||||
int serial)
|
int serial)
|
||||||
{
|
{
|
||||||
DynamicProfileEntry ret;
|
DynamicProfileRule ret;
|
||||||
ret.serial_number = serial;
|
ret.serial_number = serial;
|
||||||
ret.iso = row[columns_.iso];
|
ret.iso = row[columns_.iso];
|
||||||
ret.fnumber = row[columns_.fnumber];
|
ret.fnumber = row[columns_.fnumber];
|
||||||
@ -372,8 +372,8 @@ void DynamicProfilePanel::render_profilepath(
|
|||||||
#define RENDER_RANGE_(tp, name, prec) \
|
#define RENDER_RANGE_(tp, name, prec) \
|
||||||
auto row = *iter; \
|
auto row = *iter; \
|
||||||
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell); \
|
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell); \
|
||||||
DynamicProfileEntry::Range<tp> r = row[columns_. name]; \
|
DynamicProfileRule::Range<tp> r = row[columns_. name]; \
|
||||||
DynamicProfileEntry dflt; \
|
DynamicProfileRule dflt; \
|
||||||
if (r.min > dflt.name.min || r.max < dflt.name.max) { \
|
if (r.min > dflt.name.min || r.max < dflt.name.max) { \
|
||||||
auto value = to_str(r.min, prec) + " - " + to_str(r.max, prec); \
|
auto value = to_str(r.min, prec) + " - " + to_str(r.max, prec); \
|
||||||
ct->property_text() = value; \
|
ct->property_text() = value; \
|
||||||
@ -420,7 +420,7 @@ void DynamicProfilePanel::render_expcomp(
|
|||||||
#define RENDER_OPTIONAL_(name) \
|
#define RENDER_OPTIONAL_(name) \
|
||||||
auto row = *iter; \
|
auto row = *iter; \
|
||||||
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell); \
|
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell); \
|
||||||
DynamicProfileEntry::Optional o = row[columns_. name]; \
|
DynamicProfileRule::Optional o = row[columns_. name]; \
|
||||||
if (o.enabled) { \
|
if (o.enabled) { \
|
||||||
ct->property_text() = o.value; \
|
ct->property_text() = o.value; \
|
||||||
} else { \
|
} else { \
|
||||||
@ -488,8 +488,8 @@ void DynamicProfilePanel::on_button_new()
|
|||||||
static_cast<Gtk::Window &>(*get_toplevel()));
|
static_cast<Gtk::Window &>(*get_toplevel()));
|
||||||
int status = d.run();
|
int status = d.run();
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
DynamicProfileEntry entry = d.get_entry();
|
DynamicProfileRule rule = d.get_rule();
|
||||||
add_entry(entry);
|
add_rule(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,24 +504,24 @@ void DynamicProfilePanel::on_button_edit()
|
|||||||
static_cast<Gtk::Window &>(*get_toplevel()));
|
static_cast<Gtk::Window &>(*get_toplevel()));
|
||||||
auto it = s->get_selected();
|
auto it = s->get_selected();
|
||||||
Gtk::TreeModel::Row row = *(s->get_selected());
|
Gtk::TreeModel::Row row = *(s->get_selected());
|
||||||
d.set_entry(to_entry(row));
|
d.set_rule(to_rule(row));
|
||||||
int status = d.run();
|
int status = d.run();
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
update_entry(row, d.get_entry());
|
update_rule(row, d.get_rule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::save()
|
void DynamicProfilePanel::save()
|
||||||
{
|
{
|
||||||
std::vector<DynamicProfileEntry> entries;
|
std::vector<DynamicProfileRule> rules;
|
||||||
int serial = 1;
|
int serial = 1;
|
||||||
for (auto row : treemodel_->children()) {
|
for (auto row : treemodel_->children()) {
|
||||||
entries.emplace_back(to_entry(row, serial++));
|
rules.emplace_back(to_rule(row, serial++));
|
||||||
}
|
}
|
||||||
if (!storeDynamicProfileEntries(entries)) {
|
if (!storeDynamicProfileRules(rules)) {
|
||||||
printf("Error in saving dynamic profile rules\n");
|
printf("Error in saving dynamic profile rules\n");
|
||||||
} else {
|
} else {
|
||||||
printf("Saved %d dynamic profile rules\n", int(entries.size()));
|
printf("Saved %d dynamic profile rules\n", int(rules.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@ public:
|
|||||||
void save();
|
void save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_entry(Gtk::TreeModel::Row row,
|
void update_rule(Gtk::TreeModel::Row row,
|
||||||
const DynamicProfileEntry &entry);
|
const DynamicProfileRule &rule);
|
||||||
void add_entry(const DynamicProfileEntry &entry);
|
void add_rule(const DynamicProfileRule &rule);
|
||||||
DynamicProfileEntry to_entry(Gtk::TreeModel::Row row, int serial=0);
|
DynamicProfileRule to_rule(Gtk::TreeModel::Row row, int serial=0);
|
||||||
|
|
||||||
void on_button_quit();
|
void on_button_quit();
|
||||||
void on_button_up();
|
void on_button_up();
|
||||||
@ -55,13 +55,13 @@ private:
|
|||||||
add(profilepath);
|
add(profilepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Range<int>> iso;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<int>> iso;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> fnumber;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> fnumber;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> focallen;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> focallen;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> shutterspeed;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> shutterspeed;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Range<double>> expcomp;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<double>> expcomp;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Optional> camera;
|
Gtk::TreeModelColumn<DynamicProfileRule::Optional> camera;
|
||||||
Gtk::TreeModelColumn<DynamicProfileEntry::Optional> lens;
|
Gtk::TreeModelColumn<DynamicProfileRule::Optional> lens;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> profilepath;
|
Gtk::TreeModelColumn<Glib::ustring> profilepath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ private:
|
|||||||
class EditDialog: public Gtk::Dialog {
|
class EditDialog: public Gtk::Dialog {
|
||||||
public:
|
public:
|
||||||
EditDialog(const Glib::ustring &title, Gtk::Window &parent);
|
EditDialog(const Glib::ustring &title, Gtk::Window &parent);
|
||||||
void set_entry(const DynamicProfileEntry &entry);
|
void set_rule(const DynamicProfileRule &rule);
|
||||||
DynamicProfileEntry get_entry();
|
DynamicProfileRule get_rule();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_ranges();
|
void set_ranges();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user