# HG changeset patch # User Michiel Broek # Date 1650802520 -7200 # Node ID 24bc2de721d9b08923892f6b214b91bfa96cb7cf # Parent 771b0b00092a95579e8d896eb98079838e7a7cc4 Activated print recipe button. The recipe record structure is now global. Added global product record structure. diff -r 771b0b00092a -r 24bc2de721d9 src/EditRecipe.cpp --- a/src/EditRecipe.cpp Sat Apr 23 20:00:35 2022 +0200 +++ b/src/EditRecipe.cpp Sun Apr 24 14:15:20 2022 +0200 @@ -16,6 +16,7 @@ */ #include "MainWindow.h" #include "EditRecipe.h" +#include "PrinterDialog.h" #include "../ui/ui_EditRecipe.h" #include "Utils.h" #include "global.h" diff -r 771b0b00092a -r 24bc2de721d9 src/EditRecipe.h --- a/src/EditRecipe.h Sat Apr 23 20:00:35 2022 +0200 +++ b/src/EditRecipe.h Sun Apr 24 14:15:20 2022 +0200 @@ -13,232 +13,7 @@ #include #include - -/* - * Fermentables, Hops, Miscs, Yeasts and Mashs are stored in the - * database in json arrays. These are the QList structures. - */ -struct Fermentables -{ - QString f_name; - QString f_origin; - QString f_supplier; - double f_amount; - double f_cost; - int f_type; - double f_yield; - double f_color; - double f_coarse_fine_diff; - double f_moisture; - double f_diastatic_power; - double f_protein; - double f_dissolved_protein; - double f_max_in_batch; - int f_graintype; - int f_added; - bool f_recommend_mash; - bool f_add_after_boil; - bool f_adjust_to_total_100; - double f_percentage; - double f_di_ph; - double f_acid_to_ph_57; -}; - - -struct Hops -{ - QString h_name; - QString h_origin; - double h_amount; - double h_cost; - int h_type; - int h_form; - int h_useat; - double h_time; - double h_alpha; - double h_beta; - double h_hsi; - double h_humulene; - double h_caryophyllene; - double h_cohumulone; - double h_myrcene; - double h_total_oil; -}; - - -struct Miscs -{ - QString m_name; - double m_amount; - int m_type; - int m_use_use; - double m_time; - bool m_amount_is_weight; - double m_cost; -}; - - -struct Yeasts -{ - QString y_name; - QString y_laboratory; - QString y_product_id; - double y_amount; - int y_type; - int y_form; - double y_min_temperature; - double y_max_temperature; - int y_flocculation; - double y_attenuation; - double y_cells; - double y_tolerance; - double y_inventory; - int y_use; - bool y_sta1; - bool y_bacteria; - bool y_harvest_top; - int y_harvest_time; - double y_pitch_temperature; - bool y_pofpos; - int y_zymocide; - int y_gr_hl_lo; - double y_sg_lo; - int y_gr_hl_hi; - double y_sg_hi; - double y_cost; -}; - - -struct Mashs -{ - QString step_name; - int step_type; - double step_volume; ///< The water volume upto this step. - double step_infuse_amount; ///< Infuse/decoction volume this step. - double step_infuse_temp; ///< Infuse/decoction temperature. - double step_temp; ///< Start tmperature this step. - double step_time; ///< Step rest time. - double ramp_time; ///< Estimated ramp time to this step. - double end_temp; ///< End temperature this step. - double step_wg_ratio; ///< Current water/grain ratio. -}; - - -/* - * The main recipe record stored in the database. - */ -struct Recipe -{ - int record; - QString uuid; - bool locked; - QString st_name; - QString st_letter; - QString st_guide; - QString st_category; - int st_category_number; - int st_type; - double st_og_min; - double st_og_max; - double st_fg_min; - double st_fg_max; - double st_ibu_min; - double st_ibu_max; - double st_color_min; - double st_color_max; - double st_carb_min; - double st_carb_max; - double st_abv_min; - double st_abv_max; - - QString name; - QString notes; - int type; - double batch_size; - double boil_size; - double boil_time; - double efficiency; - double est_og; - double est_fg; - double est_abv; - double est_color; - int color_method; - double est_ibu; - int ibu_method; - double est_carb; - - double sparge_temp; - double sparge_ph; - double sparge_volume; - int sparge_source; - int sparge_acid_type; - double sparge_acid_perc; - double sparge_acid_amount; - double mash_ph; - QString mash_name; - bool calc_acid; - - QString w1_name; ///< Water source 1 - double w1_amount; - double w1_calcium; - double w1_sulfate; - double w1_chloride; - double w1_sodium; - double w1_magnesium; - double w1_total_alkalinity; - double w1_ph; - double w1_cost; - QString w2_name; ///< Water source 2 - double w2_amount; - double w2_calcium; - double w2_sulfate; - double w2_chloride; - double w2_sodium; - double w2_magnesium; - double w2_total_alkalinity; - double w2_ph; - double w2_cost; - double wg_amount; ///< Mixed water - double wg_calcium; - double wg_sulfate; - double wg_chloride; - double wg_sodium; - double wg_magnesium; - double wg_total_alkalinity; - double wg_ph; - double wb_calcium; ///< Treated water - double wb_sulfate; - double wb_chloride; - double wb_sodium; - double wb_magnesium; - double wb_total_alkalinity; - double wb_ph; - int wa_acid_name; - double wa_acid_perc; - int wa_base_name; - - QList fermentables; - QList hops; - QList miscs; - QList yeasts; - QList mashs; - - /* - * These are not in the MySL database, but are global variables - * that belong with the loaded recipe data and are present to - * make things easier. - */ - int fermentables_row; ///< Current row, -1 is invalid. - bool fermentables_use100; ///< Use percentages instead of amount - int hops_row; - int miscs_row; - int yeasts_row; - int mashs_row; - double mashs_kg; ///< Kg fermentables in the mash. - int mashs_time; ///< Total mash time. - double preboil_sg; -}; - +#include "global.h" namespace Ui { class EditRecipe; @@ -361,7 +136,7 @@ QString bar_100 = "QProgressBar::chunk {background: #80FF80;}"; int recno; bool textIsChanged = false; - Recipe *recipe; +// Recipe *recipe; /* * Variables for popup ingredients editing. */ diff -r 771b0b00092a -r 24bc2de721d9 src/EditRecipeExport.cpp --- a/src/EditRecipeExport.cpp Sat Apr 23 20:00:35 2022 +0200 +++ b/src/EditRecipeExport.cpp Sun Apr 24 14:15:20 2022 +0200 @@ -264,8 +264,7 @@ void EditRecipe::on_printButton_clicked() { - qDebug() << "print"; + PrinterDialog(PR_RECIPE, -1, this); } - diff -r 771b0b00092a -r 24bc2de721d9 src/EditRecipeTab6.cpp --- a/src/EditRecipeTab6.cpp Sat Apr 23 20:00:35 2022 +0200 +++ b/src/EditRecipeTab6.cpp Sun Apr 24 14:15:20 2022 +0200 @@ -154,8 +154,8 @@ double EditRecipe::infusionVol(double step_infused, double step_mashkg, double infuse_temp, double step_temp, double last_temp) { - double a = last_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); - double b = step_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); + double a = last_temp * (equip_tun_weight * equip_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); + double b = step_temp * (equip_tun_weight * equip_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); double vol = round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)) * 100.0) / 100.0; if (vol < 0) @@ -167,7 +167,7 @@ double EditRecipe::decoctionVol(double step_volume, double step_temp, double prev_temp) { - double a = (eq_tun_weight * eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); + double a = (equip_tun_weight * equip_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); double b = SpecificHeatWater * (99 - step_temp); double vol = 0; @@ -198,9 +198,9 @@ n = 20; // tun is preheated. tuntemp = recipe->mashs.at(i).step_temp; for (j = 0; j < n; j++) { - a = recipe->mashs_kg * graintemp * SpecificHeatMalt + eq_tun_weight * tuntemp * eq_tun_specific_heat; + a = recipe->mashs_kg * graintemp * SpecificHeatMalt + equip_tun_weight * tuntemp * equip_tun_specific_heat; b = recipe->mashs[i].step_temp * - (eq_tun_weight * eq_tun_specific_heat + + (equip_tun_weight * equip_tun_specific_heat + recipe->mashs.at(i).step_infuse_amount * SpecificHeatWater + recipe->mashs_kg * SpecificHeatMalt) - SlakingHeat * recipe->mashs_kg; diff -r 771b0b00092a -r 24bc2de721d9 src/PrinterDialog.cpp --- a/src/PrinterDialog.cpp Sat Apr 23 20:00:35 2022 +0200 +++ b/src/PrinterDialog.cpp Sun Apr 24 14:15:20 2022 +0200 @@ -15,6 +15,7 @@ * along with this program. If not, see . */ #include "PrinterDialog.h" +#include "EditRecipe.h" #include "config.h" #include "global.h" @@ -293,6 +294,11 @@ query.next(); y += 20; } + } else if (p_job == PR_RECIPE) { + + printHeader(&painter); + y = 120; + } @@ -322,6 +328,8 @@ painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Inventory") + " " + my_brewery_name); } else if (p_job == PR_YEASTBANK) { painter->drawText(120, 0, 500, 40, Qt::AlignLeft, tr("Yeastbank") + " " + my_brewery_name); + } else if (p_job == PR_RECIPE) { + painter->drawText(120, 0, 500, 40, Qt::AlignLeft, recipe->name); } else { painter->drawText(120, 0, 500, 40, Qt::AlignLeft, "?? " + my_brewery_name); } diff -r 771b0b00092a -r 24bc2de721d9 src/PrinterDialog.h --- a/src/PrinterDialog.h Sat Apr 23 20:00:35 2022 +0200 +++ b/src/PrinterDialog.h Sun Apr 24 14:15:20 2022 +0200 @@ -6,7 +6,7 @@ #include -enum JobType { PR_SUPPLIES, PR_YEASTBANK }; +enum JobType { PR_SUPPLIES, PR_YEASTBANK, PR_RECIPE }; namespace Ui { class PrinterDialog; diff -r 771b0b00092a -r 24bc2de721d9 src/global.cpp --- a/src/global.cpp Sat Apr 23 20:00:35 2022 +0200 +++ b/src/global.cpp Sun Apr 24 14:15:20 2022 +0200 @@ -19,6 +19,8 @@ int my_default_water = -1; QString my_yeastlab = ""; +Recipe *recipe; + const QStringList style_types({ QObject::tr("Lager"), diff -r 771b0b00092a -r 24bc2de721d9 src/global.h --- a/src/global.h Sat Apr 23 20:00:35 2022 +0200 +++ b/src/global.h Sun Apr 24 14:15:20 2022 +0200 @@ -4,6 +4,7 @@ #include #include #include +#include #define Ka1 0.0000004445 @@ -29,8 +30,8 @@ #define SpecificHeatWater 1.0 #define SpecificHeatMalt 0.399 //cal/g.°C #define SlakingHeat 10.318 //cal/g.°C -#define eq_tun_weight 2.0 // 2 Kg pot -#define eq_tun_specific_heat 0.110 +#define equip_tun_weight 2.0 // 2 Kg pot +#define equip_tun_specific_heat 0.110 struct Acid @@ -47,6 +48,494 @@ extern QList my_acids; +/* + * Fermentables, Hops, Miscs, Yeasts and Mashs are stored in the + * database in json arrays. These are the QList structures. + */ +struct Fermentables +{ + QString f_name; + QString f_origin; + QString f_supplier; + double f_amount; + double f_cost; + int f_type; + double f_yield; + double f_color; + double f_coarse_fine_diff; + double f_moisture; + double f_diastatic_power; + double f_protein; + double f_dissolved_protein; + double f_max_in_batch; + int f_graintype; + int f_added; + bool f_recommend_mash; + bool f_add_after_boil; + bool f_adjust_to_total_100; + double f_percentage; + double f_di_ph; + double f_acid_to_ph_57; + double f_inventory; ///< In product, current inventory. + bool f_avail; ///< Product available in database. +}; + + +struct Hops +{ + QString h_name; + QString h_origin; + double h_amount; + double h_cost; + int h_type; + int h_form; + int h_useat; + double h_time; + double h_alpha; + double h_beta; + double h_hsi; + double h_humulene; + double h_caryophyllene; + double h_cohumulone; + double h_myrcene; + double h_total_oil; + double h_inventory; ///< In product, current inventory. + bool h_avail; ///< Product available in database. +}; + + +struct Miscs +{ + QString m_name; + double m_amount; + int m_type; + int m_use_use; + double m_time; + bool m_amount_is_weight; + double m_cost; + double m_inventory; ///< In product, current inventory. + bool m_avail; ///< Product available in database. +}; + + +struct Yeasts +{ + QString y_name; + QString y_laboratory; + QString y_product_id; + double y_amount; + int y_type; + int y_form; + double y_min_temperature; + double y_max_temperature; + int y_flocculation; + double y_attenuation; + double y_cells; + double y_tolerance; + int y_use; + bool y_sta1; + bool y_bacteria; + bool y_harvest_top; + int y_harvest_time; + double y_pitch_temperature; + bool y_pofpos; + int y_zymocide; + int y_gr_hl_lo; + double y_sg_lo; + int y_gr_hl_hi; + double y_sg_hi; + double y_cost; + double y_inventory; ///< In product, current inventory. + bool y_avail; ///< Product available in database. +}; + + +struct Mashs +{ + QString step_name; + int step_type; + double step_volume; ///< The water volume upto this step. + double step_infuse_amount; ///< Infuse/decoction volume this step. + double step_infuse_temp; ///< Infuse/decoction temperature. + double step_temp; ///< Start tmperature this step. + double step_time; ///< Step rest time. + double ramp_time; ///< Estimated ramp time to this step. + double end_temp; ///< End temperature this step. + double step_wg_ratio; ///< Current water/grain ratio. + double step_ph; ///< In product, measured pH. + double step_sg; ///< In product, measured SG. +}; + + +/* + * The main recipe record stored in the database. + */ +struct Recipe +{ + int record; + QString uuid; + bool locked; + QString st_name; + QString st_letter; + QString st_guide; + QString st_category; + int st_category_number; + int st_type; + double st_og_min; + double st_og_max; + double st_fg_min; + double st_fg_max; + double st_ibu_min; + double st_ibu_max; + double st_color_min; + double st_color_max; + double st_carb_min; + double st_carb_max; + double st_abv_min; + double st_abv_max; + + QString name; + QString notes; + int type; + double batch_size; + double boil_size; + double boil_time; + double efficiency; + double est_og; + double est_fg; + double est_abv; + double est_color; + int color_method; + double est_ibu; + int ibu_method; + double est_carb; + + double sparge_temp; + double sparge_ph; + double sparge_volume; + int sparge_source; + int sparge_acid_type; + double sparge_acid_perc; + double sparge_acid_amount; + double mash_ph; + QString mash_name; + bool calc_acid; + + QString w1_name; ///< Water source 1 + double w1_amount; + double w1_calcium; + double w1_sulfate; + double w1_chloride; + double w1_sodium; + double w1_magnesium; + double w1_total_alkalinity; + double w1_ph; + double w1_cost; + QString w2_name; ///< Water source 2 + double w2_amount; + double w2_calcium; + double w2_sulfate; + double w2_chloride; + double w2_sodium; + double w2_magnesium; + double w2_total_alkalinity; + double w2_ph; + double w2_cost; + double wg_amount; ///< Mixed water + double wg_calcium; + double wg_sulfate; + double wg_chloride; + double wg_sodium; + double wg_magnesium; + double wg_total_alkalinity; + double wg_ph; + double wb_calcium; ///< Treated water + double wb_sulfate; + double wb_chloride; + double wb_sodium; + double wb_magnesium; + double wb_total_alkalinity; + double wb_ph; + int wa_acid_name; + double wa_acid_perc; + int wa_base_name; + + QList fermentables; + QList hops; + QList miscs; + QList yeasts; + QList mashs; + + /* + * These are not in the MySL database, but are global variables + * that belong with the loaded recipe data and are present to + * make things easier. + */ + int fermentables_row; ///< Current row, -1 is invalid. + bool fermentables_use100; ///< Use percentages instead of amount + int hops_row; + int miscs_row; + int yeasts_row; + int mashs_row; + double mashs_kg; ///< Kg fermentables in the mash. + int mashs_time; ///< Total mash time. + double preboil_sg; +}; + + +/* + * The main product record stored in the database. + */ +struct Product +{ + int record; + QString uuid; + QString name; + QString code; + QDate birth; + int stage; + QString notes; + bool log_brew; + bool log_fermentation; + bool log_ispindel; + bool log_co2pressure; + int inventory_reduced; + bool locked; + + QString eq_name; + QString eq_notes; + double eq_boil_size; + double eq_batch_size; + double eq_tun_volume; + double eq_tun_weight; + double eq_tun_specific_heat; + int eq_tun_material; + double eq_tun_height; + double eq_top_up_water; + double eq_trub_chiller_loss; + double eq_evap_rate; + double eq_boil_time; + bool eq_calc_boil_volume; + double eq_top_up_kettle; + double eq_hop_utilization; + double eq_lauter_volume; + double eq_lauter_height; + double eq_lauter_deadspace; + double eq_kettle_volume; + double eq_kettle_height; + double eq_mash_volume; + double eq_mash_max; + double eq_efficiency; + + QDateTime brew_date_start; + double brew_mash_ph; + double brew_mash_sg; + double brew_mash_efficiency; + double brew_sparge_temperature; + double brew_sparge_volume; + double brew_sparge_est; + double brew_sparge_ph; + double brew_preboil_volume; + double brew_preboil_sg; + double brew_preboil_ph; + double brew_preboil_efficiency; + double brew_aboil_volume; + double brew_aboil_sg; + double brew_aboil_ph; + double brew_aboil_efficiency; + int brew_cooling_method; + double brew_cooling_time; + double brew_cooling_to; + double brew_whirlpool9; + double brew_whirlpool7; + double brew_whirlpool6; + double brew_whirlpool2; + double brew_fermenter_volume; + double brew_fermenter_extrawater; + double brew_fermenter_tcloss; + double brew_aeration_time; + double brew_aeration_speed; + int brew_aeration_type; + double brew_fermenter_sg; + double brew_fermenter_ibu; + double brew_fermenter_color; + QDateTime brew_date_end; + + double og; + double fg; + double primary_start_temp; + double primary_max_temp; + double primary_end_temp; + double primary_end_sg; + QDate primary_end_date; + double secondary_temp; + double secondary_end_sg; + QDate secondary_end_date; + double tertiary_temp; + + QDate package_date; + double package_volume; + double package_infuse_amount; + double package_infuse_abv; + double package_infuse_notes; + double package_abv; + double package_ph; + double bottle_amount; + double bottle_carbonation; + int bottle_priming_sugar; + double bottle_priming_amount; + double bottle_priming_water; + double bottle_carbonation_temp; + double keg_amount; + double keg_carbonation; + int keg_priming_sugar; + double keg_priming_amount; + double keg_priming_water; + double keg_carbonation_temp; + bool keg_forced_carb; + double keg_pressure; + + QString taste_notes; + double taste_rate; + QDate taste_date; + QString taste_color; + QString taste_transparency; + QString taste_head; + QString taste_aroma; + QString taste_taste; + QString taste_mouthfeel; + QString taste_aftertaste; + + QString st_name; + QString st_letter; + QString st_guide; + QString st_category; + int st_category_number; + int st_type; + double st_og_min; + double st_og_max; + double st_fg_min; + double st_fg_max; + double st_ibu_min; + double st_ibu_max; + double st_color_min; + double st_color_max; + double st_carb_min; + double st_carb_max; + double st_abv_min; + double st_abv_max; + + int type; + double batch_size; + double boil_size; + double boil_time; + double efficiency; + double est_og; + double est_og3; + double est_fg; + double est_abv; + double est_color; + int color_method; + double est_ibu; + int ibu_method; + double est_carb; + + double sparge_temp; + double sparge_ph; + double sparge_volume; + int sparge_source; + int sparge_acid_type; + double sparge_acid_perc; + double sparge_acid_amount; + double mash_ph; + QString mash_name; + bool calc_acid; + + QString w1_name; ///< Water source 1 + double w1_amount; + double w1_calcium; + double w1_sulfate; + double w1_chloride; + double w1_sodium; + double w1_magnesium; + double w1_total_alkalinity; + double w1_ph; + double w1_cost; + QString w2_name; ///< Water source 2 + double w2_amount; + double w2_calcium; + double w2_sulfate; + double w2_chloride; + double w2_sodium; + double w2_magnesium; + double w2_total_alkalinity; + double w2_ph; + double w2_cost; + double wg_amount; ///< Mixed water + double wg_calcium; + double wg_sulfate; + double wg_chloride; + double wg_sodium; + double wg_magnesium; + double wg_total_alkalinity; + double wg_ph; + double wb_calcium; ///< Treated water + double wb_sulfate; + double wb_chloride; + double wb_sodium; + double wb_magnesium; + double wb_total_alkalinity; + double wb_ph; + int wa_acid_name; + double wa_acid_perc; + int wa_base_name; + + bool starter_enable; + int starter_type; + double starter_sg; + int starter_viability; + QDate yeast_prod_date; + double yeast_pitchrate; + int prop1_type; + double prop1_volume; + int prop2_type; + double prop2_volume; + int prop3_type; + double prop3_volume; + int prop4_type; + double prop4_volume; + + int divide_type; + double divide_size; + double divide_factor; + int divide_parts; + int divide_part; + + QList fermentables; + QList hops; + QList miscs; + QList yeasts; + QList mashs; + + /* + * These are not in the MySL database, but are global variables + * that belong with the loaded product data and are present to + * make things easier. + */ + int fermentables_row; ///< Current row, -1 is invalid. + bool fermentables_use100; ///< Use percentages instead of amount + int hops_row; + int miscs_row; + int yeasts_row; + int mashs_row; + double mashs_kg; ///< Kg fermentables in the mash. + int mashs_time; ///< Total mash time. + double preboil_sg; +}; + + +extern Recipe *recipe; + extern QString my_brewery_name; extern QByteArray my_logoByteArray; extern int my_factor_mashhop;