IBU method names are now global.

Tue, 05 Jul 2022 14:31:39 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 05 Jul 2022 14:31:39 +0200
changeset 336
e97f9e87d94b
parent 335
c4b4a2879bb8
child 337
8133cdb19aa1

IBU method names are now global.

src/EditProduct.cpp file | annotate | diff | comparison | revisions
src/EditProductExport.cpp file | annotate | diff | comparison | revisions
src/EditRecipe.cpp file | annotate | diff | comparison | revisions
src/EditRecipeExport.cpp file | annotate | diff | comparison | revisions
src/PrinterDialog.cpp file | annotate | diff | comparison | revisions
src/ProdOnDate.cpp file | annotate | diff | comparison | revisions
src/ProdOnTree.cpp file | annotate | diff | comparison | revisions
src/RecipesTree.cpp file | annotate | diff | comparison | revisions
src/Setup.cpp file | annotate | diff | comparison | revisions
src/Utils.cpp file | annotate | diff | comparison | revisions
src/global.cpp file | annotate | diff | comparison | revisions
src/global.h file | annotate | diff | comparison | revisions
--- a/src/EditProduct.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/EditProduct.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -51,9 +51,8 @@
     ui->color_methodEdit->addItem("Halberstadt");
     ui->color_methodEdit->addItem("Naudts");
 
-    ui->ibu_methodEdit->addItem("Tinseth");
-    ui->ibu_methodEdit->addItem("Rager");
-    ui->ibu_methodEdit->addItem("Daniels");
+    for (int i = 0; i < 3; i++)
+	ui->ibu_methodEdit->addItem(g_ibu_method[i]);
 
     for (int i = 0; i < my_acids.size(); i++) {
 	ui->mw_acidPick->addItem(my_acids.at(i).name_en);
--- a/src/EditProductExport.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/EditProductExport.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -23,7 +23,6 @@
     qDebug() << "export";
 
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
     const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" });
     /*                                                    "Leaf Wet", "Cryo", "Extract" */
     /*  We use more hop forms then beerxml knows about, so we send known names */
@@ -79,7 +78,7 @@
     }
     if (product->est_ibu > 0) {
 	xmlWriter->writeTextElement("EST_IBU", QString::number(product->est_ibu, 'f', 1));
-	xmlWriter->writeTextElement("IBU_METHOD", ibu_method[product->ibu_method]);
+	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[product->ibu_method]);
     }
     xmlWriter->writeTextElement("BMS_COOLING_TO", QString::number(product->brew_cooling_to, 'f', 1));
 
@@ -420,7 +419,6 @@
 void EditProduct::toforumProduct()
 {
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
 
     QString memo = QString("[u][b]BMSapp v");
     memo.append(VERSIONSTRING); // For some stupid reason this must be on it's own.
@@ -437,7 +435,7 @@
     memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(product->est_fg, 'f', 3) + " SG[/data][/row]\n");
     memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(product->est_abv, 'f', 1) + "%[/data][/row]\n");
     memo.append("[row][data]Kleur (" + color_method[product->color_method] + ")[/data][data]" + QString::number(product->est_color, 'f', 0) + " EBC[/data][/row]\n");
