2025-06-17T17:28:21

This commit is contained in:
yuntang 2025-06-17 17:28:22 +08:00
parent bfbf12cf2e
commit 08c7f5147b
11 changed files with 126 additions and 51 deletions

Binary file not shown.

View File

@ -395,6 +395,8 @@ void XlsxHandler::readAnalysisOperation(
ao.mode = AnalysisMode::OnsetTemperaturePoint;
}else if(modeStr == AnaOpRecorder::EndsetTemperaturePointStr){
ao.mode = AnalysisMode::EndsetTemperaturePoint;
}else if(modeStr == AnaOpRecorder::OITStr){
ao.mode = AnalysisMode::OIT;
}
ao.x1 = sheet->cellAt(startLineIndex, 2)->value().toDouble();
@ -464,6 +466,11 @@ void XlsxHandler::writeAnalysisOperationDetail(QXlsx::Document *xlsx, const int
analysisOpName = AnalysisOperationRecorder::EndsetTemperaturePointStr;
break;
}
case AnalysisMode::OIT:
{
analysisOpName = AnalysisOperationRecorder::OITStr;
break;
}
default:break;
}
@ -696,8 +703,8 @@ int XlsxHandler::deleteInvalidRow(QXlsx::Document *doc)
|| cellValue == AnaOpRecorder::EndsetTemperaturePointStr
) {
qDebug() << "Row" << row << "is empty or contains specified string. Deleting row.";
// sheet->deleteRows(row, 1); // 删除当前行
// sheet->deleteRow(row);
// sheet->deleteRows(row, 1); // 删除当前行
// sheet->deleteRow(row);
}
}
}

View File

@ -122,7 +122,6 @@ private:
void smoothness(const int level);
QVector<Global::ExperimentData> smoothnessDetail(const int level,const QVector<Global::ExperimentData>&);
void smoothnessExperimentData(const int level);
private:
bool _manuallyStopTheExperimentFlag;
Ui::MainWindow *ui;

View File

