Wed, 11 May 2022 11:33:29 +0200
Added field to show the needed cells. Colors in the starter table for good and error results.
src/EditProductTab6.cpp | file | annotate | diff | comparison | revisions | |
ui/EditProduct.ui | file | annotate | diff | comparison | revisions |
--- a/src/EditProductTab6.cpp Sat May 07 13:55:36 2022 +0200 +++ b/src/EditProductTab6.cpp Wed May 11 11:33:29 2022 +0200 @@ -243,6 +243,7 @@ initcells = (product->yeasts.at(i).y_cells / 1000000000) * product->yeasts.at(i).y_amount * (product->starter_viability / 100.0); needed = round(product->yeast_pitchrate * volume * plato * 10.0) / 10.0; + ui->neededShow->setValue(needed); if (needed > initcells) { maybe_starter = true; } @@ -390,6 +391,8 @@ item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if ((result.irate < 25) || (result.irate > 100)) + item->setForeground(QBrush(QColor(Qt::red))); ui->starterTable->setItem(step -1, 2, item); item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); @@ -398,10 +401,15 @@ item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); ui->starterTable->setItem(step -1, 4, item); item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if (result.growf < 1) + item->setForeground(QBrush(QColor(Qt::red))); + if ((stype > 0) && (result.growf > 3)) + item->setForeground(QBrush(QColor(Qt::red))); ui->starterTable->setItem(step -1, 5, item); pWidget = new QWidget(); @@ -429,188 +437,65 @@ */ qDebug() << " calcSteps() recalculate"; - if (product->prop_volume[0] > 0) { - result = calcStep(product->prop_volume[0] * 1000, product->prop_type[0], tcells); - ui->starterTable->setRowCount(1); - item = new QTableWidgetItem(starters[product->prop_type[0]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(0, 0, item); + for (step = 0; step < 4; step++) { + if (product->prop_volume[step] > 0) { + result = calcStep(product->prop_volume[step] * 1000, product->prop_type[step], tcells); + ui->starterTable->setRowCount(step + 1); + item = new QTableWidgetItem(starters[product->prop_type[step]]); + item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); + ui->starterTable->setItem(step, 0, item); - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 1, item); + item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->starterTable->setItem(step, 1, item); - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 2, item); + item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if ((result.irate < 25) || (result.irate > 100)) + item->setForeground(QBrush(QColor(Qt::red))); + ui->starterTable->setItem(step, 2, item); - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 3, item); + item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->starterTable->setItem(step, 3, item); - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 4, item); + item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); + ui->starterTable->setItem(step, 4, item); - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 5, item); + item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if (result.growf < 1) + item->setForeground(QBrush(QColor(Qt::red))); + if ((stype > 0) && (result.growf > 3)) + item->setForeground(QBrush(QColor(Qt::red))); + ui->starterTable->setItem(step, 5, item); - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("0")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(0, 6, pWidget); + pWidget = new QWidget(); + QToolButton* btn_edit = new QToolButton(); + btn_edit->setObjectName(QString("%1").arg(step)); /* Send row with the button */ + btn_edit->setIcon(iconT); + connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); + pLayout = new QHBoxLayout(pWidget); + pLayout->addWidget(btn_edit); + pLayout->setContentsMargins(5, 0, 5, 0); + pWidget->setLayout(pLayout); + ui->starterTable->setCellWidget(step, 6, pWidget); - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; - product->prop_type[1] = product->prop_type[2] = product->prop_type[3] = 0; - return; - } else if (product->prop_volume[1] == 0) { // Extra step needed, start with the same size. - product->prop_volume[1] = product->prop_volume[0]; - product->prop_type[1] = product->prop_type[0]; + tcells = result.totcells; + if (result.totcells > needed) { // Hit the target + for (int i = step + 1; i < 4; i++) { + product->prop_volume[i] = 0; + product->prop_type[i] = 0; + } + return; + } else if ((step < 3) && (product->prop_volume[step + 1] == 0)) { // Extra step needed, start with the same size. + product->prop_volume[step + 1] = product->prop_volume[step]; + product->prop_type[step + 1] = product->prop_type[step]; + } } } - if (product->prop_volume[1] > 0) { - result = calcStep(product->prop_volume[1] * 1000, product->prop_type[1], tcells); - ui->starterTable->setRowCount(2); - item = new QTableWidgetItem(starters[product->prop_type[1]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(1, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("1")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(1, 6, pWidget); - - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - product->prop_volume[2] = product->prop_volume[3] = 0; - product->prop_type[2] = product->prop_type[3] = 0; - return; - } else if (product->prop_volume[2] == 0) { // Extra step needed, start with the same size. - product->prop_volume[2] = product->prop_volume[1]; - product->prop_type[2] = product->prop_type[1]; - } - } - if (product->prop_volume[2] > 0) { - result = calcStep(product->prop_volume[2] * 1000, product->prop_type[2], tcells); - ui->starterTable->setRowCount(3); - item = new QTableWidgetItem(starters[product->prop_type[2]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(2, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("2")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(2, 6, pWidget); - - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - product->prop_volume[3] = 0; - product->prop_type[3] = 0; - return; - } else if (product->prop_volume[3] == 0) { // Extra step needed, start with the same size. - product->prop_volume[3] = product->prop_volume[2]; - product->prop_type[3] = product->prop_type[2]; - } - } - if (product->prop_volume[3] > 0) { - result = calcStep(product->prop_volume[3] * 1000, product->prop_type[3], tcells); - ui->starterTable->setRowCount(4); - item = new QTableWidgetItem(starters[product->prop_type[3]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(3, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("3")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(3, 6, pWidget); - } } }
--- a/ui/EditProduct.ui Sat May 07 13:55:36 2022 +0200 +++ b/ui/EditProduct.ui Wed May 11 11:33:29 2022 +0200 @@ -3103,6 +3103,53 @@ </size> </property> </widget> + <widget class="QLabel" name="neededLabel"> + <property name="geometry"> + <rect> + <x>360</x> + <y>40</y> + <width>181</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Need million cells:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QDoubleSpinBox" name="neededShow"> + <property name="geometry"> + <rect> + <x>550</x> + <y>40</y> + <width>91</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::NoButtons</enum> + </property> + <property name="accelerated"> + <bool>false</bool> + </property> + <property name="decimals"> + <number>1</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="value"> + <double>0.000000000000000</double> + </property> + </widget> </widget> <widget class="QWidget" name="yeastDry"> <widget class="QLabel" name="label_2">