--- a/src/CalibrateiSpindel.cpp Mon Oct 16 11:39:20 2023 +0200 +++ b/src/CalibrateiSpindel.cpp Mon Oct 16 13:25:58 2023 +0200 @@ -57,7 +57,6 @@ _node = query.value("node").toString(); _alias = query.value("alias").toString(); ui->nameEdit->setText(_node+"/"+_alias); - qDebug() << query.value("calibrate").toString(); QJsonParseError parseError; const auto& json = query.value("calibrate").toString(); @@ -73,14 +72,11 @@ QJsonArray polyData = jsonObj.value("polyData").toArray(); for (int i = 0; i < polyData.size(); i++) { Old[i] = New[i] = polyData.at(i).toDouble(); - qDebug() << i << New[i]; } _data_old = QString("(%1 * x^3) + (%2 * x^2) + (%3 * x) + %4").arg(Old[0], 0, 'f', 9, '0').arg(Old[1], 0, 'f', 9, '0').arg(Old[2], 0, 'f', 9, '0').arg(Old[3], 0, 'f', 9, '0'); ui->oldEdit->setText(_data_old); - qDebug() << "calData: " << jsonObj["calData"].toArray(); QJsonArray calData = jsonObj.value("calData").toArray(); - qDebug() << calData; oldtotal = 0; for (int i = 0; i < calData.size(); i++) { QJsonObject calObj = calData.at(i).toObject(); @@ -99,7 +95,6 @@ } connect(ui->dataTable, SIGNAL(cellChanged(int, int)), this, SLOT(cell_Changed(int, int))); -// connect(parent, SIGNAL(updateiSpindel(QString)), this, SLOT(refreshiSpindel(QString))); emit refreshTable(); } @@ -140,7 +135,6 @@ this->dataHasErrors = false; for (int i = 0; i < newtotal; i++) { - qDebug() << i << nCal[i].sg << nCal[i].plato << nCal[i].angle; y[i] = nCal[i].plato; x[i] = nCal[i].angle; @@ -195,7 +189,6 @@ ui->dataTable->setCellWidget(i, 3, pWidget); } int rc = Polyfit::polyfit(newtotal, x, y, 4, New); - qDebug() << "poly:" << rc << New[0] << New[1] << New[2] << New[3]; _data_new = QString("(%1 * x^3) + (%2 * x^2) + (%3 * x) + %4").arg(New[0], 0, 'f', 9, '0').arg(New[1], 0, 'f', 9, '0').arg(New[2], 0, 'f', 9, '0').arg(New[3], 0, 'f', 9, '0'); ui->newEdit->setText(_data_new); @@ -204,7 +197,6 @@ * Check the new formula against the old formula. */ this->textIsChanged = (_data_old.compare(_data_new) == 0) ? false:true; - qDebug() << "changed" << this->textIsChanged << _data_old.compare(_data_new); CalibrateiSpindel::WindowTitle(); new_plot = new QLineSeries(); @@ -255,6 +247,7 @@ CalibrateiSpindel::~CalibrateiSpindel() { delete ui; + emit entry_changed(); } @@ -336,19 +329,8 @@ return; } - if (row == (newtotal - 1)) { - qDebug() << "Delete last row"; - newtotal--; - } else { - newtotal--; - for (int i = row; i < newtotal; i++) { - nCal[i].sg = nCal[i+1].sg; - nCal[i].plato = nCal[i+1].plato; - nCal[i].angle = nCal[i+1].angle; - qDebug() << i << " < " << i+1; - } - } - + nCal.removeAt(row); + newtotal--; emit refreshTable(); } @@ -356,6 +338,17 @@ void CalibrateiSpindel::on_addButton_clicked() { qDebug() << "Add row" << newtotal; + this->ignoreChanges = true; + + Calibrate c; + c.plato = 10.0; + c.angle = 50.0; + c.sg = Utils::plato_to_sg(10.0); + nCal.append(c); + newtotal++; + + this->ignoreChanges = false; + emit refreshTable(); } @@ -376,7 +369,6 @@ } nCal[nRow].sg = d; nCal[nRow].plato = Utils::sg_to_plato(d); - qDebug() << "sg" << nCal[nRow].sg << "plato" << nCal[nRow].plato; } else if (nCol == 1) { double d = ui->dataTable->item(nRow, 1)->text().toDouble(); if (d < 0 || d > 25) { @@ -385,7 +377,6 @@ } nCal[nRow].plato = d; nCal[nRow].sg = Utils::plato_to_sg(d); - qDebug() << "sg" << nCal[nRow].sg << "plato" << nCal[nRow].plato; } else if (nCol == 2) { double d = ui->dataTable->item(nRow, 2)->text().toDouble(); if (d < 10 || d > 80) {