Merge with 'Beep6581/dev'

This commit is contained in:
Pandagrapher
2023-08-12 18:03:41 +02:00
132 changed files with 8909 additions and 3413 deletions

View File

@@ -243,6 +243,9 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
auto m = ProcEventMapper::getInstance();
EvWBObserver10 = m->newEvent(ALLNORAW, "HISTORY_MSG_WBALANCE_OBSERVER10");
EvWBitcwbprim = m->newEvent(ALLNORAW, "HISTORY_MSG_WBITC_PRIM");
EvWBitcwbalg = m->newEvent(ALLNORAW, "HISTORY_MSG_WBITC_OBS");
EvWBitcwgreen = m->newEvent(ALLNORAW, "HISTORY_MSG_WBITC_GREEN");
resetButton = Gtk::manage (new Gtk::Button()); // No label, keep it short
setExpandAlignProperties(resetButton, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
@@ -328,6 +331,10 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
StudLabel = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
StudLabel->set_tooltip_text(M("TP_WBALANCE_STUDLABEL_TOOLTIP"));
PatchLabel = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
PatchLabel->set_tooltip_text(M("TP_WBALANCE_PATCHLABEL_TOOLTIP"));
PatchlevelLabel = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
PatchlevelLabel->set_tooltip_text(M("TP_WBALANCE_PATCHLEVELLABEL_TOOLTIP"));
mulLabel = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
mulLabel->set_tooltip_text(M("TP_WBALANCE_MULLABEL_TOOLTIP"));
@@ -336,7 +343,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
temp = Gtk::manage (new Adjuster (M("TP_WBALANCE_TEMPERATURE"), MINTEMP, MAXTEMP, 5, CENTERTEMP, itempL, itempR, &wbSlider2Temp, &wbTemp2Slider));
green = Gtk::manage (new Adjuster (M("TP_WBALANCE_GREEN"), MINGREEN, MAXGREEN, 0.001, 1.0, igreenL, igreenR));
equal = Gtk::manage (new Adjuster (M("TP_WBALANCE_EQBLUERED"), MINEQUAL, MAXEQUAL, 0.001, 1.0, iblueredL, iblueredR));
tempBias = Gtk::manage (new Adjuster(M("TP_WBALANCE_TEMPBIAS"), -0.5, 0.5, 0.01, 0.0, itempbiasL, itempbiasR));
tempBias = Gtk::manage (new Adjuster(M("TP_WBALANCE_TEMPBIAS"), -1.1, 1.1, 0.005, 0.0, itempbiasL, itempbiasR));
observer10 = Gtk::manage(new CheckBox(M("TP_WBALANCE_OBSERVER10"), multiImage));
cache_customTemp (0);
@@ -351,6 +358,32 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
tempBias->show ();
observer10->show();
itcwbFrame = Gtk::manage(new Gtk::Frame(M("TP_WBALANCE_ITCWB_FRA")));
itcwbFrame->set_label_align(0.025, 0.5);
itcwbFrame->set_tooltip_markup (M("PREFERENCES_WBACORR_TOOLTIP"));
ToolParamBlock* const itcwbBox = Gtk::manage(new ToolParamBlock());
itcwb_green = Gtk::manage (new Adjuster (M("TP_WBALANCE_ITCWGREEN"), -0.35, 0.35, 0.005, 0.));
itcwb_green ->set_tooltip_markup (M("TP_WBALANCE_ITCWGREEN_TOOLTIP"));
itcwb_alg = Gtk::manage (new Gtk::CheckButton (M("TP_WBALANCE_ITCWB_ALG")));
itcwb_alg ->set_tooltip_markup (M("TP_WBALANCE_ITCWALG_TOOLTIP"));
itcwb_alg ->set_active (false);
itcwb_prim = Gtk::manage (new MyComboBoxText ());
itcwb_prim->append(M("TP_WBALANCE_ITCWB_PRIM_SRGB"));
itcwb_prim->append(M("TP_WBALANCE_ITCWB_PRIM_BETA"));
itcwb_prim->append(M("TP_WBALANCE_ITCWB_PRIM_XYZCAM"));
itcwb_prim->append(M("TP_WBALANCE_ITCWB_PRIM_JDCMAX"));
itcwb_prim->set_active(1);
itcwb_primconn = itcwb_prim->signal_changed().connect(sigc::mem_fun(*this, &WhiteBalance::itcwb_prim_changed));
itcwb_prim ->set_tooltip_markup (M("TP_WBALANCE_ITCWPRIM_TOOLTIP"));
/* Gtk::Box* boxgreen = Gtk::manage (new Gtk::Box ());
boxgreen->show ();
@@ -359,6 +392,8 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
boxgreen->pack_start(*igreenR);*/
pack_start(*mulLabel);
pack_start(*StudLabel);
pack_start(*PatchLabel);
pack_start(*PatchlevelLabel);
pack_start (*temp);
//pack_start (*boxgreen);
@@ -368,14 +403,33 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, TOOL_NAME, M("TP_WBALANC
pack_start(*observer10);
itcwbBox->pack_start (*itcwb_green);
itcwbBox->pack_start (*itcwb_alg);
itcwbBox->pack_start (*itcwb_prim);
itcwbFrame->add(*itcwbBox);
pack_start(*itcwbFrame);
if(options.rtSettings.itcwb_enable) {
itcwb_green->show();
itcwb_alg->show();
itcwb_prim->show();
itcwbFrame->show();
} else {
itcwb_green->show();
itcwb_alg->hide();
itcwb_prim->hide();
}
temp->setAdjusterListener (this);
green->setAdjusterListener (this);
equal->setAdjusterListener (this);
tempBias->setAdjusterListener (this);
observer10->setCheckBoxListener(this);
itcwb_green->setAdjusterListener (this);
spotbutton->signal_pressed().connect( sigc::mem_fun(*this, &WhiteBalance::spotPressed) );
methconn = method->signal_changed().connect( sigc::mem_fun(*this, &WhiteBalance::optChanged) );
itcwb_algconn = itcwb_alg->signal_toggled().connect( sigc::mem_fun(*this, &WhiteBalance::itcwb_alg_toggled) );
resetButton->signal_pressed().connect( sigc::mem_fun(*this, &WhiteBalance::resetWB) );
spotsize->signal_changed().connect( sigc::mem_fun(*this, &WhiteBalance::spotSizeChanged) );
}
@@ -397,9 +451,36 @@ void WhiteBalance::enabledChanged()
}
}
}
void WhiteBalance::itcwb_prim_changed ()
{
if (listener && getEnabled()) {
listener->panelChanged(EvWBitcwbprim, M("GENERAL_ENABLED"));
}
}
void WhiteBalance::itcwb_alg_toggled ()
{
if (batchMode) {
if (itcwb_alg->get_inconsistent()) {
itcwb_alg->set_inconsistent (false);
itcwb_algconn.block (true);
itcwb_alg->set_active (false);
itcwb_algconn.block (false);
} else if (lastitcwb_alg) {
itcwb_alg->set_inconsistent (true);
}
lastitcwb_alg = itcwb_alg->get_active ();
}
if (listener && getEnabled()) {
if (itcwb_alg->get_active ()) {
listener->panelChanged (EvWBitcwbalg, M("GENERAL_ENABLED"));
} else {
listener->panelChanged (EvWBitcwbalg, M("GENERAL_DISABLED"));
}
}
}
void WhiteBalance::adjusterChanged(Adjuster* a, double newval)
{
@@ -423,6 +504,7 @@ void WhiteBalance::adjusterChanged(Adjuster* a, double newval)
(
a == equal
|| a == tempBias
|| a == itcwb_green
)
&& ppMethod.second.type == WBEntry::Type::AUTO
)
@@ -453,12 +535,16 @@ void WhiteBalance::adjusterChanged(Adjuster* a, double newval)
if (listener && getEnabled()) {
if (a == temp) {
listener->panelChanged (EvWBTemp, Glib::ustring::format ((int)a->getValue()));
itcwbFrame->set_sensitive(false);
} else if (a == green) {
listener->panelChanged (EvWBGreen, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue()));
itcwbFrame->set_sensitive(false);
} else if (a == equal) {
listener->panelChanged (EvWBequal, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue()));
} else if (a == tempBias) {
listener->panelChanged (EvWBtempBias, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(2), a->getValue()));
} else if (a == itcwb_green) {
listener->panelChanged (EvWBitcwgreen, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(2), a->getValue()));
}
}
}
@@ -493,6 +579,7 @@ void WhiteBalance::checkBoxToggled(CheckBox* c, CheckValue newval)
}
}
void WhiteBalance::optChanged ()
{
Gtk::TreeModel::Row row = getActiveMethod();
@@ -510,6 +597,8 @@ void WhiteBalance::optChanged ()
}
StudLabel->hide();
mulLabel->show();
PatchLabel->hide();
PatchlevelLabel->hide();
if (opt != row[methodColumns.colId]) {
@@ -529,8 +618,16 @@ void WhiteBalance::optChanged ()
bool autit = (currMethod.ppLabel == "autitcgreen");
if (autit) {
StudLabel->show();
PatchLabel->show();
PatchlevelLabel->show();
equal->hide();
itcwbFrame->set_sensitive(true);
} else {
StudLabel->hide();
PatchLabel->hide();
PatchlevelLabel->hide();
equal->show();
itcwbFrame->set_sensitive(false);
}
switch (currMethod.type) {
@@ -624,6 +721,8 @@ void WhiteBalance::spotPressed ()
{
StudLabel->hide();
mulLabel->show();
PatchLabel->hide();
PatchlevelLabel->hide();
if (wblistener) {
wblistener->spotWBRequested (getSize());
@@ -649,6 +748,41 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited)
tempBias->setValue (pp->wb.tempBias);
tempBias->set_sensitive(true);
itcwb_algconn.block (true);
itcwb_alg->set_active (pp->wb.itcwb_alg);
itcwb_algconn.block (false);
lastitcwb_alg = pp->wb.itcwb_alg;
itcwb_green->setValue (pp->wb.itcwb_green);
itcwb_primconn.block (true);
if (pp->wb.itcwb_prim == "srgb") {
itcwb_prim->set_active(0);
} else if (pp->wb.itcwb_prim == "beta") {
itcwb_prim->set_active(1);
} else if (pp->wb.itcwb_prim == "XYZcam") {
itcwb_prim->set_active(2);
} else if (pp->wb.itcwb_prim == "jdcmax") {
itcwb_prim->set_active(3);
}
itcwb_primconn.block (false);
if(options.rtSettings.itcwb_enable) {
itcwb_green->show();
itcwb_alg->show();
itcwb_prim->show();
itcwbFrame->show();
} else {
itcwb_green->hide();
itcwb_alg->hide();
itcwb_prim->hide();
itcwbFrame->hide();
}
if (pedited) {
// By default, temperature and green are said "UnEdited", but it may change later
temp->setEditedState (UnEdited);
@@ -656,6 +790,8 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited)
equal->setEditedState (pedited->wb.equal ? Edited : UnEdited);
tempBias->setEditedState (pedited->wb.tempBias ? Edited : UnEdited);
observer10->setEdited(pedited->wb.observer);
itcwb_alg->set_inconsistent (!pedited->wb.itcwb_alg);
itcwb_green->setEditedState (pedited->wb.itcwb_green ? Edited : UnEdited);
}
if (pedited && !pedited->wb.method) {
@@ -766,9 +902,21 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited)
bool autit = (wbValues.ppLabel == "autitcgreen");
if (autit) {
StudLabel->show();
PatchLabel->show();
PatchlevelLabel->show();
equal->hide();
if(pp->wb.itcwb_sampling) {
tempBias->set_sensitive(false);
}
itcwbFrame->set_sensitive(!pp->wb.itcwb_sampling);
itcwb_prim_changed ();
} else {
StudLabel->hide();
PatchLabel->hide();
PatchlevelLabel->hide();
mulLabel->show();
equal->show();
itcwbFrame->set_sensitive(false);
}
}
@@ -794,16 +942,32 @@ void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited)
pedited->wb.equal = equal->getEditedState ();
pedited->wb.tempBias = tempBias->getEditedState ();
pedited->wb.observer = observer10->getEdited();
pedited->wb.itcwb_alg = !itcwb_alg->get_inconsistent();
pedited->wb.method = row[methodColumns.colLabel] != M("GENERAL_UNCHANGED");
pedited->wb.enabled = !get_inconsistent();
pedited->wb.itcwb_prim = itcwb_prim->get_active_text() != M("GENERAL_UNCHANGED");
pedited->wb.itcwb_green = itcwb_green->getEditedState ();
}
pp->wb.enabled = getEnabled();
if (itcwb_prim->get_active_row_number() == 0) {
pp->wb.itcwb_prim = "srgb";
} else if (itcwb_prim->get_active_row_number() == 1){
pp->wb.itcwb_prim = "beta";
} else if (itcwb_prim->get_active_row_number() == 2){
pp->wb.itcwb_prim = "XYZcam";
} else if (itcwb_prim->get_active_row_number() == 3){
pp->wb.itcwb_prim = "jdcmax";
}
const std::pair<bool, const WBEntry&> ppMethod = findWBEntry (row[methodColumns.colLabel], WBLT_GUI);
if (ppMethod.first) {
pp->wb.method = ppMethod.second.ppLabel;
if (pp->wb.method != "autitcgreen") {
// Prepare migration to new ITCWB algorithm.
pp->wb.itcwb_sampling = false;
}
}
pp->wb.temperature = temp->getIntValue ();
@@ -815,7 +979,9 @@ void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited)
: observer10->getValue() == CheckValue::off
? rtengine::StandardObserver::TWO_DEGREES
: pp->wb.observer;
pp->wb.itcwb_alg = itcwb_alg->get_active ();
pp->wb.tempBias = tempBias->getValue ();
pp->wb.itcwb_green = itcwb_green->getValue ();
}
void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited)
@@ -823,6 +989,7 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited*
equal->setDefault (defParams->wb.equal);
tempBias->setDefault (defParams->wb.tempBias);
itcwb_green->setDefault (defParams->wb.itcwb_green);
if (wbp && defParams->wb.method == "Camera") {
double ctemp;
@@ -845,11 +1012,13 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited*
green->setDefaultEditedState (pedited->wb.green ? Edited : UnEdited);
equal->setDefaultEditedState (pedited->wb.equal ? Edited : UnEdited);
tempBias->setDefaultEditedState (pedited->wb.tempBias ? Edited : UnEdited);
itcwb_green->setDefaultEditedState (pedited->wb.itcwb_green ? Edited : UnEdited);
} else {
temp->setDefaultEditedState (Irrelevant);
green->setDefaultEditedState (Irrelevant);
equal->setDefaultEditedState (Irrelevant);
tempBias->setDefaultEditedState (Irrelevant);
itcwb_green->setDefaultEditedState (Irrelevant);
}
}
@@ -1001,24 +1170,63 @@ inline Gtk::TreeRow WhiteBalance::getActiveMethod ()
return *(method->get_active());
}
void WhiteBalance::WBChanged(double temperature, double greenVal, double rw, double gw, double bw, float studgood)
void WhiteBalance::WBChanged(int met, double temperature, double greenVal, double rw, double gw, double bw, float temp0, float delta, int bia, int dread, float studgood, float minchrom, int kmin, float histmin, float histmax)
{
idle_register.add(
[this, temperature, greenVal, rw, gw, bw, studgood]() -> bool
[this, met, temperature, greenVal, rw, gw, bw, temp0, delta, bia, dread, studgood, minchrom, kmin, histmin, histmax]() -> bool
{
disableListener();
temp->setValue(temperature);
green->setValue(greenVal);
double stud;
stud = studgood;
if(studgood < 0.0001) {
stud = 0.0001;
}
int bia2 = bia;
mulLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_MULLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(4), rw),
Glib::ustring::format(std::fixed, std::setprecision(2), gw),
Glib::ustring::format(std::fixed, std::setprecision(4), bw))
);
StudLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_STUDLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(4), studgood))
if(bia == 3) {
bia2 = bia - 1;
StudLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_STUDLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(4), stud),
Glib::ustring::format(std::fixed, std::setprecision(0), bia2),
Glib::ustring::format(std::fixed, std::setprecision(0), temp0))
);
} else if(bia == 2) {
StudLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_STUDLABEL1"),
Glib::ustring::format(std::fixed, std::setprecision(4), stud),
Glib::ustring::format(std::fixed, std::setprecision(0), bia),
Glib::ustring::format(std::fixed, std::setprecision(0), temp0))
);
} else {
StudLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_STUDLABEL0"),
Glib::ustring::format(std::fixed, std::setprecision(4), stud),
Glib::ustring::format(std::fixed, std::setprecision(0), bia),
Glib::ustring::format(std::fixed, std::setprecision(0), temp0))
);
}
PatchLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_PATCHLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(0), dread),
Glib::ustring::format(std::fixed, std::setprecision(4), minchrom),
Glib::ustring::format(std::fixed, std::setprecision(0), kmin))
);
PatchlevelLabel->set_text(
Glib::ustring::compose(M("TP_WBALANCE_PATCHLEVELLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(4), delta),
Glib::ustring::format(std::fixed, std::setprecision(0), histmin),
Glib::ustring::format(std::fixed, std::setprecision(0), histmax))
);
temp->setDefault(temperature);
green->setDefault(greenVal);
enableListener();