diff --git a/rtdata/languages/default b/rtdata/languages/default index 7d95a680e..a053cc275 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1213,6 +1213,7 @@ HISTORY_MSG_PDSHARPEN_RADIUS_BOOST;CS - Corner radius boost HISTORY_MSG_PIXELSHIFT_DEMOSAIC;PS - Demosaic method for motion HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION;Line noise filter direction HISTORY_MSG_PREPROCESS_PDAFLINESFILTER;PDAF lines filter +HISTORY_MSG_PREPROCWB_MODE;Preprocess WB Mode HISTORY_MSG_PRSHARPEN_CONTRAST;PRS - Contrast threshold HISTORY_MSG_RAWCACORR_AUTOIT;Raw CA Correction - Iterations HISTORY_MSG_RAWCACORR_COLORSHIFT;Raw CA Correction - Avoid color shift @@ -1494,6 +1495,7 @@ PARTIALPASTE_PREPROCESS_GREENEQUIL;Green equilibration PARTIALPASTE_PREPROCESS_HOTPIXFILT;Hot pixel filter PARTIALPASTE_PREPROCESS_LINEDENOISE;Line noise filter PARTIALPASTE_PREPROCESS_PDAFLINESFILTER;PDAF lines filter +PARTIALPASTE_PREPROCWB;Preprocess White Balance PARTIALPASTE_PRSHARPENING;Post-resize sharpening PARTIALPASTE_RAWCACORR_AUTO;CA auto-correction PARTIALPASTE_RAWCACORR_AVOIDCOLORSHIFT;CA avoid color shift @@ -2817,6 +2819,10 @@ TP_PREPROCESS_LINEDENOISE_DIRECTION_PDAF_LINES;Horizontal only on PDAF rows TP_PREPROCESS_LINEDENOISE_DIRECTION_VERTICAL;Vertical TP_PREPROCESS_NO_FOUND;None found TP_PREPROCESS_PDAFLINESFILTER;PDAF lines filter +TP_PREPROCWB_LABEL;Preprocess White Balance +TP_PREPROCWB_MODE;Mode +TP_PREPROCWB_MODE_AUTO;Auto +TP_PREPROCWB_MODE_CAMERA;Camera TP_PRSHARPENING_LABEL;Post-Resize Sharpening TP_PRSHARPENING_TOOLTIP;Sharpens the image after resizing. Only works when the "Lanczos" resizing method is used. It is impossible to preview the effects of this tool. See RawPedia for usage instructions. TP_RAWCACORR_AUTO;Auto-correction diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index a532190d2..ad9bb9f58 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -3020,7 +3020,12 @@ void ImProcFunctions::InverseBlurNoise_Local(LabImage * originalmask, float **bu } } -static void calclight(float lum, float koef, float &lumnew, const LUTf &lightCurveloc) +static void calclight(float lum, float &lumnew, const LUTf &lightCurveloc) +{ + lumnew = CLIPLOC(lightCurveloc[lum]); +} + +static void calclightinv(float lum, float koef, float &lumnew, const LUTf &lightCurveloc) { lumnew = koef != -100.f ? CLIPLOC(lightCurveloc[lum]) : 0.f; } @@ -5757,7 +5762,7 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp float lightcont; if ((lp.ligh != 0.f || lp.cont != 0)) { - calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve + calclightinv(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -5776,7 +5781,7 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp float fac = (100.f + factorx * lp.chro) / 100.f; //chroma factor transition if ((lp.ligh != 0.f || lp.cont != 0)) { - calclight(original->L[y][x], lp.ligh, lumnew, lightCurveloc); + calclightinv(original->L[y][x], lp.ligh, lumnew, lightCurveloc); } float lightcont = lumnew ; //apply lightness @@ -5834,7 +5839,7 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp float lightcont; if ((lp.ligh != 0.f || lp.cont != 0)) { - calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve + calclightinv(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -5852,7 +5857,7 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp } else { if ((lp.ligh != 0.f || lp.cont != 0)) { - calclight(original->L[y][x], lp.ligh, lumnew, lightCurveloc); + calclightinv(original->L[y][x], lp.ligh, lumnew, lightCurveloc); } float lightcont = lumnew ; @@ -15086,7 +15091,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (lp.ligh != 0.f || lp.cont != 0) {//slider luminance or slider contrast with curve - calclight(bufcolcalcL, lp.ligh, bufcolcalcL, lightCurveloc); + calclight(bufcolcalcL, bufcolcalcL, lightCurveloc); } if (lllocalcurve && locallutili && lp.qualcurvemet != 0) {// L=f(L) curve diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index e4443b63a..3bd8403cc 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -4487,6 +4487,23 @@ Glib::ustring RAWParams::XTransSensor::getMethodString(Method method) return getMethodStrings()[toUnderlying(method)]; } + +RAWParams::PreprocessWB::PreprocessWB() : + mode(Mode::AUTO) +{ +} + +bool RAWParams::PreprocessWB::operator ==(const PreprocessWB& other) const +{ + return mode == other.mode; +} + +bool RAWParams::PreprocessWB::operator !=(const PreprocessWB& other) const +{ + return !(*this == other); +} + + RAWParams::RAWParams() : df_autoselect(false), ff_AutoSelect(false), @@ -4525,6 +4542,7 @@ bool RAWParams::operator ==(const RAWParams& other) const && cared == other.cared && cablue == other.cablue && expos == other.expos + && preprocessWB == other.preprocessWB && hotPixelFilter == other.hotPixelFilter && deadPixelFilter == other.deadPixelFilter && hotdeadpix_thresh == other.hotdeadpix_thresh; @@ -5970,6 +5988,9 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->filmNegative.baseValues, "Film Negative", "GreenBase", filmNegative.greenBase, keyFile); saveToKeyfile(!pedited || pedited->filmNegative.baseValues, "Film Negative", "BlueBase", filmNegative.blueBase, keyFile); +// Preprocess WB + saveToKeyfile(!pedited || pedited->raw.preprocessWB.mode, "RAW Preprocess WB", "Mode", toUnderlying(raw.preprocessWB.mode), keyFile); + // EXIF change list if (!pedited || pedited->exif) { for (ExifPairs::const_iterator i = exif.begin(); i != exif.end(); ++i) { @@ -8177,6 +8198,16 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) } } + if (keyFile.has_group("RAW Preprocess WB")) { + if (keyFile.has_key("RAW Preprocess WB", "Mode")) { + raw.preprocessWB.mode = RAWParams::PreprocessWB::Mode(keyFile.get_integer("RAW Preprocess WB", "Mode")); + + if (pedited) { + pedited->raw.preprocessWB.mode = true; + } + } + } + if (keyFile.has_group("MetaData")) { int mode = int(MetaDataParams::TUNNEL); assignFromKeyfile(keyFile, "MetaData", "Mode", pedited, mode, pedited->metadata.mode); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index b89fd95f7..df965e0bb 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -2041,6 +2041,22 @@ struct RAWParams { // exposure before interpolation double expos; + struct PreprocessWB { + enum class Mode { + CAMERA = 0, + AUTO + }; + + Mode mode; + + PreprocessWB(); + + bool operator ==(const PreprocessWB& other) const; + bool operator !=(const PreprocessWB& other) const; + }; + + PreprocessWB preprocessWB; + bool hotPixelFilter; bool deadPixelFilter; int hotdeadpix_thresh; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 75088a07c..f94070f2d 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1161,25 +1161,8 @@ int RawImageSource::load (const Glib::ustring &fname, bool firstFrameOnly) double cam_b = imatrices.rgb_cam[2][0] * camwb_red + imatrices.rgb_cam[2][1] * camwb_green + imatrices.rgb_cam[2][2] * camwb_blue; camera_wb = ColorTemp (cam_r, cam_g, cam_b, 1.); // as shot WB - ColorTemp ReferenceWB; - double ref_r, ref_g, ref_b; - { - // ...then we re-get the constants but now with auto which gives us better demosaicing and CA auto-correct - // performance for strange white balance settings (such as UniWB) - ri->get_colorsCoeff(ref_pre_mul, scale_mul, c_black, true); - refwb_red = ri->get_pre_mul(0) / ref_pre_mul[0]; - refwb_green = ri->get_pre_mul(1) / ref_pre_mul[1]; - refwb_blue = ri->get_pre_mul(2) / ref_pre_mul[2]; - initialGain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); - ref_r = imatrices.rgb_cam[0][0] * refwb_red + imatrices.rgb_cam[0][1] * refwb_green + imatrices.rgb_cam[0][2] * refwb_blue; - ref_g = imatrices.rgb_cam[1][0] * refwb_red + imatrices.rgb_cam[1][1] * refwb_green + imatrices.rgb_cam[1][2] * refwb_blue; - ref_b = imatrices.rgb_cam[2][0] * refwb_red + imatrices.rgb_cam[2][1] * refwb_green + imatrices.rgb_cam[2][2] * refwb_blue; - ReferenceWB = ColorTemp (ref_r, ref_g, ref_b, 1.); - } - if (settings->verbose) { printf("Raw As Shot White balance: temp %f, tint %f\n", camera_wb.getTemp(), camera_wb.getGreen()); - printf("Raw Reference (auto) white balance: temp %f, tint %f, multipliers [%f %f %f | %f %f %f]\n", ReferenceWB.getTemp(), ReferenceWB.getGreen(), ref_r, ref_g, ref_b, refwb_red, refwb_blue, refwb_green); } /*{ @@ -1249,6 +1232,27 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le MyTime t1, t2; t1.set(); + { + // Recalculate the scaling coefficients, using auto WB if selected in the Preprocess WB param. + // Auto WB gives us better demosaicing and CA auto-correct performance for strange white balance settings (such as UniWB) + ri->get_colorsCoeff( ref_pre_mul, scale_mul, c_black, raw.preprocessWB.mode == RAWParams::PreprocessWB::Mode::AUTO); + + refwb_red = ri->get_pre_mul(0) / ref_pre_mul[0]; + refwb_green = ri->get_pre_mul(1) / ref_pre_mul[1]; + refwb_blue = ri->get_pre_mul(2) / ref_pre_mul[2]; + initialGain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); + + const double ref_r = imatrices.rgb_cam[0][0] * refwb_red + imatrices.rgb_cam[0][1] * refwb_green + imatrices.rgb_cam[0][2] * refwb_blue; + const double ref_g = imatrices.rgb_cam[1][0] * refwb_red + imatrices.rgb_cam[1][1] * refwb_green + imatrices.rgb_cam[1][2] * refwb_blue; + const double ref_b = imatrices.rgb_cam[2][0] * refwb_red + imatrices.rgb_cam[2][1] * refwb_green + imatrices.rgb_cam[2][2] * refwb_blue; + const ColorTemp ReferenceWB = ColorTemp (ref_r, ref_g, ref_b, 1.); + + if (settings->verbose) { + printf("Raw Reference white balance: temp %f, tint %f, multipliers [%f %f %f | %f %f %f]\n", ReferenceWB.getTemp(), ReferenceWB.getGreen(), ref_r, ref_g, ref_b, refwb_red, refwb_blue, refwb_green); + } + } + + Glib::ustring newDF = raw.dark_frame; RawImage *rid = nullptr; diff --git a/rtgui/CMakeLists.txt b/rtgui/CMakeLists.txt index 6719d9de2..cfadb7928 100644 --- a/rtgui/CMakeLists.txt +++ b/rtgui/CMakeLists.txt @@ -117,6 +117,7 @@ set(NONCLISOURCEFILES popuptogglebutton.cc preferences.cc preprocess.cc + preprocesswb.cc previewhandler.cc previewloader.cc previewmodepanel.cc diff --git a/rtgui/locallabtools.cc b/rtgui/locallabtools.cc index 0b8c8582e..c693d0a3b 100644 --- a/rtgui/locallabtools.cc +++ b/rtgui/locallabtools.cc @@ -2355,6 +2355,7 @@ LocallabExposure::LocallabExposure(): fatBox->pack_start(*fatanchor); fatFrame->add(*fatBox); pack_start(*fatFrame); + pack_start(*expcomp); pack_start(*sensiex); pack_start(*structexp); pack_start(*blurexpde); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 2dfa525dc..954dd68ad 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -643,6 +643,7 @@ void ParamsEdited::set(bool v) filmNegative.greenExp = v; filmNegative.blueRatio = v; filmNegative.baseValues = v; + raw.preprocessWB.mode = v; exif = v; iptc = v; @@ -1737,6 +1738,7 @@ void ParamsEdited::initFrom(const std::vector& filmNegative.baseValues = filmNegative.baseValues && p.filmNegative.redBase == other.filmNegative.redBase && p.filmNegative.greenBase == other.filmNegative.greenBase && p.filmNegative.blueBase == other.filmNegative.blueBase; + raw.preprocessWB.mode = raw.preprocessWB.mode && p.raw.preprocessWB.mode == other.raw.preprocessWB.mode; // How the hell can we handle that??? // exif = exif && p.exif==other.exif @@ -5753,6 +5755,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.filmNegative.blueBase = mods.filmNegative.blueBase; } + if (raw.preprocessWB.mode) { + toEdit.raw.preprocessWB.mode = mods.raw.preprocessWB.mode; + } + // Exif changes are added to the existing ones if (exif) { for (procparams::ExifPairs::const_iterator i = mods.exif.begin(); i != mods.exif.end(); ++i) { @@ -6711,3 +6717,8 @@ bool CaptureSharpeningParamsEdited::isUnchanged() const { return enabled && contrast && autoContrast && autoRadius && deconvradius && deconvradiusOffset && deconviter && deconvitercheck; } + +bool RAWParamsEdited::PreprocessWBParamsEdited::isUnchanged() const +{ + return mode; +} diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index c3d7473e1..33613e7a8 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -1189,6 +1189,14 @@ struct RAWParamsEdited { bool ff_clipControl; bool exPos; + struct PreprocessWBParamsEdited { + bool mode; + + bool isUnchanged() const; + }; + + PreprocessWBParamsEdited preprocessWB; + bool isUnchanged() const; }; diff --git a/rtgui/partialpastedlg.cc b/rtgui/partialpastedlg.cc index d3f95fa79..6808a2cc6 100644 --- a/rtgui/partialpastedlg.cc +++ b/rtgui/partialpastedlg.cc @@ -308,6 +308,8 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren filmNegative = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FILMNEGATIVE")) ); //--- captureSharpening = Gtk::manage (new Gtk::CheckButton (M("TP_PDSHARPENING_LABEL")) ); + //--- + raw_preprocwb = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PREPROCWB"))); Gtk::VBox* vboxes[9]; Gtk::HSeparator* hseps[9]; @@ -391,13 +393,6 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren //META vboxes[7]->pack_start (*meta, Gtk::PACK_SHRINK, 2); vboxes[7]->pack_start (*hseps[7], Gtk::PACK_SHRINK, 2); - vboxes[7]->pack_start(*metadata, Gtk::PACK_SHRINK, 2); - vboxes[7]->pack_start (*exifch, Gtk::PACK_SHRINK, 2); - vboxes[7]->pack_start (*iptc, Gtk::PACK_SHRINK, 2); - - //RAW - vboxes[8]->pack_start (*raw, Gtk::PACK_SHRINK, 2); - vboxes[8]->pack_start (*hseps[8], Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_method, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_border, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_imagenum, Gtk::PACK_SHRINK, 2); @@ -415,6 +410,7 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren vboxes[8]->pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 0); vboxes[8]->pack_start (*raw_expos, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_black, Gtk::PACK_SHRINK, 2); + vboxes[8]->pack_start (*raw_preprocwb, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 0); vboxes[8]->pack_start (*df_file, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*df_AutoSelect, Gtk::PACK_SHRINK, 2); @@ -423,13 +419,14 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren vboxes[8]->pack_start (*ff_AutoSelect, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*ff_BlurType, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*ff_BlurRadius, Gtk::PACK_SHRINK, 2); - vboxes[8]->pack_start (*captureSharpening, Gtk::PACK_SHRINK, 2); + vboxes[8]->pack_start (*ff_ClipControl, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 0); vboxes[8]->pack_start (*raw_ca_autocorrect, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_caredblue, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*raw_ca_avoid_colourshift, Gtk::PACK_SHRINK, 2); vboxes[8]->pack_start (*Gtk::manage (new Gtk::HSeparator ()), Gtk::PACK_SHRINK, 0); vboxes[8]->pack_start (*filmNegative, Gtk::PACK_SHRINK, 2); + vboxes[8]->pack_start (*captureSharpening, Gtk::PACK_SHRINK, 2); Gtk::VBox* vbCol1 = Gtk::manage (new Gtk::VBox ()); Gtk::VBox* vbCol2 = Gtk::manage (new Gtk::VBox ()); @@ -582,6 +579,8 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren filmNegativeConn = filmNegative->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); //--- captureSharpeningConn = captureSharpening->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); + //--- + raw_preprocwbConn = raw_preprocwb->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); add_button (M("GENERAL_OK"), Gtk::RESPONSE_OK); add_button (M("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); @@ -658,6 +657,7 @@ void PartialPasteDlg::rawToggled () ConnectionBlocker raw_ca_avoid_colourshiftBlocker(raw_ca_avoid_colourshiftconn); ConnectionBlocker filmNegativeBlocker(filmNegativeConn); ConnectionBlocker captureSharpeningBlocker(captureSharpeningConn); + ConnectionBlocker raw_preprocwbBlocker(raw_preprocwbConn); raw->set_inconsistent (false); @@ -688,6 +688,7 @@ void PartialPasteDlg::rawToggled () raw_ca_avoid_colourshift->set_active (raw->get_active ()); filmNegative->set_active (raw->get_active()); captureSharpening->set_active (raw->get_active()); + raw_preprocwb->set_active (raw->get_active()); } void PartialPasteDlg::basicToggled () @@ -1191,6 +1192,10 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param filterPE.pdsharpening.deconvitercheck = falsePE.pdsharpening.deconvitercheck; } + if (!raw_preprocwb->get_active ()) { + filterPE.raw.preprocessWB.mode = falsePE.raw.preprocessWB.mode; + } + // Locallab shall be kept in last position if (!locallab->get_active () && !locallab->get_inconsistent()) { filterPE.locallab = falsePE.locallab; diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index f675a7dca..94bc2868c 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -219,6 +219,7 @@ public: Gtk::CheckButton* filmNegative; Gtk::CheckButton* captureSharpening; + Gtk::CheckButton* raw_preprocwb; sigc::connection everythingConn, basicConn, detailConn, colorConn, lensConn, compositionConn, metaConn, rawConn, advancedConn; sigc::connection locallabConn; @@ -232,6 +233,7 @@ public: sigc::connection raw_caredblueConn, raw_ca_autocorrectConn, raw_ca_avoid_colourshiftconn, raw_hotpix_filtConn, raw_deadpix_filtConn, raw_pdaf_lines_filterConn, raw_linenoiseConn, raw_greenthreshConn, raw_ccStepsConn, raw_methodConn, raw_borderConn, raw_imagenumConn, raw_dcb_iterationsConn, raw_lmmse_iterationsConn, raw_pixelshiftConn, raw_dcb_enhanceConn, raw_exposConn, raw_blackConn; sigc::connection filmNegativeConn; sigc::connection captureSharpeningConn; + sigc::connection raw_preprocwbConn; public: PartialPasteDlg (const Glib::ustring &title, Gtk::Window* parent); diff --git a/rtgui/preprocesswb.cc b/rtgui/preprocesswb.cc new file mode 100644 index 000000000..170371318 --- /dev/null +++ b/rtgui/preprocesswb.cc @@ -0,0 +1,97 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2020 Alberto Romei + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include + +#include "preprocesswb.h" +#include "eventmapper.h" + +#include "guiutils.h" +#include "options.h" + +#include "../rtengine/procparams.h" + +using namespace rtengine; +using namespace rtengine::procparams; + +PreprocessWB::PreprocessWB() : + FoldableToolPanel(this, "preprocesswb", M("TP_PREPROCWB_LABEL")), + evPreprocessWBMode(ProcEventMapper::getInstance()->newEvent(FIRST, "HISTORY_MSG_PREPROCWB_MODE")), + mode(Gtk::manage(new MyComboBoxText())) +{ + Gtk::HBox *hb = Gtk::manage(new Gtk::HBox()); + hb->pack_start(*Gtk::manage(new Gtk::Label(M("TP_PREPROCWB_MODE") + ": ")), Gtk::PACK_SHRINK, 0); + + mode->append(M("TP_PREPROCWB_MODE_CAMERA")); + mode->append(M("TP_PREPROCWB_MODE_AUTO")); + + hb->pack_start(*mode); + + mode->set_active(0); + mode->signal_changed().connect(sigc::mem_fun(*this, &PreprocessWB::modeChanged)); + + mode->show(); + + pack_start(*hb, Gtk::PACK_SHRINK, 4); +} + +void PreprocessWB::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited) +{ + disableListener(); + + mode->set_active(int(pp->raw.preprocessWB.mode)); + + enableListener(); +} + +void PreprocessWB::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited) +{ + if (mode->get_active_row_number() != 2) { + pp->raw.preprocessWB.mode = RAWParams::PreprocessWB::Mode(mode->get_active_row_number()); + } + + if (pedited) { + pedited->raw.preprocessWB.mode = mode->get_active_row_number() != 2; // UNCHANGED entry, see setBatchMode + } + +} + +void PreprocessWB::setBatchMode(bool batchMode) +{ + ToolPanel::setBatchMode(batchMode); + + if (batchMode) { + mode->append(M("GENERAL_UNCHANGED")); + mode->set_active_text(M("GENERAL_UNCHANGED")); + } +} + +void PreprocessWB::setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited) +{ +} + +void PreprocessWB::trimValues(rtengine::procparams::ProcParams* pp) +{ +} + +void PreprocessWB::modeChanged() +{ + if (listener) { + listener->panelChanged(evPreprocessWBMode, mode->get_active_text()); + } +} diff --git a/rtgui/preprocesswb.h b/rtgui/preprocesswb.h new file mode 100644 index 000000000..343d2e9e9 --- /dev/null +++ b/rtgui/preprocesswb.h @@ -0,0 +1,47 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2020 Alberto Romei + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#pragma once + +#include + +#include "adjuster.h" +#include "toolpanel.h" + +class PreprocessWB final: + public ToolParamBlock, + public FoldableToolPanel +{ + +private: + const rtengine::ProcEvent evPreprocessWBMode; + + MyComboBoxText* mode; + +public: + + PreprocessWB(); + + void read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override; + void write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override; + void setBatchMode(bool batchMode) override; + void setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override; + void setAdjusterBehavior(bool add); + void trimValues(rtengine::procparams::ProcParams* pp) override; + void modeChanged(); +}; diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 013d36d13..8b02355b8 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -94,6 +94,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), favorit flatfield = Gtk::manage(new FlatField()); rawcacorrection = Gtk::manage(new RAWCACorr()); rawexposure = Gtk::manage(new RAWExposure()); + preprocessWB = Gtk::manage (new PreprocessWB ()); bayerrawexposure = Gtk::manage(new BayerRAWExposure()); xtransrawexposure = Gtk::manage(new XTransRAWExposure()); fattal = Gtk::manage(new FattalToneMapping()); @@ -159,6 +160,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), favorit addfavoritePanel (sensorxtrans->getPackBox(), xtransprocess, 2); addfavoritePanel (sensorxtrans->getPackBox(), xtransrawexposure, 2); addfavoritePanel (rawPanel, rawexposure); + addfavoritePanel (rawPanel, preprocessWB); addfavoritePanel (rawPanel, preprocess); addfavoritePanel (rawPanel, darkframe); addfavoritePanel (rawPanel, flatfield); @@ -399,6 +401,7 @@ void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtr sensorxtrans->FoldableToolPanel::hide(); xtransprocess->FoldableToolPanel::hide(); xtransrawexposure->FoldableToolPanel::hide(); + preprocessWB->FoldableToolPanel::hide(); preprocess->FoldableToolPanel::hide(); flatfield->FoldableToolPanel::show(); filmNegative->FoldableToolPanel::hide(); @@ -419,6 +422,7 @@ void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtr sensorxtrans->FoldableToolPanel::hide(); xtransprocess->FoldableToolPanel::hide(); xtransrawexposure->FoldableToolPanel::hide(); + preprocessWB->FoldableToolPanel::hide(); preprocess->FoldableToolPanel::hide(); flatfield->FoldableToolPanel::hide(); filmNegative->FoldableToolPanel::hide(); @@ -440,6 +444,7 @@ void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtr sensorxtrans->FoldableToolPanel::hide(); xtransprocess->FoldableToolPanel::hide(); xtransrawexposure->FoldableToolPanel::hide(); + preprocessWB->FoldableToolPanel::hide(); preprocess->FoldableToolPanel::hide(); flatfield->FoldableToolPanel::hide(); filmNegative->FoldableToolPanel::hide(); diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 190da818b..b8b6ee783 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -60,6 +60,7 @@ #include "perspective.h" #include "pparamschangelistener.h" #include "preprocess.h" +#include "preprocesswb.h" #include "profilechangelistener.h" #include "prsharpening.h" #include "rawcacorrection.h" @@ -157,6 +158,7 @@ protected: FlatField* flatfield; RAWCACorr* rawcacorrection; RAWExposure* rawexposure; + PreprocessWB* preprocessWB; BayerRAWExposure* bayerrawexposure; XTransRAWExposure* xtransrawexposure; FattalToneMapping *fattal;