diff --git a/AnalysisTool-release/bin/log/20250619.log b/AnalysisTool-release/bin/log/20250619.log new file mode 100644 index 0000000..4c06b20 --- /dev/null +++ b/AnalysisTool-release/bin/log/20250619.log @@ -0,0 +1,47 @@ +[2025-06-19 11:29:31,232] main... +[2025-06-19 11:29:31,232] config file existed. +[2025-06-19 11:29:31,245] version:1.0.4.0 +[2025-06-19 11:29:31,253] setEventHandlerEnable...0 +[2025-06-19 11:30:36,317] main... +[2025-06-19 11:30:36,319] config file existed. +[2025-06-19 11:30:36,329] version:1.0.4.0 +[2025-06-19 11:30:36,337] setEventHandlerEnable...0 +[2025-06-19 11:30:39,937] xlsx sample weight:26.89 +[2025-06-19 11:30:39,937] startLineIndex:11 +[2025-06-19 11:30:39,937] data size:839 +[2025-06-19 11:30:39,939] startLineIndex:857 +[2025-06-19 11:30:39,939] data size:1157 +[2025-06-19 11:30:39,939] Cell does not exist. +[2025-06-19 11:30:41,742] xlsx sample weight:7 +[2025-06-19 11:30:41,743] Cell does not exist. +[2025-06-19 11:30:43,161] xlsx sample weight:1 +[2025-06-19 11:30:43,161] startLineIndex:11 +[2025-06-19 11:30:43,161] data size:298 +[2025-06-19 11:30:43,161] Cell does not exist. +[2025-06-19 11:31:50,869] main... +[2025-06-19 11:31:50,869] config file existed. +[2025-06-19 11:31:50,878] version:1.0.4.0 +[2025-06-19 11:31:50,888] setEventHandlerEnable...0 +[2025-06-19 11:31:53,589] xlsx sample weight:1 +[2025-06-19 11:31:53,589] startLineIndex:11 +[2025-06-19 11:31:53,589] data size:298 +[2025-06-19 11:31:53,589] Cell does not exist. +[2025-06-19 11:31:55,248] clearExperimentData... +[2025-06-19 11:31:56,695] xlsx sample weight:26.89 +[2025-06-19 11:31:56,695] startLineIndex:11 +[2025-06-19 11:31:56,695] data size:830 +[2025-06-19 11:31:56,697] startLineIndex:848 +[2025-06-19 11:31:56,697] data size:6631 +[2025-06-19 11:31:56,701] ana op size:1 +[2025-06-19 11:31:56,701] cfd fileName:new.xlsx +[2025-06-19 11:31:56,701] ao mode:OIT +[2025-06-19 11:31:56,701] x1:33.1687,x2:91.1893 +[2025-06-19 11:32:16,013] clearExperimentData... +[2025-06-19 11:32:18,019] xlsx sample weight:7 +[2025-06-19 11:32:18,019] Cell does not exist. +[2025-06-19 11:32:19,224] xlsx sample weight:26.89 +[2025-06-19 11:32:19,224] startLineIndex:11 +[2025-06-19 11:32:19,224] data size:839 +[2025-06-19 11:32:19,224] startLineIndex:857 +[2025-06-19 11:32:19,224] data size:1157 +[2025-06-19 11:32:19,224] Cell does not exist. diff --git a/AnalysisTool-release/experiment_data/analysis_state/new.xlsx b/AnalysisTool-release/experiment_data/analysis_state/new.xlsx new file mode 100644 index 0000000..94db2ce Binary files /dev/null and b/AnalysisTool-release/experiment_data/analysis_state/new.xlsx differ diff --git a/AnalysisTool-release/experiment_data/sample_data/1.xlsx b/AnalysisTool-release/experiment_data/sample_data/氧化诱导期11111.xlsx similarity index 100% rename from AnalysisTool-release/experiment_data/sample_data/1.xlsx rename to AnalysisTool-release/experiment_data/sample_data/氧化诱导期11111.xlsx diff --git a/AnalysisTool-release/experiment_data/sample_data/氮气氧气Oit2.xlsx b/AnalysisTool-release/experiment_data/sample_data/氮气氧气Oit2.xlsx new file mode 100644 index 0000000..27db18b Binary files /dev/null and b/AnalysisTool-release/experiment_data/sample_data/氮气氧气Oit2.xlsx differ diff --git a/experiment_data/sample_data/1.xlsx b/experiment_data/sample_data/1.xlsx deleted file mode 100644 index fe9a26d..0000000 Binary files a/experiment_data/sample_data/1.xlsx and /dev/null differ diff --git a/experiment_data/sample_data/new.xlsx b/experiment_data/sample_data/new.xlsx index db680cd..a5469fd 100644 Binary files a/experiment_data/sample_data/new.xlsx and b/experiment_data/sample_data/new.xlsx differ diff --git a/experiment_data/sample_data/氧化诱导期.xlsx b/experiment_data/sample_data/氧化诱导期.xlsx new file mode 100644 index 0000000..670dac1 Binary files /dev/null and b/experiment_data/sample_data/氧化诱导期.xlsx differ diff --git a/experiment_data/sample_data/氧化诱导期222222.xlsx b/experiment_data/sample_data/氧化诱导期222222.xlsx new file mode 100644 index 0000000..b365a16 Binary files /dev/null and b/experiment_data/sample_data/氧化诱导期222222.xlsx differ diff --git a/experiment_data/sample_data/氮气氧气Oit2.xlsx b/experiment_data/sample_data/氮气氧气Oit2.xlsx new file mode 100644 index 0000000..8005307 Binary files /dev/null and b/experiment_data/sample_data/氮气氧气Oit2.xlsx differ diff --git a/src/data/pointcalculate.cpp b/src/data/pointcalculate.cpp index 664ea94..1a34a79 100644 --- a/src/data/pointcalculate.cpp +++ b/src/data/pointcalculate.cpp @@ -283,8 +283,10 @@ float PointCalculate::calculateArea() { QPair PointCalculate::calculateStartAndEndPoint() { - QPair leftMaxDiffPointPair = PointCalculate::calculateMaxDiffPointLeft(); - QPair rightMaxDiffPointPair = PointCalculate::calculateMaxDiffPointRight(); + QPair leftMaxDiffPointPair = + PointCalculate::calculateMaxDiffPointLeft(); + QPair rightMaxDiffPointPair = + PointCalculate::calculateMaxDiffPointRight(); #if 0 logde<<"b1:"< PointCalculate::calculateStartAndEndPoint() logde<<"b3:"< x2){ + if(ed.phaseIndex == edSelectTimeX2.phaseIndex){ + startEd = ed; break; } } return startEd; } + +Global::ExperimentData PointCalculate::getClosestDataByTime(const float time) +{ + ExperimentData resultData; + + float minDiff = std::numeric_limits::max(); + + for(Global::ExperimentData &ed:_dataVtr){ + float diff = std::abs(ed.runTime - time); + if (diff < minDiff) { + minDiff = diff; + resultData = ed; + } + } + + return resultData; +} + +Global::ExperimentData PointCalculate::findEndSetDataByTime(const double x1, const double x2) +{ + Global::ExperimentData resultEd; + + // QVector edVtr = getDataInXRange(x1,x2); + // if(edVtr.empty()){ + // return resultEd; + // } + + QVector edVtr; + for(const Global::ExperimentData &ed : _dataVtr) { + if(x1 < ed.runTime && ed.runTime < x2){ + edVtr.push_back(ed); + }else if (ed.runTime > x2){ + break; + } + } + + double maxDsc = std::numeric_limits::min(); + for(Global::ExperimentData& ed:edVtr){ + if(ed.dsc > maxDsc){ + maxDsc = ed.dsc; + } + } + + // 从后往前遍历,找到第一个 dsc 与 standardDsc 相等的 ExperimentData + for (auto it = edVtr.begin(); it != edVtr.end(); ++it) { + if(std::abs(it->dsc - maxDsc) < Global::OnsetAndEndSetRate * maxDsc){ + resultEd = *it; // 找到匹配项,返回该值 + break; + } + } + + return resultEd; +} + +QPair +PointCalculate::calculateOITStartAndEndDataByTime(const double x1, const double x2) +{ + // 获取起点数据。 + Global::ExperimentData startData = getOITStartData(x1,x2); + + // 计算OIT结束数据(需根据实际逻辑实现) + Global::ExperimentData endData; + + QPair maxDiffDataPair = + calculateMaxDiffDataByTime(x1,x2); + + ExperimentData selectedData = getClosestDataByTime(x1); + + // calculate intersection point. + QPointF selectedPoint1(selectedData.runTime,selectedData.dsc); + QPointF selectedPoint2(selectedData.runTime + 10,selectedData.dsc); + QPointF maxDiffPoint1(maxDiffDataPair.first.runTime,maxDiffDataPair.first.dsc); + QPointF maxDiffPoint2(maxDiffDataPair.second.runTime,maxDiffDataPair.second.dsc); + QPointF intersectionPoint = calculateIntersection(selectedPoint1,selectedPoint2, + maxDiffPoint1,maxDiffPoint2); + + return qMakePair(QPointF(startData.runTime,startData.dsc), + intersectionPoint); +} + +QPair +PointCalculate::calculateMaxDiffDataByTime( + const double x1,const double x2) +{ + QVector rangeEdVtr; + for(const Global::ExperimentData &ed : _dataVtr) { + if(x1 < ed.runTime && ed.runTime < x2){ + rangeEdVtr.push_back(ed); + }else if (ed.runTime > x2){ + break; + } + } + + // + float maxDiff = std::numeric_limits::min(); + Global::ExperimentData targetCurrentData,targetLastPointData; + for(int i = 0; i < rangeEdVtr.size() - 1;i++){ + Global::ExperimentData currentData = rangeEdVtr.at(i); + Global::ExperimentData lastPointData = rangeEdVtr.at(i+1); + + double diff = std::abs(lastPointData.dsc - currentData.dsc); + if(diff > maxDiff){ + maxDiff = diff; + + targetCurrentData = currentData; + targetLastPointData = lastPointData; + } + } + + return qMakePair(targetCurrentData,targetLastPointData); + +#if 0 + float maxDiff = std::numeric_limits::min(); + QPointF currentPoint,lastPoint; + + for (int i = 0; i < _dataVtr.size() - 1; ++i) { + const float currentTime = _dataVtr.at(i).sampleTemp; + const float currentY = _dataVtr.at(i).dsc; + + // if(type == MaxDiffPointDetailType::Left){ + // if(currentX <= _leftSelectedPoint.x()){ + // continue; + // } + // if(currentX >= _peakPoint.x()){ + // break; + // } + // }else{ + if(currentTime <= _peakPoint.x()){ + continue; + } + if(currentTime >= _rightSelectedPoint.x()){ + break; + } + // } + // + const float lastX = _dataVtr.at(i + 1).sampleTemp; + const float lastY = _dataVtr.at(i + 1).dsc; + float diff = std::abs(currentY - lastY); + if(diff > maxDiff){ + maxDiff = diff; + + currentPoint.setX(currentTime); + currentPoint.setY(currentY); + lastPoint.setX(lastX); + lastPoint.setY(lastY); + } + } + + return qMakePair(currentPoint,lastPoint); +#endif +} diff --git a/src/data/pointcalculate.h b/src/data/pointcalculate.h index b3f8ee7..5018ba2 100644 --- a/src/data/pointcalculate.h +++ b/src/data/pointcalculate.h @@ -24,6 +24,8 @@ QVector getPointVtrInXRange(const float, const float); void setRegionPointX(const float,const float); ExperimentData getClosestDataByTemperature(const float); +ExperimentData getClosestDataByTime(const float); + QPointF getClosestPointByX(const float); QVector getNearbyPointGroupByX(const float); @@ -38,6 +40,8 @@ QPair getTheMaximumAndMinimumValuesOfTime( QPair calculateStartAndEndPoint(); QPair calculateStartAndEndData(); +QPair calculateOITStartAndEndDataByTime(const double x1,const double x2); + float calculateArea(); double obtainTimeValueBasedOnTemperatureValue(const double sampleTemp); @@ -45,6 +49,7 @@ ExperimentData findOnSetDataByTemperature(const double x1,const double x2); ExperimentData findEndSetDataByTemperature(const double x1,const double x2); ExperimentData findOnSetDataByTime(const double x1,const double x2); +ExperimentData findEndSetDataByTime(const double x1,const double x2); ExperimentData getOITStartData(const double x1,const double x2); @@ -90,6 +95,8 @@ enum MaxDiffPointDetailType{ Right }; QPair calculateMaxDiffPointDetail(const MaxDiffPointDetailType type); +QPair calculateMaxDiffDataByTime( + const double x1,const double x2); QPointF calculateIntersection(const QPointF p1,const QPointF p2, const QPointF p3, const QPointF p4); diff --git a/src/data/xlsxhandler.cpp b/src/data/xlsxhandler.cpp index 3ba6576..67bd2ca 100644 --- a/src/data/xlsxhandler.cpp +++ b/src/data/xlsxhandler.cpp @@ -108,10 +108,13 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex for(int i = 0; i < dataSize; i++) { Global::ExperimentData data; + data.phaseIndex = phaseTotal.phaseIndex; +#if 0 if(i == 0){ data.phaseIndex = phaseTotal.phaseIndex; logde<<"read file,set phaseIndex:"<cellAt(startLineIndex, 2)->value().toDouble(); data.sampleTemp = workSheet->cellAt(startLineIndex, 3)->value().toDouble(); data.dsc = workSheet->cellAt(startLineIndex, 4)->value().toDouble(); diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index 8f618c6..da1f025 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -208,9 +208,11 @@ void CentralWidget::startExperiment() if(_yAxis2Curve != nullptr){ _yAxis2Curve = nullptr; } - _customPlot->yAxis2->setRange(0, 400); - _customPlot->xAxis->setRange(-5, 400); + _customPlot->xAxis->setRange(-5, 60); _customPlot->yAxis->setRange(-20, 20); + _customPlot->yAxis2->setRange(0, 400); + + _customPlot->replot(); } void CentralWidget::setAnalysisMode(const AnalysisMode mode) @@ -276,8 +278,6 @@ void CentralWidget::slotModeModify(const Global::Mode mode) void CentralWidget::slotRecvCommonData(const CommonData &cd) { - logde<<"slotRecvCommonData run time:"<dataVtr.empty()){ ed.phaseIndex = Global::_currentCurveExperimentDataPtr->phaseIndex; - logde<<"current phase index:"<phaseIndex; + logde<<"change phase, index:"<phaseIndex; _currentCurve = nullptr; } @@ -304,7 +304,9 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd) if(!_currentCurve){ logde<<"_currentCurve is nullptr"; _currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis); - _currentCurve->setObjectName(Global::ObjectNameExperiemnt); + _currentCurve->setObjectName(Global::ObjectNameExperiemnt + + Global::Separator + + QString::number(Global::_currentCurveExperimentDataPtr->phaseIndex)); Global::_currentCurveExperimentDataPtr->curve = _currentCurve; } @@ -320,39 +322,17 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd) _yAxis2Curve->setObjectName(Global::ObjectNameExperiemnt); // 设置曲线颜色 - QPen pen(Qt::red); // 创建一个红色的画笔 - pen.setWidth(1); // 设置画笔宽度 + QPen pen(Qt::red); // 创建一个红色的画笔 + pen.setWidth(1); // 设置画笔宽度 _yAxis2Curve->setPen(pen); // 将画笔应用到曲线 } _yAxis2Curve->addData(index++,cd.add_run_time, cd.sample_temp); _currentCurve->addData(index++,cd.add_run_time, cd.dsc); - - // _customPlot->yAxis2->setRange(0, 400); } - // Set asis xy range. - // axis dsc -20 20 - // time 0 100 - // temp 0 400 - - // _customPlot->xAxis->setRange(0, 400); - // _customPlot->yAxis->setRange(-20, 20); - - // _customPlot->rescaleAxes(); _customPlot->replot(); - - - -#if 0 - logde<<"_curveExperimentDataVtr size:" - <dataVtr.size(); -#endif - } void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) @@ -385,6 +365,7 @@ void CentralWidget::slotAnalysisSettingApply() } QString selectedCurveObjectName = _currentCurve->objectName(); + logde<<"slotAnalysisSettingApply objectName:"< totalDataVtr; @@ -398,6 +379,7 @@ void CentralWidget::slotAnalysisSettingApply() if(ced.smoothDataVtr.empty()){ // PointCalculate::setAnalysisData(ced.dataVtr); totalDataVtr.append(ced.dataVtr); + }else{ // PointCalculate::setAnalysisData(ced.smoothDataVtr); totalDataVtr.append(ced.smoothDataVtr); @@ -429,6 +411,8 @@ void CentralWidget::slotAnalysisSettingApply() for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ if(pti.smoothDataVtr.empty()){ totalDataVtr.append(pti.dataVtr); + + logde <<" data phase index:"<point1->coords().x(); double x2 = _line2->point1->coords().x(); @@ -463,7 +438,7 @@ void CentralWidget::slotAnalysisSettingApply() } // - loadAnalysisData(_analysisMode,x1,x2,_currentCurve->objectName()); + calculateAnalysisResult(_analysisMode,x1,x2,_currentCurve->objectName()); if(Global::_mode == Global::Mode::Analysis){ AnalysisOperation ao; @@ -619,18 +594,10 @@ void CentralWidget::slotSelectionChangedByUser() for (QCPAbstractPlottable* plottable : selectedPlottables) { // 检查是否是 QCPCurve if (QCPCurve* curve = dynamic_cast(plottable)) { - logde << "Selected Curve:" << curve->objectName().toStdString(); + logde << "selected Curve:" << curve->objectName().toStdString(); _currentCurve = curve; // 更新当前选中的曲线 } } - -#if 0 - // 如果没有选中的曲线 - if (selectedPlottables.isEmpty()) { - logde<< "No curve selected"; - _currentCurve = nullptr; // 清空当前选中的曲线 - } -#endif } void CentralWidget::uiLoadXlsxFileData() @@ -766,7 +733,7 @@ void CentralWidget::uiLoadXlsxFileData() if(!cfd.analysisOperationVtr.empty()){ for(AnaOpRecorder::AnalysisOperation& ao :cfd.analysisOperationVtr){ - loadAnalysisData(ao.mode,ao.x1,ao.x2,cfd.filePath); + calculateAnalysisResult(ao.mode,ao.x1,ao.x2,cfd.filePath); } } } @@ -1356,9 +1323,11 @@ void CentralWidget::deleteCurveByObjectName(const QString objectName) _customPlot->replot(); } -void CentralWidget::loadAnalysisData( +void CentralWidget::calculateAnalysisResult( const AnalysisMode mode,const double x1,const double x2,const QString objectName) { + logde<<"calculateAnalysisResult..."; + switch (mode) { case AnalysisMode::NumericalLabel: { @@ -1536,25 +1505,45 @@ void CentralWidget::loadAnalysisData( case AnalysisMode::OIT:{ logde<<"oit x1,x2:"< tickPositions = _customPlot->yAxis->tickVector(); double step = tickPositions.at(1) - tickPositions.at(0); // - Global::ExperimentData ed = PointCalculate::findOnSetDataByTime(x1,x2); + Global::ExperimentData startData = PointCalculate::getOITStartData(x1,x2); + // Global::ExperimentData endData = PointCalculate::findOnSetDataByTime(x1,x2); + + PointCalculate::setRegionPointX(x1,x2); + QPair + startEndDataPair = PointCalculate::calculateStartAndEndData(); // Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2); // PointCalculate::setRegionPointX(x1,x2); - Global::ExperimentData startData = PointCalculate::getOITStartData(x1,x2); // QPair // startEndDataPair = PointCalculate::calculateStartAndEndData(); logde<<"start data time:"< tickPositions = _customPlot->yAxis->tickVector(); + double step = tickPositions.at(1) - tickPositions.at(0); - drawOITLine(startData,ed,step,objectName); + QPairstartEndPointPair = + PointCalculate::calculateOITStartAndEndDataByTime(x1,x2); + + Global::ExperimentData startData; + startData.runTime = startEndPointPair.first.x(); + startData.dsc = startEndPointPair.first.y(); + + Global::ExperimentData endData; + endData.runTime = startEndPointPair.second.x(); + endData.dsc = startEndPointPair.second.y(); + + + drawOITLine(startData,endData,step,objectName); break; } @@ -1675,7 +1664,7 @@ void CentralWidget::slotAxisModify(const float temp) float value = temp + 20; - _customPlot->xAxis->setRange(10,value); + _customPlot->xAxis->setRange(0,value); _customPlot->yAxis->setRange(-5,5); } diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index eb581d9..376e2a8 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -114,7 +114,7 @@ private: void clearData(const ClearDataMode); void clearAllUiData(); - void loadAnalysisData(const AnalysisMode mode,const double x1,const double x2,const QString objectName); + void calculateAnalysisResult(const AnalysisMode mode,const double x1,const double x2,const QString objectName); void drawOITLine(const Global::ExperimentData startData, const Global::ExperimentData endData,