优化开始结束时间获取
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), readThread(new ReadThread), customTime(new CustomTimeThread) {
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), readThread(new ReadThread), customTime(new CustomTime) {
|
||||
ui->setupUi(this);
|
||||
// 创建版本号标签并添加到状态栏的右端
|
||||
QLabel *m_versionLabel = new QLabel(tr("v1.2.0"), this);
|
||||
@ -21,15 +21,14 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(readThread, &ReadThread::clearCombo, this, &MainWindow::clearCombo);
|
||||
connect(readThread, &ReadThread::showStatusbar, this, &MainWindow::showStatusbar);
|
||||
connect(readThread, &ReadThread::setProgressBar, this, &MainWindow::setProgressBar);
|
||||
connect(readThread, &ReadThread::setBeginTime, this, &MainWindow::setBeginTime);
|
||||
connect(readThread, &ReadThread::setEndTime, this, &MainWindow::setEndTime);
|
||||
connect(readThread, &ReadThread::setTime, this, &MainWindow::setTime);
|
||||
connect(readThread, &ReadThread::addCombo, this, &MainWindow::addCombo);
|
||||
connect(readThread, &ReadThread::closeProg, this, &MainWindow::closeProg);
|
||||
|
||||
//customTime
|
||||
connect(customTime, &CustomTimeThread::setProgressBar, this, &MainWindow::setProgressBar);
|
||||
connect(customTime, &CustomTimeThread::setPlotView, this, &MainWindow::setPlotView);
|
||||
connect(customTime, &CustomTimeThread::setWidget, this, &MainWindow::setWidget);
|
||||
connect(customTime, &CustomTime::setProgressBar, this, &MainWindow::setProgressBar);
|
||||
connect(customTime, &CustomTime::setPlotView, this, &MainWindow::setPlotView);
|
||||
connect(customTime, &CustomTime::setWidget, this, &MainWindow::setWidget);
|
||||
|
||||
}
|
||||
|
||||
@ -62,20 +61,46 @@ void MainWindow::on_openFileBtn_clicked() {
|
||||
|
||||
|
||||
void MainWindow::on_timeCustomBtn_clicked() {
|
||||
if (file.fileName().isEmpty()) {
|
||||
QMessageBox::warning(this, "警告", "请先打开一个日志");
|
||||
return;
|
||||
//校验数据
|
||||
if (!inspectionData()) { return; }
|
||||
|
||||
//传入数据绘图
|
||||
customTime->setValue(jd, dataName);
|
||||
|
||||
// 获取文件大小
|
||||
int fileSize = 0;
|
||||
for (int i : jd) {
|
||||
fileSize += g_param[i].size();
|
||||
}
|
||||
|
||||
//设置进度条
|
||||
ui->progressBar->setValue(0);
|
||||
ui->progressBar->setMaximum(fileSize);
|
||||
ui->progressBar->show();
|
||||
|
||||
//运行线程
|
||||
customTime->start();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_dataCustomBtn_clicked() {
|
||||
|
||||
}
|
||||
|
||||
bool MainWindow::inspectionData() {
|
||||
//关闭打开的窗口
|
||||
if (widget) {
|
||||
widget->close();
|
||||
delete widget;
|
||||
widget = nullptr;
|
||||
}
|
||||
|
||||
//判断是否已打开日志文件
|
||||
if (file.fileName().isEmpty()) {
|
||||
QMessageBox::warning(this, "警告", "请先打开一个日志");
|
||||
return false;
|
||||
}
|
||||
//获取基带id
|
||||
QVector<int> jd;
|
||||
jd.clear();
|
||||
if (ui->jd1->isChecked()) {
|
||||
jd.append(0);
|
||||
}
|
||||
@ -88,48 +113,30 @@ void MainWindow::on_timeCustomBtn_clicked() {
|
||||
if (ui->jd4->isChecked()) {
|
||||
jd.append(3);
|
||||
}
|
||||
|
||||
//判断基带是否为空
|
||||
if (jd.isEmpty()) {
|
||||
QMessageBox::warning(this, "警告", "请至少选择一个基带");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取时间
|
||||
beginTime = ui->beginTimeEdit->dateTime();
|
||||
endTime = ui->endTimeEdit->dateTime();
|
||||
//判断时间是否合法
|
||||
if (beginTime > endTime) {
|
||||
QMessageBox::warning(this, "警告", "请选择正确的时间段");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
//获取参数名
|
||||
QString dataName = ui->comboBox->currentText();
|
||||
dataName = ui->comboBox->currentText();
|
||||
//判断参数名是否正确
|
||||
if (!namelist.keys().contains(dataName)) {
|
||||
QMessageBox::warning(this, "警告", "未找到该数据");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//传入数据绘图
|
||||
customTime->setValue(jd, dataName);
|
||||
//创建新窗口
|
||||
widget = new QWidget();
|
||||
widget->setWindowTitle(dataName);
|
||||
|
||||
// 获取文件大小
|
||||
int fileSize = 0;
|
||||
for (int i = 0; i < jd.size(); ++i) {
|
||||
fileSize += g_param[jd[i]].size();
|
||||
}
|
||||
|
||||
//设置进度条
|
||||
ui->progressBar->setValue(0);
|
||||
ui->progressBar->setMaximum(fileSize);
|
||||
ui->progressBar->show();
|
||||
|
||||
customTime->start();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_dataCustomBtn_clicked() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::clearCombo() {
|
||||
@ -144,11 +151,8 @@ void MainWindow::setProgressBar(int bytesRead) {
|
||||
ui->progressBar->setValue(bytesRead);
|
||||
}
|
||||
|
||||
void MainWindow::setBeginTime(const QDateTime &beginTime) {
|
||||
void MainWindow::setTime() {
|
||||
ui->beginTimeEdit->setDateTime(beginTime);
|
||||
}
|
||||
|
||||
void MainWindow::setEndTime(const QDateTime &endTime) {
|
||||
ui->endTimeEdit->setDateTime(endTime);
|
||||
}
|
||||
|
||||
@ -167,6 +171,7 @@ void MainWindow::closeProg() {
|
||||
|
||||
void MainWindow::setPlotView(int jd, bool isNum, bool isTime) {
|
||||
QCustomPlot *qCustomPlot = new QCustomPlot();
|
||||
|
||||
//标题
|
||||
QCPTextElement *m_title;
|
||||
qCustomPlot->plotLayout()->insertRow(0);
|
||||
@ -200,12 +205,13 @@ void MainWindow::setPlotView(int jd, bool isNum, bool isTime) {
|
||||
qCustomPlot->addGraph();
|
||||
qCustomPlot->graph(0)->setData(xData[jd], yData[jd]);
|
||||
|
||||
|
||||
// 自动调整轴范围
|
||||
qCustomPlot->rescaleAxes();
|
||||
|
||||
//设置鼠标拖动和滚轮
|
||||
qCustomPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
|
||||
|
||||
//设置X轴范围
|
||||
if (!xData[jd].empty()) {
|
||||
qCustomPlot->xAxis->setRange(xData[jd].first(), xData[jd].last());
|
||||
}
|
||||
|
Reference in New Issue
Block a user