src/CalibrateiSpindel.cpp

Sat, 14 Oct 2023 11:23:24 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 14 Oct 2023 11:23:24 +0200
changeset 505
7ae4d022cf8f
parent 504
ea7cf64c9a6c
child 506
ea07f6c97a69
permissions
-rw-r--r--

Load and show current calibration 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"
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include "MainWindow.h"
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
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 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
26 {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 QSqlQuery query;
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 #ifdef DEBUG_MONITOR
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 qDebug() << "CalibrateiSpindel record:" << id;
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 #endif
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
33 ui->setupUi(this);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
34 this->recno = id;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
35 setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
36 WindowTitle();
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 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
39 query.bindValue(":recno", this->recno);
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 query.exec();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 if (query.next()) {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 _node = query.value("node").toString();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 _alias = query.value("alias").toString();
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
45 ui->nameEdit->setText(_node+"/"+_alias);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
46
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
47 QJsonParseError parseError;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
48 const auto& json = query.value("calibrate").toString();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
49
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
50 if (!json.trimmed().isEmpty()) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
51 const auto& formattedJson = QString("%1").arg(json);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
52 QJsonDocument jsonResponse = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
53 if (parseError.error != QJsonParseError::NoError) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
54 qWarning() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
55 } else {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
56
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
57 QJsonObject jsonObj = jsonResponse.object();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
58 // qDebug() << "polyData: " << jsonObj["polyData"].toArray();
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 // qDebug() << polyData;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
61 for (int i = 0; i < polyData.size(); i++) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
62 Old[i] = New[i] = polyData.at(i).toDouble();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
63 qDebug() << i << New[i];
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
64 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
65 _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
66 ui->oldEdit->setText(_data_old);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
67
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
68 qDebug() << "calData: " << jsonObj["calData"].toArray();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
69 QJsonArray calData = jsonObj.value("calData").toArray();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
70 qDebug() << calData;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
71 totaldata = 0;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
72 for (int i = 0; i < calData.size(); i++) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
73 QJsonObject calObj = calData.at(i).toObject();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
74 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
75 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
76 oCal[i].sg = nCal[i].sg = Utils::plato_to_sg(oCal[i].plato);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
77 totaldata++;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
78 }
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 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
81 }
503
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 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
85 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
86 // 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
87 emit refreshTable();
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
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
91 void CalibrateiSpindel::refreshTable()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
92 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
93 QString w;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
94 QWidget* pWidget;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
95 QHBoxLayout* pLayout;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
96 double d;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
97
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
98 qDebug() << "refreshTable" << totaldata;
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 /*
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
101 * 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
102 * 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
103 */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
104 this->ignoreChanges = true;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
105
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
106 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
107 ui->dataTable->setColumnCount(4);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
108 ui->dataTable->setColumnWidth(0, 100); /* SG */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
109 ui->dataTable->setColumnWidth(1, 100); /* °Plato */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
110 ui->dataTable->setColumnWidth(2, 100); /* Tilt angle */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
111 ui->dataTable->setColumnWidth(3, 55); /* Del button */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
112 ui->dataTable->setHorizontalHeaderLabels(labels);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
113 ui->dataTable->verticalHeader()->hide();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
114 ui->dataTable->setRowCount(totaldata);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
115
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
116 for (int i = 0; i < totaldata; i++) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
117 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
118
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
119 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
120 QTableWidgetItem *item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
121 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
122 ui->dataTable->setItem(i, 0, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
123
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
124 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
125 item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
126 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
127 ui->dataTable->setItem(i, 1, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
128
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
129 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
130 item = new QTableWidgetItem(w);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
131 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
132 ui->dataTable->setItem(i, 2, item);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
133
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
134 /* Add the Delete row button */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
135 pWidget = new QWidget();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
136 QPushButton* btn_del = new QPushButton();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
137 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
138 btn_del->setText(tr("Del"));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
139 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
140 pLayout = new QHBoxLayout(pWidget);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
141 pLayout->addWidget(btn_del);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
142 pLayout->setContentsMargins(5, 0, 5, 0);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
143 pWidget->setLayout(pLayout);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
144 ui->dataTable->setCellWidget(i, 3, pWidget);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
145 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
146
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
147 this->ignoreChanges = false;
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 CalibrateiSpindel::~CalibrateiSpindel()
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 {
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
153 delete ui;
503
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 void CalibrateiSpindel::on_quitButton_clicked()
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 {
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 this->close();
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 this->setResult(1);
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 }
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162
61c114afb0ee Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163
505
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
164 void CalibrateiSpindel::on_saveButton_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
165 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
166 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
167
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
168
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
169 void CalibrateiSpindel::on_deleteRow_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
170 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
171 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
172 int row = pb->objectName().toInt();
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
173 qDebug() << "Delete row" << row;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
174 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
175
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
176
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
177 void CalibrateiSpindel::on_addButton_clicked()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
178 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
179 qDebug() << "Add row" << totaldata;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
180 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
181
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
182
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
183 void CalibrateiSpindel::cell_Changed(int nRow, int nCol)
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
184 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
185 QString w;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
186
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
187 if (this->ignoreChanges)
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
188 return;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
189
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
190 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
191
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
192 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
193
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
194
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
195 /*
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
196 * Window header, mark any change with '**'
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
197 */
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
198 void CalibrateiSpindel::WindowTitle()
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
199 {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
200 QString txt;
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
201
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
202 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
203
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
204 if (this->textIsChanged) {
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
205 txt.append((QString(" **")));
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
206 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
207 setWindowTitle(txt);
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
208 }
7ae4d022cf8f Load and show current calibration data.
Michiel Broek <mbroek@mbse.eu>
parents: 504
diff changeset
209

mercurial