85 lines
3.0 KiB
C++
85 lines
3.0 KiB
C++
#include "threadpoltchart.h"
|
|
#include <QDebug>
|
|
|
|
threadPoltChart::threadPoltChart(QObject *parent)
|
|
: QThread{parent} {
|
|
}
|
|
|
|
void threadPoltChart::setValue(QVector<int> 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();
|
|
}
|