-    memo.append("[row][data]Bitterheid (" + ibu_method[product->ibu_method] + ")[/data][data]" + QString::number(product->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
+    memo.append("[row][data]Bitterheid (" + QString(g_ibu_method[product->ibu_method]) + ")[/data][data]" + QString::number(product->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
     memo.append("[/tabular]\n\n");
 
     memo.append("[u][b]Vergistbare ingrediƫnten[/b][/u]\n");
--- a/src/EditRecipe.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/EditRecipe.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -48,9 +48,8 @@
     ui->color_methodEdit->addItem("Halberstadt");
     ui->color_methodEdit->addItem("Naudts");
 
-    ui->ibu_methodEdit->addItem("Tinseth");
-    ui->ibu_methodEdit->addItem("Rager");
-    ui->ibu_methodEdit->addItem("Daniels");
+    for (int i = 0; i < 3; i++)
+	ui->ibu_methodEdit->addItem(g_ibu_method[i]);
 
     for (int i = 0; i < my_acids.size(); i++) {
 	ui->mw_acidPick->addItem(my_acids.at(i).name_en);
--- a/src/EditRecipeExport.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/EditRecipeExport.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -21,7 +21,6 @@
 void EditRecipe::exportBeerXML()
 {
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
     const QStringList hop_forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet" });
     /*                                                    "Leaf Wet", "Cryo", "Extract" */
     /*  We use more hop forms then beerxml knows about, so we send known names */
@@ -73,7 +72,7 @@
     }
     if (recipe->est_ibu > 0) {
 	xmlWriter->writeTextElement("EST_IBU", QString::number(recipe->est_ibu, 'f', 1));
-	xmlWriter->writeTextElement("IBU_METHOD", ibu_method[recipe->ibu_method]);
+	xmlWriter->writeTextElement("IBU_METHOD", g_ibu_method[recipe->ibu_method]);
     }
 
     xmlWriter->writeStartElement("STYLE");
@@ -437,7 +436,6 @@
 void EditRecipe::toforumRecipe()
 {
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
 
     QString memo = QString("[u][b]BMSapp v");
     memo.append(VERSIONSTRING);	// For some stupid reason this must be on it's own.
@@ -454,7 +452,7 @@
     memo.append("[row][data]Geschatte eind densiteit[/data][data]" + QString::number(recipe->est_fg, 'f', 3) + " SG[/data][/row]\n");
     memo.append("[row][data]Geschat alcohol[/data][data]" + QString::number(recipe->est_abv, 'f', 1) + "%[/data][/row]\n");
     memo.append("[row][data]Kleur (" + color_method[recipe->color_method] + ")[/data][data]" + QString::number(recipe->est_color, 'f', 0) + " EBC[/data][/row]\n");
-    memo.append("[row][data]Bitterheid (" + ibu_method[recipe->ibu_method] + ")[/data][data]" + QString::number(recipe->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
+    memo.append("[row][data]Bitterheid (" + QString(g_ibu_method[recipe->ibu_method]) + ")[/data][data]" + QString::number(recipe->est_ibu, 'f', 1) + " IBU[/data][/row]\n");
     memo.append("[/tabular]\n\n");
 
     memo.append("[u][b]Vergistbare ingrediƫnten[/b][/u]\n");
--- a/src/PrinterDialog.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/PrinterDialog.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -67,7 +67,6 @@
     const QColor w_line(  120, 255, 250, 255);
 
     const QStringList y_unit({tr("pkg"), tr("gr"), tr("ml"), tr("ml"), tr("ml"), tr("ml"), tr("gr")});
-    const QStringList ibu_method({ "Tinseth", "Rager", "Daniels", "Garetz", "Mosher", "Noonan" });
     const QStringList color_method({ "Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
     const QStringList cooling_method({"-", tr("Emersion chiller"), tr("Counterflow chiller"), tr("Au bain marie"), tr("Natural") });
 
@@ -367,7 +366,7 @@
 	painter.drawText(260, y+4,  90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_color_min, 1, 'f', 0).arg(recipe->st_color_max, 1, 'f', 0));
 	painter.setPen(Qt::black);
         painter.fillRect(405, y,   330, 20, c_line1);
-        painter.drawText(405, y+4, 150, 20, Qt::AlignLeft, tr("IBU (") + ibu_method[recipe->ibu_method] + ")");
+        painter.drawText(405, y+4, 150, 20, Qt::AlignLeft, tr("IBU (") + g_ibu_method[recipe->ibu_method] + ")");
         painter.drawText(555, y+4,  90, 20, Qt::AlignLeft, QString("%1").arg(recipe->est_ibu, 1, 'f', 1));
 	painter.drawText(645, y+4,  90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(recipe->st_ibu_min, 1, 'f', 0).arg(recipe->st_ibu_max, 1, 'f', 0));
 	y += 40;
@@ -748,7 +747,7 @@
         painter.drawText(260, y+4,  90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(product->st_color_min, 1, 'f', 0).arg(product->st_color_max, 1, 'f', 0));
 	painter.setPen(Qt::black);
         painter.fillRect(405, y,   330, 20, c_line1);
-        painter.drawText(405, y+4, 150, 20, Qt::AlignLeft, tr("IBU (") + ibu_method[product->ibu_method] + ")");
+        painter.drawText(405, y+4, 150, 20, Qt::AlignLeft, tr("IBU (") + g_ibu_method[product->ibu_method] + ")");
         painter.drawText(555, y+4,  90, 20, Qt::AlignLeft, QString("%1").arg(product->est_ibu, 1, 'f', 1));
         painter.drawText(645, y+4,  90, 20, Qt::AlignLeft, QString("(%1 - %2)").arg(product->st_ibu_min, 1, 'f', 0).arg(product->st_ibu_max, 1, 'f', 0));
 	y += 20;
--- a/src/ProdOnDate.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/ProdOnDate.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -299,7 +299,6 @@
     qDebug() << "showRecipe" << record;
 
     const QStringList c_method({"Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList i_method({"Tinseth", "Rager", "Daniels" });
 
     /*
      * If no recipe is "pre" selected, return.
@@ -330,7 +329,7 @@
 	colorEdit->setStyleSheet(Utils::ebc_to_style(query.value(7).toInt()));
 	colormethodEdit->setText(c_method[query.value(8).toInt()]);
 	ibuEdit->setValue(query.value(9).toInt());
-	ibumethodEdit->setText(i_method[query.value(10).toInt()]);
+	ibumethodEdit->setText(g_ibu_method[query.value(10).toInt()]);
 	co2Edit->setValue(query.value(11).toDouble());
 	remarksEdit->setPlainText(query.value(12).toString());
 	recipeBox->setTitle(query.value(14).toString() + " - " + query.value(13).toString());
--- a/src/ProdOnTree.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/ProdOnTree.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -321,7 +321,6 @@
     qDebug() << "showRecipe" << record;
 
     const QStringList c_method({"Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList i_method({"Tinseth", "Rager", "Daniels" });
 
     /*
      * If no recipe is "pre" selected, return.
@@ -352,7 +351,7 @@
 	colorEdit->setStyleSheet(Utils::ebc_to_style(query.value(7).toInt()));
 	colormethodEdit->setText(c_method[query.value(8).toInt()]);
 	ibuEdit->setValue(query.value(9).toInt());
-	ibumethodEdit->setText(i_method[query.value(10).toInt()]);
+	ibumethodEdit->setText(g_ibu_method[query.value(10).toInt()]);
 	co2Edit->setValue(query.value(11).toDouble());
 	remarksEdit->setPlainText(query.value(12).toString());
 	recipeBox->setTitle(query.value(14).toString() + " - " + query.value(13).toString());
--- a/src/RecipesTree.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/RecipesTree.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -330,7 +330,6 @@
     qDebug() << "showRecipe" << record;
 
     const QStringList c_method({"Morey", "Mosher", "Daniels", "Halberstadt", "Naudts" });
-    const QStringList i_method({"Tinseth", "Rager", "Daniels" });
 
     /*
      * If no recipe is "pre" selected, return.
@@ -361,7 +360,7 @@
 	colorEdit->setStyleSheet(Utils::ebc_to_style(query.value(7).toInt()));
 	colormethodEdit->setText(c_method[query.value(8).toInt()]);
 	ibuEdit->setValue(query.value(9).toInt());
-	ibumethodEdit->setText(i_method[query.value(10).toInt()]);
+	ibumethodEdit->setText(g_ibu_method[query.value(10).toInt()]);
 	co2Edit->setValue(query.value(11).toDouble());
 	remarksEdit->setPlainText(query.value(12).toString());
 	recipeBox->setTitle(query.value(13).toString());
--- a/src/Setup.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/Setup.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -16,6 +16,7 @@
  */
 #include "Setup.h"
 #include "config.h"
+#include "global.h"
 #include "MainWindow.h"
 
 
@@ -321,14 +322,11 @@
     colorEdit->addItem("Daniels");
     colorEdit->addItem("Halberstadt");
     colorEdit->addItem("Naudts");
-    colorEdit->setEditable(true);
     colorEdit->setCurrentIndex(query.value("color_method").toInt());
     connect(colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
 
-    ibuEdit->addItem("Tinseth");
-    ibuEdit->addItem("Rager");
-    ibuEdit->addItem("Daniels");
-    ibuEdit->setEditable(true);
+    for (int i = 0; i < 3; i++)
+	ibuEdit->addItem(g_ibu_method[i]);
     ibuEdit->setCurrentIndex(query.value("ibu_method").toInt());
     connect(ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
 
--- a/src/Utils.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/Utils.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -360,6 +360,38 @@
     return round((og * 1000 - fg * 1000) * factor * 100) / 100;
 }
 
+/*
+double Utils::boilIBU(int Form, double SG, double Volume, double Amount, double Time, double Alpha, int Method)
+{
+    if (Method == 0) { // Tinseth
+*/        /* http://realbeer.com/hops/research.html */
+/*        AddedAlphaAcids = (alpha * mass * 1000) / liters;
+        Bigness_factor = 1.65 * pow(0.000125, gravity - 1);
+        BoilTime_factor = ((1 - exp(-0.04 * time)) / 4.15);
+        utiisation = Bigness_factor * BoilTime_factor;
+        ibu = round((utiisation * AddedAlphaAcids * fmoment * pfactor + whirlibus) * 100) / 100;
+    }
+    if (Method == 2) { // Daniels
+        if (Form == 2) // Leaf
+            boilfactor = -(0.0041 * time * time) + (0.6162 * time) + 1.5779;
+        else
+            boilfactor = -(0.0051 * time * time) + (0.7835 * time) + 1.9348;
+        if (gravity < 1050)
+            sgfactor = 0;
+        else
+            sgfactor = (gravity - 1050) / 200;
+        ibu = round((fmoment * ((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor))) + whirlibus) * 100) / 100;
+    }
+    if (Method == 1) { // Rager
+        boilfactor = fmoment * 18.11 + 13.86 * tanh((time * 31.32) / 18.27);
+        if (gravity < 1050)
+            sgfactor = 0;
+        else
+            sgfactor = (gravity - 1050) / 200;
+        ibu = round(((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor)) + whirlibus) * 100) / 100;
+    }
+}
+*/
 
 double Utils::toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha,
 		    int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6, double Fulltime)
--- a/src/global.cpp	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/global.cpp	Tue Jul 05 14:31:39 2022 +0200
@@ -63,6 +63,12 @@
     QT_TRANSLATE_NOOP("BeerType", "Cider")
 };
 
+const char * g_ibu_method[3] = {
+    "Tinseth",
+    "Rager",
+    "Daniels"
+};
+
 const char * const g_fermentable_types[5] = {
     QT_TRANSLATE_NOOP("FermentableType", "Grain"),
     QT_TRANSLATE_NOOP("FermentableType", "Sugar"),
--- a/src/global.h	Sun Jul 03 19:02:02 2022 +0200
+++ b/src/global.h	Tue Jul 05 14:31:39 2022 +0200
@@ -687,6 +687,7 @@
 extern const char * const g_prod_split[];
 extern const char * const g_recipe_types[];
 extern const char * const g_style_types[];
+extern const char * g_ibu_method[3];
 
 enum FermentableTypes {
 	FERMENTABLE_TYPE_GRAIN,

mercurial