完成数据变化绘图
This commit is contained in:
@ -22,8 +22,8 @@ set(PROJECT_SOURCES
|
||||
global.h
|
||||
readthread.cpp
|
||||
readthread.h
|
||||
customtime.h
|
||||
customtime.cpp
|
||||
customthread.h
|
||||
customthread.cpp
|
||||
qcustomplot.h
|
||||
qcustomplot.cpp
|
||||
)
|
||||
|
@ -9,14 +9,14 @@ CONFIG += c++11
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
customtime.cpp \
|
||||
customthread.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
qcustomplot.cpp \
|
||||
readthread.cpp
|
||||
|
||||
HEADERS += \
|
||||
customtime.h \
|
||||
customthread.h \
|
||||
global.h \
|
||||
mainwindow.h \
|
||||
qcustomplot.h \
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "customtime.h"
|
||||
#include "customthread.h"
|
||||
|
||||
CustomTime::CustomTime(QObject *parent)
|
||||
CustomThread::CustomThread(QObject *parent)
|
||||
: QThread{parent} {}
|
||||
|
||||
void CustomTime::setValue(QVector<int> vector, QString string) {
|
||||
void CustomThread::setValue(QVector<int> vector, QString string) {
|
||||
this->jd = vector;
|
||||
this->dataName = string;
|
||||
}
|
||||
|
||||
void CustomTime::run() {
|
||||
void CustomThread::run() {
|
||||
m_PlotView.clear();
|
||||
rule.clear();
|
||||
|
||||
@ -20,6 +20,7 @@ void CustomTime::run() {
|
||||
bool isEnum = namelist[dataName];
|
||||
int bytesRead = 0;
|
||||
for (int i = 0; i < jd.size(); ++i) {
|
||||
int X = 0;
|
||||
QString tem = "这是一个无实际作用的标识";
|
||||
for (int j = 0; j < g_param[jd[i]].size(); j++) {
|
||||
//更新进度条
|
||||
@ -27,15 +28,22 @@ void CustomTime::run() {
|
||||
emit setProgressBar(bytesRead);
|
||||
|
||||
QDateTime temTime = QDateTime::fromString(g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
|
||||
if (temTime >= beginTime && temTime < endTime) {
|
||||
if (temTime >= beginTime && temTime <= endTime) {
|
||||
if (g_param[jd[i]][j].contains(dataName)) {
|
||||
tem = g_param[jd[i]][j][dataName];
|
||||
} else {
|
||||
if (!isTime) {
|
||||
continue;
|
||||
}
|
||||
if (tem == "这是一个无实际作用的标识") {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
xData[jd[i]].append(temTime.toMSecsSinceEpoch() / 1000.0);
|
||||
if (isTime) {
|
||||
xData[jd[i]].append(temTime.toMSecsSinceEpoch() / 1000.0);
|
||||
} else {
|
||||
xData[jd[i]].append(X++);
|
||||
}
|
||||
if (isEnum) {
|
||||
yData[jd[i]].append(tem.toDouble());
|
||||
} else {
|
||||
@ -48,10 +56,14 @@ void CustomTime::run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
emit setPlotView(jd[i], isEnum, true);
|
||||
emit setPlotView(jd[i], isEnum, isTime);
|
||||
}
|
||||
|
||||
emit setWidget();
|
||||
quit();
|
||||
}
|
||||
|
||||
void CustomThread::setIsTime(bool IsTime) {
|
||||
CustomThread::isTime = IsTime;
|
||||
}
|
||||
|
@ -4,13 +4,15 @@
|
||||
#include <QThread>
|
||||
#include "global.h"
|
||||
|
||||
class CustomTime : public QThread {
|
||||
class CustomThread : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomTime(QObject *parent = nullptr);
|
||||
explicit CustomThread(QObject *parent = nullptr);
|
||||
|
||||
void setValue(QVector<int> vector, QString string);
|
||||
|
||||
void setIsTime(bool IsTime);
|
||||
|
||||
signals:
|
||||
|
||||
void setProgressBar(int bytesRead);
|
||||
@ -25,6 +27,7 @@ protected:
|
||||
private:
|
||||
QVector<int> jd;
|
||||
QString dataName;
|
||||
bool isTime;
|
||||
};
|
||||
|
||||
#endif // CUSTOMTIMETHREAD_H
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), readThread(new ReadThread), customTime(new CustomTime) {
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), readThread(new ReadThread), customTime(new CustomThread) {
|
||||
ui->setupUi(this);
|
||||
// 创建版本号标签并添加到状态栏的右端
|
||||
QLabel *m_versionLabel = new QLabel(tr("v1.2.0"), this);
|
||||
@ -26,9 +26,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(readThread, &ReadThread::closeProg, this, &MainWindow::closeProg);
|
||||
|
||||
//customTime
|
||||
connect(customTime, &CustomTime::setProgressBar, this, &MainWindow::setProgressBar);
|
||||
connect(customTime, &CustomTime::setPlotView, this, &MainWindow::setPlotView);
|
||||
connect(customTime, &CustomTime::setWidget, this, &MainWindow::setWidget);
|
||||
connect(customTime, &CustomThread::setProgressBar, this, &MainWindow::setProgressBar);
|
||||
connect(customTime, &CustomThread::setPlotView, this, &MainWindow::setPlotView);
|
||||
connect(customTime, &CustomThread::setWidget, this, &MainWindow::setWidget);
|
||||
|
||||
}
|
||||
|
||||
@ -64,27 +64,19 @@ void MainWindow::on_timeCustomBtn_clicked() {
|
||||
//校验数据
|
||||
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->setIsTime(true);
|
||||
customTime->start();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_dataCustomBtn_clicked() {
|
||||
//校验数据
|
||||
if (!inspectionData()) { return; }
|
||||
|
||||
//运行线程
|
||||
customTime->setIsTime(false);
|
||||
customTime->start();
|
||||
}
|
||||
|
||||
bool MainWindow::inspectionData() {
|
||||
@ -100,7 +92,7 @@ bool MainWindow::inspectionData() {
|
||||
return false;
|
||||
}
|
||||
//获取基带id
|
||||
jd.clear();
|
||||
QVector<int> jd;
|
||||
if (ui->jd1->isChecked()) {
|
||||
jd.append(0);
|
||||
}
|
||||
@ -127,7 +119,7 @@ bool MainWindow::inspectionData() {
|
||||
return false;
|
||||
}
|
||||
//获取参数名
|
||||
dataName = ui->comboBox->currentText();
|
||||
QString dataName = ui->comboBox->currentText();
|
||||
//判断参数名是否正确
|
||||
if (!namelist.keys().contains(dataName)) {
|
||||
QMessageBox::warning(this, "警告", "未找到该数据");
|
||||
@ -136,6 +128,20 @@ bool MainWindow::inspectionData() {
|
||||
//创建新窗口
|
||||
widget = new QWidget();
|
||||
widget->setWindowTitle(dataName);
|
||||
|
||||
//传入数据绘图
|
||||
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();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "readthread.h"
|
||||
#include "customtime.h"
|
||||
#include "customthread.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
@ -61,9 +61,8 @@ private slots:
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ReadThread *readThread;
|
||||
CustomTime *customTime;
|
||||
QVector<int> jd;
|
||||
QString dataName;
|
||||
CustomThread *customTime;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -14,7 +14,7 @@ ReadThread::ReadThread(QObject *parent)
|
||||
kexue.setPattern("^[0-9].[0-9]e[+-][0-9][0-9]");
|
||||
}
|
||||
|
||||
bool ReadThread::isNumeric(QString data) {
|
||||
bool ReadThread::isNumeric(const QString& data) {
|
||||
bool flag = false;
|
||||
patternMatch = pattern.match(data);
|
||||
if (patternMatch.hasMatch()) {
|
||||
|
@ -13,7 +13,7 @@ Q_OBJECT
|
||||
public:
|
||||
explicit ReadThread(QObject *parent = nullptr);
|
||||
|
||||
bool isNumeric(QString data);
|
||||
bool isNumeric(const QString &data);
|
||||
|
||||
signals:
|
||||
|
||||
|
Reference in New Issue
Block a user