Several files astylized.
This commit is contained in:
parent
fb5466bc8c
commit
8c309d0f04
@ -25,7 +25,8 @@
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
const int ISO_MAX = 512000;
|
||||
const double FNUMBER_MAX = 100.0;
|
||||
@ -43,6 +44,7 @@ bool DynamicProfileRule::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);
|
||||
@ -81,7 +83,8 @@ bool DynamicProfileRule::matches(const rtengine::ImageMetaData *im) const
|
||||
&& lens (im->getLens()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
void get_int_range (DynamicProfileRule::Range<int> &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
@ -90,6 +93,7 @@ void get_int_range(DynamicProfileRule::Range<int> &dest,
|
||||
try {
|
||||
int min = kf.get_integer (group, key + "_min");
|
||||
int max = kf.get_integer (group, key + "_max");
|
||||
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
@ -106,6 +110,7 @@ void get_double_range(DynamicProfileRule::Range<double> &dest,
|
||||
try {
|
||||
double min = kf.get_double (group, key + "_min");
|
||||
double max = kf.get_double (group, key + "_max");
|
||||
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
@ -121,6 +126,7 @@ void get_optional(DynamicProfileRule::Optional &dest,
|
||||
{
|
||||
try {
|
||||
bool e = kf.get_boolean (group, key + "_enabled");
|
||||
|
||||
if (e) {
|
||||
Glib::ustring s = kf.get_string (group, key + "_value");
|
||||
dest.enabled = e;
|
||||
@ -160,6 +166,7 @@ bool DynamicProfileRules::loadRules()
|
||||
{
|
||||
dynamicRules.clear();
|
||||
Glib::KeyFile kf;
|
||||
|
||||
try {
|
||||
if (!kf.load_from_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"))) {
|
||||
return false;
|
||||
@ -167,20 +174,26 @@ bool DynamicProfileRules::loadRules()
|
||||
} catch (Glib::Error &e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf ("loading dynamic profiles...\n");
|
||||
}
|
||||
|
||||
auto groups = kf.get_groups();
|
||||
|
||||
for (auto group : groups) {
|
||||
// groups are of the form "rule N", where N is a positive integer
|
||||
if (group.find ("rule ") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::istringstream buf (group.c_str() + 5);
|
||||
int serial = 0;
|
||||
|
||||
if (! (buf >> serial) || !buf.eof()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf (" loading rule %d\n", serial);
|
||||
}
|
||||
@ -195,12 +208,14 @@ bool DynamicProfileRules::loadRules()
|
||||
get_double_range (rule.expcomp, kf, group, "expcomp");
|
||||
get_optional (rule.camera, kf, group, "camera");
|
||||
get_optional (rule.lens, kf, group, "lens");
|
||||
|
||||
try {
|
||||
rule.profilepath = kf.get_string (group, "profilepath");
|
||||
} catch (Glib::KeyFileError &) {
|
||||
dynamicRules.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
std::sort (dynamicRules.begin(), dynamicRules.end());
|
||||
rulesLoaded = true;
|
||||
return true;
|
||||
@ -211,7 +226,9 @@ bool DynamicProfileRules::storeRules()
|
||||
if (options.rtSettings.verbose) {
|
||||
printf ("saving dynamic profiles...\n");
|
||||
}
|
||||
|
||||
Glib::KeyFile kf;
|
||||
|
||||
for (auto &rule : dynamicRules) {
|
||||
std::ostringstream buf;
|
||||
buf << "rule " << rule.serial_number;
|
||||
@ -225,6 +242,7 @@ bool DynamicProfileRules::storeRules()
|
||||
set_optional (kf, group, "lens", rule.lens);
|
||||
kf.set_string (group, "profilepath", rule.profilepath);
|
||||
}
|
||||
|
||||
return kf.save_to_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <vector>
|
||||
#include "../rtgui/options.h"
|
||||
|
||||
class DynamicProfileRule {
|
||||
class DynamicProfileRule
|
||||
{
|
||||
public:
|
||||
template <class T>
|
||||
struct Range {
|
||||
@ -61,7 +62,8 @@ public:
|
||||
Glib::ustring profilepath;
|
||||
};
|
||||
|
||||
class DynamicProfileRules {
|
||||
class DynamicProfileRules
|
||||
{
|
||||
protected:
|
||||
/** cache for dynamic profile rules */
|
||||
std::vector<DynamicProfileRule> dynamicRules;
|
||||
|
@ -507,7 +507,9 @@ PartialProfile *ProfileStore::loadDynamicProfile(const ImageMetaData *im)
|
||||
if (options.rtSettings.verbose) {
|
||||
printf ("found matching profile %s\n", rule.profilepath.c_str());
|
||||
}
|
||||
|
||||
const PartialProfile *p = getProfile (rule.profilepath);
|
||||
|
||||
if (p != nullptr) {
|
||||
p->applyTo (ret->pparams);
|
||||
} else {
|
||||
@ -515,6 +517,7 @@ PartialProfile *ProfileStore::loadDynamicProfile(const ImageMetaData *im)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -30,14 +30,12 @@
|
||||
// DynamicProfilePanel::EditDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
|
||||
Gtk::Window &parent):
|
||||
DynamicProfilePanel::EditDialog::EditDialog (const Glib::ustring &title, Gtk::Window &parent):
|
||||
Gtk::Dialog (title, parent)
|
||||
{
|
||||
profilepath_ = Gtk::manage (new ProfileStoreComboBox());
|
||||
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
|
||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("DYNPROFILEEDITOR_PROFILE"))),
|
||||
false, false, 4);
|
||||
hb->pack_start (*Gtk::manage (new Gtk::Label (M ("DYNPROFILEEDITOR_PROFILE"))), false, false, 4);
|
||||
hb->pack_start (*profilepath_, true, true, 2);
|
||||
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
|
||||
|
||||
@ -84,12 +82,12 @@ void DynamicProfilePanel::EditDialog::set_rule(
|
||||
lens_->set_text (rule.lens.value);
|
||||
|
||||
profilepath_->updateProfileList();
|
||||
|
||||
if (!profilepath_->setActiveRowFromFullPath (rule.profilepath)) {
|
||||
profilepath_->setInternalEntry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
|
||||
{
|
||||
DynamicProfileRule ret;
|
||||
@ -165,15 +163,12 @@ void DynamicProfilePanel::EditDialog::add_range(const Glib::ustring &name,
|
||||
from->set_numeric (true);
|
||||
to->set_numeric (true);
|
||||
hb->pack_start (*from, true, true, 2);
|
||||
hb->pack_start(*Gtk::manage(new Gtk::Label(" - ")),
|
||||
false, false, 4);
|
||||
hb->pack_start (*Gtk::manage (new Gtk::Label (" - ")), false, false, 4);
|
||||
hb->pack_start (*to, true, true, 2);
|
||||
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
|
||||
}
|
||||
|
||||
|
||||
void DynamicProfilePanel::EditDialog::add_optional(const Glib::ustring &name,
|
||||
Gtk::CheckButton *&check, Gtk::Entry *&field)
|
||||
void DynamicProfilePanel::EditDialog::add_optional (const Glib::ustring &name, Gtk::CheckButton *&check, Gtk::Entry *&field)
|
||||
{
|
||||
check = Gtk::manage (new Gtk::CheckButton (name));
|
||||
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
|
||||
@ -229,67 +224,81 @@ DynamicProfilePanel::DynamicProfilePanel():
|
||||
treeview_.set_model (treemodel_);
|
||||
|
||||
auto cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
int cols_count = treeview_.append_column(
|
||||
M("DYNPROFILEEDITOR_PROFILE"), *cell);
|
||||
int cols_count = treeview_.append_column ( M ("DYNPROFILEEDITOR_PROFILE"), *cell);
|
||||
auto col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_profilepath));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (
|
||||
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_camera));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (M ("EXIFFILTER_LENS"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_lens));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (M ("EXIFFILTER_ISO"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_iso));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (M ("EXIFFILTER_APERTURE"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_fnumber));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (M ("EXIFFILTER_FOCALLEN"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_focallen));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (M ("EXIFFILTER_SHUTTER"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
*this, &DynamicProfilePanel::render_shutterspeed));
|
||||
}
|
||||
|
||||
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||
cols_count = treeview_.append_column (
|
||||
M ("EXIFFILTER_EXPOSURECOMPENSATION"), *cell);
|
||||
col = treeview_.get_column (cols_count - 1);
|
||||
|
||||
if (col) {
|
||||
col->set_cell_data_func (
|
||||
*cell, sigc::mem_fun (
|
||||
@ -348,6 +357,7 @@ void DynamicProfilePanel::render_profilepath(
|
||||
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *> (cell);
|
||||
auto value = row[columns_.profilepath];
|
||||
auto pse = ProfileStore::getInstance()->findEntryFromFullPath (value);
|
||||
|
||||
if (pse != nullptr) {
|
||||
ct->property_text() = pse->label;
|
||||
} else {
|
||||
@ -369,7 +379,8 @@ void DynamicProfilePanel::render_profilepath(
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
template <class V>
|
||||
Glib::ustring to_str (V n, int precision = 1)
|
||||
@ -392,9 +403,10 @@ void DynamicProfilePanel::render_fnumber(
|
||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||
{
|
||||
RENDER_RANGE_ (double, fnumber,
|
||||
[](double f)
|
||||
{ return std::string("f/") +
|
||||
rtengine::ImageMetaData::apertureToString(f); });
|
||||
[] (double f) {
|
||||
return std::string ("f/") +
|
||||
rtengine::ImageMetaData::apertureToString (f);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -449,10 +461,13 @@ void DynamicProfilePanel::render_lens(
|
||||
void DynamicProfilePanel::on_button_up()
|
||||
{
|
||||
auto s = treeview_.get_selection();
|
||||
|
||||
if (!s->count_selected_rows()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = s->get_selected();
|
||||
|
||||
if (it != treemodel_->children().begin()) {
|
||||
auto it2 = it;
|
||||
--it2;
|
||||
@ -463,12 +478,15 @@ void DynamicProfilePanel::on_button_up()
|
||||
void DynamicProfilePanel::on_button_down()
|
||||
{
|
||||
auto s = treeview_.get_selection();
|
||||
|
||||
if (!s->count_selected_rows()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = s->get_selected();
|
||||
auto it2 = it;
|
||||
++it2;
|
||||
|
||||
if (it2 != treemodel_->children().end()) {
|
||||
treemodel_->iter_swap (it, it2);
|
||||
}
|
||||
@ -478,9 +496,11 @@ void DynamicProfilePanel::on_button_down()
|
||||
void DynamicProfilePanel::on_button_delete()
|
||||
{
|
||||
auto s = treeview_.get_selection();
|
||||
|
||||
if (!s->count_selected_rows()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = s->get_selected();
|
||||
treemodel_->erase (it);
|
||||
}
|
||||
@ -491,6 +511,7 @@ void DynamicProfilePanel::on_button_new()
|
||||
EditDialog d (M ("DYNPROFILEEDITOR_NEW_RULE"),
|
||||
static_cast<Gtk::Window &> (*get_toplevel()));
|
||||
int status = d.run();
|
||||
|
||||
if (status == 1) {
|
||||
DynamicProfileRule rule = d.get_rule();
|
||||
add_rule (rule);
|
||||
@ -501,14 +522,17 @@ void DynamicProfilePanel::on_button_new()
|
||||
void DynamicProfilePanel::on_button_edit()
|
||||
{
|
||||
auto s = treeview_.get_selection();
|
||||
|
||||
if (!s->count_selected_rows()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditDialog d (M ("DYNPROFILEEDITOR_EDIT_RULE"),
|
||||
static_cast<Gtk::Window &> (*get_toplevel()));
|
||||
Gtk::TreeModel::Row row = * (s->get_selected());
|
||||
d.set_rule (to_rule (row));
|
||||
int status = d.run();
|
||||
|
||||
if (status == 1) {
|
||||
update_rule (row, d.get_rule());
|
||||
}
|
||||
@ -519,6 +543,7 @@ void DynamicProfilePanel::save()
|
||||
{
|
||||
std::vector<DynamicProfileRule> rules;
|
||||
int serial = 1;
|
||||
|
||||
for (auto row : treemodel_->children()) {
|
||||
rules.emplace_back (to_rule (row, serial++));
|
||||
}
|
||||
|
@ -23,14 +23,14 @@
|
||||
#include "../rtengine/dynamicprofile.h"
|
||||
#include "profilestorecombobox.h"
|
||||
|
||||
class DynamicProfilePanel: public Gtk::VBox {
|
||||
class DynamicProfilePanel: public Gtk::VBox
|
||||
{
|
||||
public:
|
||||
DynamicProfilePanel();
|
||||
void save();
|
||||
|
||||
private:
|
||||
void update_rule(Gtk::TreeModel::Row row,
|
||||
const DynamicProfileRule &rule);
|
||||
void update_rule (Gtk::TreeModel::Row row, const DynamicProfileRule &rule);
|
||||
void add_rule (const DynamicProfileRule &rule);
|
||||
DynamicProfileRule to_rule (Gtk::TreeModel::Row row, int serial = 0);
|
||||
|
||||
@ -41,7 +41,8 @@ private:
|
||||
void on_button_edit();
|
||||
void on_button_delete();
|
||||
|
||||
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord {
|
||||
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
DynamicProfileColumns()
|
||||
{
|
||||
@ -66,24 +67,17 @@ private:
|
||||
};
|
||||
|
||||
// cell renderers
|
||||
void render_iso(Gtk::CellRenderer* cell,
|
||||
const Gtk::TreeModel::iterator& iter);
|
||||
void render_fnumber(Gtk::CellRenderer* cell,
|
||||
const Gtk::TreeModel::iterator& iter);
|
||||
void render_focallen(Gtk::CellRenderer* cell,
|
||||
const Gtk::TreeModel::iterator& iter);
|
||||
void render_shutterspeed(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_lens(Gtk::CellRenderer* cell,
|
||||
const Gtk::TreeModel::iterator& iter);
|
||||
void render_profilepath(Gtk::CellRenderer* cell,
|
||||
const Gtk::TreeModel::iterator& iter);
|
||||
void render_iso (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||
void render_fnumber (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||
void render_focallen (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||
void render_shutterspeed (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_lens (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||
void render_profilepath (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||
|
||||
class EditDialog: public Gtk::Dialog {
|
||||
class EditDialog: public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
EditDialog (const Glib::ustring &title, Gtk::Window &parent);
|
||||
void set_rule (const DynamicProfileRule &rule);
|
||||
@ -91,10 +85,8 @@ private:
|
||||
|
||||
private:
|
||||
void set_ranges();
|
||||
void add_range(const Glib::ustring &name,
|
||||
Gtk::SpinButton *&from, Gtk::SpinButton *&to);
|
||||
void add_optional(const Glib::ustring &name,
|
||||
Gtk::CheckButton *&check, Gtk::Entry *&field);
|
||||
void add_range (const Glib::ustring &name, Gtk::SpinButton *&from, Gtk::SpinButton *&to);
|
||||
void add_optional (const Glib::ustring &name, Gtk::CheckButton *&check, Gtk::Entry *&field);
|
||||
|
||||
Gtk::SpinButton *iso_min_;
|
||||
Gtk::SpinButton *iso_max_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user