-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
79 lines (55 loc) · 1.48 KB
/
mainwindow.cpp
File metadata and controls
79 lines (55 loc) · 1.48 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::initValues(std::list<unsigned int> amount, std::list<float> time){
this->time = time;
this->amount = amount;
}
void MainWindow::on_pushButton_clicked()
{
float max_time = time.front();
unsigned max_amount = amount.front();
float min_time = time.front();
unsigned min_amount = amount.front();
QVector<double> x(time.size()), y(amount.size());
int i = 0;
while(!amount.empty()) {
x[i] = amount.front();
y[i] = time.front();
if(time.front() > max_time){
max_time = time.front();
}
if(time.front() < min_time){
min_time = time.front();
}
if(amount.front() > max_amount){
max_amount = amount.front();
}
if(amount.front() < min_amount){
min_amount = amount.front();
}
time.pop_front();
amount.pop_front();
i++;
}
ui->plot->clearGraphs();
ui->plot->addGraph();
ui->plot->graph(0)->setData(x,y);
ui->plot->xAxis->setLabel("Time");
ui->plot->yAxis->setLabel("CountOfWord");
ui->plot->xAxis->setRange(0, max_amount);
///
double minY = min_time;
double maxY = max_time;
ui->plot->yAxis->setRange(minY,maxY);
ui->plot->replot();
}