2
* ScaleRecipeTool.cpp is part of Brewtarget, and is Copyright Philip G. Lee
3
* (rocketman768@gmail.com), 2009.
5
* Brewtarget is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* Brewtarget is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include "ScaleRecipeTool.h"
20
#include "brewtarget.h"
21
#include <QMessageBox>
23
ScaleRecipeTool::ScaleRecipeTool(QWidget* parent) : QDialog(parent)
28
connect(buttonBox, SIGNAL(accepted()), this, SLOT(scale()) );
29
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()) );
32
void ScaleRecipeTool::setRecipe(Recipe* rec)
37
void ScaleRecipeTool::show()
39
// Set the batch size display to the current batch size.
42
double batchSize = recObs->getBatchSize_l();
43
lineEdit_newBatchSize->setText(Brewtarget::displayAmount(batchSize, Units::liters));
49
void ScaleRecipeTool::scale()
56
double currentBatchSize_l = recObs->getBatchSize_l();
57
double newBatchSize_l = Unit::qstringToSI(lineEdit_newBatchSize->text());
59
double ratio = newBatchSize_l / currentBatchSize_l;
61
// I think you want the equipment to be clean.
62
recObs->setEquipment(new Equipment());
63
recObs->setBatchSize_l(newBatchSize_l);
64
recObs->setBoilSize_l(newBatchSize_l);
66
size = recObs->getNumFermentables();
67
for( i = 0; i < size; ++i )
69
Fermentable* ferm = recObs->getFermentable(i);
73
ferm->setAmount_kg(ferm->getAmount_kg() * ratio);
76
size = recObs->getNumHops();
77
for( i = 0; i < size; ++i )
79
Hop* hop = recObs->getHop(i);
83
hop->setAmount_kg(hop->getAmount_kg() * ratio);
86
size = recObs->getNumMiscs();
87
for( i = 0; i < size; ++i )
89
Misc* misc = recObs->getMisc(i);
93
misc->setAmount( misc->getAmount() * ratio );
96
size = recObs->getNumWaters();
97
for( i = 0; i < size; ++i )
99
Water* water = recObs->getWater(i);
103
water->setAmount_l(water->getAmount_l() * ratio);
106
Mash *mash = recObs->getMash();
110
size = mash->getNumMashSteps();
111
for( i = 0; i < size; ++i )
113
MashStep* step = mash->getMashStep(i);
117
// Reset all these to zero so that the user
118
// will know to re-run the mash wizard.
119
step->setDecoctionAmount_l(0);
120
step->setInfuseAmount_l(0);
123
// I don't think I should scale the yeasts.
125
// Let the user know what happened.
126
QMessageBox::information(this, tr("Recipe Scaled"),
127
tr("The equipment and mash have been reset due to the fact that mash temperatures do not scale easily. Please re-run the mash wizard.") );
b'\\ No newline at end of file'