This repository was archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
151 lines (136 loc) · 4.63 KB
/
mainwindow.cpp
File metadata and controls
151 lines (136 loc) · 4.63 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
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "model/singletarget.h"
#include <QDebug>
MainWindow::MainWindow(QSplashScreen *splash, QWidget *parent) :
QMainWindow(parent), selectGrp(NULL), splashScreen(splash),
ui(new Ui::MainWindow), splashTimer(this)
{
ui->setupUi(this);
connect(ui->settingBtn, SIGNAL(clicked()), this, SLOT(onSettingButtonClick()));
connect(ui->groupInfoBtn, SIGNAL(clicked()), this, SLOT(onGroupInfoButtonClick()));
connect(ui->startBtn, SIGNAL(toggled(bool)), this, SLOT(onStartButtonToggled(bool)));
connect(ui->pauseBtn, SIGNAL(toggled(bool)), this, SLOT(onPauseButtonToggled(bool)));
connect(&timer, SIGNAL(timeout()), this, SLOT(timeOutHandler()));
grpInfoWindow = NULL;
map = new TTMap();
QGridLayout *layout = new QGridLayout();
layout->setMargin(2);
layout -> addWidget(map);
ui -> mapWidget -> setLayout(layout);
connect(map, SIGNAL(targetSelectet(TargetGroup*))
, this, SLOT(targetSelectedHandler(TargetGroup*)));
connect(map, SIGNAL(targetsUpdated()), this, SLOT(targetsUpdateHandler()));
connect(&splashTimer, SIGNAL(timeout()), this, SLOT(splashScreenTimerHandler()));
idLabel = ui->idLabel;
tLabel = ui->tLabel;
sxLabel = ui->sxLabel;
axLabel = ui->axLabel;
vxLabel = ui->vxLabel;
syLabel = ui->syLabel;
ayLabel = ui->ayLabel;
vyLabel = ui->vyLabel;
szLabel = ui->szLabel;
azLabel = ui->azLabel;
vzLabel = ui->vzLabel;
//showMaximized();
setMinimumSize(size());
targetsUpdateHandler();
splashTimer.start(2000);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onSettingButtonClick()
{
SettingDialog SettingDialog(this);
SettingDialog.exec();
}
void MainWindow::onStartButtonToggled(bool toggled)
{
if (toggled) {
if (ui->pauseBtn->isChecked()) ui->pauseBtn->toggle();
ui->pauseBtn->setEnabled(true);
ui->groupInfoBtn->setEnabled(true);
ui->settingBtn->setEnabled(false);
ui->startBtn->setText("停止跟踪");
map->start();
qDebug() << "开始跟踪...";
timer.start(5000);
} else {
if (ui->pauseBtn->isChecked()) ui->pauseBtn->toggle();
ui->pauseBtn->setEnabled(false);
ui->groupInfoBtn->setEnabled(false);
ui->settingBtn->setEnabled(true);
ui->startBtn->setText("开始跟踪");
map->stop();
qDebug() << "停止跟踪。";
selectGrp = NULL;
targetsUpdateHandler();
}
if (grpInfoWindow != NULL) grpInfoWindow->updateTable();
}
void MainWindow::onPauseButtonToggled(bool toggled)
{
if (toggled) {
ui->pauseBtn->setText("开始");
} else {
ui->pauseBtn->setText("暂停");
}
map->pause(!toggled);
}
void MainWindow::onGroupInfoButtonClick()
{
if (grpInfoWindow == NULL) grpInfoWindow = new GroupListWindow(this);
grpInfoWindow->show();
grpInfoWindow->updateTable();
}
void MainWindow::targetSelectedHandler(TargetGroup *grp)
{
selectGrp = grp;
}
void MainWindow::targetsUpdateHandler()
{
if (selectGrp) {
idLabel->setText(QString("G%1").arg(selectGrp->getID()));
SingleTarget *t = selectGrp->getTarget(0);
if (t) {
sxLabel->setText(QString("%1").arg(t->getCurrState()->getPositionX()));
syLabel->setText(QString("%1").arg(t->getCurrState()->getPositionY()));
szLabel->setText(QString("%1").arg(t->getCurrState()->getPositionZ()));
vxLabel->setText(QString("%1").arg(t->getCurrState()->getSpeedX()));
vyLabel->setText(QString("%1").arg(t->getCurrState()->getSpeedY()));
vzLabel->setText(QString("%1").arg(t->getCurrState()->getSpeedZ()));
axLabel->setText(QString("%1").arg(t->getCurrState()->getAcceleratinX()));
ayLabel->setText(QString("%1").arg(t->getCurrState()->getAcceleratinY()));
azLabel->setText(QString("%1").arg(t->getCurrState()->getAcceleratinZ()));
}
} else {
idLabel->setText("NAN");
tLabel->setText("0");
sxLabel->setText("0");
syLabel->setText("0");
szLabel->setText("0");
axLabel->setText("0");
ayLabel->setText("0");
azLabel->setText("0");
vxLabel->setText("0");
vyLabel->setText("0");
vzLabel->setText("0");
}
}
//开场
void MainWindow::splashScreenTimerHandler()
{
show();
splashScreen -> finish(this);
delete splashScreen;
splashTimer.stop();
}
void MainWindow::timeOutHandler()
{
ui->startTrackLineEdit->setText("5.23");
ui->daCorrectnessLineEdit->setText("98.11");
ui->trackCorrectnessLineEdit->setText("95.76");
}