更改为QCustplot
This commit is contained in:
@ -19,6 +19,11 @@ set(PROJECT_SOURCES
|
|||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
gloab.h
|
gloab.h
|
||||||
gloab.cpp
|
gloab.cpp
|
||||||
|
lib/qcustomplot.h
|
||||||
|
lib/qcustomplot.cpp
|
||||||
|
qcustplot.cpp
|
||||||
|
qcustplot.h
|
||||||
|
qcustplot.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
@ -4,10 +4,11 @@ QString Gloab::fileName="";
|
|||||||
QVector<QMap<QString,QString>> Gloab::g_param[4];
|
QVector<QMap<QString,QString>> Gloab::g_param[4];
|
||||||
QMap<QString,QString> Gloab::temData;
|
QMap<QString,QString> Gloab::temData;
|
||||||
QMap<QString,bool> Gloab::namelist;
|
QMap<QString,bool> Gloab::namelist;
|
||||||
QList<QtCharts::QChartView*> Gloab::m_chartViews;
|
QList<QCustPlot*> Gloab::m_QCView;
|
||||||
QWidget * Gloab::widget;
|
QWidget * Gloab::widget;
|
||||||
QVector<QString> Gloab::rule;
|
QVector<QString> Gloab::rule;
|
||||||
QFile Gloab::file;
|
QFile Gloab::file;
|
||||||
qint64 Gloab::fileSize;
|
qint64 Gloab::fileSize;
|
||||||
qint64 Gloab::bytesRead;
|
qint64 Gloab::bytesRead;
|
||||||
QCompleter *Gloab::completer;
|
QCompleter *Gloab::completer;
|
||||||
|
QVector<double> Gloab::xData,Gloab::yData;
|
||||||
|
5
gloab.h
5
gloab.h
@ -14,19 +14,22 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QLineSeries>
|
#include <QLineSeries>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
|
#include "qcustplot.h"
|
||||||
|
|
||||||
class Gloab{
|
class Gloab{
|
||||||
public:
|
public:
|
||||||
static QString fileName;
|
static QString fileName;
|
||||||
static QVector<QMap<QString,QString>> g_param[4];
|
static QVector<QMap<QString,QString>> g_param[4];
|
||||||
static QMap<QString,QString> temData;
|
static QMap<QString,QString> temData;
|
||||||
static QMap<QString,bool> namelist;
|
static QMap<QString,bool> namelist;
|
||||||
static QList<QtCharts::QChartView*> m_chartViews;
|
static QList<QCustPlot*> m_QCView;
|
||||||
static QWidget *widget;
|
static QWidget *widget;
|
||||||
static QVector<QString> rule;
|
static QVector<QString> rule;
|
||||||
static QFile file;
|
static QFile file;
|
||||||
static qint64 fileSize;
|
static qint64 fileSize;
|
||||||
static qint64 bytesRead;
|
static qint64 bytesRead;
|
||||||
static QCompleter *completer;
|
static QCompleter *completer;
|
||||||
|
static QVector<double> xData,yData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
9
log7.pro
9
log7.pro
@ -1,6 +1,6 @@
|
|||||||
QT += core gui charts
|
QT += core gui charts
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
@ -10,21 +10,26 @@ CONFIG += c++11
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
gloab.cpp \
|
gloab.cpp \
|
||||||
|
lib/qcustomplot.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
qcustplot.cpp \
|
||||||
threadchart.cpp \
|
threadchart.cpp \
|
||||||
threadpoltchart.cpp \
|
threadpoltchart.cpp \
|
||||||
threadread.cpp
|
threadread.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
gloab.h \
|
gloab.h \
|
||||||
|
lib/qcustomplot.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
|
qcustplot.h \
|
||||||
threadchart.h \
|
threadchart.h \
|
||||||
threadpoltchart.h \
|
threadpoltchart.h \
|
||||||
threadread.h
|
threadread.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui \
|
||||||
|
qcustplot.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 12.0.2, 2024-09-12T17:38:37. -->
|
<!-- Written by QtCreator 12.0.2, 2024-09-13T11:44:52. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
107
mainwindow.cpp
107
mainwindow.cpp
@ -1,6 +1,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include "lib/qcustomplot.h"
|
||||||
|
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
|
|
||||||
@ -23,15 +24,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(thread_read, &threadRead::closeProg, this, &MainWindow::closeProg);
|
connect(thread_read, &threadRead::closeProg, this, &MainWindow::closeProg);
|
||||||
|
|
||||||
//chart
|
//chart
|
||||||
connect(thread_chart, &ThreadChart::newCandS, this, &MainWindow::newCandS);
|
|
||||||
connect(thread_chart, &ThreadChart::appSeries, this, &MainWindow::appSeries);
|
|
||||||
connect(thread_chart, &ThreadChart::setChartView, this, &MainWindow::setChartView);
|
connect(thread_chart, &ThreadChart::setChartView, this, &MainWindow::setChartView);
|
||||||
connect(thread_chart, &ThreadChart::setWidget, this, &MainWindow::setWidget);
|
connect(thread_chart, &ThreadChart::setWidget, this, &MainWindow::setWidget);
|
||||||
connect(thread_chart, &ThreadChart::setProgressBar, this, &MainWindow::setProgressBar);
|
connect(thread_chart, &ThreadChart::setProgressBar, this, &MainWindow::setProgressBar);
|
||||||
|
|
||||||
//plot
|
//plot
|
||||||
connect(thread_polt, &threadPoltChart::newCandS, this, &MainWindow::newPlotCandS);
|
|
||||||
connect(thread_polt, &threadPoltChart::appSeries, this, &MainWindow::appSeries);
|
|
||||||
connect(thread_polt, &threadPoltChart::setChartView, this, &MainWindow::setPlotChartView);
|
connect(thread_polt, &threadPoltChart::setChartView, this, &MainWindow::setPlotChartView);
|
||||||
connect(thread_polt, &threadPoltChart::setWidget, this, &MainWindow::setWidget);
|
connect(thread_polt, &threadPoltChart::setWidget, this, &MainWindow::setWidget);
|
||||||
connect(thread_polt, &threadPoltChart::setProgressBar, this, &MainWindow::setProgressBar);
|
connect(thread_polt, &threadPoltChart::setProgressBar, this, &MainWindow::setProgressBar);
|
||||||
@ -94,7 +91,6 @@ void MainWindow::addCombo(const QStringList &list) {
|
|||||||
|
|
||||||
void MainWindow::setProgressBar(int percent) {
|
void MainWindow::setProgressBar(int percent) {
|
||||||
progressBar->setValue(percent);
|
progressBar->setValue(percent);
|
||||||
// qApp->processEvents(); // 更新UI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeProg() {
|
void MainWindow::closeProg() {
|
||||||
@ -103,76 +99,30 @@ void MainWindow::closeProg() {
|
|||||||
ui->widget->close();
|
ui->widget->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::newCandS() {
|
|
||||||
chart = new QChart;
|
|
||||||
series = new QLineSeries;
|
|
||||||
// series->setPointsVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::appSeries(qreal A, qreal B) {
|
|
||||||
series->append(A, B);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setChartView(int jd, bool isEnum) {
|
void MainWindow::setChartView(int jd, bool isEnum) {
|
||||||
// 设置图表标题
|
// 设置图表标题
|
||||||
chart->setTitle(QString("基带 %1").arg(jd+1));
|
QCustPlot *qCustPlot = new QCustPlot(Gloab::xData, Gloab::yData, jd, isEnum, true);
|
||||||
chart->addSeries(series);
|
// 将qCustPlot添加到容器中
|
||||||
if (isEnum) {
|
Gloab::m_QCView.append(qCustPlot);
|
||||||
chart->createDefaultAxes();
|
|
||||||
// 获取X轴
|
|
||||||
QList<QAbstractAxis *> xAxes = chart->axes(Qt::Horizontal);
|
|
||||||
// 断开所有与该轴关联的系列
|
|
||||||
series->detachAxis(xAxes[0]);
|
|
||||||
// 从图表中移除轴
|
|
||||||
chart->removeAxis(xAxes[0]);
|
|
||||||
} else {
|
|
||||||
// 创建类别Y轴
|
|
||||||
QCategoryAxis *axisY = new QCategoryAxis();
|
|
||||||
for (int var = 1; var < Gloab::rule.size(); ++var) {
|
|
||||||
axisY->append(Gloab::rule[var], var);
|
|
||||||
}
|
|
||||||
//刻度线和刻度的label对齐
|
|
||||||
axisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
|
|
||||||
axisY->setRange(0, Gloab::rule.size() + 1);
|
|
||||||
chart->setAxisY(axisY, series);
|
|
||||||
// series->attachAxis(axisY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 创建一个时间轴
|
|
||||||
QDateTimeAxis *axisX = new QDateTimeAxis;
|
|
||||||
axisX->setTickCount(10);
|
|
||||||
axisX->setFormat("HH:mm"); // 设置时间格式
|
|
||||||
chart->addAxis(axisX, Qt::AlignBottom);
|
|
||||||
series->attachAxis(axisX);
|
|
||||||
|
|
||||||
|
|
||||||
// 创建QChartView
|
|
||||||
QChartView *chartView = new QChartView(chart);
|
|
||||||
chartView->setRenderHint(QPainter::Antialiasing);
|
|
||||||
|
|
||||||
// 将chartView添加到容器中
|
|
||||||
Gloab::m_chartViews.append(chartView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setWidget() {
|
void MainWindow::setWidget() {
|
||||||
// 设置布局
|
// 设置布局
|
||||||
int wide = 850;
|
int wide = 850;
|
||||||
int hight = 600;
|
int hight = 600;
|
||||||
if (Gloab::m_chartViews.size() > 1) {
|
if (Gloab::m_QCView.size() > 1) {
|
||||||
wide = 1800;
|
wide = 1800;
|
||||||
}
|
}
|
||||||
QGridLayout *gridLayout = new QGridLayout(Gloab::widget);
|
QGridLayout *gridLayout = new QGridLayout(Gloab::widget);
|
||||||
for (int i = 0, j = 0; i < Gloab::m_chartViews.size(); i++) {
|
for (int i = 0, j = 0; i < Gloab::m_QCView.size(); i++) {
|
||||||
if (i != 0 && i % 2 == 0) {
|
if (i != 0 && i % 2 == 0) {
|
||||||
j++;
|
j++;
|
||||||
hight += 350;
|
hight += 350;
|
||||||
}
|
}
|
||||||
gridLayout->addWidget(Gloab::m_chartViews[i], j, i - 2 * j);
|
gridLayout->addWidget(Gloab::m_QCView[i], j, i - 2 * j);
|
||||||
}
|
}
|
||||||
Gloab::widget->resize(wide, hight);
|
Gloab::widget->resize(wide, hight);
|
||||||
// Gloab::widget->setMaximumHeight(950);
|
|
||||||
|
|
||||||
Gloab::widget->move(70, 20);
|
Gloab::widget->move(70, 20);
|
||||||
Gloab::widget->show();
|
Gloab::widget->show();
|
||||||
|
|
||||||
@ -181,48 +131,13 @@ void MainWindow::setWidget() {
|
|||||||
ui->widget->close();
|
ui->widget->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::newPlotCandS() {
|
|
||||||
chart = new QChart;
|
|
||||||
series = new QLineSeries;
|
|
||||||
// series->setPointsVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setPlotChartView(int jd, bool isEnum) {
|
void MainWindow::setPlotChartView(int jd, bool isEnum) {
|
||||||
// 设置图表标题
|
// 设置图表标题
|
||||||
chart->setTitle(QString("基带 %1").arg(jd+1));
|
QCustPlot *qCustPlot = new QCustPlot(Gloab::xData, Gloab::yData, jd, isEnum, false);
|
||||||
chart->addSeries(series);
|
// 将qCustPlot添加到容器中
|
||||||
if (isEnum) {
|
Gloab::m_QCView.append(qCustPlot);
|
||||||
chart->createDefaultAxes();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//创建默认XY轴
|
|
||||||
chart->createDefaultAxes();
|
|
||||||
//删除Y轴
|
|
||||||
// 获取Y轴
|
|
||||||
QList<QAbstractAxis *> yAxes = chart->axes(Qt::Vertical);
|
|
||||||
// 断开所有与该轴关联的系列
|
|
||||||
series->detachAxis(yAxes[0]);
|
|
||||||
// 从图表中移除轴
|
|
||||||
chart->removeAxis(yAxes[0]);
|
|
||||||
// 创建类别Y轴
|
|
||||||
QCategoryAxis *axisY = new QCategoryAxis();
|
|
||||||
for (int var = 1; var < Gloab::rule.size(); ++var) {
|
|
||||||
axisY->append(Gloab::rule[var], var);
|
|
||||||
}
|
|
||||||
//刻度线和刻度的label对齐
|
|
||||||
axisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
|
|
||||||
axisY->setRange(0, Gloab::rule.size() + 1);
|
|
||||||
chart->setAxisY(axisY, series);
|
|
||||||
// plotSeries->attachAxis(axisY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 创建QChartView
|
|
||||||
QChartView *chartView = new QChartView(chart);
|
|
||||||
chartView->setRenderHint(QPainter::Antialiasing);
|
|
||||||
|
|
||||||
// 将chartView添加到容器中
|
|
||||||
Gloab::m_chartViews.append(chartView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_lineChart_clicked() {
|
void MainWindow::on_lineChart_clicked() {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
|
#include "qcustplot.h"
|
||||||
#include "threadchart.h"
|
#include "threadchart.h"
|
||||||
#include "threadpoltchart.h"
|
#include "threadpoltchart.h"
|
||||||
|
|
||||||
@ -38,12 +38,9 @@ private slots:
|
|||||||
void setProgressBar(int percent);
|
void setProgressBar(int percent);
|
||||||
void closeProg();
|
void closeProg();
|
||||||
|
|
||||||
void newCandS();
|
|
||||||
void appSeries(qreal A,qreal B);
|
|
||||||
void setChartView(int jd,bool isEnum);
|
void setChartView(int jd,bool isEnum);
|
||||||
void setWidget();
|
void setWidget();
|
||||||
|
|
||||||
void newPlotCandS();
|
|
||||||
void setPlotChartView(int jd,bool isEnum);
|
void setPlotChartView(int jd,bool isEnum);
|
||||||
|
|
||||||
void on_lineChart_clicked();
|
void on_lineChart_clicked();
|
||||||
|
60
qcustplot.cpp
Normal file
60
qcustplot.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include "qcustplot.h"
|
||||||
|
#include "ui_qcustplot.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "gloab.h"
|
||||||
|
|
||||||
|
QCustPlot::QCustPlot(QVector<double> xData, QVector<double> 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<QCPAxisTickerDateTime> timeTicker(new QCPAxisTickerDateTime);
|
||||||
|
timeTicker->setDateTimeFormat("hh:mm:ss");
|
||||||
|
ui->plot->xAxis->setTicker(timeTicker);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Y轴
|
||||||
|
if(!isNub){
|
||||||
|
QVector<double> ticks;
|
||||||
|
QVector<QString> labels;
|
||||||
|
for (int i = 1; i < Gloab::rule.size(); ++i) {
|
||||||
|
ticks.append(i);
|
||||||
|
labels.append(Gloab::rule[i]);
|
||||||
|
}
|
||||||
|
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
|
||||||
|
textTicker->addTicks(ticks, labels);
|
||||||
|
ui->plot->yAxis->setTicker(textTicker);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加图形
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
25
qcustplot.h
Normal file
25
qcustplot.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef QCUSTPLOT_H
|
||||||
|
#define QCUSTPLOT_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "lib/qcustomplot.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class QCustPlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QCustPlot : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QCustPlot(QVector<double> xData, QVector<double> yData, int jd, bool isNub, bool isTime,
|
||||||
|
QWidget *parent = nullptr);
|
||||||
|
~QCustPlot();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::QCustPlot *ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QCUSTPLOT_H
|
39
qcustplot.ui
Normal file
39
qcustplot.ui
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>QCustPlot</class>
|
||||||
|
<widget class="QWidget" name="QCustPlot">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>673</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCustomPlot" name="plot" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>QCustomPlot</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lib/qcustomplot.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -14,13 +14,15 @@ void ThreadChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTim
|
|||||||
|
|
||||||
|
|
||||||
void ThreadChart::run() {
|
void ThreadChart::run() {
|
||||||
Gloab::m_chartViews.clear();
|
Gloab::m_QCView.clear();
|
||||||
Gloab::rule.clear();
|
Gloab::rule.clear();
|
||||||
Gloab::rule.append("状态");
|
Gloab::rule.append("状态");
|
||||||
//判断右侧数据是否为数字型
|
//判断右侧数据是否为数字型
|
||||||
bool isEnum = Gloab::namelist[dataName];
|
bool isEnum = Gloab::namelist[dataName];
|
||||||
for (int i = 0; i < jd.size(); ++i) {
|
for (int i = 0; i < jd.size(); ++i) {
|
||||||
emit newCandS();
|
// emit newCandS();
|
||||||
|
Gloab::xData.clear();
|
||||||
|
Gloab::yData.clear();
|
||||||
qreal y = 114.514;
|
qreal y = 114.514;
|
||||||
QString tem1 = "无数据";
|
QString tem1 = "无数据";
|
||||||
// 为每个图表添加数据
|
// 为每个图表添加数据
|
||||||
@ -35,16 +37,13 @@ void ThreadChart::run() {
|
|||||||
if (temTime >= beginTime && temTime < endTime) {
|
if (temTime >= beginTime && temTime < endTime) {
|
||||||
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
|
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
|
||||||
if (y != 114.514) {
|
if (y != 114.514) {
|
||||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
||||||
|
Gloab::yData.append(y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Gloab::g_param[jd[i]][j][dataName].contains(".")) {
|
y = Gloab::g_param[jd[i]][j][dataName].toDouble();
|
||||||
y = Gloab::g_param[jd[i]][j][dataName].toDouble();
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
||||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
Gloab::yData.append(y);
|
||||||
} else {
|
|
||||||
y = Gloab::g_param[jd[i]][j][dataName].toLongLong();
|
|
||||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,14 +61,16 @@ void ThreadChart::run() {
|
|||||||
if (!Gloab::rule.contains(tem1)) {
|
if (!Gloab::rule.contains(tem1)) {
|
||||||
Gloab::rule.append(tem1);
|
Gloab::rule.append(tem1);
|
||||||
}
|
}
|
||||||
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
||||||
|
Gloab::yData.append(Gloab::rule.indexOf(tem1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tem1 = Gloab::g_param[jd[i]][j][dataName];
|
tem1 = Gloab::g_param[jd[i]][j][dataName];
|
||||||
if (!Gloab::rule.contains(tem1)) {
|
if (!Gloab::rule.contains(tem1)) {
|
||||||
Gloab::rule.append(tem1);
|
Gloab::rule.append(tem1);
|
||||||
}
|
}
|
||||||
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
||||||
|
Gloab::yData.append(Gloab::rule.indexOf(tem1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
threadPoltChart::threadPoltChart(QObject *parent)
|
threadPoltChart::threadPoltChart(QObject *parent)
|
||||||
: QThread{parent} {
|
: QThread{parent} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void threadPoltChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime) {
|
void threadPoltChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime) {
|
||||||
@ -13,21 +13,18 @@ void threadPoltChart::setValue(QVector<int> jd, QString dataName, QDateTime begi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void threadPoltChart::run() {
|
void threadPoltChart::run() {
|
||||||
Gloab::m_chartViews.clear();
|
Gloab::m_QCView.clear();
|
||||||
Gloab::rule.clear();
|
Gloab::rule.clear();
|
||||||
Gloab::rule.append("状态");
|
Gloab::rule.append("状态");
|
||||||
|
//判断右侧数据是否为数字型
|
||||||
|
bool isEnum = Gloab::namelist[dataName];
|
||||||
for (int i = 0; i < jd.size(); ++i) {
|
for (int i = 0; i < jd.size(); ++i) {
|
||||||
int X = 1;
|
int X = 1;
|
||||||
emit newCandS();
|
Gloab::xData.clear();
|
||||||
|
Gloab::yData.clear();
|
||||||
|
|
||||||
// 为每个图表添加数据
|
// 为每个图表添加数据
|
||||||
//判断右侧数据是否为数字型
|
|
||||||
bool isEnum = Gloab::namelist[dataName];
|
|
||||||
if (dataName.contains("版本号")) {
|
|
||||||
isEnum = false;
|
|
||||||
}
|
|
||||||
if (isEnum) {
|
if (isEnum) {
|
||||||
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
|
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
|
||||||
//更新进度条
|
//更新进度条
|
||||||
@ -35,11 +32,11 @@ void threadPoltChart::run() {
|
|||||||
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
|
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
|
||||||
emit setProgressBar(percent);
|
emit setProgressBar(percent);
|
||||||
|
|
||||||
if (Gloab::g_param[jd[i]][j].keys().size()<=deleteName.size()) {
|
if (Gloab::g_param[jd[i]][j].keys().size() <= deleteName.size()) {
|
||||||
bool f=true;
|
bool f = true;
|
||||||
for(auto key : Gloab::g_param[jd[i]][j].keys()) {
|
for (auto key: Gloab::g_param[jd[i]][j].keys()) {
|
||||||
if (!deleteName.contains(key)) {
|
if (!deleteName.contains(key)) {
|
||||||
f=false;
|
f = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,11 +49,8 @@ void threadPoltChart::run() {
|
|||||||
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
|
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
|
||||||
if (temTime >= beginTime && temTime < endTime) {
|
if (temTime >= beginTime && temTime < endTime) {
|
||||||
if (Gloab::g_param[jd[i]][j].contains(dataName)) {
|
if (Gloab::g_param[jd[i]][j].contains(dataName)) {
|
||||||
if (Gloab::g_param[jd[i]][j][dataName].contains(".")) {
|
Gloab::xData.append(X++);
|
||||||
emit appSeries(X++, Gloab::g_param[jd[i]][j][dataName].toDouble());
|
Gloab::yData.append(Gloab::g_param[jd[i]][j][dataName].toDouble());
|
||||||
} else {
|
|
||||||
emit appSeries(X++, Gloab::g_param[jd[i]][j][dataName].toLongLong());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +68,8 @@ void threadPoltChart::run() {
|
|||||||
if (!Gloab::rule.contains(tem1)) {
|
if (!Gloab::rule.contains(tem1)) {
|
||||||
Gloab::rule.append(tem1);
|
Gloab::rule.append(tem1);
|
||||||
}
|
}
|
||||||
emit appSeries(X++, Gloab::rule.indexOf(tem1));
|
Gloab::xData.append(X++);
|
||||||
|
Gloab::yData.append(Gloab::rule.indexOf(tem1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newCandS();
|
|
||||||
|
|
||||||
void appSeries(qreal A, qreal B);
|
|
||||||
|
|
||||||
void setChartView(int jd, bool isEnum);
|
void setChartView(int jd, bool isEnum);
|
||||||
|
|
||||||
void setWidget();
|
void setWidget();
|
||||||
|
Reference in New Issue
Block a user