src/CalibrateiSpindel.cpp

Sat, 14 Oct 2023 16:10:14 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 14 Oct 2023 16:10:14 +0200
changeset 506
ea07f6c97a69
parent 505
7ae4d022cf8f
child 507
fa07b6c6238a
permissions
-rw-r--r--

Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.

503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * CalibrateiSpindel.cpp is part of bmsapp.
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "CalibrateiSpindel.h"
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
18 #include "../ui/ui_CalibrateiSpindel.h"
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "global.h"
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "Utils.h"
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
21 #include "polyfit.h"
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 #include "MainWindow.h"
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 CalibrateiSpindel::CalibrateiSpindel(int id, QWidget *parent) : QDialog(parent), ui(new Ui::CalibrateiSpindel)
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 QSqlQuery query;
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 #ifdef DEBUG_MONITOR
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 qDebug() << "CalibrateiSpindel record:" << id;
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 #endif
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
34 ui->setupUi(this);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
35 this->recno = id;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
36 setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
37 WindowTitle();
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 query.prepare("SELECT node,alias,calibrate FROM mon_ispindels WHERE record = :recno");
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 query.bindValue(":recno", this->recno);
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 query.exec();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 if (query.next()) {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 _node = query.value("node").toString();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 _alias = query.value("alias").toString();
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
46 ui->nameEdit->setText(_node+"/"+_alias);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
47
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
48 QJsonParseError parseError;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
49 const auto& json = query.value("calibrate").toString();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
50
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
51 if (!json.trimmed().isEmpty()) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
52 const auto& formattedJson = QString("%1").arg(json);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
53 QJsonDocument jsonResponse = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
54 if (parseError.error != QJsonParseError::NoError) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
55 qWarning() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
56 } else {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
57
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
58 QJsonObject jsonObj = jsonResponse.object();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
59 QJsonArray polyData = jsonObj.value("polyData").toArray();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
60 for (int i = 0; i < polyData.size(); i++) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
61 Old[i] = New[i] = polyData.at(i).toDouble();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
62 qDebug() << i << New[i];
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
63 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
64 _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');
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
65 ui->oldEdit->setText(_data_old);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
66
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
67 qDebug() << "calData: " << jsonObj["calData"].toArray();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
68 QJsonArray calData = jsonObj.value("calData").toArray();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
69 qDebug() << calData;
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
70 oldtotal = 0;
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
71 for (int i = 0; i < calData.size(); i++) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
72 QJsonObject calObj = calData.at(i).toObject();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
73 oCal[i].plato = nCal[i].plato = calObj["plato"].toDouble();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
74 oCal[i].angle = nCal[i].angle = calObj["angle"].toDouble();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
75 oCal[i].sg = nCal[i].sg = Utils::plato_to_sg(oCal[i].plato);
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
76 oldtotal++;
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
77 }
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
78 newtotal = oldtotal;
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
79 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
80 }
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
84 connect(ui->dataTable, SIGNAL(cellChanged(int, int)), this, SLOT(cell_Changed(int, int)));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
85 // connect(parent, SIGNAL(updateiSpindel(QString)), this, SLOT(refreshiSpindel(QString)));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
86 emit refreshTable();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
87 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
88
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
89
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
90 void CalibrateiSpindel::refreshTable()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
91 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
92 QString w;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
93 QWidget* pWidget;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
94 QHBoxLayout* pLayout;
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
95 double d, x[12], y[12];
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
96
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
97 qDebug() << "refreshTable" << oldtotal << newtotal;
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
98
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
99 /*
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
100 * During filling the table turn off the cellChanged signal because every cell that is filled
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
101 * triggers the cellChanged signal. The QTableWidget has no better signal to use.
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
102 */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
103 this->ignoreChanges = true;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
104
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
105 const QStringList labels({tr("SG"), tr("°Plato"), tr("Angle"), tr("Del")});
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
106 ui->dataTable->setColumnCount(4);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
107 ui->dataTable->setColumnWidth(0, 100); /* SG */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
108 ui->dataTable->setColumnWidth(1, 100); /* °Plato */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
109 ui->dataTable->setColumnWidth(2, 100); /* Tilt angle */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
110 ui->dataTable->setColumnWidth(3, 55); /* Del button */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
111 ui->dataTable->setHorizontalHeaderLabels(labels);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
112 ui->dataTable->verticalHeader()->hide();
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
113 ui->dataTable->setRowCount(newtotal);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
114
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
115 for (int i = 0; i < 12; i++) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
116 x[i] = y[i] = 0;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
117 }
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
118
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
119 for (int i = 0; i < newtotal; i++) {
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
120 qDebug() << i << nCal[i].sg << nCal[i].plato << nCal[i].angle;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
121
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
122 y[i] = nCal[i].plato;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
123 x[i] = nCal[i].angle;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
124
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
125 w = QString("%1").arg(nCal[i].sg, 1, 'f', 4, '0');
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
126 QTableWidgetItem *item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
127 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
128 ui->dataTable->setItem(i, 0, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
129
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
130 w = QString("%1").arg(nCal[i].plato, 1, 'f', 3, '0');
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
131 item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
132 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
133 ui->dataTable->setItem(i, 1, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
134
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
135 w = QString("%1").arg(nCal[i].angle, 1, 'f', 5, '0');
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
136 item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
137 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
138 ui->dataTable->setItem(i, 2, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
139
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
140 /* Add the Delete row button */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
141 pWidget = new QWidget();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
142 QPushButton* btn_del = new QPushButton();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
143 btn_del->setObjectName(QString("%1").arg(i)); /* Send row with the button */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
144 btn_del->setText(tr("Del"));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
145 connect(btn_del, SIGNAL(clicked()), this, SLOT(on_deleteRow_clicked()));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
146 pLayout = new QHBoxLayout(pWidget);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
147 pLayout->addWidget(btn_del);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
148 pLayout->setContentsMargins(5, 0, 5, 0);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
149 pWidget->setLayout(pLayout);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
150 ui->dataTable->setCellWidget(i, 3, pWidget);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
151 }
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
152 int rc = Polyfit::polyfit(newtotal, x, y, 4, New);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
153 qDebug() << "poly:" << rc << New[0] << New[1] << New[2] << New[3];
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
154
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
155 _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');
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
156 ui->newEdit->setText(_data_new);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
157
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
158 /*
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
159 * Check the new formula against the old formula.
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
160 */
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
161 this->textIsChanged = (_data_old.compare(_data_new) == 0) ? false:true;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
162 qDebug() << "changed" << this->textIsChanged << _data_old.compare(_data_new);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
163 CalibrateiSpindel::WindowTitle();
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
164
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
165 new_plot = new QLineSeries();
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
166 old_plot = new QLineSeries();
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
167
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
168 for (int i = 0; i < oldtotal; i++) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
169 old_plot->append(oCal[i].angle, oCal[i].plato);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
170 }
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
171 for (int i = 0; i < newtotal; i++) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
172 new_plot->append(nCal[i].angle, nCal[i].plato);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
173 }
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
174
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
175 old_plot->setName(tr("Old"));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
176 new_plot->setName(tr("New"));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
177
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
178 chart = new QChart();
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
179 chart->setTitle(tr("Calibration plot"));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
180 chart->addSeries(old_plot);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
181 chart->addSeries(new_plot);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
182
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
183 QValueAxis *axisX = new QValueAxis;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
184 axisX->setRange(10, 80);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
185 axisX->setTickCount(8);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
186 axisX->setLabelFormat("%.0f");
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
187 axisX->setTitleText(tr("Angle"));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
188 axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
189 chart->addAxis(axisX, Qt::AlignBottom);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
190 old_plot->attachAxis(axisX);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
191 new_plot->attachAxis(axisX);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
192
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
193 QValueAxis *axisY = new QValueAxis;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
194 axisY->setRange(0, 20);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
195 axisY->setTickCount(11);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
196 axisY->setLabelFormat("%.1f");
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
197 axisY->setTitleText("Plato");
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
198 axisY->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
199 chart->addAxis(axisY, Qt::AlignLeft);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
200 old_plot->attachAxis(axisY);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
201 new_plot->attachAxis(axisY);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
202
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
203 ui->chartView->setRenderHint(QPainter::Antialiasing);
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
204 ui->chartView->setChart(chart);
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
205
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
206 this->ignoreChanges = false;
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 CalibrateiSpindel::~CalibrateiSpindel()
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 {
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
212 delete ui;
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 void CalibrateiSpindel::on_quitButton_clicked()
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 this->close();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 this->setResult(1);
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
223 void CalibrateiSpindel::on_saveButton_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
224 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
225 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
226
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
227
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
228 void CalibrateiSpindel::on_deleteRow_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
229 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
230 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
231 int row = pb->objectName().toInt();
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
232 qDebug() << "Delete row" << row << newtotal;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
233
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
234 if (newtotal < 4) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
235 QMessageBox::warning(this, tr("iSpindel calibrate"), tr("You cannot delete too many rows."));
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
236 return;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
237 }
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
238
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
239 if (row == (newtotal - 1)) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
240 qDebug() << "Delete last row";
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
241 newtotal--;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
242 } else {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
243 newtotal--;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
244 for (int i = row; i < newtotal; i++) {
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
245 nCal[i].sg = nCal[i+1].sg;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
246 nCal[i].plato = nCal[i+1].plato;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
247 nCal[i].angle = nCal[i+1].angle;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
248 qDebug() << i << " < " << i+1;
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
249 }
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
250 }
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
251
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
252 emit refreshTable();
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
253 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
254
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
255
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
256 void CalibrateiSpindel::on_addButton_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
257 {
506
ea07f6c97a69 Added Simple polynomial fitting functions written by Henry M. Forson. Added a graph that displays the old and new iSpindel calibration curve. Implemented delete row from the data.
Michiel Broek <mbroek@mbse.eu>
parents: 505
diff changeset
258 qDebug() << "Add row" << newtotal;
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
259 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
260
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
261
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
262 void CalibrateiSpindel::cell_Changed(int nRow, int nCol)
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
263 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
264 QString w;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
265
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
266 if (this->ignoreChanges)
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
267 return;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
268
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
269 qDebug() << "Cell at row " + QString::number(nRow) + " column " + QString::number(nCol) + " was changed.";
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
270
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
271 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
272
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
273
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
274 /*
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
275 * Window header, mark any change with '**'
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
276 */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
277 void CalibrateiSpindel::WindowTitle()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
278 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
279 QString txt;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
280
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
281 txt = QString(tr("BMSapp - Calibrate iSpindel %1").arg(this->recno));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
282
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
283 if (this->textIsChanged) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
284 txt.append((QString(" **")));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
285 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
286 setWindowTitle(txt);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
287 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
288

mercurial