diff --git a/AnalysisTool-release/bin/DSCAnalysisTool_1.0.2.exe b/AnalysisTool-release/bin/DSCAnalysisTool_1.0.2.exe new file mode 100644 index 0000000..14940c9 Binary files /dev/null and b/AnalysisTool-release/bin/DSCAnalysisTool_1.0.2.exe differ diff --git a/AnalysisTool-release/bin/log/20250605.log b/AnalysisTool-release/bin/log/20250605.log new file mode 100644 index 0000000..df1f479 --- /dev/null +++ b/AnalysisTool-release/bin/log/20250605.log @@ -0,0 +1,24 @@ +[2025-06-05 14:26:20,323] main... +[2025-06-05 14:26:20,325] config file existed. +[2025-06-05 14:26:20,363] version:1.0.2.0 +[2025-06-05 14:26:20,396] setEventHandlerEnable...0 +[2025-06-05 14:27:13,511] main... +[2025-06-05 14:27:13,511] config file existed. +[2025-06-05 14:27:13,520] version:1.0.2.0 +[2025-06-05 14:27:13,529] setEventHandlerEnable...0 +[2025-06-05 14:27:17,437] xlsx sample weight:8.17 +[2025-06-05 14:27:17,437] startLineIndex:11 +[2025-06-05 14:27:17,437] data size:6930 +[2025-06-05 14:27:17,442] ana op size:0 +[2025-06-05 14:27:22,232] setEventHandlerEnable...1 +[2025-06-05 14:27:31,300] dataVtr size:6929 +[2025-06-05 14:27:31,300] select point param left,right:226.746,248.46 +[2025-06-05 14:27:31,300] peakPoint:232.533,11.7595 +[2025-06-05 14:27:31,300] peak point:232.533,11.7595 +[2025-06-05 14:27:31,300] select point left:232.479,11.745 +[2025-06-05 14:27:31,300] select point right:232.593,11.7372 +[2025-06-05 14:27:31,300] coefficient:1 +[2025-06-05 14:27:31,300] area:0.00856458 +[2025-06-05 14:27:31,300] peakPoint:232.533,11.7595 +[2025-06-05 14:27:31,300] start,end:0,0 +[2025-06-05 14:27:31,300] xMax:332.214 diff --git a/AnalysisTool-release/experiment_data/sample_data/锡铜炉实验.xlsx b/AnalysisTool-release/experiment_data/sample_data/锡铜炉实验.xlsx new file mode 100644 index 0000000..a909af9 Binary files /dev/null and b/AnalysisTool-release/experiment_data/sample_data/锡铜炉实验.xlsx differ diff --git a/experiment_data/analysis_state/1434-new.xlsx b/experiment_data/analysis_state/1434-new.xlsx new file mode 100644 index 0000000..53a6d67 Binary files /dev/null and b/experiment_data/analysis_state/1434-new.xlsx differ diff --git a/experiment_data/analysis_state/1625-new.xlsx b/experiment_data/analysis_state/1625-new.xlsx new file mode 100644 index 0000000..1f2b1bb Binary files /dev/null and b/experiment_data/analysis_state/1625-new.xlsx differ diff --git a/experiment_data/analysis_state/1637-new.xlsx b/experiment_data/analysis_state/1637-new.xlsx new file mode 100644 index 0000000..6fbbcac Binary files /dev/null and b/experiment_data/analysis_state/1637-new.xlsx differ diff --git a/experiment_data/analysis_state/6-1-new.xlsx b/experiment_data/analysis_state/6-1-new.xlsx new file mode 100644 index 0000000..b5fd905 Binary files /dev/null and b/experiment_data/analysis_state/6-1-new.xlsx differ diff --git a/experiment_data/analysis_state/6-155new.xlsx b/experiment_data/analysis_state/6-155new.xlsx new file mode 100644 index 0000000..4717bf9 Binary files /dev/null and b/experiment_data/analysis_state/6-155new.xlsx differ diff --git a/experiment_data/analysis_state/6-15new.xlsx b/experiment_data/analysis_state/6-15new.xlsx new file mode 100644 index 0000000..64b00f3 Binary files /dev/null and b/experiment_data/analysis_state/6-15new.xlsx differ diff --git a/experiment_data/analysis_state/6-new.xlsx b/experiment_data/analysis_state/6-new.xlsx new file mode 100644 index 0000000..0efa999 Binary files /dev/null and b/experiment_data/analysis_state/6-new.xlsx differ diff --git a/experiment_data/analysis_state/63-new.xlsx b/experiment_data/analysis_state/63-new.xlsx new file mode 100644 index 0000000..79bba7c Binary files /dev/null and b/experiment_data/analysis_state/63-new.xlsx differ diff --git a/experiment_data/analysis_state/64-new.xlsx b/experiment_data/analysis_state/64-new.xlsx new file mode 100644 index 0000000..ef40192 Binary files /dev/null and b/experiment_data/analysis_state/64-new.xlsx differ diff --git a/experiment_data/analysis_state/65-new.xlsx b/experiment_data/analysis_state/65-new.xlsx new file mode 100644 index 0000000..2ccaf42 Binary files /dev/null and b/experiment_data/analysis_state/65-new.xlsx differ diff --git a/experiment_data/analysis_state/~$1637-new.xlsx b/experiment_data/analysis_state/~$1637-new.xlsx new file mode 100644 index 0000000..d4a5841 Binary files /dev/null and b/experiment_data/analysis_state/~$1637-new.xlsx differ diff --git a/src/data/lowesssmoother.cpp b/src/data/lowesssmoother.cpp index 39ccbe6..88cb7e6 100644 --- a/src/data/lowesssmoother.cpp +++ b/src/data/lowesssmoother.cpp @@ -1,4 +1,4 @@ -#include "LowessSmoother.h" +#include "lowesssmoother.h" #include namespace Lowess { diff --git a/src/data/pointcalculate.cpp b/src/data/pointcalculate.cpp index 9f8d293..f6de377 100644 --- a/src/data/pointcalculate.cpp +++ b/src/data/pointcalculate.cpp @@ -892,3 +892,4 @@ QString PointCalculate::textFormatGlassTranstionWithTime(const float t1, const f } + diff --git a/src/data/xlsxhandler.cpp b/src/data/xlsxhandler.cpp index ca38ec0..6333ad0 100644 --- a/src/data/xlsxhandler.cpp +++ b/src/data/xlsxhandler.cpp @@ -20,7 +20,7 @@ void XlsxHandler::test() #endif QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx"; - writeFile(sourceFilePath); + writeExperimentFile(sourceFilePath); } int XlsxHandler::readFile(const QString filePath, Global::CurveFileData &cfd) @@ -79,11 +79,11 @@ int XlsxHandler::readFile(const QString filePath, Global::CurveFileData &cfd) phaseTotalVtr.push_back(phaseTotal); // print -// logde<<"index:"<& edVtr = Global::_curveExperimentDataVtr.at(i).dataVtr; @@ -258,10 +261,10 @@ void XlsxHandler::writeFile(const QString filePath) xlsx.write(row , 2, edVtr.size()); row++; -// logde<<"edVtr size:"<& aoVtr = AnalysisOperationRecorder::_analysisOperationVtr; + if(aoVtr.empty()){ + return; + } + xlsx->write(localRow , 1, ConAnalysisOperationCount); xlsx->write(localRow , 2, aoVtr.size()); localRow++; @@ -518,3 +525,56 @@ void XlsxHandler::writeAnalysisOperationDetail(QXlsx::Document *xlsx, const int localRow++; } } + +void XlsxHandler::writeSmoothnessFile(const QString filePath) +{ +#if 0 + if(Global::_curveFileDataVtr.empty()){ + // Load experiment data. + logde<<"experiment vtr size:"<isCurrentCurve(ced.curve)){ + logde<<"load experiment data."; + // PointCalculate::setAnalysisData(ced.dataVtr); + dataVtr = ced.dataVtr; + Global::_smoothnessFileName = ced.fileName; + break; + } + } + }else{ + // Load xlsx file data. + for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ + if(_centralWidget->isCurrentCurve(pti.curve)){ + // PointCalculate::setAnalysisData(pti.dataVtr); + dataVtr = pti.dataVtr; + Global::_smoothnessFileName = cfd.fileName; + break; + } + } + } + } +#endif +} + +void XlsxHandler::writeAnalysisiFile(const QString filePath) +{ + QXlsx::Document* xlsx = openXlsxFile(_currentFilePath); + if(!xlsx){ + logde<<"xlsx is nullptr." ; + return; + } + + QXlsx::Worksheet *sheet = xlsx->currentWorksheet(); + if(!sheet) + { + logde << "current sheet is empty."; + return; + } + int index = sheet->dimension().lastRow(); + logde<<"lastRow:"< _curveFileDataVtr; int _currentPhase = 0; @@ -13,6 +15,10 @@ ExperimentInfo _experimentInfo; QVector _curveExperimentDataVtr; CurveExperimentData* _currentCurveExperimentDataPtr = nullptr; +bool _smoothnessFlag = false; +QVector _curveSmoothnessDataVtr; +QString _smoothnessFileName; + bool _enthalpyCoefficientEnableFlag = false; QVector _enthalpyCoefficientVtr; diff --git a/src/global.h b/src/global.h index c80a8d3..9a8e3f7 100644 --- a/src/global.h +++ b/src/global.h @@ -34,12 +34,18 @@ const double OnsetAndEndSetRate = 0.01; //curve object name const QString objectNameExperiemnt("experiment"); +//const QString objectNameSmoothness("smoothness"); // enum LanguageType{ Chinese, English }; +enum AxisMode{ + SingleY, + DoubleY +}; + const QString EnglishStr("English"); const QString ChineseStr("中文"); @@ -111,6 +117,12 @@ extern int _currentPhase; extern ExperimentInfo _experimentInfo; extern QVector _curveExperimentDataVtr; extern CurveExperimentData* _currentCurveExperimentDataPtr; +extern bool _smoothnessFlag; +#if 0 +// Smoothness data +extern QVector _curveSmoothnessDataVtr; +extern QString _smoothnessFileName; +#endif // Call clear function at the right time. void clearExperimentData(); @@ -124,6 +136,8 @@ extern bool _displayTimeValue; // extern LanguageType _languageType; +extern AxisMode _axisMode; + // common func QString converDoubleToStr(const double); void quadraticLeastSquaresFit(double x[], double y[], int n, double coeff[]); diff --git a/src/main.cpp b/src/main.cpp index 31598c5..1e59566 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) { - system("chcp 65001"); +// system("chcp 65001"); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7b8bf93..28b08d7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,5 +1,6 @@ #include +#include "lowesssmoother.h" #include "mainwindow.h" #include "ui_mainwindow.h" #include "global.h" @@ -269,18 +270,24 @@ bool MainWindow::saveFile(const QString fileName,const Global::Mode mode) return false; } + // Save file. if(mode == Global::Mode::Analysis){ if(Global::_curveFileDataVtr.empty()){ logde<<"analysis experiemt data..."; - XlsxHandler::writeFile(filePath); -// XlsxHandler::writeAnalysisOperation(filePath); + XlsxHandler::writeExperimentFile(filePath); + // XlsxHandler::writeAnalysisOperation(filePath); }else{ logde<<"analysis xlsx data..."; - XlsxHandler::writeAnalysisOperation(filePath); + if(Global::_smoothnessFlag){ + + }else{ + XlsxHandler::appendAnalysisOperation(filePath); + } } }else if(mode == Global::Mode::Experiment){ logde<<"writeFile..."; - XlsxHandler::writeFile(filePath); + XlsxHandler::writeExperimentFile(filePath); + #if 0 // Clear data. Global::clearExperimentData(); @@ -290,9 +297,203 @@ bool MainWindow::saveFile(const QString fileName,const Global::Mode mode) return true; } +void MainWindow::smoothness(const int level) +{ + Global::_smoothnessFlag = true; + // process data. + QVector targetDataVtr; + QString objectName; + QCPCurve ** curvePtrPtr; + + if(!Global::_curveExperimentDataVtr.empty()){ + for(auto & item:Global::_curveExperimentDataVtr){ + if(_centralWidget->isCurrentCurve(item.curve)){ + smoothnessDetail(level,item.dataVtr); + + targetDataVtr = item.dataVtr; + objectName = Global::objectNameExperiemnt; + curvePtrPtr = &item.curve; + } + } + }else{ + for(Global::CurveFileData &cfd :Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ + if(_centralWidget->isCurrentCurve(pti.curve)){ + smoothnessDetail(level,pti.dataVtr); + + targetDataVtr = pti.dataVtr; + objectName = cfd.fileName; + curvePtrPtr = &pti.curve; + + // +#if 0 + Global::ExperimentData ed; + ed.sampleTemp = 2222; + ed.dsc = 2222; + + pti.dataVtr.push_back(ed); +#endif + } + } + } + } + + // + _centralWidget->deleteCurrentCurve(); + + // + _centralWidget->addSmoothnessCurveData(targetDataVtr,objectName); + + *curvePtrPtr = _centralWidget->getCurrentCurve(); + + +#if 0 + // Get current data vtr; + QVector dataVtr; + + if(Global::_curveFileDataVtr.empty()){ + // Load experiment data. + logde<<"experiment vtr size:"<isCurrentCurve(ced.curve)){ + logde<<"load experiment data."; + // PointCalculate::setAnalysisData(ced.dataVtr); + dataVtr = ced.dataVtr; + Global::_smoothnessFileName = ced.fileName; + break; + } + } + }else{ + // Load xlsx file data. + for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ + if(_centralWidget->isCurrentCurve(pti.curve)){ + // PointCalculate::setAnalysisData(pti.dataVtr); + dataVtr = pti.dataVtr; + Global::_smoothnessFileName = cfd.fileName; + break; + } + } + } + } + + if(dataVtr.empty()){ + return; + } + + // smoothness. + Lowess::Config config; + config.smoothingFactor = level * 0.1; + config.robustnessIterations = 3; + + std::vector x; + std::vector y; + + for(Global::ExperimentData& ed:dataVtr) { + if(Global::_axisMode == Global::AxisMode::SingleY){ + x.push_back(ed.sampleTemp); + }else{ + x.push_back(ed.runTime); + } + + y.push_back(ed.dsc); + } + + logde<<"smooth start..."; + std::vector yest = Lowess::smooth(x, y, config); + logde<<"smooth end..."; + + // Delete current curve; + _centralWidget->deleteCurrentCurve(); + + // Add new Curve. + QVector newCurveDataVtr; + for(int i = 0; i < x.size();i++){ + Global::ExperimentData ed; + if(Global::_axisMode == Global::AxisMode::SingleY){ + ed.sampleTemp = x.at(i); + ed.runTime = dataVtr.at(i).runTime; + }else{ + ed.runTime = x.at(i); + ed.sampleTemp = dataVtr.at(i).sampleTemp; + } + + ed.dsc = yest.at(i); + ed.constantTempTime = dataVtr.at(i).constantTempTime; + + newCurveDataVtr.push_back(ed); + } + _centralWidget->addSmoothnessCurveData(newCurveDataVtr); +#endif +} + +QVector MainWindow::smoothnessDetail(const int level,QVector& dataVtr) +{ + Lowess::Config config; + config.smoothingFactor = level * 0.1; + config.robustnessIterations = 3; + + std::vector x; + std::vector y; + + for(const Global::ExperimentData& ed:dataVtr) { + if(Global::_axisMode == Global::AxisMode::SingleY){ + x.push_back(ed.sampleTemp); + }else{ + x.push_back(ed.runTime); + } + + y.push_back(ed.dsc); + } + + logde<<"smooth start..."; + std::vector yest = Lowess::smooth(x, y, config); + logde<<"smooth end..."; + + // target data vector. + QVector targetVtr; + + for(int i = 0; i < x.size();i++){ + Global::ExperimentData ed; + if(Global::_axisMode == Global::AxisMode::SingleY){ + ed.sampleTemp = x.at(i); + ed.runTime = dataVtr.at(i).runTime; + }else{ + ed.runTime = x.at(i); + ed.sampleTemp = dataVtr.at(i).sampleTemp; + } + + ed.dsc = yest.at(i); + ed.constantTempTime = dataVtr.at(i).constantTempTime; + + targetVtr.push_back(ed); + } + + dataVtr.clear(); + dataVtr = targetVtr; + + return targetVtr; +} + +void MainWindow::smoothnessExperimentData(const int level) +{ +#if 0 + for(int i = 0;i < Global::_curveExperimentDataVtr.size();i++){ + Global::CurveExperimentData ced = Global::_curveExperimentDataVtr.at(i); + smoothnessDetail() + } +#endif + + for(auto & item:Global::_curveExperimentDataVtr){ + smoothnessDetail(level,item.dataVtr); + } + +} + void MainWindow::on_actionStop_triggered() { logde<<" Stop experiment ..."; + if(Global::_mode == Global::Mode::Experiment) { QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop); @@ -303,6 +504,7 @@ void MainWindow::on_actionStop_triggered() // if(saveExperimentFile(Global::_experimentInfo.sampleName)){ // _leftWidget->reloadFileName(); // } + if(saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment)){ _leftWidget->reloadFileName(); } @@ -365,6 +567,7 @@ void MainWindow::slotSaveExperimentalDataMsgBox() } else { on_actionClearAllData_triggered(); } + #if 0 // Clear data. logde<<"save mesg box.clearExperimentData..."; @@ -548,5 +751,47 @@ void MainWindow::on_actionLanguage_triggered() Global::_languageType = Global::LanguageType::Chinese; ui->actionLanguage->setText(Global::ChineseStr); } - } + +void MainWindow::on_actionSmoothness1_triggered() +{ + smoothness(1); +} + +void MainWindow::on_actionSmoothness2_triggered() +{ + smoothness(2); +} +void MainWindow::on_actionSmoothness3_triggered() +{ + smoothness(3); +} +void MainWindow::on_actionSmoothness4_triggered() +{ + smoothness(4); +} +void MainWindow::on_actionSmoothness5_triggered() +{ + smoothness(5); +} +void MainWindow::on_actionSmoothness6_triggered() +{ + smoothness(6); +} +void MainWindow::on_actionSmoothness7_triggered() +{ + smoothness(7); +} +void MainWindow::on_actionSmoothness8_triggered() +{ + smoothness(8); +} +void MainWindow::on_actionSmoothness9_triggered() +{ + smoothness(9); +} +void MainWindow::on_actionSmoothness10_triggered() +{ + smoothness(10); +} + diff --git a/src/mainwindow.h b/src/mainwindow.h index 6e3f591..49e55e1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -98,12 +98,29 @@ private slots: void on_actionLanguage_triggered(); + void on_actionSmoothness1_triggered(); + void on_actionSmoothness2_triggered(); + void on_actionSmoothness3_triggered(); + void on_actionSmoothness4_triggered(); + void on_actionSmoothness5_triggered(); + void on_actionSmoothness6_triggered(); + void on_actionSmoothness7_triggered(); + void on_actionSmoothness8_triggered(); + void on_actionSmoothness9_triggered(); + void on_actionSmoothness10_triggered(); + private: + void setAnalysisData(); void connections(); void setActionEnable(const bool); void setSubWidgetAttribute(QWidget *); bool saveFile(const QString fileName,const Global::Mode); + + void smoothness(const int level); + QVector smoothnessDetail(const int level,QVector&); + void smoothnessExperimentData(const int level); + private: bool _manuallyStopTheExperimentFlag; Ui::MainWindow *ui; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7fe8411..b7bc2bb 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -75,16 +75,16 @@ 平滑 - - - - - - - - - - + + + + + + + + + + @@ -360,52 +360,52 @@ language - + 1级 - + 2级 - + 3级 - + 4级 - + 5级 - + 6级 - + 7级 - + 8级 - + 9级 - + 10级 diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index 9fc02aa..6d3aea7 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -15,6 +15,7 @@ namespace AnaOpRecorder = AnalysisOperationRecorder; using AnaOpRecorderOperation = AnalysisOperationRecorder::AnalysisOperation; +using namespace Global; CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) @@ -22,7 +23,6 @@ CentralWidget::CentralWidget(QWidget *parent) // ,_customPlot(new QCustomPlot(this)) ,_analysisMode(AnalysisMode::Null) ,_currentCurve(nullptr) - ,_axisMode(AxisMode::SingleY) { setMouseTracking(true); @@ -119,6 +119,87 @@ void CentralWidget::switchAxisMode() uiLoadXlsxFileData(); } +bool CentralWidget::isCurrentCurve(QCPCurve *curve) +{ + return _currentCurve == curve; +} + +void CentralWidget::deleteCurrentCurve() +{ + slotDelCurve(_currentCurve); +} + +void CentralWidget::addSmoothnessCurveData( + const QVector &dataVtr,const QString objectName) +{ + PointCalculate::setAnalysisData(dataVtr); + + // Load data. + // QVector dataVtr; + QVector tVtr,xVtr, yVtr; + int index = 0; + for (const Global::ExperimentData &ed : dataVtr) + { + tVtr.push_back(index++); + if(_axisMode == AxisMode::SingleY){ + xVtr.push_back(ed.sampleTemp); + }else{ + xVtr.push_back(ed.runTime); + } + yVtr.push_back(ed.dsc); + } + + _currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis); + _currentCurve->setData(tVtr, xVtr, yVtr); + _currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选 + _currentCurve->setLineStyle(QCPCurve::lsLine); // 线性连接 + + _currentCurve->setObjectName(objectName); + + // Set axis range. + QPair minMaxXAxisPair; + if(_axisMode == AxisMode::SingleY){ + // Axis x is temperature value. + minMaxXAxisPair = PointCalculate::getMinAndMaxOfSampleTemp(); + }else{ + // Axis x is time value. + minMaxXAxisPair = PointCalculate::getMinAndMaxOfRunTime(); + } + QPairnewXAxisPair = PointCalculate::getMinAndMaxOfAxis( + minMaxXAxisPair.first,minMaxXAxisPair.second); + _customPlot->xAxis->setRange(newXAxisPair.first, newXAxisPair.second); + + QPair minMaxYAxisPair = PointCalculate::getMinAndMaxOfDSC(); + QPairnewYAxisPair = PointCalculate::getMinAndMaxOfAxis( + minMaxYAxisPair.first,minMaxYAxisPair.second); + _customPlot->yAxis->setRange(newYAxisPair.first , + newYAxisPair.second); + // + // pti.curve = _currentCurve; + + // Add analysis operation data. +#if 0 + if(cfd.analysisOperationVtr.size() > 0){ + for(AnaOpRecorder::AnalysisOperation& ao + :cfd.analysisOperationVtr){ + loadAnalysisData(ao.mode,ao.x1,ao.x2,cfd.fileName); + } + } +#endif + + // Refresh ui. + _customPlot->replot(); + +#if 0 + // Save data. + CurveExperimentData ced; + ced.curve = _currentCurve; + ced.dataVtr = dataVtr; + + // Global::_curveSmoothnessDataVtr.push_back(ced); +#endif +} + void CentralWidget::setAnalysisMode(const AnalysisMode mode) { _analysisMode = mode; @@ -241,6 +322,7 @@ void CentralWidget::slotAnalysisSettingApply() return; } + // Set curve data to PointCalculate. if(Global::_curveFileDataVtr.empty()){ // Load experiment data. logde<<"experiment vtr size:"<point1->coords().x(); double x2 = _line2->point1->coords().x(); @@ -349,6 +443,7 @@ void CentralWidget::slotDrawCustomText(const QString str) void CentralWidget::slotDelCurve(QCPCurve *curve) { if(!curve){ + logde<<"current curve is nullptr."; return; } @@ -490,7 +585,6 @@ void CentralWidget::uiLoadXlsxFileData() _currentCurve->setObjectName(cfd.fileName); // Set axis range. - QPair minMaxXAxisPair; if(_axisMode == AxisMode::SingleY){ // Axis x is temperature value. @@ -703,7 +797,7 @@ void CentralWidget::glassTransitionHandle(const double x1,const double x2,const QString str = PointCalculate::textFormatGlassTranstion(intersection1.x(), averagePoint.x(), intersection2.x()); - if(_axisMode == AxisMode::DoubleY){ + if(Global::_axisMode == Global::AxisMode::DoubleY){ Global::ExperimentData intersection1Ed = PointCalculate::getClosestDataByTemperature(intersection1.x()); Global::ExperimentData averageEd = @@ -750,10 +844,10 @@ QPointF CentralWidget::onsetTemperaturePointHandle(const double x1,const double { Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2); - if(_axisMode == AxisMode::SingleY){ - return QPointF(ed.sampleTemp,ed.dsc); + if(Global::_axisMode == Global::AxisMode::SingleY){ + return QPointF(ed.sampleTemp,ed.dsc); }else{ - return QPointF(ed.runTime,ed.dsc); + return QPointF(ed.runTime,ed.dsc); } } @@ -761,10 +855,10 @@ QPointF CentralWidget::endSetTemperaturePointHandle(const double x1, const doubl { Global::ExperimentData ed = PointCalculate::findEndSetDataByTemperature(x1,x2); - if(_axisMode == AxisMode::SingleY){ - return QPointF(ed.sampleTemp,ed.dsc); + if(Global::_axisMode == Global::AxisMode::SingleY){ + return QPointF(ed.sampleTemp,ed.dsc); }else{ - return QPointF(ed.runTime,ed.dsc); + return QPointF(ed.runTime,ed.dsc); } } @@ -848,7 +942,7 @@ QPointF CentralWidget::getTheCoordinatesOfTheTextBox(const QPointF point) QVector ticks = _customPlot->xAxis->tickVector(); int numTicks = ticks.size(); -// logde<<"ticks:"<setVisible(false); _currentCurve = nullptr; + + Global::_smoothnessFlag = false; case ClearDataMode::JustUi: //ui clearAllUiData(); @@ -1317,3 +1413,6 @@ void CentralWidget::slotAxisModify(const float temp) _customPlot->xAxis->setRange(10,value); _customPlot->yAxis->setRange(-5,5); } + + + diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index 586fee5..9fc213a 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -31,16 +31,20 @@ public: QPixmap getPixMap(); - enum AxisMode{ - SingleY, - DoubleY - }; void switchAxisMode(); + struct AxisInfo{ bool visiable; double lower; double upper; }; + + bool isCurrentCurve(QCPCurve* curve); + + void deleteCurrentCurve(); + void addSmoothnessCurveData(const QVector &,const QString objectName); + + QCPCurve * getCurrentCurve(){return _currentCurve;} signals: void sigContextMenuShow(const QPoint); void sigSendLineXCoord(const int,const double); @@ -109,11 +113,10 @@ private: private: AnalysisOperationRecorder::AnalysisMode _analysisMode; LocalCustomPlot *_customPlot; - QCPCurve *_currentCurve; + QCPCurve * _currentCurve; EventHandler* _eventHandler; QCPItemStraightLine *_line1,*_line2; QVector _lineVtr; - AxisMode _axisMode; QVector _analysisFilePathVtr; double _x1Record;