-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
122 lines (103 loc) · 2.8 KB
/
mainwindow.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
113
114
115
116
117
118
119
120
121
122
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
#include "globals.h"
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MainWindow::MakePlot();
angleCorrectionPlot = new AngleCorrection(this);
angleCorrectionPlot->show();
}
MainWindow::~MainWindow()
{
delete ui;
delete newCurve;
delete ePlot;
delete angleCorrectionPlot;
}
// Initial Plot
void MainWindow::MakePlot()
{
QVector<double> x, y, t;
this->newCurve = new QCPCurve(ui->customPlot->xAxis, ui->customPlot->yAxis);
ui->customPlot->addPlottable(this->newCurve);
x.append(0);
y.append(0);
this->newCurve->setData(x, y);
QPen pen;
pen.setColor(Qt::blue);
pen.setWidth(2);
this->newCurve->setPen(pen);
ui->customPlot->yAxis->setLabelFont(QFont("Helvetica",15));
ui->customPlot->xAxis->setTickLabelFont(QFont("Helvetica",12));
ui->customPlot->xAxis->setLabelFont(QFont("Helvetica",15));
ui->customPlot->yAxis->setTickLabelFont(QFont("Helvetica",12));
ui->customPlot->xAxis->setLabel("X (cm)");
ui->customPlot->yAxis->setLabel("Y (cm)");
ui->customPlot->xAxis->setRange(-100, 100);
ui->customPlot->yAxis->setRange(-100, 100);
ui->customPlot->replot();
}
// Update Plot - Add X,Y
void MainWindow::UpdatePlot(double x, double y)
{
this->newCurve->addData(x, y);
if (x > 90 || y > 90){
ui->customPlot->yAxis->setRange(-200, 200);
ui->customPlot->xAxis->setRange(-200, 200);
}
if (x > 190 || y > 190){
ui->customPlot->yAxis->setRange(-400, 400);
ui->customPlot->xAxis->setRange(-400, 400);
}
if (x > 390 || y > 390){
ui->customPlot->yAxis->setRange(-800, 800);
ui->customPlot->xAxis->setRange(-800, 800);
}
ui->customPlot->replot();
}
// Update The Angle Correction Plot
void MainWindow::AngleCorrectionUpdate(double deltaX, double deltaY, double predX, double predY)
{
this->angleCorrectionPlot->UpdatePlot(deltaX, deltaY, predX, predY);
}
// Save Plot To File
void MainWindow::SavePlot()
{
ui->customPlot->savePng("./outputs/"+ QString::fromStdString(currentTime) +"location.png");
}
// Save and Close (will exit program)
void MainWindow::on_close_button_clicked()
{
this->close();
qApp->exit();
}
void MainWindow::on_save_button_clicked()
{
this->SavePlot();
}
// Opens Euler Plot
void MainWindow::on_euler_button_clicked()
{
ePlot = new EulerPlot(this);
ePlot->show();
}
// Stops Optical Flow Execution
void MainWindow::on_optical_button_clicked()
{
end_run = 1;
}
// Clear Data From Graph
void MainWindow::on_clear_button_clicked()
{
this->newCurve->clearData();
}
void MainWindow::on_reset_button_clicked()
{
currLocation.x = 0;
currLocation.y = 0;
}