diff --git a/.gitignore b/.gitignore index aced9cb..8b3612c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ +.idea/ *.user -.idea \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ff0fa86..79d71cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(ReadLog_7 VERSION 0.1 LANGUAGES CXX) +project(ReadLog VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) @@ -9,60 +9,52 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Charts) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Charts) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) +find_package(Qt5 COMPONENTS PrintSupport REQUIRED) + set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h mainwindow.ui - gloab.h - gloab.cpp - lib/qcustomplot.h - lib/qcustomplot.cpp - qcustplot.cpp - qcustplot.h - qcustplot.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(ReadLog_7 + qt_add_executable(ReadLog MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: -# set_property(TARGET ReadLog_7 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# set_property(TARGET ReadLog APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) - add_library(ReadLog_7 SHARED + add_library(ReadLog SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() - add_executable(ReadLog_7 + add_executable(ReadLog ${PROJECT_SOURCES} - threadread.h threadread.cpp - threadchart.h threadchart.cpp - threadpoltchart.h threadpoltchart.cpp - log7.pro - + qcustomplot.cpp qcustomplot.h ) endif() endif() -target_link_libraries(ReadLog_7 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Charts) +target_link_libraries(ReadLog PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) +target_link_libraries(ReadLog PRIVATE Qt5::PrintSupport) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ReadLog_7) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ReadLog) endif() -set_target_properties(ReadLog_7 PROPERTIES +set_target_properties(ReadLog PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} @@ -71,12 +63,12 @@ set_target_properties(ReadLog_7 PROPERTIES ) include(GNUInstallDirs) -install(TARGETS ReadLog_7 +install(TARGETS ReadLog BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(ReadLog_7) + qt_finalize_executable(ReadLog) endif() diff --git a/log7.pro b/ReadLog.pro similarity index 60% rename from log7.pro rename to ReadLog.pro index 8a2a93f..e936a67 100644 --- a/log7.pro +++ b/ReadLog.pro @@ -1,4 +1,4 @@ -QT += core gui charts +QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport @@ -9,27 +9,16 @@ CONFIG += c++11 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ - gloab.cpp \ - lib/qcustomplot.cpp \ main.cpp \ - mainwindow.cpp \ - qcustplot.cpp \ - threadchart.cpp \ - threadpoltchart.cpp \ - threadread.cpp + mainwindow.cpp + # qcustomplot.cpp HEADERS += \ - gloab.h \ - lib/qcustomplot.h \ - mainwindow.h \ - qcustplot.h \ - threadchart.h \ - threadpoltchart.h \ - threadread.h + mainwindow.h + # qcustomplot.h FORMS += \ - mainwindow.ui \ - qcustplot.ui + mainwindow.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin diff --git a/gloab.cpp b/gloab.cpp deleted file mode 100644 index 619e6b7..0000000 --- a/gloab.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "gloab.h" - -QString Gloab::fileName=""; -QVector> Gloab::g_param[4]; -QMap Gloab::temData; -QMap Gloab::namelist; -QList Gloab::m_QCView; -QWidget * Gloab::widget; -QVector Gloab::rule; -QFile Gloab::file; -qint64 Gloab::fileSize; -qint64 Gloab::bytesRead; -QCompleter *Gloab::completer; -QVector Gloab::xData[4],Gloab::yData[4]; diff --git a/gloab.h b/gloab.h deleted file mode 100644 index 86de6ff..0000000 --- a/gloab.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Created by Sherlock on 2024/8/12. -// - -#ifndef GLOAB_H -#define GLOAB_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qcustplot.h" - -class Gloab{ -public: - static QString fileName; - static QVector> g_param[4]; - static QMap temData; - static QMap namelist; - static QList m_QCView; - static QWidget *widget; - static QVector rule; - static QFile file; - static qint64 fileSize; - static qint64 bytesRead; - static QCompleter *completer; - static QVector xData[4],yData[4]; -}; - - -#endif //GLOAB_H diff --git a/log7.pro.user b/log7.pro.user deleted file mode 100644 index ff420cd..0000000 --- a/log7.pro.user +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - EnvironmentId - {212c491d-8228-40db-8cc9-f183f9b9d8d0} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - 0 - false - true - false - 0 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 6 - true - - - - true - - - false - true - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Qt 5.12.0 (mingw73_64) - Qt 5.12.0 (mingw73_64) - {edc54fcd-f681-4a0a-ba77-11a1a5c94a66} - 0 - 0 - 0 - - 0 - C:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Debug - C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - C:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Release - C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - - 0 - C:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Profile - C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - 0 - - 3 - - - 0 - 部署 - 部署 - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - 0 - true - - - 2 - - false - log72 - Qt4ProjectManager.Qt4RunConfiguration:C:/Work/QT/ReadLog/log7/log7.pro - C:/Work/QT/ReadLog/log7/log7.pro - true - true - true - true - C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/main.cpp b/main.cpp index 5b40f4d..9c658e2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,15 +1,12 @@ #include "mainwindow.h" #include -#include +#include int main(int argc, char *argv[]) { - // qputenv("QT_SCALE_FACTOR", "2.0"); - QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - QTextCodec::setCodecForLocale(codec); QApplication a(argc, argv); - MainWindow w; - w.show(); + MainWindow w; + w.show(); return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 7069aa0..7cf4cbc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,289 +1,22 @@ #include "mainwindow.h" -#include -#include "lib/qcustomplot.h" +#include "ui_mainwindow.h" -#include "./ui_mainwindow.h" +#include +#include +#include +#include MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::MainWindow) - , thread_read(new threadRead), thread_chart(new ThreadChart),thread_polt(new threadPoltChart){ + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ ui->setupUi(this); - this->setWindowTitle("日志查询工具"); - // 创建版本号标签 - m_versionLabel = new QLabel(tr("v1.2.0"), this); - // 将标签添加到状态栏的右端 - ui->statusbar->addPermanentWidget(m_versionLabel); - - connect(thread_read, &threadRead::clearCombo, this, &MainWindow::clearCombo); - connect(thread_read, &threadRead::showStatusbar, this, &MainWindow::showStatusbar); - connect(thread_read, &threadRead::setBeginTime, this, &MainWindow::setBeginTime); - connect(thread_read, &threadRead::setEndTime, this, &MainWindow::setEndTime); - connect(thread_read, &threadRead::addCombo, this, &MainWindow::addCombo); - connect(thread_read, &threadRead::setProgressBar, this, &MainWindow::setProgressBar); - connect(thread_read, &threadRead::closeProg, this, &MainWindow::closeProg); - - //chart - connect(thread_chart, &ThreadChart::setChartView, this, &MainWindow::setChartView); - connect(thread_chart, &ThreadChart::setWidget, this, &MainWindow::setWidget); - connect(thread_chart, &ThreadChart::setProgressBar, this, &MainWindow::setProgressBar); - - //plot - connect(thread_polt, &threadPoltChart::setChartView, this, &MainWindow::setPlotChartView); - connect(thread_polt, &threadPoltChart::setWidget, this, &MainWindow::setWidget); - connect(thread_polt, &threadPoltChart::setProgressBar, this, &MainWindow::setProgressBar); } -MainWindow::~MainWindow() { +MainWindow::~MainWindow() +{ delete ui; } -void MainWindow::on_openFileBtn_clicked() { - Gloab::fileName = QFileDialog::getOpenFileName(); - //打开文件 - Gloab::file.setFileName(Gloab::fileName); - if (!Gloab::file.open(QIODevice::ReadOnly)) { - // 打开失败时弹窗 - QString dlgTitle = "错误"; - QString strInfo = "文件打开失败"; - QMessageBox::warning(this, dlgTitle, strInfo); - //退出 - return; - } - - //设置进度条 - layout = new QVBoxLayout(ui->widget); - progressBar = new QProgressBar(ui->widget); - layout->addWidget(progressBar); - ui->widget->show(); - - // 获取文件大小 - Gloab::fileSize = Gloab::file.size(); - Gloab::bytesRead = 0; - - thread_read->start(); -} - - -void MainWindow::clearCombo() { - ui->comboBox->clear(); -} - -void MainWindow::showStatusbar(const QString &message) { - ui->statusbar->showMessage(message); -} - -void MainWindow::setBeginTime(const QDateTime &begin) { - ui->beginTime->setDateTime(begin); -} - -void MainWindow::setEndTime(const QDateTime &begin) { - ui->endTime->setDateTime(begin); -} - -void MainWindow::addCombo(const QStringList &list) { - ui->comboBox->addItems(list); - //根据输入匹配下拉框 - Gloab::completer = new QCompleter(list); - Gloab::completer->setFilterMode(Qt::MatchContains); - ui->comboBox->setCompleter(Gloab::completer); - -} - -void MainWindow::setProgressBar(int percent) { - progressBar->setValue(percent); -} - -void MainWindow::closeProg() { - layout->deleteLater(); - progressBar->deleteLater(); - ui->widget->close(); -} - - -void MainWindow::setChartView(int jd, bool isEnum) { - // 设置图表标题 - QCustPlot *qCustPlot = new QCustPlot(Gloab::xData[jd], Gloab::yData[jd], jd, isEnum, true); - // 将qCustPlot添加到容器中 - Gloab::m_QCView.append(qCustPlot); -} - -void MainWindow::setWidget() { - // 设置布局 - int wide = 850; - int hight = 600; - if (Gloab::m_QCView.size() > 1) { - wide = 1800; - } - QGridLayout *gridLayout = new QGridLayout(Gloab::widget); - for (int i = 0, j = 0; i < Gloab::m_QCView.size(); i++) { - if (i != 0 && i % 2 == 0) { - j++; - hight += 350; - } - gridLayout->addWidget(Gloab::m_QCView[i], j, i - 2 * j); - } - Gloab::widget->resize(wide, hight); - Gloab::widget->move(70, 20); - Gloab::widget->show(); - - layout->deleteLater(); - progressBar->deleteLater(); - ui->widget->close(); -} - - - -void MainWindow::setPlotChartView(int jd, bool isEnum) { - // 设置图表标题 - QCustPlot *qCustPlot = new QCustPlot(Gloab::xData[jd], Gloab::yData[jd], jd, isEnum, false); - // 将qCustPlot添加到容器中 - Gloab::m_QCView.append(qCustPlot); -} - -void MainWindow::on_lineChart_clicked() { - if (Gloab::fileName.isEmpty()) { - QMessageBox::warning(this, "警告", "请先打开一个日志"); - return; - } - - //关闭打开的窗口 - if (Gloab::widget) { - Gloab::widget->close(); - delete Gloab::widget; - Gloab::widget = nullptr; - } - - //获取基带id - QVector jd; - if (ui->jd1->isChecked()) { - jd.append(0); - } - if (ui->jd2->isChecked()) { - jd.append(1); - } - if (ui->jd3->isChecked()) { - jd.append(2); - } - if (ui->jd4->isChecked()) { - jd.append(3); - } - - if (jd.isEmpty()) { - QMessageBox::warning(this, "警告", "请至少选择一个基带"); - return; - } - - //获取时间 - QDateTime beginTime = ui->beginTime->dateTime(); - QDateTime endTime = ui->endTime->dateTime(); - if (beginTime>endTime) { - QMessageBox::warning(this, "警告", "请选择正确的时间段"); - return; - } - //获取参数名 - QString dataName = ui->comboBox->currentText(); - if (!Gloab::namelist.keys().contains(dataName)) { - QMessageBox::warning(this, "警告", "未找到该数据"); - return; - } - - //传入数据绘图 - thread_chart->setValue(jd, dataName, beginTime, endTime); - Gloab::widget = new QWidget(); - Gloab::widget->setWindowTitle(dataName); - - //设置进度条 - layout = new QVBoxLayout(ui->widget); - progressBar = new QProgressBar(ui->widget); - layout->addWidget(progressBar); - ui->widget->show(); - - // 获取文件大小 - Gloab::fileSize=0; - for (int i = 0; i < jd.size(); ++i) { - Gloab::fileSize+=Gloab::g_param[jd[i]].size(); - } - Gloab::bytesRead = 0; - - thread_chart->start(); - -} - -bool MainWindow::isNumeric(const QString &str) { - // 正则表达式匹配数字和可选的正负号 - QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$"); - QRegularExpressionMatch patternMatch = pattern.match(str); - // 使用std::regex_match来检查字符串是否完全匹配模式 - return patternMatch.hasMatch(); -} - -void MainWindow::on_plotChart_clicked() -{ - if (Gloab::fileName.isEmpty()) { - QMessageBox::warning(this, "警告", "请先打开一个日志"); - return; - } - //关闭打开的窗口 - if (Gloab::widget) { - Gloab::widget->close(); - delete Gloab::widget; - Gloab::widget = nullptr; - } - - //获取基带id - QVector jd; - if (ui->jd1->isChecked()) { - jd.append(0); - } - if (ui->jd2->isChecked()) { - jd.append(1); - } - if (ui->jd3->isChecked()) { - jd.append(2); - } - if (ui->jd4->isChecked()) { - jd.append(3); - } - if (jd.isEmpty()) { - QMessageBox::warning(this, "警告", "请至少选择一个基带"); - return; - } - - //获取时间 - QDateTime beginTime = ui->beginTime->dateTime(); - QDateTime endTime = ui->endTime->dateTime(); - if (beginTime>endTime) { - QMessageBox::warning(this, "警告", "请选择正确的时间段"); - return; - } - - //获取参数名 - QString dataName = ui->comboBox->currentText(); - if (!Gloab::namelist.keys().contains(dataName)) { - QMessageBox::warning(this, "警告", "未找到该数据"); - return; - } - - - //传入数据绘图 - thread_polt->setValue(jd, dataName, beginTime, endTime); - Gloab::widget = new QWidget(); - Gloab::widget->setWindowTitle(dataName); - - //设置进度条 - layout = new QVBoxLayout(ui->widget); - progressBar = new QProgressBar(ui->widget); - layout->addWidget(progressBar); - ui->widget->show(); - - // 获取文件大小 - Gloab::fileSize=0; - for (int i = 0; i < jd.size(); ++i) { - Gloab::fileSize+=Gloab::g_param[jd[i]].size(); - } - Gloab::bytesRead = 0; - - thread_polt->start(); -} diff --git a/mainwindow.h b/mainwindow.h index 50dce2b..429ed6d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -1,17 +1,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "gloab.h" -#include "threadread.h" #include -#include -#include -#include -#include -#include "qcustplot.h" -#include "threadchart.h" -#include "threadpoltchart.h" - QT_BEGIN_NAMESPACE namespace Ui { @@ -27,39 +17,8 @@ public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); -private slots: - void on_openFileBtn_clicked(); - - void clearCombo(); - void showStatusbar(const QString &message); - void setBeginTime(const QDateTime &begin); - void setEndTime(const QDateTime &begin); - void addCombo(const QStringList &list); - void setProgressBar(int percent); - void closeProg(); - - void setChartView(int jd,bool isEnum); - void setWidget(); - - void setPlotChartView(int jd,bool isEnum); - - void on_lineChart_clicked(); - - bool isNumeric(const QString &str); - - void on_plotChart_clicked(); private: Ui::MainWindow *ui; - QLabel *m_versionLabel; - threadRead *thread_read; - ThreadChart *thread_chart; - threadPoltChart *thread_polt; - - QProgressBar *progressBar; - QVBoxLayout *layout; - QChart *chart; - QLineSeries *series; - }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index f4565fd..d055eb2 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,44 +6,40 @@ 0 0 - 800 - 600 + 450 + 700 MainWindow - - - - - - 14 - - - - 时间图 - - - + + 宋体 12 - 开始时间 + 结束时间 - + - - - - 14 - + + + + 0 + 0 + + + + + 0 + 40 + yyyy/MM/dd HH:mm:ss @@ -54,139 +50,67 @@ - - - Qt::Vertical - - + + - 20 + 0 40 - - - - - - - 12 - - - - 选择基带 - - - - - - - 14 - + + + + + + 0 + 0 + - - 基带1 + + + 16777215 + 16777215 + - - - - - - - 14 - + + 24 - - 基带4 + + Qt::AlignCenter - - - - - - - 14 - - - - 基带3 - - - - - - - - 14 - - - - 基带2 + + false - - - - - 12 - - - - 数据 - - - - - - true - - - - 14 - - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + 宋体 12 - 结束时间 + 开始时间 - + - - - - 14 - + + + + 0 + 0 + + + + + 0 + 40 + yyyy/MM/dd HH:mm:ss @@ -196,35 +120,59 @@ - - - - Qt::Vertical + + + + + 0 + 0 + - - - 20 - 40 - - - - - - - - - - 14 + 宋体 + 12 - - 数据变化图 + + 选择基带 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 基带 1 + + + + + + + 基带 2 + + + + + + + 基带 3 + + + + + + + 基带 4 + + + + - + Qt::Vertical @@ -237,7 +185,7 @@ - + Qt::Vertical @@ -250,11 +198,24 @@ - + + + + 0 + 0 + + + + + 0 + 40 + + - 14 + 宋体 + 16 @@ -262,8 +223,104 @@ - - + + + + + 0 + 0 + + + + + 宋体 + 12 + + + + 选择数据 + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 宋体 + 14 + + + + true + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 宋体 + 16 + + + + 时间图 + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 宋体 + 16 + + + + 数据变化图 + + + + + Qt::Vertical @@ -277,16 +334,6 @@ - - - - 0 - 0 - 800 - 20 - - - diff --git a/lib/qcustomplot.cpp b/qcustomplot.cpp similarity index 100% rename from lib/qcustomplot.cpp rename to qcustomplot.cpp diff --git a/lib/qcustomplot.h b/qcustomplot.h similarity index 100% rename from lib/qcustomplot.h rename to qcustomplot.h diff --git a/qcustplot.cpp b/qcustplot.cpp deleted file mode 100644 index 957802c..0000000 --- a/qcustplot.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "qcustplot.h" -#include "ui_qcustplot.h" -#include -#include -#include "gloab.h" - -QCustPlot::QCustPlot(QVector xData, QVector yData, int jd, bool isNub, bool isTime, - QWidget *parent) - : QWidget(parent) - , ui(new Ui::QCustPlot) -{ - ui->setupUi(this); - - //标题 - QCPTextElement *m_title; - ui->plot->plotLayout()->insertRow(0); - m_title = new QCPTextElement(ui->plot, QString("基带 %1").arg(jd+1)); - ui->plot->plotLayout()->addElement(0, 0, m_title); - - // X轴 - if (isTime) { - QSharedPointer timeTicker(new QCPAxisTickerDateTime); - timeTicker->setDateTimeFormat("hh:mm:ss"); - ui->plot->xAxis->setTicker(timeTicker); - } - - // Y轴 - if(!isNub){ - QVector ticks; - QVector labels; - for (int i = 1; i < Gloab::rule.size(); ++i) { - ticks.append(i); - labels.append(Gloab::rule[i]); - } - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->plot->yAxis->setTicker(textTicker); - }else{ - ui->plot->yAxis->setNumberFormat("f"); - ui->plot->yAxis->setNumberPrecision(2); - } - - // 添加图形 - ui->plot->addGraph(); - ui->plot->graph(0)->setData(xData, yData); - - - // 自动调整轴范围 - ui->plot->rescaleAxes(); - - ui->plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom ); - - if(!xData.empty()){ - ui->plot->xAxis->setRange(xData.first(),xData.last()); - } - -} - -QCustPlot::~QCustPlot() -{ - delete ui; -} - diff --git a/qcustplot.h b/qcustplot.h deleted file mode 100644 index d32ee6a..0000000 --- a/qcustplot.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef QCUSTPLOT_H -#define QCUSTPLOT_H - -#include -#include "lib/qcustomplot.h" - -namespace Ui { -class QCustPlot; -} - -class QCustPlot : public QWidget -{ - Q_OBJECT - -public: - explicit QCustPlot(QVector xData, QVector yData, int jd, bool isNub, bool isTime, - QWidget *parent = nullptr); - ~QCustPlot(); - -private: - Ui::QCustPlot *ui; - -}; - -#endif // QCUSTPLOT_H diff --git a/qcustplot.ui b/qcustplot.ui deleted file mode 100644 index b8dbe21..0000000 --- a/qcustplot.ui +++ /dev/null @@ -1,39 +0,0 @@ - - - QCustPlot - - - - 0 - 0 - 673 - 480 - - - - Form - - - - - - - 0 - 0 - - - - - - - - - QCustomPlot - QWidget -
lib/qcustomplot.h
- 1 -
-
- - -
diff --git a/threadchart.cpp b/threadchart.cpp deleted file mode 100644 index 58e3344..0000000 --- a/threadchart.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "threadchart.h" -#include - -ThreadChart::ThreadChart(QObject *parent) - : QThread{parent} { -} - -void ThreadChart::setValue(QVector jd, QString dataName, QDateTime beginTime, QDateTime endTime) { - this->jd = jd; - this->dataName = dataName; - this->beginTime = beginTime; - this->endTime = endTime; -} - - -void ThreadChart::run() { - Gloab::m_QCView.clear(); - Gloab::rule.clear(); - Gloab::rule.append("状态"); - - for (int var = 0; var < 4; ++var) { - Gloab::xData[var].clear(); - Gloab::yData[var].clear(); - } - //判断右侧数据是否为数字型 - bool isEnum = Gloab::namelist[dataName]; - for (int i = 0; i < jd.size(); ++i) { - qreal y = 114.514; - QString tem1 = "无数据"; - // 为每个图表添加数据 - if (isEnum) { - for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) { - //更新进度条 - Gloab::bytesRead++; - int percent = Gloab::bytesRead * 100 / Gloab::fileSize; - emit setProgressBar(percent); - - QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz"); - if (temTime >= beginTime && temTime < endTime) { - if (!Gloab::g_param[jd[i]][j].contains(dataName)) { - if (y != 114.514) { - Gloab::xData[jd[i]].append(temTime.toMSecsSinceEpoch()/1000.0); - Gloab::yData[jd[i]].append(y); - } - } else { - y = Gloab::g_param[jd[i]][j][dataName].toDouble(); - Gloab::xData[jd[i]].append(temTime.toMSecsSinceEpoch()/1000.0); - Gloab::yData[jd[i]].append(y); - } - } - } - } else { - for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) { - //更新进度条 - Gloab::bytesRead++; - int percent = Gloab::bytesRead * 100 / Gloab::fileSize; - emit setProgressBar(percent); - - QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz"); - if (temTime >= beginTime && temTime < endTime) { - if (!Gloab::g_param[jd[i]][j].contains(dataName)) { - if (tem1 != "无数据") { - if (!Gloab::rule.contains(tem1)) { - Gloab::rule.append(tem1); - } - Gloab::xData[jd[i]].append(temTime.toMSecsSinceEpoch()/1000.0); - Gloab::yData[jd[i]].append(Gloab::rule.indexOf(tem1)); - } - } else { - tem1 = Gloab::g_param[jd[i]][j][dataName]; - if (!Gloab::rule.contains(tem1)) { - Gloab::rule.append(tem1); - } - Gloab::xData[jd[i]].append(temTime.toMSecsSinceEpoch()/1000.0); - Gloab::yData[jd[i]].append(Gloab::rule.indexOf(tem1)); - } - } - } - } - emit setChartView(jd[i], isEnum); - } - - emit setWidget(); - quit(); -} diff --git a/threadchart.h b/threadchart.h deleted file mode 100644 index 553bbd7..0000000 --- a/threadchart.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef THREADCHART_H -#define THREADCHART_H - -#include -#include -#include -#include -using namespace QtCharts; -#include -#include -#include -#include -#include - - -#include "gloab.h" - -class ThreadChart : public QThread { - Q_OBJECT - -public: - explicit ThreadChart(QObject *parent = nullptr); - - void setValue(QVector jd, QString dataName, QDateTime beginTime, QDateTime endTime); - - -signals: - void newCandS(); - void appSeries(qreal A,qreal B); - void setChartView(int jd,bool isEnum); - void setWidget(); - void setProgressBar(int percent); - -protected: - void run() override; - -private: - QVector jd; - QDateTime beginTime; - QDateTime endTime; - QString dataName; -}; - -#endif // THREADCHART_H diff --git a/threadpoltchart.cpp b/threadpoltchart.cpp deleted file mode 100644 index f722d04..0000000 --- a/threadpoltchart.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "threadpoltchart.h" -#include - -threadPoltChart::threadPoltChart(QObject *parent) - : QThread{parent} { -} - -void threadPoltChart::setValue(QVector jd, QString dataName, QDateTime beginTime, QDateTime endTime) { - this->jd = jd; - this->dataName = dataName; - this->beginTime = beginTime; - this->endTime = endTime; -} - - -void threadPoltChart::run() { - Gloab::m_QCView.clear(); - Gloab::rule.clear(); - Gloab::rule.append("状态"); - - for (int var = 0; var < 4; ++var) { - Gloab::xData[var].clear(); - Gloab::yData[var].clear(); - } - //判断右侧数据是否为数字型 - bool isEnum = Gloab::namelist[dataName]; - for (int i = 0; i < jd.size(); ++i) { - int X = 1; - // 为每个图表添加数据 - if (isEnum) { - for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) { - //更新进度条 - Gloab::bytesRead++; - int percent = Gloab::bytesRead * 100 / Gloab::fileSize; - emit setProgressBar(percent); - - if (Gloab::g_param[jd[i]][j].keys().size() <= deleteName.size()) { - bool f = true; - for (auto key: Gloab::g_param[jd[i]][j].keys()) { - if (!deleteName.contains(key)) { - f = false; - break; - } - } - if (f) { - continue; - } - } - - - QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz"); - if (temTime >= beginTime && temTime < endTime) { - if (Gloab::g_param[jd[i]][j].contains(dataName)) { - Gloab::xData[jd[i]].append(X++); - Gloab::yData[jd[i]].append(Gloab::g_param[jd[i]][j][dataName].toDouble()); - } - } - } - } else { - for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) { - //更新进度条 - Gloab::bytesRead++; - int percent = Gloab::bytesRead * 100 / Gloab::fileSize; - emit setProgressBar(percent); - - QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz"); - if (temTime >= beginTime && temTime < endTime) { - if (Gloab::g_param[jd[i]][j].contains(dataName)) { - QString tem1 = Gloab::g_param[jd[i]][j][dataName]; - if (!Gloab::rule.contains(tem1)) { - Gloab::rule.append(tem1); - } - Gloab::xData[jd[i]].append(X++); - Gloab::yData[jd[i]].append(Gloab::rule.indexOf(tem1)); - } - } - } - } - emit setChartView(jd[i], isEnum); - } - - emit setWidget(); - quit(); -} diff --git a/threadpoltchart.h b/threadpoltchart.h deleted file mode 100644 index b3ef874..0000000 --- a/threadpoltchart.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef THREADPOLTCHART_H -#define THREADPOLTCHART_H - -#include -#include -#include -#include -using namespace QtCharts; -#include -#include -#include -#include -#include - - -#include "gloab.h" - -class threadPoltChart : public QThread { - Q_OBJECT - -public: - explicit threadPoltChart(QObject *parent = nullptr); - - void setValue(QVector jd, QString dataName, QDateTime beginTime, QDateTime endTime ); - - -signals: - void setChartView(int jd, bool isEnum); - - void setWidget(); - - void setProgressBar(int percent); - -protected: - void run() override; - -private: - QVector jd; - QDateTime beginTime; - QDateTime endTime; - QString dataName; - QStringList deleteName; -}; - -#endif // THREADPOLTCHART_H diff --git a/threadread.cpp b/threadread.cpp deleted file mode 100644 index f8aae66..0000000 --- a/threadread.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "threadread.h" - -threadRead::threadRead(QObject *parent) - : QThread{parent} { -} - -bool threadRead::isNumeric(QString data) { - bool flag = false; - // 正则表达式匹配数字和可选的正负号 - QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$"); - QRegularExpressionMatch patternMatch =pattern.match(data); - if(patternMatch.hasMatch()){ - flag = true; - } - QRegularExpression kexue("^[0-9].[0-9]e[+-][0-9][0-9]"); - QRegularExpressionMatch kexueMatch =kexue.match(data); - if(kexueMatch.hasMatch()){ - flag = true; - } - return flag; -} - -void threadRead::run() { - //正则表达式 - //时间 - QRegularExpression dateTimeRegex("([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{3})"); - QRegularExpressionMatch matchDateTime; - //基带 - QRegularExpression jdRegex("\\[.*(\\d)\\]"); - QRegularExpressionMatch matchLogLevel; - - - //初始化数据 - for (auto &i: Gloab::g_param) { - i.clear(); - } - //清除下拉框数据 - emit clearCombo(); - if(!Gloab::namelist.empty()){ - Gloab::namelist.clear(); - Gloab::completer->deleteLater(); - } - - //设置状态栏 - emit showStatusbar("正在打开文件"); - - //读取文件 - QTextStream in(&Gloab::file); - while (!in.atEnd()) { - //读取一行 - QString line = in.readLine(); - - //更新进度条 - Gloab::bytesRead += line.size(); - int percent = Gloab::bytesRead * 150 / Gloab::fileSize; - emit setProgressBar(percent); - - - /* 匹配数据 */ - //匹配日期时间 - QMap temMap; - int JD; - QString temtime; - QString temjd; - matchDateTime = dateTimeRegex.match(line); - if (matchDateTime.hasMatch()) { - temtime = matchDateTime.captured(1); - temMap["时间"] = temtime; - } else { - continue; - } - //匹配基带 - matchLogLevel = jdRegex.match(line); - if (matchLogLevel.hasMatch()) { - temjd = matchLogLevel.captured(1); - temMap["基带"] = temjd; - JD = temjd.toInt() - 1; - } else { - continue; - } - - //设置开始时间 - if (Gloab::temData.isEmpty()) { - emit setBeginTime(QDateTime::fromString(temtime, "yyyy-MM-dd hh:mm:ss:zzz")); - } - Gloab::temData.clear(); - Gloab::temData["时间"] = temtime; - //将左右拆分 - QStringList dataParts = line.split(']'); - //判断右侧是否有数据 - if (dataParts[1].isEmpty()) { - continue; - } - //将右侧数据拆分 - QStringList data = dataParts[1].split(','); - for (int i = 0; i < data.size(); i++) { - //将每一条数据拆为数据名和值 - QStringList tem = data[i].split('='); - if (tem.size() < 2) { - continue; - } - if (!Gloab::namelist.contains(tem[0])) { - Gloab::namelist[tem[0]]=isNumeric(tem[1]); - if (tem[0].contains("版本号")) { - Gloab::namelist[tem[0]] = false; - } - } - Gloab::temData[tem[0]] = tem[1]; - } - //记录数据 - Gloab::g_param[JD].append(Gloab::temData); - - } - - //设置结束时间 - emit setEndTime(QDateTime::fromString(Gloab::temData["时间"], "yyyy-MM-dd hh:mm:ss:zzz")); - - //设置状态栏 - emit showStatusbar("打开成功:" + Gloab::fileName); - - //添加下拉框数据 - emit addCombo(Gloab::namelist.keys()); - - //关闭 - emit closeProg(); - Gloab::file.close(); - Gloab::temData.clear(); - quit(); -} diff --git a/threadread.h b/threadread.h deleted file mode 100644 index 1e7621c..0000000 --- a/threadread.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef THREADREAD_H -#define THREADREAD_H - -#include "gloab.h" - -#include - -class threadRead : public QThread { - Q_OBJECT - -public: - explicit threadRead(QObject *parent = nullptr); - bool isNumeric(QString data); - -signals: - void clearCombo(); - void showStatusbar(QString message); - void setBeginTime(QDateTime begin); - void setEndTime(QDateTime begin); - void addCombo(QStringList list); - void setProgressBar(int percent); - void closeProg(); - -private: - - -protected: - void run() Q_DECL_OVERRIDE; -}; - -#endif // THREADREAD_H