@ -9,8 +9,8 @@ const QString PeakSynthesisAnalysisStr("PeakSynthesisAnalysis");
const QString GlassTransitionStr("GlassTransition");
const QString OnsetTemperaturePointStr("OnsetTemperaturePoint");
const QString EndsetTemperaturePointStr("EndsetTemperaturePoint");
const QString OITStr("OIT");
#if 1
enum AnalysisMode{
Null,
NumericalLabel,
@ -22,7 +22,6 @@ enum AnalysisMode{
EndsetTemperaturePoint,
OIT
};
#endif
struct AnalysisOperation{
QString filePath;
@ -39,7 +38,6 @@ extern QVector<AnalysisOperation> _analysisOperationVtr;
void removeTheLastAnalysisOperation();
void removeAnalysisOperationByObjectName(const QString objectName);
}

View File

@ -331,6 +331,7 @@ void CentralWidget::slotAnalysisSettingApply()
QString selectedCurveObjectName = _currentCurve->objectName();
// Set curve data to PointCalculate.
QVector<ExperimentData> totalDataVtr;
if(Global::_curveFileDataVtr.empty()){
// Load experiment data.
logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size();
@ -339,15 +340,19 @@ void CentralWidget::slotAnalysisSettingApply()
if(ced.curve == _currentCurve){
logde<<"load experiment data.";
if(ced.smoothDataVtr.empty()){
PointCalculate::setAnalysisData(ced.dataVtr);
// PointCalculate::setAnalysisData(ced.dataVtr);
totalDataVtr.append(ced.dataVtr);
}else{
PointCalculate::setAnalysisData(ced.smoothDataVtr);
// PointCalculate::setAnalysisData(ced.smoothDataVtr);
totalDataVtr.append(ced.smoothDataVtr);
}
break;
}
}
}else{
// Load xlsx file data.
#if 0
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(pti.curve == _currentCurve){
@ -356,12 +361,32 @@ void CentralWidget::slotAnalysisSettingApply()
}else{
PointCalculate::setAnalysisData(pti.smoothDataVtr);
}
break;
}
}
}
#endif
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(pti.curve == _currentCurve){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(pti.smoothDataVtr.empty()){
totalDataVtr.append(pti.dataVtr);
}else{
totalDataVtr.append(pti.smoothDataVtr);
}
}
break;
}
}
}
}
PointCalculate::setAnalysisData(totalDataVtr);
#if 0
// Load smoothness data.
for(Global::CurveExperimentData& ced:Global::_curveSmoothnessDataVtr){
@ -602,6 +627,7 @@ void CentralWidget::uiLoadXlsxFileData()
_currentCurve->setObjectName(cfd.filePath);
#if 0
// Set axis range.
QPair<float, float> minMaxXAxisPair;
if(_axisMode == AxisMode::SingleY){
@ -620,14 +646,37 @@ void CentralWidget::uiLoadXlsxFileData()
minMaxYAxisPair.first,minMaxYAxisPair.second);
_customPlot->yAxis->setRange(newYAxisPair.first ,
newYAxisPair.second);
#endif
//
pti.curve = _currentCurve;
}
// Axis setting.
PointCalculate::setAnalysisData(allDataVtr);
// Set axis range.
QPair<float, float> minMaxXAxisPair;
if(_axisMode == AxisMode::SingleY){
// Axis x is temperature value.
minMaxXAxisPair = PointCalculate::getMinAndMaxOfSampleTemp();
}else{
// Axis x is time value.
minMaxXAxisPair = PointCalculate::getMinAndMaxOfRunTime();
}
QPair<float, float>newXAxisPair = PointCalculate::getMinAndMaxOfAxis(
minMaxXAxisPair.first,minMaxXAxisPair.second);
_customPlot->xAxis->setRange(newXAxisPair.first, newXAxisPair.second);
QPair<float, float> minMaxYAxisPair = PointCalculate::getMinAndMaxOfDSC();
QPair<float, float>newYAxisPair = PointCalculate::getMinAndMaxOfAxis(
minMaxYAxisPair.first,minMaxYAxisPair.second);
_customPlot->yAxis->setRange(newYAxisPair.first ,
newYAxisPair.second);
// Add analysis operation data.
if(cfd.analysisOperationVtr.size() > 0){
logde<<"analysis operation vtr size:"
<<cfd.analysisOperationVtr.size();
if(!cfd.analysisOperationVtr.empty()){
for(AnaOpRecorder::AnalysisOperation& ao
:cfd.analysisOperationVtr){
loadAnalysisData(ao.mode,ao.x1,ao.x2,cfd.filePath);
@ -1085,7 +1134,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
_currentCurve = nullptr;
// Global::_smoothnessFlag = false;
setAxisMode(Global::AxisMode::SingleY);
case ClearDataMode::JustUi:
//ui
clearAllUiData();
@ -1409,21 +1458,30 @@ void CentralWidget::loadAnalysisData(
case AnalysisMode::OIT:{
logde<<"oit x1,x2:"<<x1<<","<<x2;
Global::ExperimentData ed = PointCalculate::findOnSetDataByTime(x1,x2);
//
QVector<double> tickPositions = _customPlot->yAxis->tickVector();
// qDebug() << "Y-axis tick positions:";
// for (double pos : tickPositions) {
// qDebug() << pos;
// }
double step = tickPositions.at(1) - tickPositions.at(0);
// Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2);
//
Global::ExperimentData ed = PointCalculate::findOnSetDataByTime(x1,x2);
// PointCalculate::setRegionPointX(x1,x2);
// Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2);
// PointCalculate::setRegionPointX(x1,x2);
Global::ExperimentData startData = PointCalculate::_dataVtr.first();
// QPair<Global::ExperimentData,Global::ExperimentData>
// startEndDataPair = PointCalculate::calculateStartAndEndData();
// QPair<Global::ExperimentData,Global::ExperimentData>
// startEndDataPair = PointCalculate::calculateStartAndEndData();
logde<<"start data time:"<<startData.runTime;
logde<<"end data time:"<<ed.runTime;
drawOITLine(startData,ed);
drawOITLine(startData,ed,step,objectName);
break;
}
@ -1432,69 +1490,80 @@ void CentralWidget::loadAnalysisData(
}
}
void CentralWidget::drawOITLine(const Global::ExperimentData startData,const Global::ExperimentData endData)
void CentralWidget::drawOITLine(
const Global::ExperimentData startData,
const Global::ExperimentData endData,
const int step,
const QString objectName)
{
#if 0
// Draw start vertical line.
QVector<double> xVtr,yVtr;
xVtr.push_back(startData.runTime);
xVtr.push_back(startData.runTime);
logde << "step:"<<step;
yVtr.push_back(startData.dsc - 10);
yVtr.push_back(startData.dsc - 20);
double localStep = static_cast<double>(step) / 5 / 2;
QCPGraph *startLine = _customPlot->addGraph();
startLine->setData(xVtr, yVtr);
startLine->setPen(QPen(Qt::red, 1));
double startOffset = localStep ;
double endOffset = localStep * 2;
// Draw end vertical line.
xVtr.clear();
yVtr.clear();
xVtr.push_back(endData.runTime);
xVtr.push_back(endData.runTime);
logde<<"start/end offset:"
<<startOffset<<","<<endOffset;
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
double verticalLineStartY = startData.dsc - startOffset;
double verticalLineEndY = startData.dsc - endOffset;
double totalLineDsc = startData.dsc - (endOffset - startOffset) * 1.5;
// 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->start->setCoords(startData.runTime,verticalLineStartY);
startLine->end->setCoords(startData.runTime,verticalLineEndY);
startLine->setPen(QPen(Qt::red, 1));
ItemManager::addTemporaryQCPItemLine(startLine,objectName);
// 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->start->setCoords(endData.runTime,verticalLineStartY);
endLine->end->setCoords(endData.runTime,verticalLineEndY);
endLine->setPen(QPen(Qt::red, 1));
ItemManager::addTemporaryQCPItemLine(endLine,objectName);
// 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->start->setCoords(startData.runTime,totalLineDsc);
totalLine->end->setCoords(endData.runTime,totalLineDsc);
totalLine->setPen(QPen(Qt::red, 1));
ItemManager::addTemporaryQCPItemLine(totalLine,objectName);
// Draw title.
double textX = (endData.runTime - startData.runTime) / 2 + endData.runTime;
double textX = (endData.runTime - startData.runTime) / 3 + startData.runTime;
double textY = verticalLineEndY;
QCPItemText *textLabel = new QCPItemText(_customPlot);
textLabel->setPositionAlignment(Qt::AlignCenter); // 对齐方式
textLabel->setPositionAlignment(Qt::AlignLeft); // 对齐方式
textLabel->position->setType(QCPItemPosition::ptPlotCoords); // 使用数据坐标
textLabel->position->setCoords(textX,startData.dsc - 20); // 设置文本位置在指定点上方
textLabel->position->setCoords(textX,textY); // 设置文本位置在指定点上方
textLabel->setText("OIT:123.44"); // 设置文本内容
double elapseMin = endData.runTime - startData.runTime;
QString elapseMinStr = QString("OIT: ") + Global::converDoubleToStr(elapseMin)
+ QString(" min");
textLabel->setText(elapseMinStr); // 设置文本内容
QFont font(QFont("Arial", 10));
textLabel->setFont(font);
textLabel->setSelectedFont(font);
textLabel->setSelectable(true); // 设置为可选
ItemManager::addTemporaryQCPItemText(textLabel,objectName);
_customPlot->replot();
}
void CentralWidget::setAxisMode(AxisMode mode)
{
if(_axisMode != mode){
_axisMode = mode;
uiLoadXlsxFileData();
}
}
void CentralWidget::clearAllData()
{
Global::_mode = Global::Mode::Analysis;

View File

@ -112,11 +112,13 @@ private:
void clearData(const ClearDataMode);
void clearAllUiData();
void loadAnalysisData(const AnalysisMode mode,const double x1,const double x2,const QString objectName);
void drawOITLine(const Global::ExperimentData startData,const Global::ExperimentData endData);
void drawOITLine(const Global::ExperimentData startData,
const Global::ExperimentData endData,
const int step,const QString objectName);
void setAxisMode(Global::AxisMode mode);
private:
AnalysisOperationRecorder::AnalysisMode _analysisMode;
LocalCustomPlot *_customPlot;