-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
154 lines (117 loc) · 4.11 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// Created by ahmee on 4/9/2024.
//
// You may need to build the project (run Qt uic code generator) to get "ui_Mainwindow.h" resolved
#include "mainwindow.h"
#include "ui_Mainwindow.h"
int count = 0;
int graph_page = 0;
enum page_table {brakes_general = 0,brakes_bias_cone = 6, susp_positions = 1,
susp_hist = 2, tuning = 3, gps = 4};
main_window::main_window(QWidget *parent) :
QWidget(parent), ui(new Ui::main_window) {
ui->setupUi(this);
//connect signals to slots
connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(set_page_to_brake_bias_cone()));
connect(ui->outing_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(print_int(int)));
connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(set_page_to_brake_general()));
connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(set_page_to_susp_pos()));
//setting up time series chart
mychart->addSeries(first_line);
mychart->setTitle("This is a line series chart");
axisX->setMax(5);
axisY->setMax(5);
mychart->addAxis(axisX, Qt::AlignBottom);
mychart->addAxis(axisY, Qt::AlignLeft);
first_line->attachAxis(axisX);
first_line->attachAxis(axisY);
ui->chart_one->setChart(my_charts[graph_page]);
//setting up scatter plot
second_chart->addSeries(my_scatter);
my_scatter->setMarkerShape(QScatterSeries::MarkerShapeCircle);
my_scatter->setMarkerSize(10.0);
my_scatter->append(5, 5);
my_scatter->append(2, 2);
my_scatter->append(2.1, 2.1);
second_y->setMax(10);
second_X->setMax(10);
second_chart->addAxis(second_X, Qt::AlignBottom);
second_chart->addAxis(second_y, Qt::AlignLeft);
my_scatter->attachAxis(second_X);
my_scatter->attachAxis(second_y);
//setting up histogram
QBarSet *first_set = new QBarSet("number one");
QBarSet *second_set = new QBarSet("number two");
*first_set << 1 << 2 ;
*second_set << 3 << 4;
my_bar->append(first_set);
my_bar->append(second_set);
third_chart->addSeries(my_bar);
QStringList categories;
categories << "Jan" << "Feb";
third_X->append(categories);
third_chart->addAxis(third_X, Qt::AlignBottom);
my_bar->attachAxis(third_X);
third_chart->addAxis(third_y, Qt::AlignLeft);
my_bar->attachAxis(third_y);
}
void main_window::on_pushButton_clicked(){
QThread *my_thread = QThread::create([this] {
while (true) {
this->first_line->append(count, (count * count) + (2 * count) + 6);
axisX->setMax(count + 1);
axisY->setMax((count * count) + (2 * count) + 6);
qInfo("");
count++;
if (count > 5){
first_line->remove(0);
double new_x = first_line->at(0).x();
double new_y = first_line->at(0).y();
axisX->setMin(new_x);
axisY->setMin(new_y);
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}});
my_thread->start();
}
void main_window::on_pushButton_2_clicked(){
graph_page += 1;
ui->chart_one->setChart(my_charts[graph_page % 3]);
}
void main_window::on_pushButton_3_clicked(){
graph_page -= 1;
ui->chart_one->setChart(my_charts[graph_page % 3]);
}
void main_window::on_pushButton_4_clicked(){
ui->plot_container->setCurrentIndex(0);
}
void main_window::set_page_to_brake_bias_cone(){
ui->plot_container->setCurrentIndex(brakes_bias_cone);
qInfo("lol");
}
void main_window::print_int(int index) {
qInfo() << std::to_string(index);
}
void main_window::set_page_to_brake_general() {
ui->plot_container->setCurrentIndex(brakes_general);
qInfo("lol");
}
void main_window::set_page_to_susp_pos() {
ui->plot_container->setCurrentIndex(susp_positions);
qInfo("lol");
}
void main_window::set_page_to_susp_his() {
ui->plot_container->setCurrentIndex(2);
qInfo("lol");
}
void main_window::set_page_to_tuning() {
ui->plot_container->setCurrentIndex(1);
qInfo("lol");
}
void main_window::set_page_to_gps() {
ui->plot_container->setCurrentIndex(3);
qInfo("lol");
}
main_window::~main_window() {
delete ui;
}