diff --git a/AnalysisTool-release/bin/AnalysisTool.exe b/AnalysisTool-release/bin/AnalysisTool.exe deleted file mode 100644 index 7285c59..0000000 Binary files a/AnalysisTool-release/bin/AnalysisTool.exe and /dev/null differ diff --git a/AnalysisTool-release/bin/AnalysisTool_0.9.8.exe b/AnalysisTool-release/bin/AnalysisTool_0.9.8.exe new file mode 100644 index 0000000..2e0b149 Binary files /dev/null and b/AnalysisTool-release/bin/AnalysisTool_0.9.8.exe differ diff --git a/AnalysisTool-release/bin/log/20250516.log b/AnalysisTool-release/bin/log/20250516.log new file mode 100644 index 0000000..369aefb --- /dev/null +++ b/AnalysisTool-release/bin/log/20250516.log @@ -0,0 +1,244 @@ +[2025-05-16 11:10:34,571] main... +[2025-05-16 11:10:34,571] config config file existed. +[2025-05-16 11:10:34,635] setEventHandlerEnable...0 +[2025-05-16 11:10:42,955] main... +[2025-05-16 11:10:42,955] config config file existed. +[2025-05-16 11:10:42,974] setEventHandlerEnable...0 +[2025-05-16 11:10:49,769] clearExperimentData... +[2025-05-16 11:10:49,772] slotSendData:9 +[2025-05-16 11:10:49,772] slotSendData:a5 5a 06 82 2c 00 01 28 55 +[2025-05-16 11:10:49,772] start experiment,set soft into experiment mode. +[2025-05-16 11:10:52,426] clearExperimentData... +[2025-05-16 11:13:11,330] main... +[2025-05-16 11:13:11,330] config config file existed. +[2025-05-16 11:13:11,347] setEventHandlerEnable...0 +[2025-05-16 11:17:08,149] main... +[2025-05-16 11:17:08,150] config config file existed. +[2025-05-16 11:17:08,169] setEventHandlerEnable...0 +[2025-05-16 11:17:19,308] main... +[2025-05-16 11:17:19,309] config config file existed. +[2025-05-16 11:17:19,328] setEventHandlerEnable...0 +[2025-05-16 11:17:22,413] xlsx sample weight:1 +[2025-05-16 11:17:22,414] startLineIndex:11 +[2025-05-16 11:17:22,414] data size:1762 +[2025-05-16 11:17:22,415] startLineIndex:1780 +[2025-05-16 11:17:22,415] data size:331 +[2025-05-16 11:17:22,415] dataIndex:2116 +[2025-05-16 11:17:22,415] Cell does not exist. +[2025-05-16 11:17:24,817] xlsx sample weight:1 +[2025-05-16 11:17:24,817] startLineIndex:11 +[2025-05-16 11:17:24,817] data size:814 +[2025-05-16 11:17:24,817] startLineIndex:832 +[2025-05-16 11:17:24,817] data size:600 +[2025-05-16 11:17:24,818] startLineIndex:1439 +[2025-05-16 11:17:24,818] data size:301 +[2025-05-16 11:17:24,818] dataIndex:1745 +[2025-05-16 11:17:24,818] Cell does not exist. +[2025-05-16 11:17:25,924] xlsx sample weight:17.2800006866455 +[2025-05-16 11:17:25,924] startLineIndex:11 +[2025-05-16 11:17:25,925] data size:1264 +[2025-05-16 11:17:25,925] dataIndex:1280 +[2025-05-16 11:17:25,925] Cell does not exist. +[2025-05-16 11:17:26,709] xlsx sample weight:13.9200000762939 +[2025-05-16 11:17:26,709] startLineIndex:11 +[2025-05-16 11:17:26,709] data size:1820 +[2025-05-16 11:17:26,711] dataIndex:1836 +[2025-05-16 11:17:26,711] ana op size:6 +[2025-05-16 11:17:26,711] ao mode:1822 +[2025-05-16 11:17:26,711] x1:6.236,x2:144.584 +[2025-05-16 11:17:26,711] ao mode:1823 +[2025-05-16 11:17:26,711] x1:6.239,x2:144.849 +[2025-05-16 11:17:26,711] ao mode:1824 +[2025-05-16 11:17:26,711] x1:6.243,x2:144.849 +[2025-05-16 11:17:26,711] ao mode:1825 +[2025-05-16 11:17:26,711] x1:6.246,x2:144.849 +[2025-05-16 11:17:26,712] ao mode:1826 +[2025-05-16 11:17:26,712] x1:6.25,x2:144.991 +[2025-05-16 11:17:26,712] ao mode:1827 +[2025-05-16 11:17:26,712] x1:6.253,x2:144.991 +[2025-05-16 13:24:22,525] main... +[2025-05-16 13:24:22,526] config config file existed. +[2025-05-16 13:24:22,587] setEventHandlerEnable...0 +[2025-05-16 13:24:24,999] xlsx sample weight:0 +[2025-05-16 13:24:24,999] startLineIndex:11 +[2025-05-16 13:24:25,000] data size:3550 +[2025-05-16 13:24:25,001] dataIndex:3566 +[2025-05-16 13:24:25,001] Cell does not exist. +[2025-05-16 13:24:45,510] xlsx sample weight:8.31 +[2025-05-16 13:24:45,511] startLineIndex:11 +[2025-05-16 13:24:45,511] data size:7279 +[2025-05-16 13:24:45,515] dataIndex:7295 +[2025-05-16 13:24:45,515] Cell does not exist. +[2025-05-16 13:24:47,444] xlsx sample weight:0 +[2025-05-16 13:24:47,445] startLineIndex:11 +[2025-05-16 13:24:47,445] data size:3550 +[2025-05-16 13:24:47,446] dataIndex:3566 +[2025-05-16 13:24:47,447] Cell does not exist. +[2025-05-16 13:24:48,355] xlsx sample weight:1 +[2025-05-16 13:24:48,356] startLineIndex:11 +[2025-05-16 13:24:48,356] data size:298 +[2025-05-16 13:24:48,356] dataIndex:314 +[2025-05-16 13:24:48,356] Cell does not exist. +[2025-05-16 13:24:49,205] xlsx sample weight: +[2025-05-16 13:24:49,205] dataIndex:9 +[2025-05-16 13:24:49,205] Cell does not exist. +[2025-05-16 13:24:49,936] xlsx sample weight:1 +[2025-05-16 13:24:49,936] startLineIndex:11 +[2025-05-16 13:24:49,936] data size:814 +[2025-05-16 13:24:49,937] startLineIndex:832 +[2025-05-16 13:24:49,937] data size:600 +[2025-05-16 13:24:49,937] startLineIndex:1439 +[2025-05-16 13:24:49,938] data size:301 +[2025-05-16 13:24:49,938] dataIndex:1745 +[2025-05-16 13:24:49,938] Cell does not exist. +[2025-05-16 13:24:50,645] xlsx sample weight: +[2025-05-16 13:24:50,645] dataIndex:9 +[2025-05-16 13:24:50,645] Cell does not exist. +[2025-05-16 13:24:51,305] xlsx sample weight: +[2025-05-16 13:24:51,305] dataIndex:9 +[2025-05-16 13:24:51,307] Cell does not exist. +[2025-05-16 13:24:51,853] xlsx sample weight: +[2025-05-16 13:24:51,853] dataIndex:9 +[2025-05-16 13:24:51,853] Cell does not exist. +[2025-05-16 13:24:52,463] xlsx sample weight:1 +[2025-05-16 13:24:52,464] startLineIndex:11 +[2025-05-16 13:24:52,464] data size:1762 +[2025-05-16 13:24:52,466] startLineIndex:1780 +[2025-05-16 13:24:52,466] data size:331 +[2025-05-16 13:24:52,466] dataIndex:2116 +[2025-05-16 13:24:52,466] Cell does not exist. +[2025-05-16 13:24:52,999] xlsx sample weight: +[2025-05-16 13:24:52,999] dataIndex:9 +[2025-05-16 13:24:52,999] Cell does not exist. +[2025-05-16 13:24:53,648] xlsx sample weight: +[2025-05-16 13:24:53,648] dataIndex:9 +[2025-05-16 13:24:53,648] Cell does not exist. +[2025-05-16 13:24:54,161] xlsx sample weight:1 +[2025-05-16 13:24:54,161] startLineIndex:11 +[2025-05-16 13:24:54,161] data size:814 +[2025-05-16 13:24:54,162] startLineIndex:832 +[2025-05-16 13:24:54,162] data size:600 +[2025-05-16 13:24:54,162] startLineIndex:1439 +[2025-05-16 13:24:54,162] data size:301 +[2025-05-16 13:24:54,163] dataIndex:1745 +[2025-05-16 13:24:54,163] Cell does not exist. +[2025-05-16 13:24:55,079] clearExperimentData... +[2025-05-16 14:15:09,683] main... +[2025-05-16 14:15:09,684] config config file existed. +[2025-05-16 14:15:09,708] setEventHandlerEnable...0 +[2025-05-16 14:15:13,369] xlsx sample weight:8.31 +[2025-05-16 14:15:13,369] startLineIndex:11 +[2025-05-16 14:15:13,370] data size:7279 +[2025-05-16 14:15:13,373] dataIndex:7295 +[2025-05-16 14:15:13,374] Cell does not exist. +[2025-05-16 14:46:30,603] main... +[2025-05-16 14:46:30,603] config config file existed. +[2025-05-16 14:46:30,622] setEventHandlerEnable...0 +[2025-05-16 14:46:36,566] xlsx sample weight:0 +[2025-05-16 14:46:36,566] startLineIndex:11 +[2025-05-16 14:46:36,566] data size:1256 +[2025-05-16 14:46:36,567] dataIndex:1272 +[2025-05-16 14:46:36,567] Cell does not exist. +[2025-05-16 14:46:37,175] xlsx sample weight:13.9200000762939 +[2025-05-16 14:46:37,175] startLineIndex:11 +[2025-05-16 14:46:37,176] data size:7466 +[2025-05-16 14:46:37,179] dataIndex:7482 +[2025-05-16 14:46:37,180] ana op size:5 +[2025-05-16 14:46:37,180] ao mode:267.675 +[2025-05-16 14:46:37,180] x1:5.398,x2:267.675 +[2025-05-16 14:46:37,180] ao mode:267.675 +[2025-05-16 14:46:37,180] x1:5.397,x2:267.675 +[2025-05-16 14:46:37,180] ao mode:267.745 +[2025-05-16 14:46:37,180] x1:5.397,x2:267.745 +[2025-05-16 14:46:37,180] ao mode:267.745 +[2025-05-16 14:46:37,180] x1:5.396,x2:267.745 +[2025-05-16 14:46:37,180] ao mode:267.885 +[2025-05-16 14:46:37,180] x1:5.396,x2:267.885 +[2025-05-16 14:46:37,803] xlsx sample weight:13.9200000762939 +[2025-05-16 14:46:37,804] startLineIndex:11 +[2025-05-16 14:46:37,804] data size:1264 +[2025-05-16 14:46:37,805] dataIndex:1280 +[2025-05-16 14:46:37,805] Cell does not exist. +[2025-05-16 14:46:38,429] xlsx sample weight:17.2800006866455 +[2025-05-16 14:46:38,434] startLineIndex:11 +[2025-05-16 14:46:38,434] data size:1264 +[2025-05-16 14:46:38,435] dataIndex:1280 +[2025-05-16 14:46:38,450] Cell does not exist. +[2025-05-16 14:46:38,965] xlsx sample weight:13.9200000762939 +[2025-05-16 14:46:38,966] startLineIndex:11 +[2025-05-16 14:46:38,966] data size:1820 +[2025-05-16 14:46:38,967] dataIndex:1836 +[2025-05-16 14:46:38,967] ana op size:6 +[2025-05-16 14:46:38,967] ao mode:1822 +[2025-05-16 14:46:38,967] x1:6.236,x2:144.584 +[2025-05-16 14:46:38,967] ao mode:1823 +[2025-05-16 14:46:38,967] x1:6.239,x2:144.849 +[2025-05-16 14:46:38,967] ao mode:1824 +[2025-05-16 14:46:38,967] x1:6.243,x2:144.849 +[2025-05-16 14:46:38,967] ao mode:1825 +[2025-05-16 14:46:38,968] x1:6.246,x2:144.849 +[2025-05-16 14:46:38,968] ao mode:1826 +[2025-05-16 14:46:38,968] x1:6.25,x2:144.991 +[2025-05-16 14:46:38,968] ao mode:1827 +[2025-05-16 14:46:38,968] x1:6.253,x2:144.991 +[2025-05-16 14:46:39,572] xlsx sample weight:17.2800006866455 +[2025-05-16 14:46:39,573] startLineIndex:11 +[2025-05-16 14:46:39,573] data size:1264 +[2025-05-16 14:46:39,573] dataIndex:1280 +[2025-05-16 14:46:39,574] Cell does not exist. +[2025-05-16 14:46:43,099] xlsx sample weight:0 +[2025-05-16 14:46:43,099] startLineIndex:11 +[2025-05-16 14:46:43,099] data size:3550 +[2025-05-16 14:46:43,101] dataIndex:3566 +[2025-05-16 14:46:43,101] Cell does not exist. +[2025-05-16 14:46:44,529] xlsx sample weight:1 +[2025-05-16 14:46:44,529] startLineIndex:11 +[2025-05-16 14:46:44,529] data size:298 +[2025-05-16 14:46:44,529] dataIndex:314 +[2025-05-16 14:46:44,529] Cell does not exist. +[2025-05-16 14:46:45,098] xlsx sample weight: +[2025-05-16 14:46:45,099] dataIndex:9 +[2025-05-16 14:46:45,099] Cell does not exist. +[2025-05-16 14:46:45,745] xlsx sample weight:1 +[2025-05-16 14:46:45,746] startLineIndex:11 +[2025-05-16 14:46:45,746] data size:814 +[2025-05-16 14:46:45,747] startLineIndex:832 +[2025-05-16 14:46:45,747] data size:600 +[2025-05-16 14:46:45,748] startLineIndex:1439 +[2025-05-16 14:46:45,748] data size:301 +[2025-05-16 14:46:45,749] dataIndex:1745 +[2025-05-16 14:46:45,751] Cell does not exist. +[2025-05-16 14:46:46,484] xlsx sample weight: +[2025-05-16 14:46:46,484] dataIndex:9 +[2025-05-16 14:46:46,484] Cell does not exist. +[2025-05-16 14:46:47,247] xlsx sample weight: +[2025-05-16 14:46:47,247] dataIndex:9 +[2025-05-16 14:46:47,261] Cell does not exist. +[2025-05-16 14:46:47,954] xlsx sample weight: +[2025-05-16 14:46:47,954] dataIndex:9 +[2025-05-16 14:46:47,954] Cell does not exist. +[2025-05-16 14:46:48,466] xlsx sample weight:1 +[2025-05-16 14:46:48,476] startLineIndex:11 +[2025-05-16 14:46:48,476] data size:1762 +[2025-05-16 14:46:48,477] startLineIndex:1780 +[2025-05-16 14:46:48,478] data size:331 +[2025-05-16 14:46:48,478] dataIndex:2116 +[2025-05-16 14:46:48,478] Cell does not exist. +[2025-05-16 14:46:56,422] clearExperimentData... +[2025-05-16 14:46:58,546] xlsx sample weight:0 +[2025-05-16 14:46:58,546] startLineIndex:11 +[2025-05-16 14:46:58,546] data size:3550 +[2025-05-16 14:46:58,548] dataIndex:3566 +[2025-05-16 14:46:58,548] Cell does not exist. +[2025-05-16 14:47:04,735] clearExperimentData... +[2025-05-16 14:47:05,642] xlsx sample weight:8.31 +[2025-05-16 14:47:05,643] startLineIndex:11 +[2025-05-16 14:47:05,643] data size:7279 +[2025-05-16 14:47:05,646] dataIndex:7295 +[2025-05-16 14:47:05,647] Cell does not exist. +[2025-05-16 14:47:11,343] clearExperimentData... +[2025-05-16 14:47:12,667] xlsx sample weight:8.31 +[2025-05-16 14:47:12,668] startLineIndex:11 +[2025-05-16 14:47:12,672] data size:7279 +[2025-05-16 14:47:12,679] dataIndex:7295 +[2025-05-16 14:47:12,679] Cell does not exist. diff --git a/AnalysisTool-release/experiment_data/sample_data/苯甲酸.xlsx b/AnalysisTool-release/experiment_data/sample_data/苯甲酸.xlsx new file mode 100644 index 0000000..8cd017e Binary files /dev/null and b/AnalysisTool-release/experiment_data/sample_data/苯甲酸.xlsx differ diff --git a/experiment_data/analysis_state/16-2-new.xlsx b/experiment_data/analysis_state/16-2-new.xlsx new file mode 100644 index 0000000..144edec Binary files /dev/null and b/experiment_data/analysis_state/16-2-new.xlsx differ diff --git a/experiment_data/analysis_state/16-new.xlsx b/experiment_data/analysis_state/16-new.xlsx new file mode 100644 index 0000000..d6b55ca Binary files /dev/null and b/experiment_data/analysis_state/16-new.xlsx differ diff --git a/experiment_data/sample_data/16-new.xlsx b/experiment_data/sample_data/16-new.xlsx new file mode 100644 index 0000000..38113cf Binary files /dev/null and b/experiment_data/sample_data/16-new.xlsx differ diff --git a/experiment_data/sample_data/17-new.xlsx b/experiment_data/sample_data/17-new.xlsx new file mode 100644 index 0000000..c47c0c1 Binary files /dev/null and b/experiment_data/sample_data/17-new.xlsx differ diff --git a/experiment_data/sample_data/new.xlsx b/experiment_data/sample_data/new.xlsx index 209350b..f2f0d0f 100644 Binary files a/experiment_data/sample_data/new.xlsx and b/experiment_data/sample_data/new.xlsx differ diff --git a/src/AnalysisTool.pro b/src/AnalysisTool.pro index 48a86ab..9c4514d 100644 --- a/src/AnalysisTool.pro +++ b/src/AnalysisTool.pro @@ -3,12 +3,13 @@ QT += core gui serialport printsupport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 +#CONFIG += console CONFIG+=precompile_header PRECOMPILED_HEADER=stable.h # -VERSION = 0.9.7.4 +VERSION = 0.9.8 # 设置目标文件名,包含版本号 TARGET = AnalysisTool_$${VERSION} diff --git a/src/data/xlsxhandler.cpp b/src/data/xlsxhandler.cpp index 1bbbec9..6da5c4c 100644 --- a/src/data/xlsxhandler.cpp +++ b/src/data/xlsxhandler.cpp @@ -23,14 +23,15 @@ void XlsxHandler::test() writeFile(sourceFilePath); } -int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &cfd) +int XlsxHandler::readFile(const QString filePath, Global::CurveFileData &cfd) { - if(!QFile::exists(sourceFilePath)) + if(!QFile::exists(filePath)) { - qDebug() << "xlsx file not existed:" << sourceFilePath; + qDebug() << "xlsx file not existed:" << filePath; return 1; } - QFileInfo fileInfo(sourceFilePath); + + QFileInfo fileInfo(filePath); // 获取文件的后缀名并转换为小写,方便比较 QString fileSuffix = fileInfo.suffix().toLower(); @@ -41,9 +42,11 @@ int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &c return 2; } - _currentFilePath = sourceFilePath; + _currentFilePath = filePath; - QXlsx::Document xlsx(sourceFilePath); + cfd.filePath = filePath; + + QXlsx::Document xlsx(filePath); QXlsx::Worksheet *workSheet = xlsx.currentWorksheet(); if(!workSheet) @@ -78,7 +81,7 @@ int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &c logde<<"dataIndex:"<& edVtr = Global::_curveExperimentDataVtr.at(i).dataVtr; @@ -246,10 +249,10 @@ void XlsxHandler::writeFile(const QString filePath) xlsx.write(row , 2, edVtr.size()); row++; - logde<<"edVtr size:"<& aoVtr = AnalysisOperationRecorder::_ananlysisOperationVtr; @@ -392,7 +393,8 @@ QXlsx::Document* XlsxHandler::openXlsxFile(const QString& sourceFilePath) { return xlsx; } -void XlsxHandler::readAnalysisOperation(QXlsx::Worksheet *sheet, int &startLineIndex) +void XlsxHandler::readAnalysisOperation( + QXlsx::Worksheet *sheet, int &startLineIndex,Global::CurveFileData& cfd) { QXlsx::Cell *cell = sheet->cellAt(startLineIndex, 2); if (!cell) { @@ -406,6 +408,9 @@ void XlsxHandler::readAnalysisOperation(QXlsx::Worksheet *sheet, int &startLineI for(int i = 0;i < size; i++){ AnaOpRecorderOperation ao; + + ao.filePath = cfd.filePath; + QString modeStr = sheet->cellAt(startLineIndex, 1)->value().toString(); if(modeStr == AnaOpRecorder::NumericalLabelStr){ @@ -427,7 +432,7 @@ void XlsxHandler::readAnalysisOperation(QXlsx::Worksheet *sheet, int &startLineI ao.x1 = sheet->cellAt(startLineIndex, 2)->value().toDouble(); ao.x2 = sheet->cellAt(startLineIndex, 3)->value().toDouble(); - AnaOpRecorder::_ananlysisOperationVtr.push_back(ao); + cfd.analysisOperationVtr.push_back(ao); startLineIndex++; diff --git a/src/data/xlsxhandler.h b/src/data/xlsxhandler.h index 0414b37..62f655c 100644 --- a/src/data/xlsxhandler.h +++ b/src/data/xlsxhandler.h @@ -22,7 +22,7 @@ namespace XlsxHandler { int readFile(const QString filePath,Global::CurveFileData&); void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&); - void readAnalysisOperation(QXlsx::Worksheet*,int& startLineIndex); + void readAnalysisOperation(QXlsx::Worksheet*,int& startLineIndex,Global::CurveFileData&); void writeFile(const QString filePath); void writeAnalysisOperation(const QString filePath); diff --git a/src/global.cpp b/src/global.cpp index 7e92d2b..9ceefbf 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -127,10 +127,9 @@ void clearExperimentData() { _curveExperimentDataVtr.clear(); _currentCurveExperimentDataPtr = nullptr; + _currentPhase = -1; } - - } #if 0 diff --git a/src/global.h b/src/global.h index bd33d04..a606902 100644 --- a/src/global.h +++ b/src/global.h @@ -6,6 +6,7 @@ #include #include "protocol.h" +#include "analysisoperationrecorder.h" #if 0 enum AnalysisMode{ @@ -99,10 +100,12 @@ struct PhaseTotalInfo{ QCPCurve * curve; }; +using namespace AnalysisOperationRecorder; struct CurveFileData{ - QString fileName; + QString filePath; Global::ExperimentInfo ei; QVector phaseTotalVtr; + QVector analysisOperationVtr; }; struct CurveExperimentData{ @@ -121,6 +124,7 @@ extern ExperimentInfo _experimentInfo; extern QVector _curveExperimentDataVtr; extern CurveExperimentData* _currentCurveExperimentDataPtr; +// Call this function at the right time. void clearExperimentData(); // Instrument coefficient. diff --git a/src/images.qrc b/src/images.qrc index 160f474..801bea4 100644 --- a/src/images.qrc +++ b/src/images.qrc @@ -8,5 +8,7 @@ images/logo.png images/logo.ico images/axis.png + images/clear_data.png + images/real_time.png diff --git a/src/images/clear_data.png b/src/images/clear_data.png new file mode 100644 index 0000000..60e07e5 Binary files /dev/null and b/src/images/clear_data.png differ diff --git a/src/images/real_time.png b/src/images/real_time.png new file mode 100644 index 0000000..8617ea3 Binary files /dev/null and b/src/images/real_time.png differ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 38f0f0d..0cfa115 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -42,12 +42,14 @@ MainWindow::MainWindow(QWidget *parent) _rightWidget->hide(); // ui->statusbar->showMessage("showMessage show temp message!"); + // permenent show QLabel *permenentLabel = new QLabel(this); permenentLabel->setText("Software Ver:" + qApp->applicationVersion()); ui->statusbar->addPermanentWidget(permenentLabel); ui->actionTimeAxisAnalysisPCTMode->setCheckable(true); + // setSubWidgetAttribute(_expertmentSettingForm); setSubWidgetAttribute(_specificHeatComparisonMethodForm); @@ -238,6 +240,7 @@ bool MainWindow::saveAnalysisFile(const QString fileName) return true; } #endif + bool MainWindow::saveFile(const QString fileName,const Global::Mode mode) { QString localFileName = fileName; @@ -266,6 +269,9 @@ bool MainWindow::saveFile(const QString fileName,const Global::Mode mode) XlsxHandler::writeAnalysisOperation(filePath); }else if(mode == Global::Mode::Experiment){ XlsxHandler::writeFile(filePath); + + // Clear data. + Global::clearExperimentData(); } return true; @@ -332,6 +338,7 @@ void MainWindow::on_actionRealTimeWidget_triggered() void MainWindow::slotSaveExperimentalDataMsgBox() { if(_manuallyStopTheExperimentFlag){ + logde<<"_manuallyStopTheExperimentFlag..."; return; } @@ -342,9 +349,11 @@ void MainWindow::slotSaveExperimentalDataMsgBox() saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment); } else { on_actionClearAllData_triggered(); - // Clear data. - Global::clearExperimentData(); } + + // Clear data. + logde<<"save mesg box.clearExperimentData..."; + Global::clearExperimentData(); } void MainWindow::on_actionConnectToDev_triggered() @@ -490,4 +499,5 @@ void MainWindow::on_actionAxisSetting_triggered() void MainWindow::on_actionSaveData_triggered() { saveFile(Global::_experimentInfo.sampleName,Global::_mode); + _leftWidget->reloadFileName(); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 9a6be1f..3e61ece 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -150,8 +150,21 @@ + + false + + + false + + + + :/images/real_time.png:/images/real_time.png + - 只读数据 + 实时数据 + + + false @@ -202,8 +215,15 @@ + + + :/images/clear_data.png:/images/clear_data.png + - 清除所有数据 + 清除数据 + + + 清除数据 diff --git a/src/serialport/dataparser.cpp b/src/serialport/dataparser.cpp index 015bca1..0747354 100644 --- a/src/serialport/dataparser.cpp +++ b/src/serialport/dataparser.cpp @@ -149,25 +149,11 @@ void experimentalStateSwitching(const CommonData &cd) case DeviceRunStatus::Idle: case DeviceRunStatus::Cooling: Global::_mode = Global::Mode::Analysis; + break; default:break; } - // If phase update, add new phase data to the global param. - if(Global::_currentPhase != (int)cd.current_phase){ - Global::_currentPhase = (int)cd.current_phase; - - Global::CurveExperimentData ced; - - Global::_curveExperimentDataVtr.push_back(ced); - Global::_currentCurveExperimentDataPtr = &Global::_curveExperimentDataVtr.last(); - -#if 1 - Global::_currentCurveExperimentDataPtr->fileName = - Global::_experimentInfo.sampleName; -#endif - } - #if 0 logde<<"phase:"<<(int)cd.current_phase; logde<<"run type:"<<(int)cd.run_type; diff --git a/src/serialport/serialport.cpp b/src/serialport/serialport.cpp index 84053cd..c2e07ea 100644 --- a/src/serialport/serialport.cpp +++ b/src/serialport/serialport.cpp @@ -146,12 +146,30 @@ void SerialPort::slotReadData() void SerialPort::updateStatus(const CommonData &cd) { -#if 1 -// logde<<"phase:"<<(int)cd.current_phase; -// logde<<"run type:"<<(int)cd.run_type; +#if 0 + // logde<<"phase:"<<(int)cd.current_phase; + // logde<<"run type:"<<(int)cd.run_type; logde<<"software mode:"<fileName = + Global::_experimentInfo.sampleName; + } + } + +// logde<<"_curveExperimentDataVtr size:" +// < _ananlysisOperationVtr; +extern QVector _analysisOperationVtr; // The analysis operationes from xlsx file. //extern QVector _fileAnanlysisOperationVtr; -void addAnalysisOperation(const AnalysisOperation); +//void addAnalysisOperation(const AnalysisOperation); void removeTheLastAnalysisOperation(); } diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index cb88328..008a893 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -61,6 +61,8 @@ CentralWidget::CentralWidget(QWidget *parent) connect(_eventHandler,&EventHandler::sigSendLineXCoord, this,&CentralWidget::sigSendLineXCoord); + connect(_eventHandler,&EventHandler::sigDelCurve, + this,&CentralWidget::slotDelCurve); setEventHandlerEnable(false); // @@ -218,7 +220,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd) _currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis); } - logde<<"temp:"<addData(index++,cd.sample_temp, cd.dsc); @@ -241,13 +243,24 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd) Global::_currentCurveExperimentDataPtr->dataVtr.push_back(ed); Global::_currentCurveExperimentDataPtr->curve = _currentCurve; } + +#if 0 + logde<<"_curveExperimentDataVtr size:" + <dataVtr.size(); +#endif } void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) { if(_analysisFilePathVtr.contains(filePath)){ return; + }else{ + _analysisFilePathVtr.push_back(filePath); } + // Read xlsx file. Global::CurveFileData cfd; if(XlsxHandler::readFile(filePath,cfd) != 0){ @@ -255,9 +268,6 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) return; } - QFileInfo fileInfo(filePath); - cfd.fileName = fileInfo.fileName(); - for(int i = 0;i < cfd.phaseTotalVtr.size();i++){ Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i]; @@ -270,7 +280,6 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) QPointF endPoint = startEndPointPair.second; _customPlot->xAxis->setRange(0, endPoint.x() / 3 * 4); - //QPointF peakPoint = PointCalculate::getPeakPoint(); QPair maxMinPair = PointCalculate::getMaxMinValue(); float absY = std::abs(maxMinPair.first - maxMinPair.second); _customPlot->yAxis->setRange(- absY * 2,absY *2); @@ -290,14 +299,16 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) _currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis); _currentCurve->setData(tVtr, xVtr, yVtr); - _currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选 + _currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选 _currentCurve->setLineStyle(QCPCurve::lsLine); // 线性连接 + _currentCurve->setObjectName(filePath); + pti.curve = _currentCurve; } // Add analysis operation data. - if(AnalysisOperationRecorder::_ananlysisOperationVtr.size() > 0){ + if(cfd.analysisOperationVtr.size() > 0){ for(AnaOpRecorder::AnalysisOperation& ao :AnalysisOperationRecorder::_ananlysisOperationVtr){ loadAnalysisData(ao.mode,ao.x1,ao.x2); @@ -550,6 +561,15 @@ void CentralWidget::slotDrawCustomText(const QString str) _customPlot->replot(); } +void CentralWidget::slotDelCurve(QCPCurve *curve) +{ + if(!curve){ + return; + } + + +} + void CentralWidget::slotGetAxisInfo() { QVector vtr; @@ -612,12 +632,14 @@ void CentralWidget::timerEvent(QTimerEvent *event) #endif } +#if 0 void CentralWidget::contextMenuEvent(QContextMenuEvent *event) { qDebug()<<"left menu..."; QPoint point = event->globalPos(); emit sigContextMenuShow(point); } +#endif void CentralWidget::glassTransitionHandle(const double x1,const double x2) { @@ -947,6 +969,10 @@ void CentralWidget::drawText(const QPointF point, const QString text) textLabel->setSelectedFont(font); textLabel->setSelectable(true); // 设置为可选 + // 设置文本项的位置类型为屏幕坐标比例 + textLabel->position->setTypeX(QCPItemPosition::ptAxisRectRatio); + textLabel->position->setTypeY(QCPItemPosition::ptAxisRectRatio); + ItemManager::addTemporaryQCPItemText(textLabel); // 创建指向点的线段(QCPItemLine) @@ -1004,8 +1030,11 @@ void CentralWidget::fillGraph(const double x1, const double x2) void CentralWidget::clearData(const CentralWidget::ClearDataMode mode) { if(mode == ClearDataMode::All){ + // + _analysisFilePathVtr.clear(); // Clear data. - Global::_curveExperimentDataVtr.clear(); + logde<<"clearExperimentData..."; + Global::clearExperimentData(); // Set lines visiable false. _line1->setVisible(false); @@ -1044,6 +1073,9 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode) ItemManager::removeItem(item); } } + // + AnalysisOperationRecorder::_ananlysisOperationVtr.clear(); + }else if(mode == ClearDataMode::Undo){ // Clear the data of graph. for (int i = _customPlot->plottableCount() - 1; i >= 0; --i) { @@ -1083,13 +1115,20 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode) ItemManager::removeItem(item); } } + + // + AnalysisOperationRecorder::removeTheLastAnalysisOperation(); } _customPlot->replot(); } -void CentralWidget::loadAnalysisData(const CentralWidget::AnalysisMode mode, const double x1, const double x2) +void CentralWidget::loadAnalysisData(const AnalysisOperation ao) { + if(Global::_mode == Global::Mode::Analysis){ + + } + switch (mode) { case AnalysisMode::NumericalLabel: { diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index e120c5b..89a7548 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -12,6 +12,8 @@ #include "pointcalculate.h" #include "localcustomplot.h" #include "analysisoperationrecorder.h" +#include "global.h" + class CentralWidget:public QWidget { @@ -30,13 +32,13 @@ public: }; #endif - using AnalysisMode = Global::AnalysisMode; - +// using AnalysisMode = Global::AnalysisMode; +// using AnalysisOperation = AnalysisOperationRecorder::AnalysisOperation; CentralWidget(QWidget *parent = nullptr); ~CentralWidget(); - void setAnalysisMode(const AnalysisMode); + void setAnalysisMode(const Global::AnalysisMode); void clearAllData(); EventHandler* getEvnetHandler(){return _eventHandler;} @@ -75,17 +77,21 @@ public slots: void slotAnalysisSettingLineXPoint(const int index,const double); void slotDrawCustomText(const QString); + + void slotDelCurve(QCPCurve*); // void slotGetAxisInfo(); void slotSetAxisSettings(const QVector); + protected: void timerEvent(QTimerEvent* event); - void contextMenuEvent(QContextMenuEvent *event); +// void contextMenuEvent(QContextMenuEvent *event); private: void glassTransitionHandle(const double x1,const double x2); void quadraticFit(const QVector& points, double& a, double& b, double& c); double derivativeAt(const double a, const double b, const double x); - PointCalculate::Line calculateLinearRegression(const QVector& x, const QVector& y); + PointCalculate::Line calculateLinearRegression(const QVector& x, + const QVector& y); QPointF OnsetTemperaturePointHandle(const double x1,const double x2); @@ -100,9 +106,9 @@ private: }; void clearData(const ClearDataMode); - void loadAnalysisData(const AnalysisMode,const double x1,const double x2); + void loadAnalysisData(const AnalysisOperationRecorder::AnalysisOperation); private: - AnalysisMode _analysisMode; + AnalysisOperationRecorder::AnalysisMode _analysisMode; LocalCustomPlot *_customPlot; QCPCurve *_currentCurve; EventHandler* _eventHandler; diff --git a/src/ui/eventhandler.cpp b/src/ui/eventhandler.cpp index 84dd951..b777910 100644 --- a/src/ui/eventhandler.cpp +++ b/src/ui/eventhandler.cpp @@ -159,7 +159,9 @@ void EventHandler::initMenu() _baseLineAction = new QAction("基线",_plot); _standardSampleAction = new QAction("标样",_plot); _sampleAction = new QAction("样品",_plot); + _delCurveAction = new QAction("删除当前曲线",_plot); + _menu->addAction(_delCurveAction); _menu->addAction(_specificHeatItemAction); QMenu *specificHeatItemMenu = new QMenu(_plot); @@ -175,6 +177,9 @@ void EventHandler::initMenu() this,&EventHandler::slotStandardSample); connect(_sampleAction,&QAction::triggered, this,&EventHandler::slotSample); + + connect(_delCurveAction,&QAction::triggered, + this,&EventHandler::slotDelCurve); } bool EventHandler::isNearLine(QCPItemStraightLine *line, const QPoint &pos) @@ -221,7 +226,17 @@ void EventHandler::slotSample() _plot->replot(); #endif - emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::Sample,curve); + emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::Sample,curve); +} + +void EventHandler::slotDelCurve() +{ + QCPCurve *curve = qobject_cast(_plot->selectedPlottables().front()); + if(!curve){ + return; + } + + emit sigDelCurve(curve); } void EventHandler::updateSelectedRegion() diff --git a/src/ui/eventhandler.h b/src/ui/eventhandler.h index 7905cc1..d9e7cff 100644 --- a/src/ui/eventhandler.h +++ b/src/ui/eventhandler.h @@ -34,6 +34,7 @@ public: signals: void sigSendLineXCoord(const int,const double); void sigSetCurve(const int, QCPCurve*); + void sigDelCurve(QCPCurve*); protected: bool eventFilter(QObject *obj, QEvent *event) override; private slots: @@ -41,6 +42,7 @@ private slots: void slotStandardSample(); void slotSample(); + void slotDelCurve(); private: void initMenu(); int findClosestIndex(const QVector &data, double target); @@ -56,6 +58,7 @@ private: QMenu* _menu; QAction* _specificHeatItemAction,*_baseLineAction, *_standardSampleAction,*_sampleAction; + QAction* _delCurveAction; }; #endif diff --git a/src/ui/itemmanager.cpp b/src/ui/itemmanager.cpp index bd17257..d16561e 100644 --- a/src/ui/itemmanager.cpp +++ b/src/ui/itemmanager.cpp @@ -43,8 +43,9 @@ void removeItem(QObject *obj) for (int i = _QCPItemTextVtr.size() - 1; i >= 0; --i) { QCPItemText *item = _QCPItemTextVtr[i]; if (item == obj) { + _QCPItemTextVtr.remove(i); - return; +// return; } } @@ -52,7 +53,7 @@ void removeItem(QObject *obj) QCPItemLine *item = _QCPItemLineVtr[i]; if (item == obj) { _QCPItemLineVtr.remove(i); - return; +// return; } } @@ -60,7 +61,7 @@ void removeItem(QObject *obj) QCPGraph *item = _QCPGraphVtr[i]; if (item == obj) { _QCPGraphVtr.remove(i); - return; +// return; } } diff --git a/src/ui/itemmanager.h b/src/ui/itemmanager.h index 986bb64..2e10344 100644 --- a/src/ui/itemmanager.h +++ b/src/ui/itemmanager.h @@ -8,6 +8,9 @@ const QString OriginStr("origin"); const QString ConfirmStr("confirm"); const QString TemporaryStr("temporary"); +const QString Separator("__"); + + #if 0 enum ItemAttribute{ Origin,