--- a/src/EditProductTab1.cpp Thu Aug 11 10:50:18 2022 +0200 +++ b/src/EditProductTab1.cpp Wed Aug 17 14:30:33 2022 +0200 @@ -18,6 +18,37 @@ */ +void EditProduct::calcStyle() +{ + /* + * https://www.homebrewersassociation.org/forum/index.php?topic=10548.0 + * + * Calculate the ideal BU:GU and BU:RE ranges. These values + * will be used in the RangedSliders. + */ + double bugu_min = product->st_ibu_min / ((product->st_og_min - 1) * 1000); + double bugu_max = product->st_ibu_max / ((product->st_og_max - 1) * 1000); + ui->est_buguShow->setRange(bugu_min, bugu_max); + + double fg_min = product->st_fg_min; + if (fg_min < 1.002) /* Use 1.002 fg as lowest minimal value */ + fg_min = 1.002; + + /* + * Real Extract (RE) + */ + double re = ((0.1808 * ((Utils::sg_to_plato(product->st_og_min) + Utils::sg_to_plato(product->st_og_max)) / 2)) + + (0.8192 * ((Utils::sg_to_plato(fg_min) + Utils::sg_to_plato(product->st_fg_max)) / 2))); + + /* BU:RE */ + double bure_min = product->st_ibu_min / re; + double bure_max = product->st_ibu_max / re; + ui->est_bufguShow->setRange(bure_min, bure_max); + + qDebug() << "BU:RE" << bure_min << bure_max; +} + + void EditProduct::code_changed(QString code) { product->code = code; @@ -88,6 +119,7 @@ ui->est_carbShow->setRange(query.value(15).toDouble(), query.value(16).toDouble()); ui->est_abvShow->setRange(query.value(17).toDouble(), query.value(18).toDouble()); + calcStyle(); is_changed(); }