1 /*
2 * This file is part of RawTherapee.
3 *
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5 *
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
18 */
19 #include "bayerprocess.h"
20
21 #include "eventmapper.h"
22 #include "guiutils.h"
23 #include "options.h"
24
25 #include "../rtengine/procparams.h"
26 #include "../rtengine/utils.h"
27
28 using namespace rtengine;
29 using namespace rtengine::procparams;
30
31
BayerProcess()32 BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RAW_LABEL"), options.prevdemo != PD_Sidecar)
33 {
34
35 auto m = ProcEventMapper::getInstance();
36 EvDemosaicBorder = m->newEvent(DEMOSAIC, "HISTORY_MSG_RAW_BORDER");
37 EvDemosaicContrast = m->newEvent(DEMOSAIC, "HISTORY_MSG_DUALDEMOSAIC_CONTRAST");
38 EvDemosaicAutoContrast = m->newEvent(DEMOSAIC, "HISTORY_MSG_DUALDEMOSAIC_AUTO_CONTRAST");
39 EvDemosaicPixelshiftDemosaicMethod = m->newEvent(DEMOSAIC, "HISTORY_MSG_PIXELSHIFT_DEMOSAIC");
40
41 Gtk::HBox* hb1 = Gtk::manage (new Gtk::HBox ());
42 hb1->pack_start (*Gtk::manage (new Gtk::Label ( M("TP_RAW_DMETHOD") + ": ")), Gtk::PACK_SHRINK, 4);
43 method = Gtk::manage (new MyComboBoxText ());
44
45 for(const auto method_string : procparams::RAWParams::BayerSensor::getMethodStrings()) {
46 method->append(M("TP_RAW_" + Glib::ustring(method_string).uppercase()));
47 }
48
49 method->set_active(0);
50 hb1->set_tooltip_markup (M("TP_RAW_DMETHOD_TOOLTIP"));
51
52 hb1->pack_end (*method, Gtk::PACK_EXPAND_WIDGET, 4);
53 pack_start( *hb1, Gtk::PACK_SHRINK, 4);
54
55 dualDemosaicOptions = Gtk::manage(new Gtk::VBox());
56
57 dualDemosaicContrast = Gtk::manage(new Adjuster(M("TP_RAW_DUALDEMOSAICCONTRAST"), 0, 100, 1, 20));
58 dualDemosaicContrast->setAdjusterListener(this);
59 dualDemosaicContrast->addAutoButton(M("TP_RAW_DUALDEMOSAICAUTOCONTRAST_TOOLTIP"));
60 dualDemosaicContrast->setAutoValue(true);
61 if (dualDemosaicContrast->delay < options.adjusterMaxDelay) {
62 dualDemosaicContrast->delay = options.adjusterMaxDelay;
63 }
64
65 dualDemosaicContrast->show();
66 dualDemosaicOptions->pack_start(*dualDemosaicContrast);
67 pack_start( *dualDemosaicOptions, Gtk::PACK_SHRINK, 4);
68
69 borderbox = Gtk::manage(new Gtk::HBox());
70 border = Gtk::manage(new Adjuster(M("TP_RAW_BORDER"), 0, 16, 1, 4));
71 border->setAdjusterListener (this);
72
73 if (border->delay < options.adjusterMaxDelay) {
74 border->delay = options.adjusterMaxDelay;
75 }
76
77 border->show();
78 borderbox->pack_start(*border);
79 pack_start(*borderbox, Gtk::PACK_SHRINK, 4);
80
81 imageNumberBox = Gtk::manage (new Gtk::HBox ());
82 imageNumberBox->pack_start (*Gtk::manage (new Gtk::Label ( M("TP_RAW_IMAGENUM") + ": ")), Gtk::PACK_SHRINK, 4);
83 imageNumber = Gtk::manage (new MyComboBoxText ());
84 imageNumber->append("1");
85 imageNumber->append("2");
86 imageNumber->append("3");
87 imageNumber->append("4");
88 imageNumber->set_active(0);
89 imageNumberBox->set_tooltip_text(M("TP_RAW_IMAGENUM_TOOLTIP"));
90 imageNumberBox->pack_end (*imageNumber, Gtk::PACK_EXPAND_WIDGET, 4);
91 pack_start( *imageNumberBox, Gtk::PACK_SHRINK, 4);
92
93 pack_start( *Gtk::manage( new Gtk::HSeparator()), Gtk::PACK_SHRINK, 0 );
94 ccSteps = Gtk::manage (new Adjuster (M("TP_RAW_FALSECOLOR"), 0, 5, 1, 0 ));
95 ccSteps->setAdjusterListener (this);
96
97 if (ccSteps->delay < options.adjusterMaxDelay) {
98 ccSteps->delay = options.adjusterMaxDelay;
99 }
100
101 ccSteps->show();
102 pack_start( *ccSteps, Gtk::PACK_SHRINK, 4);
103
104
105 dcbOptions = Gtk::manage (new Gtk::VBox ());
106
107 dcbIterations = Gtk::manage (new Adjuster (M("TP_RAW_DCBITERATIONS"), 0, 5, 1, 2));
108 dcbIterations->setAdjusterListener (this);
109
110 if (dcbIterations->delay < options.adjusterMaxDelay) {
111 dcbIterations->delay = options.adjusterMaxDelay;
112 }
113
114 dcbIterations->show();
115 dcbEnhance = Gtk::manage (new CheckBox(M("TP_RAW_DCBENHANCE"), multiImage));
116 dcbEnhance->setCheckBoxListener (this);
117 dcbOptions->pack_start(*dcbIterations);
118 dcbOptions->pack_start(*dcbEnhance);
119 pack_start( *dcbOptions, Gtk::PACK_SHRINK, 4);
120
121 lmmseOptions = Gtk::manage (new Gtk::VBox ());
122
123 lmmseIterations = Gtk::manage (new Adjuster (M("TP_RAW_LMMSEITERATIONS"), 0, 6, 1, 2));
124 lmmseIterations->setAdjusterListener (this);
125 lmmseIterations->set_tooltip_markup (M("TP_RAW_LMMSE_TOOLTIP"));
126
127 if (lmmseIterations->delay < options.adjusterMaxDelay) {
128 lmmseIterations->delay = options.adjusterMaxDelay;
129 }
130
131 lmmseIterations->show();
132 lmmseOptions->pack_start(*lmmseIterations);
133 pack_start( *lmmseOptions, Gtk::PACK_SHRINK, 4);
134
135 // -------------------- PixelShift ----------------------
136
137
138 pixelShiftFrame = Gtk::manage(new Gtk::Frame(M("TP_RAW_PIXELSHIFT")));
139
140 Gtk::VBox *pixelShiftMainVBox = Gtk::manage (new Gtk::VBox ());
141 pixelShiftMainVBox->set_border_width(0);
142
143 pixelShiftEqualBright = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTEQUALBRIGHT"), multiImage));
144 pixelShiftEqualBright->setCheckBoxListener (this);
145 pixelShiftEqualBright->set_tooltip_text (M("TP_RAW_PIXELSHIFTEQUALBRIGHT_TOOLTIP"));
146 pixelShiftMainVBox->pack_start(*pixelShiftEqualBright);
147
148 pixelShiftEqualBrightChannel = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTEQUALBRIGHTCHANNEL"), multiImage));
149 pixelShiftEqualBrightChannel->setCheckBoxListener (this);
150 pixelShiftEqualBrightChannel->set_tooltip_text (M("TP_RAW_PIXELSHIFTEQUALBRIGHTCHANNEL_TOOLTIP"));
151 pixelShiftMainVBox->pack_start(*pixelShiftEqualBrightChannel);
152
153 Gtk::HBox* hb3 = Gtk::manage (new Gtk::HBox ());
154 hb3->pack_start (*Gtk::manage (new Gtk::Label ( M("TP_RAW_PIXELSHIFTMOTIONMETHOD") + ": ")), Gtk::PACK_SHRINK, 4);
155 pixelShiftMotionMethod = Gtk::manage (new MyComboBoxText ());
156 pixelShiftMotionMethod->append(M("TP_RAW_PIXELSHIFTMM_OFF"));
157 pixelShiftMotionMethod->append(M("TP_RAW_PIXELSHIFTMM_AUTO"));
158 pixelShiftMotionMethod->append(M("TP_RAW_PIXELSHIFTMM_CUSTOM"));
159 pixelShiftMotionMethod->set_active(toUnderlying(RAWParams::BayerSensor::PSMotionCorrectionMethod::AUTO));
160 pixelShiftMotionMethod->show();
161 hb3->pack_start(*pixelShiftMotionMethod);
162 pixelShiftMainVBox->pack_start(*hb3);
163
164 pixelShiftOptions = Gtk::manage (new Gtk::VBox ());
165 pixelShiftOptions->set_border_width(0);
166
167 pixelShiftShowMotion = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTSHOWMOTION"), multiImage));
168 pixelShiftShowMotion->setCheckBoxListener (this);
169 pixelShiftShowMotion->set_tooltip_text (M("TP_RAW_PIXELSHIFTSHOWMOTION_TOOLTIP"));
170 pixelShiftMainVBox->pack_start(*pixelShiftShowMotion);
171
172 pixelShiftShowMotionMaskOnly = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY"), multiImage));
173 pixelShiftShowMotionMaskOnly->setCheckBoxListener (this);
174 pixelShiftShowMotionMaskOnly->set_tooltip_text (M("TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY_TOOLTIP"));
175 pixelShiftMainVBox->pack_start(*pixelShiftShowMotionMaskOnly);
176
177
178 Gtk::HBox* hb4 = Gtk::manage (new Gtk::HBox ());
179 hb4->pack_start (*Gtk::manage (new Gtk::Label ( M("TP_RAW_PIXELSHIFTDMETHOD") + ": ")), Gtk::PACK_SHRINK, 4);
180 pixelShiftDemosaicMethod = Gtk::manage (new MyComboBoxText ());
181 for(const auto method_string : procparams::RAWParams::BayerSensor::getPSDemosaicMethodStrings()) {
182 pixelShiftDemosaicMethod->append(M("TP_RAW_" + Glib::ustring(method_string).uppercase()));
183 }
184 pixelShiftDemosaicMethod->set_active(0);
185 hb4->pack_start(*pixelShiftDemosaicMethod);
186 pixelShiftOptions->pack_start(*hb4);
187
188 pixelShiftGreen = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTGREEN"), multiImage));
189 pixelShiftGreen->setCheckBoxListener (this);
190 pixelShiftOptions->pack_start(*pixelShiftGreen);
191
192 pixelShiftNonGreenCross = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTNONGREENCROSS"), multiImage));
193 pixelShiftNonGreenCross->setCheckBoxListener (this);
194 pixelShiftOptions->pack_start(*pixelShiftNonGreenCross);
195
196 pixelShiftHoleFill = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTHOLEFILL"), multiImage));
197 pixelShiftHoleFill->setCheckBoxListener (this);
198 pixelShiftHoleFill->set_tooltip_text (M("TP_RAW_PIXELSHIFTHOLEFILL_TOOLTIP"));
199 pixelShiftOptions->pack_start(*pixelShiftHoleFill);
200
201 pixelShiftBlur = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTBLUR"), multiImage));
202 pixelShiftBlur->setCheckBoxListener (this);
203 pixelShiftBlur->set_tooltip_text (M("TP_RAW_PIXELSHIFTSIGMA_TOOLTIP"));
204 pixelShiftOptions->pack_start(*pixelShiftBlur);
205
206 pixelShiftSigma = Gtk::manage (new Adjuster (M("TP_RAW_PIXELSHIFTSIGMA"), 0.5, 25, 0.1, 1.0));
207 pixelShiftSigma->set_tooltip_text (M("TP_RAW_PIXELSHIFTSIGMA_TOOLTIP"));
208 pixelShiftSigma->setAdjusterListener (this);
209
210 if (pixelShiftSigma->delay < options.adjusterMaxDelay) {
211 pixelShiftSigma->delay = options.adjusterMaxDelay;
212 }
213
214 pixelShiftSigma->show();
215 pixelShiftOptions->pack_start(*pixelShiftSigma);
216
217
218 pixelShiftSmooth = Gtk::manage (new Adjuster (M("TP_RAW_PIXELSHIFTSMOOTH"), 0, 1, 0.05, 0.7));
219 pixelShiftSmooth->set_tooltip_text (M("TP_RAW_PIXELSHIFTSMOOTH_TOOLTIP"));
220 pixelShiftSmooth->setAdjusterListener (this);
221
222 if (pixelShiftSmooth->delay < options.adjusterMaxDelay) {
223 pixelShiftSmooth->delay = options.adjusterMaxDelay;
224 }
225
226 pixelShiftSmooth->show();
227 pixelShiftOptions->pack_start(*pixelShiftSmooth);
228
229 pixelShiftEperIso = Gtk::manage (new Adjuster (M("TP_RAW_PIXELSHIFTEPERISO"), -5.0, 5.0, 0.05, 0.0));
230 pixelShiftEperIso->set_tooltip_text(M("TP_RAW_PIXELSHIFTEPERISO_TOOLTIP"));
231 pixelShiftEperIso->setAdjusterListener (this);
232
233 if (pixelShiftEperIso->delay < options.adjusterMaxDelay) {
234 pixelShiftEperIso->delay = options.adjusterMaxDelay;
235 }
236
237 pixelShiftEperIso->show();
238 pixelShiftOptions->pack_start(*pixelShiftEperIso);
239
240
241 pixelShiftMedian = Gtk::manage (new CheckBox(M("TP_RAW_PIXELSHIFTMEDIAN"), multiImage));
242 pixelShiftMedian->setCheckBoxListener (this);
243 pixelShiftMedian->set_tooltip_text (M("TP_RAW_PIXELSHIFTMEDIAN_TOOLTIP"));
244 pixelShiftOptions->pack_start(*pixelShiftMedian);
245
246 pixelShiftMainVBox->pack_start(*pixelShiftOptions);
247 pixelShiftFrame->add(*pixelShiftMainVBox);
248 pixelShiftOptions->hide();
249
250 pack_start( *pixelShiftFrame, Gtk::PACK_SHRINK, 4);
251
252 method->connect(method->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::methodChanged) ));
253 imageNumber->connect(imageNumber->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::imageNumberChanged) ));
254 pixelShiftMotionMethod->connect(pixelShiftMotionMethod->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::pixelShiftMotionMethodChanged) ));
255 pixelShiftDemosaicMethod->connect(pixelShiftDemosaicMethod->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::pixelShiftDemosaicMethodChanged) ));
256
257 }
258
~BayerProcess()259 BayerProcess::~BayerProcess ()
260 {
261 idle_register.destroy();
262 }
263
read(const rtengine::procparams::ProcParams * pp,const ParamsEdited * pedited)264 void BayerProcess::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited)
265 {
266 disableListener ();
267 method->block (true);
268 imageNumber->block (true);
269 pixelShiftDemosaicMethod->block(true);
270 //allEnhconn.block (true);
271
272 border->setValue(pp->raw.bayersensor.border);
273 imageNumber->set_active(pp->raw.bayersensor.imageNum);
274
275 for (size_t i = 0; i < procparams::RAWParams::BayerSensor::getMethodStrings().size(); ++i) {
276 if (pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodStrings()[i]) {
277 method->set_active(i);
278 oldMethod = i;
279 break;
280 }
281 }
282 for (size_t i = 0; i < procparams::RAWParams::BayerSensor::getPSDemosaicMethodStrings().size(); ++i) {
283 if (pp->raw.bayersensor.pixelShiftDemosaicMethod == procparams::RAWParams::BayerSensor::getPSDemosaicMethodStrings()[i]) {
284 pixelShiftDemosaicMethod->set_active(i);
285 break;
286 }
287 }
288
289
290 dcbIterations->setValue (pp->raw.bayersensor.dcb_iterations);
291 dcbEnhance->setValue (pp->raw.bayersensor.dcb_enhance);
292 pixelShiftShowMotion->setValue (pp->raw.bayersensor.pixelShiftShowMotion);
293 pixelShiftShowMotionMaskOnly->setValue (pp->raw.bayersensor.pixelShiftShowMotionMaskOnly);
294 if (!batchMode) {
295 pixelShiftShowMotionMaskOnly->set_sensitive (pp->raw.bayersensor.pixelShiftShowMotion);
296 }
297 pixelShiftHoleFill->setValue (pp->raw.bayersensor.pixelShiftHoleFill);
298 pixelShiftMedian->setValue (pp->raw.bayersensor.pixelShiftMedian);
299 pixelShiftGreen->setValue (pp->raw.bayersensor.pixelShiftGreen);
300 pixelShiftBlur->setValue (pp->raw.bayersensor.pixelShiftBlur);
301 pixelShiftSmooth->setValue (pp->raw.bayersensor.pixelShiftSmoothFactor);
302 if (!batchMode) {
303 pixelShiftSmooth->set_sensitive (pp->raw.bayersensor.pixelShiftBlur);
304 }
305 pixelShiftEqualBright->setValue (pp->raw.bayersensor.pixelShiftEqualBright);
306 pixelShiftEqualBrightChannel->setValue (pp->raw.bayersensor.pixelShiftEqualBrightChannel);
307 if (!batchMode) {
308 pixelShiftEqualBrightChannel->set_sensitive (pp->raw.bayersensor.pixelShiftEqualBright);
309 }
310 pixelShiftNonGreenCross->setValue (pp->raw.bayersensor.pixelShiftNonGreenCross);
311 ccSteps->setValue (pp->raw.bayersensor.ccSteps);
312 lmmseIterations->setValue (pp->raw.bayersensor.lmmse_iterations);
313 dualDemosaicContrast->setAutoValue(pp->raw.bayersensor.dualDemosaicAutoContrast);
314 dualDemosaicContrast->setValue (pp->raw.bayersensor.dualDemosaicContrast);
315
316 pixelShiftMotionMethod->set_active ((int)pp->raw.bayersensor.pixelShiftMotionCorrectionMethod);
317 pixelShiftEperIso->setValue (pp->raw.bayersensor.pixelShiftEperIso);
318 pixelShiftSigma->setValue (pp->raw.bayersensor.pixelShiftSigma);
319 if (!batchMode) {
320 pixelShiftSigma->set_sensitive (pp->raw.bayersensor.pixelShiftBlur);
321 }
322
323 if(pedited) {
324 border->setEditedState (pedited->raw.bayersensor.border ? Edited : UnEdited);
325 ccSteps->setEditedState (pedited->raw.bayersensor.ccSteps ? Edited : UnEdited);
326 dcbIterations->setEditedState ( pedited->raw.bayersensor.dcbIterations ? Edited : UnEdited);
327 dcbEnhance->setEdited (pedited->raw.bayersensor.dcbEnhance);
328 pixelShiftShowMotion->setEdited (pedited->raw.bayersensor.pixelShiftShowMotion);
329 pixelShiftShowMotionMaskOnly->setEdited (pedited->raw.bayersensor.pixelShiftShowMotionMaskOnly);
330 pixelShiftHoleFill->setEdited (pedited->raw.bayersensor.pixelShiftHoleFill);
331 pixelShiftMedian->setEdited(pedited->raw.bayersensor.pixelShiftMedian);
332 pixelShiftGreen->setEdited (pedited->raw.bayersensor.pixelShiftGreen);
333 pixelShiftBlur->setEdited (pedited->raw.bayersensor.pixelShiftBlur);
334 pixelShiftSmooth->setEditedState ( pedited->raw.bayersensor.pixelShiftSmooth ? Edited : UnEdited);
335 pixelShiftEqualBright->setEdited (pedited->raw.bayersensor.pixelShiftEqualBright);
336 pixelShiftEqualBrightChannel->setEdited (pedited->raw.bayersensor.pixelShiftEqualBrightChannel);
337 pixelShiftNonGreenCross->setEdited (pedited->raw.bayersensor.pixelShiftNonGreenCross);
338 lmmseIterations->setEditedState ( pedited->raw.bayersensor.lmmseIterations ? Edited : UnEdited);
339 dualDemosaicContrast->setEditedState ( pedited->raw.bayersensor.dualDemosaicContrast ? Edited : UnEdited);
340 dualDemosaicContrast->setAutoInconsistent (multiImage && !pedited->raw.bayersensor.dualDemosaicAutoContrast);
341 pixelShiftEperIso->setEditedState ( pedited->raw.bayersensor.pixelShiftEperIso ? Edited : UnEdited);
342 pixelShiftSigma->setEditedState ( pedited->raw.bayersensor.pixelShiftSigma ? Edited : UnEdited);
343
344 if(!pedited->raw.bayersensor.method) {
345 method->set_active_text(M("GENERAL_UNCHANGED"));
346 }
347
348 if(!pedited->raw.bayersensor.imageNum) {
349 imageNumber->set_active_text(M("GENERAL_UNCHANGED"));
350 }
351
352 if(!pedited->raw.bayersensor.pixelShiftMotionCorrectionMethod) {
353 pixelShiftMotionMethod->set_active_text(M("GENERAL_UNCHANGED"));
354 }
355
356 if(!pedited->raw.bayersensor.pixelShiftDemosaicMethod) {
357 pixelShiftDemosaicMethod->set_active_text(M("GENERAL_UNCHANGED"));
358 }
359
360 }
361 lastAutoContrast = pp->raw.bayersensor.dualDemosaicAutoContrast;
362
363 if (!batchMode) {
364 dcbOptions->set_visible(pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCB) || pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4));
365 lmmseOptions->set_visible(pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::LMMSE));
366 dualDemosaicOptions->set_visible(pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4)
367 || pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4)
368 || pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4));
369 if (pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::PIXELSHIFT)) {
370 pixelShiftOptions->set_visible(pp->raw.bayersensor.pixelShiftMotionCorrectionMethod == RAWParams::BayerSensor::PSMotionCorrectionMethod::CUSTOM);
371 pixelShiftFrame->show();
372 } else {
373 pixelShiftFrame->hide();
374 }
375
376 // False color suppression is applied to all demozaicing method, so don't hide anything
377 /*if (pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::EAHD) ||
378 pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::HPHD) ||
379 pp->raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::VNG4))
380 ccSteps->show();
381 else
382 ccSteps->hide();*/
383 }
384
385 //lastALLen = pp->raw.bayersensor.all_enhance;
386
387 method->block (false);
388 imageNumber->block (false);
389 pixelShiftDemosaicMethod->block(false);
390 //allEnhconn.block (false);
391
392 enableListener ();
393 }
394
write(rtengine::procparams::ProcParams * pp,ParamsEdited * pedited)395 void BayerProcess::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pedited)
396 {
397 pp->raw.bayersensor.ccSteps = ccSteps->getIntValue();
398 pp->raw.bayersensor.dcb_iterations = dcbIterations->getIntValue();
399 pp->raw.bayersensor.dcb_enhance = dcbEnhance->getLastActive ();
400 pp->raw.bayersensor.border = border->getIntValue();
401 pp->raw.bayersensor.lmmse_iterations = lmmseIterations->getIntValue();
402 pp->raw.bayersensor.dualDemosaicAutoContrast = dualDemosaicContrast->getAutoValue();
403 pp->raw.bayersensor.dualDemosaicContrast = dualDemosaicContrast->getValue();
404 pp->raw.bayersensor.pixelShiftMotionCorrectionMethod = (RAWParams::BayerSensor::PSMotionCorrectionMethod)pixelShiftMotionMethod->get_active_row_number();
405 pp->raw.bayersensor.pixelShiftEperIso = pixelShiftEperIso->getValue();
406 pp->raw.bayersensor.pixelShiftSigma = pixelShiftSigma->getValue();
407 pp->raw.bayersensor.pixelShiftShowMotion = pixelShiftShowMotion->getLastActive ();
408 pp->raw.bayersensor.pixelShiftShowMotionMaskOnly = pixelShiftShowMotionMaskOnly->getLastActive ();
409 pp->raw.bayersensor.pixelShiftHoleFill = pixelShiftHoleFill->getLastActive ();
410 pp->raw.bayersensor.pixelShiftMedian = pixelShiftMedian->getLastActive ();
411 pp->raw.bayersensor.pixelShiftGreen = pixelShiftGreen->getLastActive ();
412 pp->raw.bayersensor.pixelShiftBlur = pixelShiftBlur->getLastActive ();
413 pp->raw.bayersensor.pixelShiftSmoothFactor = pixelShiftSmooth->getValue();
414 pp->raw.bayersensor.pixelShiftEqualBright = pixelShiftEqualBright->getLastActive ();
415 pp->raw.bayersensor.pixelShiftEqualBrightChannel = pixelShiftEqualBrightChannel->getLastActive ();
416 pp->raw.bayersensor.pixelShiftNonGreenCross = pixelShiftNonGreenCross->getLastActive ();
417
418 int currentRow = method->get_active_row_number();
419 if( currentRow >= 0 && method->get_active_text() != M("GENERAL_UNCHANGED")) {
420 pp->raw.bayersensor.method = procparams::RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method(currentRow));
421 }
422
423 currentRow = imageNumber->get_active_row_number();
424 if (currentRow >= 0 && imageNumber->get_active_text() != M("GENERAL_UNCHANGED")) {
425 pp->raw.bayersensor.imageNum = currentRow;
426 }
427
428 currentRow = pixelShiftDemosaicMethod->get_active_row_number();
429 if( currentRow >= 0 && pixelShiftDemosaicMethod->get_active_text() != M("GENERAL_UNCHANGED")) {
430 pp->raw.bayersensor.pixelShiftDemosaicMethod = procparams::RAWParams::BayerSensor::getPSDemosaicMethodString(RAWParams::BayerSensor::PSDemosaicMethod(currentRow));
431 }
432
433
434 if (pedited) {
435 pedited->raw.bayersensor.border = border->getEditedState ();
436 pedited->raw.bayersensor.ccSteps = ccSteps->getEditedState ();
437 pedited->raw.bayersensor.method = method->get_active_text() != M("GENERAL_UNCHANGED");
438 pedited->raw.bayersensor.imageNum = imageNumber->get_active_text() != M("GENERAL_UNCHANGED");
439 pedited->raw.bayersensor.dcbIterations = dcbIterations->getEditedState ();
440 pedited->raw.bayersensor.dcbEnhance = !dcbEnhance->get_inconsistent();
441 //pedited->raw.bayersensor.allEnhance = !allEnhance->get_inconsistent();
442 pedited->raw.bayersensor.lmmseIterations = lmmseIterations->getEditedState ();
443 pedited->raw.bayersensor.dualDemosaicAutoContrast = !dualDemosaicContrast->getAutoInconsistent ();
444 pedited->raw.bayersensor.dualDemosaicContrast = dualDemosaicContrast->getEditedState ();
445 pedited->raw.bayersensor.pixelShiftMotionCorrectionMethod = pixelShiftMotionMethod->get_active_text() != M("GENERAL_UNCHANGED");
446 pedited->raw.bayersensor.pixelShiftDemosaicMethod = pixelShiftDemosaicMethod->get_active_text() != M("GENERAL_UNCHANGED");
447 pedited->raw.bayersensor.pixelShiftEperIso = pixelShiftEperIso->getEditedState ();
448 pedited->raw.bayersensor.pixelShiftSigma = pixelShiftSigma->getEditedState ();
449 pedited->raw.bayersensor.pixelShiftShowMotion = !pixelShiftShowMotion->get_inconsistent();
450 pedited->raw.bayersensor.pixelShiftShowMotionMaskOnly = !pixelShiftShowMotionMaskOnly->get_inconsistent();
451 pedited->raw.bayersensor.pixelShiftHoleFill = !pixelShiftHoleFill->get_inconsistent();
452 pedited->raw.bayersensor.pixelShiftMedian = !pixelShiftMedian->get_inconsistent();
453 pedited->raw.bayersensor.pixelShiftGreen = !pixelShiftGreen->get_inconsistent();
454 pedited->raw.bayersensor.pixelShiftBlur = !pixelShiftBlur->get_inconsistent();
455 pedited->raw.bayersensor.pixelShiftSmooth = pixelShiftSmooth->getEditedState();
456 pedited->raw.bayersensor.pixelShiftEqualBright = !pixelShiftEqualBright->get_inconsistent();
457 pedited->raw.bayersensor.pixelShiftEqualBrightChannel = !pixelShiftEqualBrightChannel->get_inconsistent();
458 pedited->raw.bayersensor.pixelShiftNonGreenCross = !pixelShiftNonGreenCross->get_inconsistent();
459 }
460 }
461
setAdjusterBehavior(bool falsecoloradd,bool iteradd,bool dualdemozecontrastadd,bool pssigmaadd,bool pssmoothadd,bool pseperisoadd)462 void BayerProcess::setAdjusterBehavior (bool falsecoloradd, bool iteradd, bool dualdemozecontrastadd, bool pssigmaadd, bool pssmoothadd, bool pseperisoadd)
463 {
464 border->setAddMode(false);
465 ccSteps->setAddMode(falsecoloradd);
466 dcbIterations->setAddMode(iteradd);
467 lmmseIterations->setAddMode(iteradd);
468 pixelShiftSmooth->setAddMode(pssmoothadd);
469 pixelShiftEperIso->setAddMode(pseperisoadd);
470 pixelShiftSigma->setAddMode(pssigmaadd);
471 dualDemosaicContrast->setAddMode(dualdemozecontrastadd);
472 }
473
trimValues(rtengine::procparams::ProcParams * pp)474 void BayerProcess::trimValues (rtengine::procparams::ProcParams* pp)
475 {
476 border->trimValue(pp->raw.bayersensor.border);
477 ccSteps->trimValue(pp->raw.bayersensor.ccSteps);
478 dcbIterations->trimValue(pp->raw.bayersensor.dcb_iterations);
479 lmmseIterations->trimValue(pp->raw.bayersensor.lmmse_iterations);
480 pixelShiftSmooth->trimValue(pp->raw.bayersensor.pixelShiftSmoothFactor);
481 pixelShiftEperIso->trimValue(pp->raw.bayersensor.pixelShiftEperIso);
482 pixelShiftSigma->trimValue(pp->raw.bayersensor.pixelShiftSigma);
483 dualDemosaicContrast->trimValue(pp->raw.bayersensor.dualDemosaicContrast);
484 }
485
setBatchMode(bool batchMode)486 void BayerProcess::setBatchMode(bool batchMode)
487 {
488 method->append (M("GENERAL_UNCHANGED"));
489 method->set_active_text(M("GENERAL_UNCHANGED")); // No name
490 pixelShiftMotionMethod->append (M("GENERAL_UNCHANGED"));
491 pixelShiftMotionMethod->set_active_text (M("GENERAL_UNCHANGED"));
492 pixelShiftDemosaicMethod->append (M("GENERAL_UNCHANGED"));
493 pixelShiftDemosaicMethod->set_active_text(M("GENERAL_UNCHANGED")); // No name
494 imageNumber->append (M("GENERAL_UNCHANGED"));
495 imageNumber->set_active_text (M("GENERAL_UNCHANGED"));
496 ToolPanel::setBatchMode (batchMode);
497 border->showEditedCB ();
498 ccSteps->showEditedCB ();
499 dcbIterations->showEditedCB ();
500 lmmseIterations->showEditedCB ();
501 dualDemosaicContrast->showEditedCB ();
502 pixelShiftEperIso->showEditedCB ();
503 pixelShiftSigma->showEditedCB ();
504 }
505
setDefaults(const rtengine::procparams::ProcParams * defParams,const ParamsEdited * pedited)506 void BayerProcess::setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited)
507 {
508 dcbIterations->setDefault( defParams->raw.bayersensor.dcb_iterations);
509 lmmseIterations->setDefault( defParams->raw.bayersensor.lmmse_iterations);
510 dualDemosaicContrast->setDefault( defParams->raw.bayersensor.dualDemosaicContrast);
511 pixelShiftEperIso->setDefault( defParams->raw.bayersensor.pixelShiftEperIso);
512 pixelShiftSigma->setDefault( defParams->raw.bayersensor.pixelShiftSigma);
513 border->setDefault (defParams->raw.bayersensor.border);
514 ccSteps->setDefault (defParams->raw.bayersensor.ccSteps);
515
516 if (pedited) {
517 dcbIterations->setDefaultEditedState( pedited->raw.bayersensor.dcbIterations ? Edited : UnEdited);
518 lmmseIterations->setDefaultEditedState( pedited->raw.bayersensor.lmmseIterations ? Edited : UnEdited);
519 dualDemosaicContrast->setDefaultEditedState( pedited->raw.bayersensor.dualDemosaicContrast ? Edited : UnEdited);
520 pixelShiftEperIso->setDefaultEditedState( pedited->raw.bayersensor.pixelShiftEperIso ? Edited : UnEdited);
521 pixelShiftSigma->setDefaultEditedState( pedited->raw.bayersensor.pixelShiftSigma ? Edited : UnEdited);
522 border->setDefaultEditedState(pedited->raw.bayersensor.border ? Edited : UnEdited);
523 ccSteps->setDefaultEditedState(pedited->raw.bayersensor.ccSteps ? Edited : UnEdited);
524 } else {
525 dcbIterations->setDefaultEditedState( Irrelevant );
526 lmmseIterations->setDefaultEditedState( Irrelevant );
527 dualDemosaicContrast->setDefaultEditedState( Irrelevant );
528 pixelShiftEperIso->setDefaultEditedState( Irrelevant );
529 pixelShiftSigma->setDefaultEditedState( Irrelevant );
530 border->setDefaultEditedState(Irrelevant);
531 ccSteps->setDefaultEditedState(Irrelevant );
532 }
533 }
534
adjusterChanged(Adjuster * a,double newval)535 void BayerProcess::adjusterChanged (Adjuster* a, double newval)
536 {
537 if (listener) {
538 if (a == dcbIterations) {
539 listener->panelChanged (EvDemosaicDCBIter, a->getTextValue() );
540 } else if (a == ccSteps) {
541 listener->panelChanged (EvDemosaicFalseColorIter, a->getTextValue() );
542 } else if (a == lmmseIterations) {
543 listener->panelChanged (EvDemosaicLMMSEIter, a->getTextValue() );
544 } else if (a == dualDemosaicContrast) {
545 listener->panelChanged (EvDemosaicContrast, a->getTextValue() );
546 } else if (a == pixelShiftEperIso) {
547 listener->panelChanged (EvPixelShiftEperIso, a->getTextValue() );
548 } else if (a == pixelShiftSigma) {
549 listener->panelChanged (EvPixelShiftSigma, a->getTextValue() );
550 } else if (a == pixelShiftSmooth) {
551 listener->panelChanged (EvPixelShiftSmooth, a->getTextValue() );
552 } else if (a == border) {
553 listener->panelChanged (EvDemosaicBorder, a->getTextValue() );
554 }
555 }
556 }
557
methodChanged()558 void BayerProcess::methodChanged ()
559 {
560 const int currentSelection = method->get_active_row_number();
561 const RAWParams::BayerSensor::Method currentMethod = RAWParams::BayerSensor::Method(currentSelection);
562
563 if (!batchMode) {
564 if (currentMethod == procparams::RAWParams::BayerSensor::Method::DCB || currentMethod == procparams::RAWParams::BayerSensor::Method::DCBVNG4) {
565 dcbOptions->show();
566 } else {
567 dcbOptions->hide();
568 }
569
570 if (currentMethod == procparams::RAWParams::BayerSensor::Method::LMMSE) {
571 lmmseOptions->show();
572 } else {
573 lmmseOptions->hide();
574 }
575
576 if (currentMethod == procparams::RAWParams::BayerSensor::Method::AMAZEVNG4 || currentMethod == procparams::RAWParams::BayerSensor::Method::DCBVNG4 || currentMethod == procparams::RAWParams::BayerSensor::Method::RCDVNG4) {
577 dualDemosaicOptions->show();
578 } else {
579 dualDemosaicOptions->hide();
580 }
581
582 if (currentMethod == procparams::RAWParams::BayerSensor::Method::PIXELSHIFT) {
583 if(pixelShiftMotionMethod->get_active_row_number() == 2) {
584 pixelShiftOptions->show();
585 } else {
586 pixelShiftOptions->hide();
587 }
588 pixelShiftFrame->show();
589 } else {
590 pixelShiftFrame->hide();
591 }
592 }
593
594 if (listener && method->get_active_row_number() >= 0) {
595 listener->panelChanged (
596 currentMethod == procparams::RAWParams::BayerSensor::Method::MONO || RAWParams::BayerSensor::Method(oldMethod) == procparams::RAWParams::BayerSensor::Method::MONO
597 ? EvDemosaicMethodPreProc
598 : EvDemosaicMethod, method->get_active_text());
599 }
600
601 oldMethod = currentSelection;
602
603 }
604
pixelShiftDemosaicMethodChanged()605 void BayerProcess::pixelShiftDemosaicMethodChanged ()
606 {
607
608 if (listener && pixelShiftDemosaicMethod->get_active_row_number() >= 0) {
609 listener->panelChanged (EvDemosaicPixelshiftDemosaicMethod, pixelShiftDemosaicMethod->get_active_text());
610 }
611 }
612
imageNumberChanged()613 void BayerProcess::imageNumberChanged ()
614 {
615 if (listener) {
616 listener->panelChanged (EvRawImageNum, imageNumber->get_active_text());
617 }
618 }
619
checkBoxToggled(CheckBox * c,CheckValue newval)620 void BayerProcess::checkBoxToggled (CheckBox* c, CheckValue newval)
621 {
622 if (c == dcbEnhance) {
623 if (listener) {
624 listener->panelChanged (EvDemosaicDCBEnhanced, dcbEnhance->getValueAsStr ());
625 }
626 } else if (c == pixelShiftShowMotion) {
627 if (!batchMode) {
628 pixelShiftShowMotionMaskOnly->set_sensitive(newval != CheckValue::off);
629 }
630 if (listener) {
631 listener->panelChanged (EvPixelshiftShowMotion, pixelShiftShowMotion->getValueAsStr ());
632 }
633 } else if (c == pixelShiftShowMotionMaskOnly) {
634 if (listener) {
635 listener->panelChanged (EvPixelshiftShowMotionMaskOnly, pixelShiftShowMotionMaskOnly->getValueAsStr ());
636 }
637 } else if (c == pixelShiftHoleFill) {
638 if (listener) {
639 listener->panelChanged (EvPixelShiftHoleFill, pixelShiftHoleFill->getValueAsStr ());
640 }
641 } else if (c == pixelShiftMedian) {
642 if (listener) {
643 listener->panelChanged (EvPixelShiftMedian, pixelShiftMedian->getValueAsStr ());
644 }
645 } else if (c == pixelShiftGreen) {
646 if (listener) {
647 listener->panelChanged (EvPixelShiftGreen, pixelShiftGreen->getValueAsStr ());
648 }
649 } else if (c == pixelShiftBlur) {
650 if (!batchMode) {
651 pixelShiftSmooth->set_sensitive(newval != CheckValue::off);
652 pixelShiftSigma->set_sensitive(newval != CheckValue::off);
653 }
654 if (listener) {
655 listener->panelChanged (EvPixelShiftBlur, pixelShiftBlur->getValueAsStr ());
656 }
657 } else if (c == pixelShiftEqualBright) {
658 if (!batchMode) {
659 pixelShiftEqualBrightChannel->set_sensitive(newval != CheckValue::off);
660 }
661 if (listener) {
662 listener->panelChanged (EvPixelShiftEqualBright, pixelShiftEqualBright->getValueAsStr ());
663 }
664 } else if (c == pixelShiftEqualBrightChannel) {
665 if (listener) {
666 listener->panelChanged (EvPixelShiftEqualBrightChannel, pixelShiftEqualBrightChannel->getValueAsStr ());
667 }
668 } else if (c == pixelShiftNonGreenCross) {
669 if (listener) {
670 listener->panelChanged (EvPixelShiftNonGreenCross, pixelShiftNonGreenCross->getValueAsStr ());
671 }
672 }
673 }
674
adjusterAutoToggled(Adjuster * a)675 void BayerProcess::adjusterAutoToggled(Adjuster* a)
676 {
677 if (multiImage) {
678 if (dualDemosaicContrast->getAutoInconsistent()) {
679 dualDemosaicContrast->setAutoInconsistent (false);
680 dualDemosaicContrast->setAutoValue (false);
681 } else if (lastAutoContrast) {
682 dualDemosaicContrast->setAutoInconsistent (true);
683 }
684
685 lastAutoContrast = dualDemosaicContrast->getAutoValue();
686 }
687
688 if (listener) {
689
690 if (a == dualDemosaicContrast) {
691 if (dualDemosaicContrast->getAutoInconsistent()) {
692 listener->panelChanged (EvDemosaicAutoContrast, M ("GENERAL_UNCHANGED"));
693 } else if (dualDemosaicContrast->getAutoValue()) {
694 listener->panelChanged (EvDemosaicAutoContrast, M ("GENERAL_ENABLED"));
695 } else {
696 listener->panelChanged (EvDemosaicAutoContrast, M ("GENERAL_DISABLED"));
697 }
698 }
699 }
700 }
701
pixelShiftMotionMethodChanged()702 void BayerProcess::pixelShiftMotionMethodChanged ()
703 {
704 if (!batchMode) {
705 if(pixelShiftMotionMethod->get_active_row_number() == 0) {
706 pixelShiftOptions->hide();
707 pixelShiftShowMotion->hide();
708 pixelShiftShowMotionMaskOnly->hide();
709 } else if(pixelShiftMotionMethod->get_active_row_number() == 2) {
710 pixelShiftOptions->show();
711 pixelShiftShowMotion->show();
712 pixelShiftShowMotionMaskOnly->show();
713 } else if(pixelShiftMotionMethod->get_active_row_number() > 0) {
714 pixelShiftOptions->hide();
715 pixelShiftShowMotion->show();
716 pixelShiftShowMotionMaskOnly->show();
717 }
718 }
719 if (listener && pixelShiftMotionMethod->get_active_row_number() >= 0) {
720 listener->panelChanged (EvPixelShiftMotionMethod, pixelShiftMotionMethod->get_active_text());
721 }
722 }
723
FrameCountChanged(int n,int frameNum)724 void BayerProcess::FrameCountChanged(int n, int frameNum)
725 {
726 idle_register.add(
727 [this, n, frameNum]() -> bool
728 {
729 imageNumber->block(true);
730
731 imageNumber->remove_all();
732 imageNumber->append("1");
733 for (int i = 2; i <= std::min(n, 6); ++i) {
734 std::ostringstream entry;
735 entry << i;
736 imageNumber->append(entry.str());
737 }
738 if (n == 2) {
739 imageNumber->append(M("TP_RAW_IMAGENUM_SN"));
740 }
741 imageNumber->set_active(std::min(frameNum, n == 2 ? n : n - 1));
742 if (n == 1) {
743 imageNumberBox->hide();
744 } else {
745 imageNumberBox->show();
746 }
747 imageNumber->block (false);
748 return false;
749 }
750 );
751 }
752
autoContrastChanged(double autoContrast)753 void BayerProcess::autoContrastChanged (double autoContrast)
754 {
755 idle_register.add(
756 [this, autoContrast]() -> bool
757 {
758 disableListener();
759 dualDemosaicContrast->setValue(autoContrast);
760 enableListener();
761 return false;
762 }
763 );
764 }
765