1
/* ============================================================
3
* This file is a part of kipi-plugins project
4
* http://www.kipi-plugins.org
7
* Description : a plugin to blend bracketed images.
9
* Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* ============================================================ */
23
#include "enfusesettings.moc"
28
#include <QGridLayout>
35
#include <kseparator.h>
39
#include <libkdcraw/rnuminput.h>
41
using namespace KDcrawIface;
43
namespace KIPIExpoBlendingPlugin
46
class EnfuseSettingsWidget::EnfuseSettingsWidgetPriv
50
EnfuseSettingsWidgetPriv()
65
QCheckBox* autoLevelsCB;
66
QCheckBox* hardMaskCB;
67
QCheckBox* ciecam02CB;
70
QLabel* exposureLabel;
71
QLabel* saturationLabel;
72
QLabel* contrastLabel;
74
RIntNumInput* levelsInput;
76
RDoubleNumInput* exposureInput;
77
RDoubleNumInput* saturationInput;
78
RDoubleNumInput* contrastInput;
81
EnfuseSettingsWidget::EnfuseSettingsWidget(QWidget* parent)
82
: QWidget(parent), d(new EnfuseSettingsWidgetPriv)
84
setAttribute(Qt::WA_DeleteOnClose);
86
QGridLayout* grid = new QGridLayout(this);
88
// ------------------------------------------------------------------------
90
d->autoLevelsCB = new QCheckBox(i18nc("enfuse settings", "Auto Levels"), this);
91
d->autoLevelsCB->setWhatsThis( i18n("Set automatic level selection (maximized) for pyramid blending."));
93
d->levelsLabel = new QLabel(i18nc("enfuse settings", "Levels:"));
94
d->levelsInput = new RIntNumInput();
95
d->levelsInput->setRange(1, 29, 1);
96
d->levelsInput->setSliderEnabled(true);
97
d->levelsInput->setDefaultValue(20);
98
d->levelsInput->setWhatsThis(i18n("Set the number of levels for pyramid blending. "
99
"A low number trades off quality of results for faster "
100
"execution time and lower memory usage."));
102
d->hardMaskCB = new QCheckBox(i18n("Hard Mask"), this);
103
d->hardMaskCB->setWhatsThis(i18n("Force hard blend masks and no averaging on finest "
104
"scale. This is especially useful for focus "
105
"stacks with thin and high contrast features, "
106
"improves sharpness at the expense of increased noise."));
108
d->exposureLabel = new QLabel(i18nc("enfuse settings", "Exposure:"));
109
d->exposureInput = new RDoubleNumInput();
110
d->exposureInput->setDecimals(2);
111
d->exposureInput->input()->setRange(0.0, 1.0, 0.01, true);
112
d->exposureInput->setDefaultValue(1.0);
113
d->exposureInput->setWhatsThis( i18n("Set the exposure contribution for the blending process. "
114
"Higher values will favor well-exposed pixels."));
116
d->saturationLabel = new QLabel(i18nc("enfuse settings", "Saturation:"));
117
d->saturationInput = new RDoubleNumInput();
118
d->saturationInput->setDecimals(2);
119
d->saturationInput->input()->setRange(0.0, 1.0, 0.01, true);
120
d->saturationInput->setDefaultValue(0.2);
121
d->saturationInput->setWhatsThis( i18n("Increasing this value makes pixels with high "
122
"saturation contribute more to the final output."));
124
d->contrastLabel = new QLabel(i18nc("enfuse settings", "Contrast:"));
125
d->contrastInput = new RDoubleNumInput();
126
d->contrastInput->setDecimals(2);
127
d->contrastInput->input()->setRange(0.0, 1.0, 0.01, true);
128
d->contrastInput->setDefaultValue(0.0);
129
d->contrastInput->setWhatsThis(i18n("Sets the relative weight of high-contrast pixels. "
130
"Increasing this weight makes pixels with neighboring differently colored "
131
"pixels contribute more to the final output. Particularly useful for focus stacks."));
133
d->ciecam02CB = new QCheckBox(i18n("Use Color Appearance Modelling"), this);
134
d->ciecam02CB->setWhatsThis(i18n("Use Color Appearance Modelling (CIECAM02) to render detailed colors. "
135
"Your input files should have embedded ICC profiles. If no ICC profile is present, "
136
"sRGB color space will be used instead. The difference between using this option "
137
"and default color blending algorithm is very slight, and will be most noticeable "
138
"when you need to blend areas of different primary colors together."));
140
// ------------------------------------------------------------------------
142
grid->addWidget(d->autoLevelsCB, 0, 0, 1, 2);
143
grid->addWidget(d->levelsLabel, 1, 0, 1, 1);
144
grid->addWidget(d->levelsInput, 1, 1, 1, 1);
145
grid->addWidget(d->hardMaskCB, 2, 0, 1, 2);
146
grid->addWidget(d->exposureLabel, 3, 0, 1, 1);
147
grid->addWidget(d->exposureInput, 3, 1, 1, 1);
148
grid->addWidget(d->saturationLabel, 4, 0, 1, 1);
149
grid->addWidget(d->saturationInput, 4, 1, 1, 1);
150
grid->addWidget(d->contrastLabel, 5, 0, 1, 1);
151
grid->addWidget(d->contrastInput, 5, 1, 1, 1);
152
grid->addWidget(d->ciecam02CB, 6, 0, 1, 2);
153
grid->setRowStretch(7, 10);
154
grid->setMargin(KDialog::spacingHint());
155
grid->setSpacing(KDialog::spacingHint());
157
// ------------------------------------------------------------------------
159
connect(d->autoLevelsCB, SIGNAL(toggled(bool)),
160
d->levelsLabel, SLOT(setDisabled(bool)));
162
connect(d->autoLevelsCB, SIGNAL(toggled(bool)),
163
d->levelsInput, SLOT(setDisabled(bool)));
166
EnfuseSettingsWidget::~EnfuseSettingsWidget()
171
void EnfuseSettingsWidget::resetToDefault()
173
d->autoLevelsCB->setChecked(true);
174
d->levelsInput->slotReset();
175
d->hardMaskCB->setChecked(false);
176
d->exposureInput->slotReset();
177
d->saturationInput->slotReset();
178
d->contrastInput->slotReset();
179
d->ciecam02CB->setChecked(false);
182
void EnfuseSettingsWidget::setSettings(const EnfuseSettings& settings)
184
d->autoLevelsCB->setChecked(settings.autoLevels);
185
d->levelsInput->setValue(settings.levels);
186
d->hardMaskCB->setChecked(settings.hardMask);
187
d->exposureInput->setValue(settings.exposure);
188
d->saturationInput->setValue(settings.saturation);
189
d->contrastInput->setValue(settings.contrast);
190
d->ciecam02CB->setChecked(settings.ciecam02);
193
EnfuseSettings EnfuseSettingsWidget::settings() const
195
EnfuseSettings settings;
196
settings.autoLevels = d->autoLevelsCB->isChecked();
197
settings.levels = d->levelsInput->value();
198
settings.hardMask = d->hardMaskCB->isChecked();
199
settings.exposure = d->exposureInput->value();
200
settings.saturation = d->saturationInput->value();
201
settings.contrast = d->contrastInput->value();
202
settings.ciecam02 = d->ciecam02CB->isChecked();
206
void EnfuseSettingsWidget::readSettings(KConfigGroup& group)
208
d->autoLevelsCB->setChecked(group.readEntry("Auto Levels", true));
209
d->levelsInput->setValue(group.readEntry("Levels Value", d->levelsInput->defaultValue()));
210
d->hardMaskCB->setChecked(group.readEntry("Hard Mask", false));
211
d->exposureInput->setValue(group.readEntry("Exposure Value", d->exposureInput->defaultValue()));
212
d->saturationInput->setValue(group.readEntry("Saturation Value", d->saturationInput->defaultValue()));
213
d->contrastInput->setValue(group.readEntry("Contrast Value", d->contrastInput->defaultValue()));
214
d->ciecam02CB->setChecked(group.readEntry("CIECAM02", false));
217
void EnfuseSettingsWidget::writeSettings(KConfigGroup& group)
219
group.writeEntry("Auto Levels", d->autoLevelsCB->isChecked());
220
group.writeEntry("Levels Value", d->levelsInput->value());
221
group.writeEntry("Hard Mask", d->hardMaskCB->isChecked());
222
group.writeEntry("Exposure Value", d->exposureInput->value());
223
group.writeEntry("Saturation Value", d->saturationInput->value());
224
group.writeEntry("Contrast Value", d->contrastInput->value());
225
group.writeEntry("CIECAM02", d->ciecam02CB->isChecked());
228
} // namespace KIPIExpoBlendingPlugin