151 } |
151 } |
152 is_changed(); |
152 is_changed(); |
153 } |
153 } |
154 |
154 |
155 |
155 |
156 void EditProduct::brew_volume_calc(double volume, double kettle_volume, double kettle_height, double est_volume, bool aboil) |
156 void EditProduct::brew_brix_changed(double val) |
|
157 { |
|
158 sg_return = Utils::brix_to_sg(val); |
|
159 } |
|
160 |
|
161 |
|
162 double EditProduct::brew_brix_edit(double sg, double sg_default) |
|
163 { |
|
164 double brix = 0.0; |
|
165 |
|
166 QDialog* dialog = new QDialog(this); |
|
167 dialog->resize(360, 110); |
|
168 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); |
|
169 buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
|
170 buttonBox->setGeometry(QRect(30, 60, 300, 32)); |
|
171 buttonBox->setLayoutDirection(Qt::LeftToRight); |
|
172 buttonBox->setOrientation(Qt::Horizontal); |
|
173 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); |
|
174 buttonBox->setCenterButtons(true); |
|
175 |
|
176 QLabel *brixLabel = new QLabel(dialog); |
|
177 brixLabel->setObjectName(QString::fromUtf8("brixLabel")); |
|
178 brixLabel->setText(tr("Refractometer Brix:")); |
|
179 brixLabel->setGeometry(QRect(10, 20, 161, 24)); |
|
180 brixLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
181 |
|
182 QDoubleSpinBox *brixEdit = new QDoubleSpinBox(dialog); |
|
183 brixEdit->setObjectName(QString::fromUtf8("brixEdit")); |
|
184 brixEdit->setGeometry(QRect(180, 20, 101, 24)); |
|
185 brixEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
186 brixEdit->setAccelerated(true); |
|
187 brixEdit->setDecimals(1); |
|
188 brixEdit->setMaximum(32.0); |
|
189 brixEdit->setSingleStep(0.1); |
|
190 |
|
191 if (sg > 1.001) |
|
192 brix = Utils::sg_to_brix(sg); |
|
193 else |
|
194 brix = Utils::sg_to_brix(sg_default); |
|
195 brixEdit->setValue(brix); |
|
196 |
|
197 connect(brixEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_brix_changed); |
|
198 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
|
199 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
|
200 |
|
201 dialog->setModal(true); |
|
202 dialog->exec(); |
|
203 if (dialog->result() == QDialog::Rejected) { |
|
204 sg_return = sg; |
|
205 } |
|
206 |
|
207 disconnect(brixEdit, nullptr, nullptr, nullptr); |
|
208 disconnect(buttonBox, nullptr, nullptr, nullptr); |
|
209 |
|
210 qDebug() << "brew_brix_edit(" << sg << sg_default << ") return" << sg_return; |
|
211 return sg_return; |
|
212 } |
|
213 |
|
214 |
|
215 void EditProduct::brew_volume_calc(double volume, double kettle_volume, double kettle_height, double est_volume, bool aboil, bool chiller) |
157 { |
216 { |
158 double k_cm; |
217 double k_cm; |
159 |
218 |
160 if (volume > 0) |
219 if ((chiller && volume > product->eq_chiller_volume) || (! chiller && volume > 0)) |
161 k_cm = Utils::kettle_cm(volume, kettle_volume, kettle_height); |
220 k_cm = Utils::kettle_cm(volume, kettle_volume, kettle_height); |
162 else |
221 else |
163 k_cm = Utils::kettle_cm(est_volume, kettle_volume, kettle_height); |
222 k_cm = Utils::kettle_cm(est_volume, kettle_volume, kettle_height); |
164 |
223 |
|
224 qDebug() << "brew_volume_calc(" << volume << kettle_volume << kettle_height << est_volume << aboil << chiller << ") cm:" << k_cm; |
|
225 |
165 QDialog* dialog = new QDialog(this); |
226 QDialog* dialog = new QDialog(this); |
166 dialog->resize(320, 110); |
227 if (chiller) |
|
228 dialog->resize(320, 140); |
|
229 else |
|
230 dialog->resize(320, 110); |
167 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); |
231 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); |
168 buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
232 buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
169 buttonBox->setGeometry(QRect(40, 65, 240, 32)); |
233 if (chiller) |
|
234 buttonBox->setGeometry(QRect(40, 95, 240, 32)); |
|
235 else |
|
236 buttonBox->setGeometry(QRect(40, 65, 240, 32)); |
170 buttonBox->setLayoutDirection(Qt::LeftToRight); |
237 buttonBox->setLayoutDirection(Qt::LeftToRight); |
171 buttonBox->setOrientation(Qt::Horizontal); |
238 buttonBox->setOrientation(Qt::Horizontal); |
172 buttonBox->setStandardButtons(QDialogButtonBox::Ok); |
239 buttonBox->setStandardButtons(QDialogButtonBox::Ok); |
173 buttonBox->setCenterButtons(true); |
240 buttonBox->setCenterButtons(true); |
174 |
241 |
187 cmEdit->setSuffix(tr(" cm")); |
254 cmEdit->setSuffix(tr(" cm")); |
188 cmEdit->setMaximum(kettle_height * 100); |
255 cmEdit->setMaximum(kettle_height * 100); |
189 cmEdit->setSingleStep(0.1); |
256 cmEdit->setSingleStep(0.1); |
190 cmEdit->setValue(k_cm); |
257 cmEdit->setValue(k_cm); |
191 |
258 |
|
259 if (chiller) { |
|
260 QLabel *opmLabel = new QLabel(dialog); |
|
261 opmLabel->setObjectName(QString::fromUtf8("opmLabel")); |
|
262 opmLabel->setText(tr("Measure with placed immersion chiller.")); |
|
263 opmLabel->setGeometry(QRect(10, 60, 300, 24)); |
|
264 opmLabel->setAlignment(Qt::AlignCenter); |
|
265 } |
|
266 |
192 if (aboil) |
267 if (aboil) |
193 connect(cmEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_aboil_cm_changed); |
268 connect(cmEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_aboil_cm_changed); |
194 else |
269 else |
195 connect(cmEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_preboil_cm_changed); |
270 connect(cmEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_preboil_cm_changed); |
196 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
271 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
340 void EditProduct::brew_aboilvol_changed(double val) |
422 void EditProduct::brew_aboilvol_changed(double val) |
341 { |
423 { |
342 if (product->brew_aboil_volume == 0) { |
424 if (product->brew_aboil_volume == 0) { |
343 product->brew_aboil_volume = product->batch_size * 1.04; |
425 product->brew_aboil_volume = product->batch_size * 1.04; |
344 const QSignalBlocker blocker1(ui->brew_aboilvolEdit); |
426 const QSignalBlocker blocker1(ui->brew_aboilvolEdit); |
345 ui->brew_aboilvolEdit->setValue(product->batch_size * 1.04); |
427 ui->brew_aboilvolEdit->setValue(product->brew_aboil_volume + product->eq_chiller_volume); |
346 } else { |
428 } else { |
347 product->brew_aboil_volume = val; |
429 product->brew_aboil_volume = val - product->eq_chiller_volume; |
348 } |
430 } |
349 is_changed(); |
431 is_changed(); |
350 calcEfficiencyAfterBoil(); |
432 calcEfficiencyAfterBoil(); |
351 } |
433 } |
352 |
434 |
353 |
435 |
354 void EditProduct::brew_aboil_cm_changed(double val) |
436 void EditProduct::brew_aboil_cm_changed(double val) |
355 { |
437 { |
356 double vol = Utils::kettle_vol(val, product->eq_kettle_volume, product->eq_kettle_height); |
438 double vol = Utils::kettle_vol(val, product->eq_kettle_volume, product->eq_kettle_height); |
357 product->brew_aboil_volume = vol; |
439 product->brew_aboil_volume = vol - product->eq_chiller_volume; |
358 const QSignalBlocker blocker1(ui->brew_aboilvolEdit); |
440 const QSignalBlocker blocker1(ui->brew_aboilvolEdit); |
359 ui->brew_aboilvolEdit->setValue(vol); |
441 ui->brew_aboilvolEdit->setValue(vol); |
360 is_changed(); |
442 is_changed(); |
361 calcEfficiencyAfterBoil(); |
443 calcEfficiencyAfterBoil(); |
362 } |
444 } |
363 |
445 |
364 |
446 |
|
447 void EditProduct::brew_aboil_brix_button() |
|
448 { |
|
449 product->brew_aboil_sg = brew_brix_edit(product->brew_aboil_sg, product->est_og3); |
|
450 ui->brew_aboilsgEdit->setValue(product->brew_aboil_sg); |
|
451 } |
|
452 |
|
453 |
365 void EditProduct::brew_aboil_button() |
454 void EditProduct::brew_aboil_button() |
366 { |
455 { |
367 brew_volume_calc(product->brew_aboil_volume, product->eq_kettle_volume, product->eq_kettle_height, product->batch_size * 1.04, true); |
456 brew_volume_calc(product->brew_aboil_volume + product->eq_chiller_volume, |
|
457 product->eq_kettle_volume, product->eq_kettle_height, |
|
458 (product->batch_size * 1.04) + product->eq_chiller_volume, |
|
459 true, (product->eq_chiller_volume > 0)); |
368 } |
460 } |
369 |
461 |
370 |
462 |
371 void EditProduct::brew_cooling_to_changed(double val) |
463 void EditProduct::brew_cooling_to_changed(double val) |
372 { |
464 { |