src/EditProductTab10.cpp

changeset 219
fa7cad488e27
parent 175
f1ed3a2a94e9
child 296
2f4e250cfed9
equal deleted inserted replaced
218:725da10db56c 219:fa7cad488e27
1 /** 1 /**
2 * EditProduct.cpp is part of bmsapp. 2 * EditProduct.cpp is part of bmsapp.
3 * 3 *
4 * Tab 2, equipment settings. 4 * Tab 10, fermentation stages.
5 * 5 *
6 * bmsapp is free software: you can redistribute it and/or modify 6 * bmsapp is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or 8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version. 9 * (at your option) any later version.
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 20
21 void EditProduct::brix_changed(double val)
22 {
23 ret_fg = Utils::brix_to_fg(Utils::sg_to_plato(product->brew_fermenter_sg), val);
24 //qDebug() << "brix_changed" << val << product->brew_fermenter_sg << ret_fg;
25 }
26
27
28 double EditProduct::get_fg(double gravity)
29 {
30 QDialog* dialog = new QDialog(this);
31 dialog->resize(360, 110);
32 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
33 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
34 buttonBox->setGeometry(QRect(30, 60, 300, 32));
35 buttonBox->setLayoutDirection(Qt::LeftToRight);
36 buttonBox->setOrientation(Qt::Horizontal);
37 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
38 buttonBox->setCenterButtons(true);
39
40 QLabel *brixLabel = new QLabel(dialog);
41 brixLabel->setObjectName(QString::fromUtf8("brixLabel"));
42 brixLabel->setText(tr("Refractometer Brix:"));
43 brixLabel->setGeometry(QRect(10, 20, 161, 24));
44 brixLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
45
46 QDoubleSpinBox *brixEdit = new QDoubleSpinBox(dialog);
47 brixEdit->setObjectName(QString::fromUtf8("brixEdit"));
48 brixEdit->setGeometry(QRect(180, 20, 101, 24));
49 brixEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
50 brixEdit->setAccelerated(true);
51 brixEdit->setDecimals(1);
52 brixEdit->setMaximum(32.0);
53 brixEdit->setSingleStep(0.1);
54 /*
55 * Search the Brix value that is needed to get this gravity.
56 * Set the found value as preset in the spinbox.
57 */
58 double brix = 0.0;
59 for (brix = 0.0; brix < 32.0; brix += 0.1) {
60 if (Utils::brix_to_fg(Utils::sg_to_plato(product->brew_fermenter_sg), brix) >= gravity)
61 break;
62 }
63 brixEdit->setValue(brix);
64
65 connect(brixEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brix_changed);
66 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
67 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
68
69 dialog->setModal(true);
70 dialog->exec();
71 if (dialog->result() == QDialog::Rejected) {
72 ret_fg = gravity;
73 }
74
75 disconnect(brixEdit, nullptr, nullptr, nullptr);
76 disconnect(buttonBox, nullptr, nullptr, nullptr);
77 return ret_fg;
78 }
79
80
81 void EditProduct::primary_start_changed(double val)
82 {
83 product->primary_start_temp = val;
84 is_changed();
85 setStage();
86 }
87
88
89 void EditProduct::primary_peak_changed(double val)
90 {
91 product->primary_max_temp = val;
92 is_changed();
93 setStage();
94 }
95
96
97 void EditProduct::primary_end_changed(double val)
98 {
99 product->primary_end_temp = val;
100 is_changed();
101 setStage();
102 }
103
104
105 void EditProduct::primary_sg_changed(double val)
106 {
107 if (product->primary_end_sg == 0 && val == 0.001) {
108 product->primary_end_sg = 0.990;
109 const QSignalBlocker blocker1(ui->prim_endsgEdit);
110 ui->prim_endsgEdit->setValue(0.990);
111 } else {
112 product->primary_end_sg = val;
113 }
114 ui->prim_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->primary_end_sg));
115 is_changed();
116 setStage();
117 }
118
119
120 void EditProduct::primary_sg_button()
121 {
122 double rc = get_fg(product->primary_end_sg);
123 ui->prim_endsgEdit->setValue(rc);
124 }
125
126
127 void EditProduct::primary_date_changed(QDate val)
128 {
129 product->primary_end_date = ui->prim_enddateEdit->nullDate();
130 is_changed();
131 setStage();
132 }
133
134
135 void EditProduct::primary_date_button()
136 {
137 ui->prim_enddateEdit->setDate(QDate::currentDate());
138 }
139
140
141 void EditProduct::primary_date_ack()
142 {
143 int rc = QMessageBox::warning(this, tr("Confirm primary"), tr("Confirm that the primary fermentation data is correct"),
144 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
145
146 if (rc == QMessageBox::No)
147 return;
148
149 product->stage = PROD_STAGE_SECONDARY;
150 setStage();
151 is_changed();
152 }
153
154
155 void EditProduct::secondary_temp_changed(double val)
156 {
157 product->secondary_temp = val;
158 is_changed();
159 setStage();
160 }
161
162
163 void EditProduct::secondary_sg_changed(double val)
164 {
165 if (product->secondary_end_sg == 0 && val == 0.001) {
166 product->secondary_end_sg = 0.990;
167 const QSignalBlocker blocker1(ui->sec_sgEdit);
168 ui->sec_sgEdit->setValue(0.990);
169 } else {
170 product->secondary_end_sg = val;
171 }
172 ui->sec_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->secondary_end_sg));
173 is_changed();
174 setStage();
175 }
176
177
178 void EditProduct::secondary_sg_button()
179 {
180 double rc;
181
182 /*
183 * Get a sensible start value.
184 */
185 if (product->secondary_end_sg >= 0.990)
186 rc = get_fg(product->secondary_end_sg);
187 else
188 rc = get_fg(product->primary_end_sg);
189 qDebug() << "secondary_sg_button" << rc << product->secondary_end_sg;
190 ui->sec_sgEdit->setValue(rc);
191 }
192
193
194 void EditProduct::secondary_date_changed(QDate val)
195 {
196 product->secondary_end_date = ui->sec_enddateEdit->nullDate();
197 qDebug() << "secondary_date_changed" << val << product->secondary_end_date;
198 is_changed();
199 setStage();
200 }
201
202
203 void EditProduct::secondary_date_button()
204 {
205 ui->sec_enddateEdit->setDate(QDate::currentDate());
206 }
207
208
209 void EditProduct::secondary_date_ack()
210 {
211 int rc = QMessageBox::warning(this, tr("Confirm secondary"), tr("Confirm that the secondary fermentation data is correct"),
212 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
213
214 if (rc == QMessageBox::No)
215 return;
216
217 product->stage = PROD_STAGE_TERTIARY;
218 setStage();
219 is_changed();
220 }
221
222
223 void EditProduct::tertiary_temp_changed(double val)
224 {
225 product->tertiary_temp = val;
226 is_changed();
227 setStage();
228 }
229
230
231 void EditProduct::tertiary_sg_changed(double val)
232 {
233 qDebug() << "tertiary_sg_changed" << val;
234 if (product->fg == 0 && val == 0.001) {
235 product->fg = 0.990;
236 const QSignalBlocker blocker1(ui->tert_sgEdit);
237 ui->tert_sgEdit->setValue(0.990);
238 } else {
239 product->fg = val;
240 }
241 ui->tert_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->fg));
242 product->package_abv = Utils::abvol(product->brew_fermenter_sg, product->fg);
243 ui->tert_abvShow->setValue(product->package_abv);
244 ui->pack_abvShow->setValue(product->package_abv);
245 is_changed();
246 setStage();
247 }
248
249
250 void EditProduct::tertiary_sg_button()
251 {
252 double rc;
253
254 /*
255 * Get a sensible start value.
256 */
257 if (product->fg >= 0.990)
258 rc = get_fg(product->fg);
259 else
260 rc = get_fg(product->secondary_end_sg);
261 qDebug() << "tertiary_sg_button" << rc << product->fg;
262 ui->tert_sgEdit->setValue(rc);
263 }
264
265
266 void EditProduct::ferm_log1_button()
267 {
268 }
269
270
271 void EditProduct::ferm_log2_button()
272 {
273 }
274
275

mercurial