-
Notifications
You must be signed in to change notification settings - Fork 0
/
p2predictions.cpp
112 lines (90 loc) · 2.91 KB
/
p2predictions.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "p2predictions.h"
#include "ui_p2predictions.h"
p2Predictions::p2Predictions(QWidget *parent) : QWidget(parent), ui(new Ui::p2Predictions)
{
ui->setupUi(this);
setIrisSpinBoxes();
//connection for updating date and time
connect(&_p2Landing, SIGNAL(dateTimeUpdate()), this, SLOT(updatePredictionsDateTime()));
}
p2Predictions::~p2Predictions()
{
delete ui;
}
void p2Predictions::on_minimizeButton_clicked()
{
emit backToLandingFromPredictions();
}
void p2Predictions::on_closeButton_clicked()
{
close();
resetIrisSpinBoxes();
ui->irisPredictionLabel->setText("");
ui->stackedWidget->setCurrentIndex(0);
emit backToLandingFromPredictions();
}
void p2Predictions::on_IrisNavButton_clicked()
{
ui->stackedWidget->setCurrentIndex(1);
}
void p2Predictions::on_TitanicNavButton_clicked()
{
ui->stackedWidget->setCurrentIndex(2);
}
void p2Predictions::on_BostonNavButton_clicked()
{
ui->stackedWidget->setCurrentIndex(3);
}
void p2Predictions::on_backToHome_clicked()
{
emit homeFromPredictionsClicked();
}
void p2Predictions::updatePredictionsDateTime()
{
ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime());
}
void p2Predictions::on_SubmitButton_clicked()
{
double sepalLength = ui->sepalLengthSpin->value();
double sepalWidth = ui->sepalWidthSpin->value();
double petalLength = ui->petalLengthSpin->value();
double petalWidth = ui->petalWidthSpin->value();
callIrisScript(sepalLength, sepalWidth, petalLength, petalWidth);
}
void p2Predictions::callIrisScript(double sepalLength, double sepalWidth, double petalLength, double petalWidth)
{
QStringList params = QStringList() << "/home/pi/Documents/IrisPredictions.py"
<< QString::number(sepalLength)
<< QString::number(sepalWidth)
<< QString::number(petalLength)
<< QString::number(petalWidth);
QProcess *process = new QProcess();
process->start("python3", params);
process->waitForFinished(-1);
QString irisPrediction = process->readAll();
ui->irisPredictionLabel->setText(irisPrediction);
process->close();
}
void p2Predictions::setIrisSpinBoxes()
{
ui->sepalLengthSpin->setRange(4.3,7.9);
ui->sepalLengthSpin->setSingleStep(0.10);
ui->sepalWidthSpin->setRange(2.0,4.4);
ui->sepalWidthSpin->setSingleStep(0.10);
ui->petalLengthSpin->setRange(1.0,6.9);
ui->petalLengthSpin->setSingleStep(0.10);
ui->petalWidthSpin->setRange(0.1,2.5);
ui->petalWidthSpin->setSingleStep(0.10);
}
void p2Predictions::resetIrisSpinBoxes()
{
ui->sepalLengthSpin->setValue(4.3);
ui->sepalWidthSpin->setValue(2.0);
ui->petalLengthSpin->setValue(1.0);
ui->petalWidthSpin->setValue(0.1);
}
void p2Predictions::on_resetButton_clicked()
{
resetIrisSpinBoxes();
ui->irisPredictionLabel->setText("");
}