src/Utils.h

Sat, 16 Apr 2022 21:54:43 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 16 Apr 2022 21:54:43 +0200
changeset 139
f947c6988e91
parent 135
e68b27ad8a40
child 168
4bc92122d001
permissions
-rw-r--r--

Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.

20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 #ifndef _UTILS_H
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 #define _UTILS_H
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
57
75d11cc05ce4 Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
4 #include <QString>
95
ef6048186cb3 Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
5 #include <QColor>
57
75d11cc05ce4 Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
6
134
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
7 // #define Ka1 0.0000004445
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
8 // #define Ka2 0.0000000000468
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
9
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 /**
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * @namespace Utils
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * @brief Global math functions.
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 namespace Utils {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 double lintner_to_kolbach(double lintner);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 double kolbach_to_lintner(double kolbach);
42
88e827ea7172 Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
20 double ebc_to_srm(double ebc);
88e827ea7172 Fixed recommend mash checkmark in fermentable editor. Added fermentables XML export.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
21 double srm_to_ebc(double srm);
102
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
22 double get_kt(int ebc);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
23 double plato_to_sg(double plato);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
24 double sg_to_plato(double sg);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
25 double brix_to_sg(double brix);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
26 double sg_to_brix(double sg);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
27 double brix_to_fg(double o_plato, double refracto);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
28 double calc_svg(double og, double fg);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
29 double estimate_sg(double sugars, double batch_size);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
30 double estimate_fg(double psugar, double pcara, double wgratio, double mashtime, double mashtemp, double svg, double og);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
31 double kw_to_srm(int colormethod, double c);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
32 double kw_to_ebc(int colormethod, double c);
b017001850df Almost finished calcFermentables()
Michiel Broek <mbroek@mbse.eu>
parents: 98
diff changeset
33 double abvol(double og, double fg);
125
2e79e0975e58 Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents: 102
diff changeset
34 double toIBU(int Use, int Form, double SG, double Volume, double Amount, double Boiltime, double Alpha,
2e79e0975e58 Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents: 102
diff changeset
35 int Method, double Whirlpool9, double Whirlpool7, double Whirlpool6);
2e79e0975e58 Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents: 102
diff changeset
36 double hopFlavourContribution(double bt, double vol, int use, double amount);
2e79e0975e58 Start hops table display. The calculated preboil_sg value is stored global in memory. Added calculations for IBU, hop flavour and aroma.
Michiel Broek <mbroek@mbse.eu>
parents: 102
diff changeset
37 double hopAromaContribution(double bt, double vol, int use, double amount);
57
75d11cc05ce4 Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
38 QString hours_to_string(int hours);
98
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
39
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
40 /**
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
41 * @brief Map SRM color to RGB and return as QColor.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
42 * @param srm The srm value.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
43 * @return QColor
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
44 */
95
ef6048186cb3 Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
45 QColor srm_to_color(int srm);
98
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
46
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
47 /**
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
48 * @brief Map EBC color to RGB and return as QColor.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
49 * @param ebc The ebc value.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
50 * @return QColor
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
51 */
95
ef6048186cb3 Added part of a beercolor plugin that needs a lot of work. Added some rangesliders in the recipe editor. Added EBC and SRM color mapping to QColor.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
52 QColor ebc_to_color(int ebc);
98
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
53
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
54 /**
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
55 * @brief Map SRM color to a QString for stylesheets.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
56 * @param srm The srm value.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
57 * @return A QString with stylesheet colors.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
58 */
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
59 QString srm_to_style(int ebc);
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
60
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
61 /**
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
62 * @brief Map EBC color to a QString for stylesheets.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
63 * @param ebc The ebc value.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
64 * @return A QString with stylesheet colors.
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
65 */
1425bf3e18ed Solved the segmentation fault when viewing recipes twice. Set colored display for the EBC color fields using a modified dynamic stylesheet.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
66 QString ebc_to_style(int srm);
134
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
67
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
68 /**
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
69 * @brief Mix water volumes and ingredients.
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
70 *
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
71 */
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
72 double mix(double v1, double v2, double c1, double c2);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
73
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
74 /**
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
75 * @brief Return mg/l as CaCO3
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
76 */
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
77 double ResidualAlkalinity(double total_alkalinity, double calcium, double magnesium);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
78
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
79 double PartCO3(double pH);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
80
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
81 double PartHCO3(double pH);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
82
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
83 double Charge(double pH);
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
84
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
85 double CalcFrac(double TpH, double pK1, double pK2, double pK3);
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 #endif

mercurial