src/EditRecipeTab1.cpp

changeset 395
7212b980a527
parent 361
ec8de79f6ff6
child 397
877420a13815
--- a/src/EditRecipeTab1.cpp	Thu Aug 11 10:50:18 2022 +0200
+++ b/src/EditRecipeTab1.cpp	Wed Aug 17 14:30:33 2022 +0200
@@ -18,6 +18,36 @@
  */
 
 
+void EditRecipe::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 = recipe->st_ibu_min / ((recipe->st_og_min - 1) * 1000);
+    double bugu_max = recipe->st_ibu_max / ((recipe->st_og_max - 1) * 1000);
+    ui->est_buguShow->setRange(bugu_min, bugu_max);
+
+    double fg_min = recipe->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(recipe->st_og_min) + Utils::sg_to_plato(recipe->st_og_max)) / 2)) +
+                (0.8192 * ((Utils::sg_to_plato(fg_min) + Utils::sg_to_plato(recipe->st_fg_max)) / 2)));
+
+    /* BU:RE */
+    double bure_min = recipe->st_ibu_min / re;
+    double bure_max = recipe->st_ibu_max / re;
+    ui->est_bufguShow->setRange(bure_min, bure_max);
+
+    qDebug() << "BU:RE" << bure_min << bure_max;
+}
+
 
 void EditRecipe::name_changed(QString name)
 {
@@ -82,6 +112,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();
 }
 

mercurial