Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.

Sat, 16 Apr 2022 14:44:50 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 16 Apr 2022 14:44:50 +0200
changeset 137
ffe8b2e9517b
parent 136
17030224d919
child 138
1189d072f346

Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.

src/EditRecipe.h file | annotate | diff | comparison | revisions
src/EditRecipeTab4.cpp file | annotate | diff | comparison | revisions
src/EditRecipeTab7.cpp file | annotate | diff | comparison | revisions
ui/EditRecipe.ui file | annotate | diff | comparison | revisions
--- a/src/EditRecipe.h	Sat Apr 16 13:05:47 2022 +0200
+++ b/src/EditRecipe.h	Sat Apr 16 14:44:50 2022 +0200
@@ -365,6 +365,8 @@
     double ProtonDeficit(double pHZ);
     double MashpH();
     void calcWater();
+    double GetBUGU();
+    double GetOptSO4Clratio();
 };
 
 #endif
--- a/src/EditRecipeTab4.cpp	Sat Apr 16 13:05:47 2022 +0200
+++ b/src/EditRecipeTab4.cpp	Sat Apr 16 14:44:50 2022 +0200
@@ -178,6 +178,7 @@
 {
     QTableWidgetItem *item;
 
+    val = round(val * 100.0) / 100.0;
     if (val == 0) {
 	/*
 	 * Remove this salt if it is in the table.
@@ -247,6 +248,7 @@
     if (this->ignoreChanges)
 	return;
 
+    val = round(val * 100.0) / 100.0;
     qDebug() << "set_brewing_salt" << salt << val;
     brewing_salt_sub(salt, val);
     calcWater();
--- a/src/EditRecipeTab7.cpp	Sat Apr 16 13:05:47 2022 +0200
+++ b/src/EditRecipeTab7.cpp	Sat Apr 16 14:44:50 2022 +0200
@@ -319,6 +319,45 @@
 	chloride = wg_chloride + RA;
     }
 
+    double BUGU = GetBUGU();
+    ui->buguEdit->setValue(BUGU);
+    if (BUGU < 0.32)
+	ui->buguResult->setText(tr("Very malty and sweet"));
+    else if (BUGU < 0.43)
+	ui->buguResult->setText(tr("Malty, sweet"));
+    else if (BUGU < 0.52)
+	ui->buguResult->setText(tr("Balanced"));
+    else if (BUGU < 0.63)
+	ui->buguResult->setText(tr("Hoppy, bitter"));
+    else
+	ui->buguResult->setText(tr("Very hoppy, very bitter"));
+
+    double OptSO4Clratio = GetOptSO4Clratio();
+    ui->so4clEdit->setValue(OptSO4Clratio);
+    ui->cur_so4clResult->setRange(0.7 * OptSO4Clratio, 1.3 * OptSO4Clratio);
+    if (OptSO4Clratio < 0.4)
+	ui->so4clResult->setText(tr("Too malty"));
+    else if (OptSO4Clratio < 0.6)
+	ui->so4clResult->setText(tr("Very malty"));
+    else if (OptSO4Clratio < 0.8)
+	ui->so4clResult->setText(tr("Malty"));
+    else if (OptSO4Clratio < 1.5)
+	ui->so4clResult->setText(tr("Balanced"));
+    else if (OptSO4Clratio < 2.0)
+	ui->so4clResult->setText(tr("Little bitter"));
+    else if (OptSO4Clratio < 4.0)
+	ui->so4clResult->setText(tr("Bitter"));
+    else if (OptSO4Clratio < 9.0)
+	ui->so4clResult->setText(tr("Very bitter"));
+    else
+	ui->so4clResult->setText(tr("Too bitter"));
+    if (chloride > 0)
+	RA = sulfate / chloride;
+    else
+	RA = 10;
+    ui->cur_so4clEdit->setValue(RA);
+    ui->cur_so4clResult->setValue(RA);
+
     ui->wb_caEdit->setValue(calcium);
     ui->wb_mgEdit->setValue(magnesium);
     ui->wb_hco3Edit->setValue(bicarbonate);
@@ -351,6 +390,26 @@
 }
 
 
+double EditRecipe::GetBUGU()
+{
+    double gu = (recipe->est_og - 1) * 1000;
+    if (gu > 0)
+	return recipe->est_ibu / gu;
+    return 0.5;
+}
+
+
+double EditRecipe::GetOptSO4Clratio()
+{
+    if (ui->wt_so4Edit->value() > 0 && ui->wt_clEdit->value()) {
+	/* If target water is selected .. */
+	return (ui->wt_so4Edit->value() / ui->wt_clEdit->value());
+    }
+    double BUGU = GetBUGU();
+    return (-1.2 * BUGU + 1.4);
+}
+
+
 void EditRecipe::on_calc_acid_clicked()
 {
     recipe->calc_acid = ! recipe->calc_acid;
--- a/ui/EditRecipe.ui	Sat Apr 16 13:05:47 2022 +0200
+++ b/ui/EditRecipe.ui	Sat Apr 16 14:44:50 2022 +0200
@@ -4064,6 +4064,199 @@
          </property>
         </widget>
        </widget>
+       <widget class="QLabel" name="buguLabel">
+        <property name="geometry">
+         <rect>
+          <x>310</x>
+          <y>340</y>
+          <width>161</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Bitterness index:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QDoubleSpinBox" name="buguEdit">
+        <property name="geometry">
+         <rect>
+          <x>480</x>
+          <y>340</y>
+          <width>71</width>
+          <height>24</height>
+         </rect>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+        <property name="buttonSymbols">
+         <enum>QAbstractSpinBox::NoButtons</enum>
+        </property>
+        <property name="accelerated">
+         <bool>false</bool>
+        </property>
+        <property name="decimals">
+         <number>2</number>
+        </property>
+        <property name="maximum">
+         <double>1000.000000000000000</double>
+        </property>
+        <property name="singleStep">
+         <double>0.100000000000000</double>
+        </property>
+       </widget>
+       <widget class="QLabel" name="buguResult">
+        <property name="geometry">
+         <rect>
+          <x>560</x>
+          <y>340</y>
+          <width>211</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="font">
+         <font>
+          <italic>true</italic>
+         </font>
+        </property>
+        <property name="text">
+         <string>N/A</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QLabel" name="so4clLabel">
+        <property name="geometry">
+         <rect>
+          <x>310</x>
+          <y>370</y>
+          <width>161</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Preffered SO4:Cl ratio:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QDoubleSpinBox" name="so4clEdit">
+        <property name="geometry">
+         <rect>
+          <x>480</x>
+          <y>370</y>
+          <width>71</width>
+          <height>24</height>
+         </rect>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+        <property name="buttonSymbols">
+         <enum>QAbstractSpinBox::NoButtons</enum>
+        </property>
+        <property name="accelerated">
+         <bool>false</bool>
+        </property>
+        <property name="decimals">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <double>1000.000000000000000</double>
+        </property>
+        <property name="singleStep">
+         <double>0.100000000000000</double>
+        </property>
+       </widget>
+       <widget class="QLabel" name="so4clResult">
+        <property name="geometry">
+         <rect>
+          <x>560</x>
+          <y>370</y>
+          <width>211</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="font">
+         <font>
+          <italic>true</italic>
+         </font>
+        </property>
+        <property name="text">
+         <string>N/A</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QLabel" name="cur_so4clLabel">
+        <property name="geometry">
+         <rect>
+          <x>310</x>
+          <y>400</y>
+          <width>161</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Current SO4:Cl ratio:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QDoubleSpinBox" name="cur_so4clEdit">
+        <property name="geometry">
+         <rect>
+          <x>480</x>
+          <y>400</y>
+          <width>71</width>
+          <height>24</height>
+         </rect>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+        <property name="buttonSymbols">
+         <enum>QAbstractSpinBox::NoButtons</enum>
+        </property>
+        <property name="accelerated">
+         <bool>false</bool>
+        </property>
+        <property name="decimals">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <double>1000.000000000000000</double>
+        </property>
+        <property name="singleStep">
+         <double>0.100000000000000</double>
+        </property>
+       </widget>
+       <widget class="RangedSlider" name="cur_so4clResult">
+        <property name="geometry">
+         <rect>
+          <x>559</x>
+          <y>400</y>
+          <width>211</width>
+          <height>20</height>
+         </rect>
+        </property>
+       </widget>
       </widget>
      </widget>
      <widget class="QPushButton" name="exportButton">

mercurial