diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 83e4ce40f..bcdf762b6 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -87,7 +87,7 @@ ImProcCoordinator::ImProcCoordinator () fw(0), fh(0), tr(0), fullw(1), fullh(1), pW(-1), pH(-1), - plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr), + plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(nullptr), awbListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr), resultValid(false), lastOutputProfile("BADFOOD"), lastOutputIntent(RI__COUNT), lastOutputBPC(false), thread(nullptr), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false), wavcontlutili(false), butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), conversionBuffer(1, 1), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f) {} @@ -307,6 +307,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.wb.temperature = currWB.getTemp (); params.wb.green = currWB.getGreen (); + if(params.wb.method == "Auto" && awbListener) { + awbListener->WBChanged(params.wb.temperature, params.wb.green); + } int tr = getCoarseBitMask(params.coarse); diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 80ad0dd99..bf1e28aaa 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -157,6 +157,8 @@ protected: AutoExpListener* aeListener; AutoCamListener* acListener; AutoBWListener* abwListener; + AutoWBListener* awbListener; + AutoColorTonListener* actListener; AutoChromaListener* adnListener; WaveletListener* awavListener; @@ -312,6 +314,10 @@ public: { abwListener = abw; } + void setAutoWBListener (AutoWBListener* awb) + { + awbListener = awb; + } void setAutoColorTonListener (AutoColorTonListener* bwct) { actListener = bwct; diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index ef3a1be70..fc793dd71 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -310,6 +310,13 @@ public : }; +class AutoWBListener +{ +public : + virtual ~AutoWBListener() = default; + virtual void WBChanged(double temp, double green) = 0; +}; + class WaveletListener { public : @@ -411,6 +418,7 @@ public: virtual void setPreviewImageListener (PreviewImageListener* l) = 0; virtual void setAutoCamListener (AutoCamListener* l) = 0; virtual void setAutoBWListener (AutoBWListener* l) = 0; + virtual void setAutoWBListener (AutoWBListener* l) = 0; virtual void setAutoColorTonListener (AutoColorTonListener* l) = 0; virtual void setAutoChromaListener (AutoChromaListener* l) = 0; virtual void setRetinexListener (RetinexListener* l) = 0; diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 98dc311f8..71281abd3 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -488,6 +488,7 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool ipc->setAutoExpListener (toneCurve); ipc->setAutoCamListener (colorappearance); ipc->setAutoBWListener (blackwhite); + ipc->setAutoWBListener (whitebalance); ipc->setAutoColorTonListener (colortoning); ipc->setAutoChromaListener (dirpyrdenoise); ipc->setWaveletListener (wavelet); diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index 6b510c471..d4390046e 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -390,26 +390,7 @@ void WhiteBalance::adjusterChanged (Adjuster* a, double newval) cache_customTempBias (tempBiasVal); } - if (a == equal || a == tempBias) { - // Recomputing AutoWB if it's the current method - if (wbp && ppMethod->type == WBT_AUTO) { - double ctemp = -1.0; - double cgreen = -1.0; - wbp->getAutoWB (ctemp, cgreen, eVal, tempBiasVal); - - if (ctemp != -1.0) { - // Set the automatics temperature value only if in SET mode - if (temp->getEditedState() && !temp->getAddMode() ) { - temp->setValue (ctemp); - } - - // Set the automatics green value only if in SET mode - if (green->getEditedState() && !green->getAddMode()) { - green->setValue (cgreen); - } - } - } - } + // Recomputing AutoWB if it's the current method will happen in improccoordinator.cc if (listener) { if (a == temp) { @@ -481,15 +462,7 @@ void WhiteBalance::optChanged () // equal remain as is } - if (!batchMode || equal->getEditedState() || tempBias->getEditedState()) { - double ctemp, cgreen; - wbp->getAutoWB (ctemp, cgreen, equal->getValue(), tempBias->getValue()); - - if (ctemp != -1.0) { - temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp); - green->setValue (green->getAddMode() ? 0.0 : cgreen); - } - } + // Recomputing AutoWB will happen in improccoordinator.cc } break; @@ -650,32 +623,7 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) green->setValue (0.0); } - // then check for the correct ones, if possible - if (wbp) { - double ctemp = -1.0; - double cgreen = -1.0; - wbp->getAutoWB (ctemp, cgreen, pp->wb.equal, pp->wb.tempBias); - - if (ctemp != -1.0) { - // Set the automatics temperature if in SET mode - if (!pedited || (pedited->wb.temperature && !temp->getAddMode()) ) { - temp->setValue (ctemp); - - if (pedited) { - temp->setEditedState (Edited); - } - } - - // Set the automatics green value if in SET mode - if (!pedited || (pedited->wb.green && !green->getAddMode())) { - green->setValue (cgreen); - - if (pedited) { - green->setEditedState (Edited); - } - } - } - } + // Recomputing AutoWB will happen in improccoordinator.cc break; @@ -755,25 +703,11 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited* temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp); green->setDefault (green->getAddMode() ? 0 : cgreen); } - } else if (wbp && defParams->wb.method == "Auto") { - // this setDefaults method is called too early ; the wbp has been set, - // but wbp is not ready to provide! - double ctemp; - double cgreen; - wbp->getAutoWB (ctemp, cgreen, defParams->wb.equal, defParams->wb.tempBias); - - if (ctemp != -1.0) { - temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp); - green->setDefault (green->getAddMode() ? 0 : cgreen); - } else { - // 6504 & 1.0 = same values as in ProcParams::setDefaults - temp->setDefault (temp->getAddMode() ? 0 : 6504); - green->setDefault (green->getAddMode() ? 0 : 1.0); - } } else { temp->setDefault (defParams->wb.temperature); green->setDefault (defParams->wb.green); } + // Recomputing AutoWB if it's the current method will happen in improccoordinator.cc if (pedited) { temp->setDefaultEditedState (pedited->wb.temperature ? Edited : UnEdited); @@ -934,3 +868,14 @@ inline Gtk::TreeRow WhiteBalance::getActiveMethod () { return *(method->get_active()); } + +void WhiteBalance::WBChanged(double temperature, double greenVal) +{ + GThreadLock lock; + disableListener(); + temp->setValue(temperature); + green->setValue(greenVal); + temp->setDefault(temperature); + green->setDefault(greenVal); + enableListener(); +} diff --git a/rtgui/whitebalance.h b/rtgui/whitebalance.h index a0d961612..fb3a443a1 100644 --- a/rtgui/whitebalance.h +++ b/rtgui/whitebalance.h @@ -34,7 +34,7 @@ public: virtual void spotWBRequested (int size) {} }; -class WhiteBalance : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel +class WhiteBalance : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::AutoWBListener { enum WB_LabelType { @@ -117,6 +117,7 @@ public: wblistener = l; } void setWB (int temp, double green); + void WBChanged (double temp, double green); void setAdjusterBehavior (bool tempadd, bool greenadd, bool equaladd, bool tempbiasadd); void trimValues (rtengine::procparams::ProcParams* pp);