diff --git a/experiment_data/sample_data/氮气氧气OTI.xlsx b/experiment_data/sample_data/氮气氧气OTI.xlsx new file mode 100644 index 0000000..b567dd8 Binary files /dev/null and b/experiment_data/sample_data/氮气氧气OTI.xlsx differ diff --git a/src/DSCAnalysisTool.pro b/src/DSCAnalysisTool.pro index b3e9b18..b2e2b18 100644 --- a/src/DSCAnalysisTool.pro +++ b/src/DSCAnalysisTool.pro @@ -9,7 +9,7 @@ CONFIG+=precompile_header PRECOMPILED_HEADER=stable.h # -VERSION = 1.0.3 +VERSION = 1.0.5 # 设置目标文件名,包含版本号 TARGET = DSCAnalysisTool_$${VERSION} diff --git a/src/data/pointcalculate.cpp b/src/data/pointcalculate.cpp index f6de377..c8946ca 100644 --- a/src/data/pointcalculate.cpp +++ b/src/data/pointcalculate.cpp @@ -891,5 +891,37 @@ QString PointCalculate::textFormatGlassTranstionWithTime(const float t1, const f .arg(QString::number(t2, 'f', 3)); } +Global::ExperimentData PointCalculate::findOnSetDataByTime(const double x1, const double x2) +{ + 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; + } + } + Global::ExperimentData resultEd; + if(edVtr.empty()){ + return resultEd; + } + + 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.rbegin(); it != edVtr.rend(); ++it) { + if(std::abs(it->dsc - maxDsc) < Global::OnsetAndEndSetRate * maxDsc){ + resultEd = *it; // 找到匹配项,返回该值 + break; + } + } + + return resultEd; +} diff --git a/src/data/pointcalculate.h b/src/data/pointcalculate.h index ed4d203..4c40331 100644 --- a/src/data/pointcalculate.h +++ b/src/data/pointcalculate.h @@ -44,6 +44,8 @@ double obtainTimeValueBasedOnTemperatureValue(const double sampleTemp); ExperimentData findOnSetDataByTemperature(const double x1,const double x2); ExperimentData findEndSetDataByTemperature(const double x1,const double x2); +ExperimentData findOnSetDataByTime(const double x1,const double x2); + // text format QString textFormatPeakPoint(const float enthalpyValue, diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 61d2db9..8b16c9c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -644,7 +644,8 @@ void MainWindow::on_actionGlassTransition_triggered() void MainWindow::on_actionOIT_triggered() { - QMessageBox::warning(this, "warnning", "on_actionOIT_triggered."); + _rightWidget->show(); + _centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::OIT); } void MainWindow::on_actionSpecificHeatCompMethod_triggered() diff --git a/src/ui/analysisoperationrecorder.h b/src/ui/analysisoperationrecorder.h index f894a99..8d67b54 100644 --- a/src/ui/analysisoperationrecorder.h +++ b/src/ui/analysisoperationrecorder.h @@ -19,7 +19,8 @@ enum AnalysisMode{ PeakSynthesisAnalysis, GlassTransition, OnsetTemperaturePoint, - EndsetTemperaturePoint + EndsetTemperaturePoint, + OIT }; #endif diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index 6d3aea7..a7347c8 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -204,6 +204,14 @@ void CentralWidget::setAnalysisMode(const AnalysisMode mode) { _analysisMode = mode; + if(mode == AnalysisMode::Null){ + _customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables); + }else{ + _customPlot->setInteractions(QCP::iSelectPlottables); + setEventHandlerEnable(true); + } + +#if 0 switch (mode) { case AnalysisMode::Null: @@ -222,6 +230,7 @@ void CentralWidget::setAnalysisMode(const AnalysisMode mode) default: break; } +#endif } void CentralWidget::slotModeModify(const Global::Mode mode) @@ -1386,11 +1395,95 @@ void CentralWidget::loadAnalysisData( break; } + case AnalysisMode::OIT:{ + logde<<"oit x1,x2:"< +// startEndDataPair = PointCalculate::calculateStartAndEndData(); + + logde<<"start data time:"< xVtr,yVtr; + xVtr.push_back(startData.runTime); + xVtr.push_back(startData.runTime); + + yVtr.push_back(startData.dsc - 10); + yVtr.push_back(startData.dsc - 20); + + QCPGraph *startLine = _customPlot->addGraph(); + startLine->setData(xVtr, yVtr); + startLine->setPen(QPen(Qt::red, 1)); + + // Draw end vertical line. + xVtr.clear(); + yVtr.clear(); + xVtr.push_back(endData.runTime); + xVtr.push_back(endData.runTime); + + yVtr.push_back(endData.dsc - 10); + yVtr.push_back(endData.dsc - 20); + + QCPGraph *endLine = _customPlot->addGraph(); + endLine->setData(xVtr, yVtr); + endLine->setPen(QPen(Qt::red, 1)); +#endif + + // Draw start line. + QCPItemLine *startLine = new QCPItemLine(_customPlot); + startLine->start->setCoords(startData.runTime,startData.dsc - 10); + startLine->end->setCoords(startData.runTime,startData.dsc - 20); + startLine->setPen(QPen(Qt::red, 1)); + // Draw end line. + QCPItemLine *endLine = new QCPItemLine(_customPlot); + endLine->start->setCoords(endData.runTime,endData.dsc - 10); + endLine->end->setCoords(endData.runTime,endData.dsc - 20); + endLine->setPen(QPen(Qt::red, 1)); + + // Draw total line. + QCPItemLine *totalLine = new QCPItemLine(_customPlot); + totalLine->start->setCoords(startData.runTime,startData.dsc - 15); + totalLine->end->setCoords(endData.runTime,endData.dsc - 15); + totalLine->setPen(QPen(Qt::red, 1)); + + // Draw title. + double textX = (endData.runTime - startData.runTime) / 2 + endData.runTime; + + QCPItemText *textLabel = new QCPItemText(_customPlot); + textLabel->setPositionAlignment(Qt::AlignCenter); // 对齐方式 + textLabel->position->setType(QCPItemPosition::ptPlotCoords); // 使用数据坐标 + textLabel->position->setCoords(textX,startData.dsc - 20); // 设置文本位置在指定点上方 + + textLabel->setText("OIT:123.44"); // 设置文本内容 + QFont font(QFont("Arial", 10)); + textLabel->setFont(font); + textLabel->setSelectedFont(font); + textLabel->setSelectable(true); // 设置为可选 + + _customPlot->replot(); +} + void CentralWidget::clearAllData() { Global::_mode = Global::Mode::Analysis; diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index 9fc213a..b28a604 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -110,6 +110,7 @@ private: void loadAnalysisData(const AnalysisMode mode,const double x1,const double x2,const QString objectName); + void drawOITLine(const Global::ExperimentData startData,const Global::ExperimentData endData); private: AnalysisOperationRecorder::AnalysisMode _analysisMode; LocalCustomPlot *_customPlot;