-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
132 lines (110 loc) · 3.51 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDateTime>
#include <QTime>
#include <QString>
#include <QMessageBox>
#include <QStackedWidget>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->stackedWidget->setCurrentIndex(0);
QWidget *spacerWidget = new QWidget(this);
QWidget *spacerWidget2 = new QWidget(this);
spacerWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
spacerWidget2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
ui->toolBar->insertWidget(ui->actionFlight_Data, spacerWidget);
ui->toolBar->insertWidget(ui->actionConnect, new QLabel(" "));
ui->toolBar->insertWidget(ui->actionConnect, ui->clock);
ui->toolBar->addWidget(spacerWidget2);
spacerWidget->setVisible(true);
spacerWidget2->setVisible(true);
// ui->toolBar->setStyleSheet("QToolBar{spacing:0px;}");
logWindow = new LogWindow(this);
commDialog = new CommDialog(this);
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MainWindow::updateClock);
timer->start(1000);
QObject::connect(this, &MainWindow::change, ui->flightGraphs->scatter, &MyQ3DScatter::receiveChange);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::initialize()
{
// auto *toolBar = new QToolBar();
auto *flightData = new FlightData();
auto *flightGraphs = new FlightGraphs();
auto *stackedWidget = new QStackedWidget();
stackedWidget->addWidget(flightData);
stackedWidget->addWidget(flightGraphs);
setCentralWidget(stackedWidget);
}
void MainWindow::updateClock()
{
ui->clock->setText(QTime::currentTime().toString("h:mm:ss ap"));
}
// void MainWindow::showCOMConnected()
// {
// ui->connection_label->setStyleSheet("color: green");
// logWindow->addCOMConnected();
// }
// void MainWindow::showSuccessfulMemAlloc()
// {
// QMessageBox::information(this, "Successful Memory Allocation", "Success");
// ui->statusbar->showMessage("Successful Memory Allocation", 5000);
// logWindow->addSuccessfulMemAlloc();
// }
// void MainWindow::showUnsuccessfulMemAlloc()
// {
// QMessageBox::warning(this, "Unsuccessful Memory Allocation", "Fail");
// ui->statusbar->showMessage("Unsuccessful Memory Allocation", 5000);
// logWindow->addUnsuccessfulMemAlloc();
// }
// void MainWindow::on_upload_telem_clicked()
// {
// // Upload telemetry, and then receive message back to see what we write
// if (1) {
// showSuccessfulMemAlloc();
// } else {
// // showUnsuccessfulMemAlloc();
// }
// }
void MainWindow::on_actionFlight_Data_triggered()
{
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_actionFlight_Graphs_triggered()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::on_actionConnect_triggered()
{
commDialog->show();
}
void MainWindow::showCOMConnection()
{
if (true) {
QMessageBox::information(this, "Connection Successful", "Serial port connected");
logWindow->addCOMConnected();
// QIcon connected = new QIcon();
// ui->actionConnect->setIcon();
}
else {
QMessageBox::information(this, "Connection Not Successful", "Error. Failed to connect to serial port.");
}
}
void MainWindow::on_actionFlight_Logs_triggered()
{
logWindow->show();
}
void MainWindow::on_action3D_Graph_triggered()
{
// qDebug() << "WORKS";
// ui->flightGraphs->addData();
emit change();
}