-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysisform.cpp
64 lines (55 loc) · 1.94 KB
/
analysisform.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "analysisform.h"
#include "ui_analysisform.h"
#include <QDebug>
AnalysisForm::AnalysisForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::AnalysisForm)
{
ui->setupUi(this);
this->tableModel = new QStandardItemModel(0, 4);
ui->tableView->setModel(this->tableModel);
this->resetTableModel();
}
AnalysisForm::~AnalysisForm()
{
delete ui;
delete this->tableModel;
}
void AnalysisForm::resetTableModel()
{
this->tableModel->clear();
this->tableModel->setHorizontalHeaderItem(0, new QStandardItem(QString("Start")));
this->tableModel->setHorizontalHeaderItem(1, new QStandardItem(QString("End")));
this->tableModel->setHorizontalHeaderItem(2, new QStandardItem(QString("Curvature")));
this->tableModel->setHorizontalHeaderItem(3, new QStandardItem(QString("Radius")));
}
void AnalysisForm::closeEvent(QCloseEvent *event)
{
emit closing();
event->accept();
}
void AnalysisForm::updateCurves(QVector<lunabotics::proto::Telemetry::Path::Curve> curves)
{
this->resetTableModel();
for (int i = 0; i < curves.size(); i++) {
lunabotics::proto::Telemetry::Path::Curve curve = curves.at(i);
qDebug() << curve.start_idx() << " " << curve.end_idx();
QStandardItem *item = new QStandardItem(QString::number(curve.start_idx()));
this->tableModel->setItem(i, 0, item);
item = new QStandardItem(QString::number(curve.end_idx()));
this->tableModel->setItem(i, 1, item);
item = new QStandardItem(QString::number(curve.curvature(), 'f', 2));
this->tableModel->setItem(i, 2, item);
item = new QStandardItem(QString::number(1/curve.curvature(), 'f', 2));
this->tableModel->setItem(i, 3, item);
}
}
void AnalysisForm::updateRadius(float minRadius)
{
if (minRadius >= 0) {
ui->minRadiusLabel->setText(QString("%1 m").arg(QString::number(minRadius, 'f', 5)));
}
else {
ui->minRadiusLabel->setText("? m");
}
}