2025-06-06T17:17:30

This commit is contained in:
yuntang 2025-06-06 17:17:31 +08:00
parent 1a5e49bbfe
commit 23667e3f8a
26 changed files with 529 additions and 57 deletions

Binary file not shown.

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
#include "LowessSmoother.h" #include "lowesssmoother.h"
#include <numeric> #include <numeric>
namespace Lowess { namespace Lowess {

View File

@ -892,3 +892,4 @@ QString PointCalculate::textFormatGlassTranstionWithTime(const float t1, const f
} }

View File

@ -20,7 +20,7 @@ void XlsxHandler::test()
#endif #endif
QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx"; QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx";
writeFile(sourceFilePath); writeExperimentFile(sourceFilePath);
} }
int XlsxHandler::readFile(const QString filePath, Global::CurveFileData &cfd) 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); phaseTotalVtr.push_back(phaseTotal);
// print // print
// logde<<"index:"<<i<<",phase cut off temp:"<<phaseTotal.phase.cutoff_temp; // logde<<"index:"<<i<<",phase cut off temp:"<<phaseTotal.phase.cutoff_temp;
} }
// logde<<"index:"<<cfd.phaseTotalVtr.first().phaseIndex // logde<<"index:"<<cfd.phaseTotalVtr.first().phaseIndex
// <<",phase cut off temp:"<<cfd.phaseTotalVtr.first().phase.cutoff_temp; // <<",phase cut off temp:"<<cfd.phaseTotalVtr.first().phase.cutoff_temp;
readAnalysisOperation(workSheet,dataIndex,cfd); readAnalysisOperation(workSheet,dataIndex,cfd);
@ -125,12 +125,15 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex
} }
} }
void XlsxHandler::writeFile(const QString filePath) void XlsxHandler::writeExperimentFile(const QString filePath)
{ {
logde<<"write file...";
#if 0
if(Global::_curveExperimentDataVtr.empty()){ if(Global::_curveExperimentDataVtr.empty()){
logde<<"_curveExperimentDataVtr empty..."; logde<<"_curveExperimentDataVtr empty...";
return; return;
} }
#endif
Global::ExperimentInfo& ei = Global::_experimentInfo; Global::ExperimentInfo& ei = Global::_experimentInfo;
@ -198,7 +201,7 @@ void XlsxHandler::writeFile(const QString filePath)
const Phase& phase = ei.phaseVtr.at(i); const Phase& phase = ei.phaseVtr.at(i);
if(phase.onoff == 0){ if(phase.onoff == 0){
// logde<<"onoff == 0."; // logde<<"onoff == 0.";
continue; continue;
} }
@ -247,8 +250,8 @@ void XlsxHandler::writeFile(const QString filePath)
row++; row++;
// phase data. // phase data.
// logde<<"Global::_curveExperimentDataVtr size:" // logde<<"Global::_curveExperimentDataVtr size:"
// <<Global::_curveExperimentDataVtr.size(); // <<Global::_curveExperimentDataVtr.size();
const QVector<Global::ExperimentData>& edVtr = const QVector<Global::ExperimentData>& edVtr =
Global::_curveExperimentDataVtr.at(i).dataVtr; Global::_curveExperimentDataVtr.at(i).dataVtr;
@ -258,10 +261,10 @@ void XlsxHandler::writeFile(const QString filePath)
xlsx.write(row , 2, edVtr.size()); xlsx.write(row , 2, edVtr.size());
row++; row++;
// logde<<"edVtr size:"<<edVtr.size(); // logde<<"edVtr size:"<<edVtr.size();
for(int index = 0;index < edVtr.size();index++){ for(int index = 0;index < edVtr.size();index++){
// logde<<"index :"<<index; // logde<<"index :"<<index;
const Global::ExperimentData & ed = edVtr.at(index); const Global::ExperimentData & ed = edVtr.at(index);
xlsx.write(row , 1, index); xlsx.write(row , 1, index);
@ -286,7 +289,7 @@ void XlsxHandler::writeFile(const QString filePath)
} }
void XlsxHandler::writeAnalysisOperation(const QString filePath) void XlsxHandler:: appendAnalysisOperation(const QString filePath)
{ {
QXlsx::Document* xlsx = openXlsxFile(_currentFilePath); QXlsx::Document* xlsx = openXlsxFile(_currentFilePath);
if(!xlsx){ if(!xlsx){
@ -466,6 +469,10 @@ void XlsxHandler::writeAnalysisOperationDetail(QXlsx::Document *xlsx, const int
QVector<AnalysisOperationRecorder::AnalysisOperation>& aoVtr = QVector<AnalysisOperationRecorder::AnalysisOperation>& aoVtr =
AnalysisOperationRecorder::_analysisOperationVtr; AnalysisOperationRecorder::_analysisOperationVtr;
if(aoVtr.empty()){
return;
}
xlsx->write(localRow , 1, ConAnalysisOperationCount); xlsx->write(localRow , 1, ConAnalysisOperationCount);
xlsx->write(localRow , 2, aoVtr.size()); xlsx->write(localRow , 2, aoVtr.size());
localRow++; localRow++;
@ -518,3 +525,56 @@ void XlsxHandler::writeAnalysisOperationDetail(QXlsx::Document *xlsx, const int
localRow++; localRow++;
} }
} }
void XlsxHandler::writeSmoothnessFile(const QString filePath)
{
#if 0
if(Global::_curveFileDataVtr.empty()){
// Load experiment data.
logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size();
for(Global::CurveExperimentData& ced:Global::_curveExperimentDataVtr){
if(_centralWidget->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:"<<index;
int row = index + 1;
writeAnalysisOperationDetail(xlsx,row);
}

View File

@ -24,10 +24,13 @@ namespace XlsxHandler {
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&); void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
void readAnalysisOperation(QXlsx::Worksheet*,int& startLineIndex,Global::CurveFileData&); void readAnalysisOperation(QXlsx::Worksheet*,int& startLineIndex,Global::CurveFileData&);
void writeFile(const QString filePath); void writeExperimentFile(const QString filePath);
void writeAnalysisOperation(const QString filePath); void appendAnalysisOperation(const QString filePath);
void writeAnalysisiFile(const QString filePath);
void writeAnalysisOperationDetail(QXlsx::Document*doc,const int row); void writeAnalysisOperationDetail(QXlsx::Document*doc,const int row);
void writeSmoothnessFile(const QString filePath);
extern QString _currentFilePath; extern QString _currentFilePath;
const QString ConUnitMg = "mg"; const QString ConUnitMg = "mg";

View File

@ -6,6 +6,8 @@
namespace Global { namespace Global {
Mode _mode = Mode::Analysis; Mode _mode = Mode::Analysis;
AxisMode _axisMode = AxisMode::SingleY;
QVector<CurveFileData> _curveFileDataVtr; QVector<CurveFileData> _curveFileDataVtr;
int _currentPhase = 0; int _currentPhase = 0;
@ -13,6 +15,10 @@ ExperimentInfo _experimentInfo;
QVector<CurveExperimentData> _curveExperimentDataVtr; QVector<CurveExperimentData> _curveExperimentDataVtr;
CurveExperimentData* _currentCurveExperimentDataPtr = nullptr; CurveExperimentData* _currentCurveExperimentDataPtr = nullptr;
bool _smoothnessFlag = false;
QVector<CurveExperimentData> _curveSmoothnessDataVtr;
QString _smoothnessFileName;
bool _enthalpyCoefficientEnableFlag = false; bool _enthalpyCoefficientEnableFlag = false;
QVector<double> _enthalpyCoefficientVtr; QVector<double> _enthalpyCoefficientVtr;

View File

@ -34,12 +34,18 @@ const double OnsetAndEndSetRate = 0.01;
//curve object name //curve object name
const QString objectNameExperiemnt("experiment"); const QString objectNameExperiemnt("experiment");
//const QString objectNameSmoothness("smoothness");
// //
enum LanguageType{ enum LanguageType{
Chinese, Chinese,
English English
}; };
enum AxisMode{
SingleY,
DoubleY
};
const QString EnglishStr("English"); const QString EnglishStr("English");
const QString ChineseStr("中文"); const QString ChineseStr("中文");
@ -111,6 +117,12 @@ extern int _currentPhase;
extern ExperimentInfo _experimentInfo; extern ExperimentInfo _experimentInfo;
extern QVector<CurveExperimentData> _curveExperimentDataVtr; extern QVector<CurveExperimentData> _curveExperimentDataVtr;
extern CurveExperimentData* _currentCurveExperimentDataPtr; extern CurveExperimentData* _currentCurveExperimentDataPtr;
extern bool _smoothnessFlag;
#if 0
// Smoothness data
extern QVector<CurveExperimentData> _curveSmoothnessDataVtr;
extern QString _smoothnessFileName;
#endif
// Call clear function at the right time. // Call clear function at the right time.
void clearExperimentData(); void clearExperimentData();
@ -124,6 +136,8 @@ extern bool _displayTimeValue;
// //
extern LanguageType _languageType; extern LanguageType _languageType;
extern AxisMode _axisMode;
// common func // common func
QString converDoubleToStr(const double); QString converDoubleToStr(const double);
void quadraticLeastSquaresFit(double x[], double y[], int n, double coeff[]); void quadraticLeastSquaresFit(double x[], double y[], int n, double coeff[]);

View File

@ -15,7 +15,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
system("chcp 65001"); // system("chcp 65001");
QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForLocale(codec);

View File

@ -1,5 +1,6 @@
#include <qmessagebox.h> #include <qmessagebox.h>
#include "lowesssmoother.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "global.h" #include "global.h"
@ -269,18 +270,24 @@ bool MainWindow::saveFile(const QString fileName,const Global::Mode mode)
return false; return false;
} }
// Save file.
if(mode == Global::Mode::Analysis){ if(mode == Global::Mode::Analysis){
if(Global::_curveFileDataVtr.empty()){ if(Global::_curveFileDataVtr.empty()){
logde<<"analysis experiemt data..."; logde<<"analysis experiemt data...";
XlsxHandler::writeFile(filePath); XlsxHandler::writeExperimentFile(filePath);
// XlsxHandler::writeAnalysisOperation(filePath); // XlsxHandler::writeAnalysisOperation(filePath);
}else{ }else{
logde<<"analysis xlsx data..."; logde<<"analysis xlsx data...";
XlsxHandler::writeAnalysisOperation(filePath); if(Global::_smoothnessFlag){
}else{
XlsxHandler::appendAnalysisOperation(filePath);
}
} }
}else if(mode == Global::Mode::Experiment){ }else if(mode == Global::Mode::Experiment){
logde<<"writeFile..."; logde<<"writeFile...";
XlsxHandler::writeFile(filePath); XlsxHandler::writeExperimentFile(filePath);
#if 0 #if 0
// Clear data. // Clear data.
Global::clearExperimentData(); Global::clearExperimentData();
@ -290,9 +297,203 @@ bool MainWindow::saveFile(const QString fileName,const Global::Mode mode)
return true; return true;
} }
void MainWindow::smoothness(const int level)
{
Global::_smoothnessFlag = true;
// process data.
QVector<Global::ExperimentData> 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<Global::ExperimentData> dataVtr;
if(Global::_curveFileDataVtr.empty()){
// Load experiment data.
logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size();
for(Global::CurveExperimentData& ced:Global::_curveExperimentDataVtr){
if(_centralWidget->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<double> x;
std::vector<double> 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<double> yest = Lowess::smooth(x, y, config);
logde<<"smooth end...";
// Delete current curve;
_centralWidget->deleteCurrentCurve();
// Add new Curve.
QVector<Global::ExperimentData> 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<Global::ExperimentData> MainWindow::smoothnessDetail(const int level,QVector<Global::ExperimentData>& dataVtr)
{
Lowess::Config config;
config.smoothingFactor = level * 0.1;
config.robustnessIterations = 3;
std::vector<double> x;
std::vector<double> 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<double> yest = Lowess::smooth(x, y, config);
logde<<"smooth end...";
// target data vector.
QVector<Global::ExperimentData> 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() void MainWindow::on_actionStop_triggered()
{ {
logde<<" Stop experiment ..."; logde<<" Stop experiment ...";
if(Global::_mode == Global::Mode::Experiment) if(Global::_mode == Global::Mode::Experiment)
{ {
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop); QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
@ -303,6 +504,7 @@ void MainWindow::on_actionStop_triggered()
// if(saveExperimentFile(Global::_experimentInfo.sampleName)){ // if(saveExperimentFile(Global::_experimentInfo.sampleName)){
// _leftWidget->reloadFileName(); // _leftWidget->reloadFileName();
// } // }
if(saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment)){ if(saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment)){
_leftWidget->reloadFileName(); _leftWidget->reloadFileName();
} }
@ -365,6 +567,7 @@ void MainWindow::slotSaveExperimentalDataMsgBox()
} else { } else {
on_actionClearAllData_triggered(); on_actionClearAllData_triggered();
} }
#if 0 #if 0
// Clear data. // Clear data.
logde<<"save mesg box.clearExperimentData..."; logde<<"save mesg box.clearExperimentData...";
@ -548,5 +751,47 @@ void MainWindow::on_actionLanguage_triggered()
Global::_languageType = Global::LanguageType::Chinese; Global::_languageType = Global::LanguageType::Chinese;
ui->actionLanguage->setText(Global::ChineseStr); 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);
}

View File

@ -98,12 +98,29 @@ private slots:
void on_actionLanguage_triggered(); 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: private:
void setAnalysisData();
void connections(); void connections();
void setActionEnable(const bool); void setActionEnable(const bool);
void setSubWidgetAttribute(QWidget *); void setSubWidgetAttribute(QWidget *);
bool saveFile(const QString fileName,const Global::Mode); bool saveFile(const QString fileName,const Global::Mode);
void smoothness(const int level);
QVector<Global::ExperimentData> smoothnessDetail(const int level,QVector<Global::ExperimentData>&);
void smoothnessExperimentData(const int level);
private: private:
bool _manuallyStopTheExperimentFlag; bool _manuallyStopTheExperimentFlag;
Ui::MainWindow *ui; Ui::MainWindow *ui;

View File

@ -75,16 +75,16 @@
<property name="title"> <property name="title">
<string>平滑</string> <string>平滑</string>
</property> </property>
<addaction name="action1"/> <addaction name="actionSmoothness1"/>
<addaction name="action2"/> <addaction name="actionSmoothness2"/>
<addaction name="action3"/> <addaction name="actionSmoothness3"/>
<addaction name="action4"/> <addaction name="actionSmoothness4"/>
<addaction name="action5"/> <addaction name="actionSmoothness5"/>
<addaction name="action6"/> <addaction name="actionSmoothness6"/>
<addaction name="action7"/> <addaction name="actionSmoothness7"/>
<addaction name="action9"/> <addaction name="actionSmoothness8"/>
<addaction name="action9_2"/> <addaction name="actionSmoothness9"/>
<addaction name="action10"/> <addaction name="actionSmoothness10"/>
</widget> </widget>
<addaction name="actionEnthalpyCorrectionEdit"/> <addaction name="actionEnthalpyCorrectionEdit"/>
<addaction name="actionEnthalpyCorrectionSelection"/> <addaction name="actionEnthalpyCorrectionSelection"/>
@ -360,52 +360,52 @@
<string>language</string> <string>language</string>
</property> </property>
</action> </action>
<action name="action1"> <action name="actionSmoothness1">
<property name="text"> <property name="text">
<string>1级</string> <string>1级</string>
</property> </property>
</action> </action>
<action name="action2"> <action name="actionSmoothness2">
<property name="text"> <property name="text">
<string>2级</string> <string>2级</string>
</property> </property>
</action> </action>
<action name="action3"> <action name="actionSmoothness3">
<property name="text"> <property name="text">
<string>3级</string> <string>3级</string>
</property> </property>
</action> </action>
<action name="action4"> <action name="actionSmoothness4">
<property name="text"> <property name="text">
<string>4级</string> <string>4级</string>
</property> </property>
</action> </action>
<action name="action5"> <action name="actionSmoothness5">
<property name="text"> <property name="text">
<string>5级</string> <string>5级</string>
</property> </property>
</action> </action>
<action name="action6"> <action name="actionSmoothness6">
<property name="text"> <property name="text">
<string>6级</string> <string>6级</string>
</property> </property>
</action> </action>
<action name="action7"> <action name="actionSmoothness7">
<property name="text"> <property name="text">
<string>7级</string> <string>7级</string>
</property> </property>
</action> </action>
<action name="action9"> <action name="actionSmoothness8">
<property name="text"> <property name="text">
<string>8级</string> <string>8级</string>
</property> </property>
</action> </action>
<action name="action9_2"> <action name="actionSmoothness9">
<property name="text"> <property name="text">
<string>9级</string> <string>9级</string>
</property> </property>
</action> </action>
<action name="action10"> <action name="actionSmoothness10">
<property name="text"> <property name="text">
<string>10级</string> <string>10级</string>
</property> </property>

View File

@ -15,6 +15,7 @@
namespace AnaOpRecorder = AnalysisOperationRecorder; namespace AnaOpRecorder = AnalysisOperationRecorder;
using AnaOpRecorderOperation = AnalysisOperationRecorder::AnalysisOperation; using AnaOpRecorderOperation = AnalysisOperationRecorder::AnalysisOperation;
using namespace Global;
CentralWidget::CentralWidget(QWidget *parent) CentralWidget::CentralWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -22,7 +23,6 @@ CentralWidget::CentralWidget(QWidget *parent)
// ,_customPlot(new QCustomPlot(this)) // ,_customPlot(new QCustomPlot(this))
,_analysisMode(AnalysisMode::Null) ,_analysisMode(AnalysisMode::Null)
,_currentCurve(nullptr) ,_currentCurve(nullptr)
,_axisMode(AxisMode::SingleY)
{ {
setMouseTracking(true); setMouseTracking(true);
@ -119,6 +119,87 @@ void CentralWidget::switchAxisMode()
uiLoadXlsxFileData(); uiLoadXlsxFileData();
} }
bool CentralWidget::isCurrentCurve(QCPCurve *curve)
{
return _currentCurve == curve;
}
void CentralWidget::deleteCurrentCurve()
{
slotDelCurve(_currentCurve);
}
void CentralWidget::addSmoothnessCurveData(
const QVector<ExperimentData> &dataVtr,const QString objectName)
{
PointCalculate::setAnalysisData(dataVtr);
// Load data.
// QVector<Global::ExperimentData> dataVtr;
QVector<double> 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<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);
//
// 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) void CentralWidget::setAnalysisMode(const AnalysisMode mode)
{ {
_analysisMode = mode; _analysisMode = mode;
@ -241,6 +322,7 @@ void CentralWidget::slotAnalysisSettingApply()
return; return;
} }
// Set curve data to PointCalculate.
if(Global::_curveFileDataVtr.empty()){ if(Global::_curveFileDataVtr.empty()){
// Load experiment data. // Load experiment data.
logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size(); logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size();
@ -248,6 +330,7 @@ void CentralWidget::slotAnalysisSettingApply()
if(ced.curve == _currentCurve){ if(ced.curve == _currentCurve){
logde<<"load experiment data."; logde<<"load experiment data.";
PointCalculate::setAnalysisData(ced.dataVtr); PointCalculate::setAnalysisData(ced.dataVtr);
break;
} }
} }
}else{ }else{
@ -261,6 +344,17 @@ void CentralWidget::slotAnalysisSettingApply()
} }
} }
} }
#if 0
// Load smoothness data.
for(Global::CurveExperimentData& ced:Global::_curveSmoothnessDataVtr){
if(ced.curve == _currentCurve){
logde<<"load smoothness data.";
PointCalculate::setAnalysisData(ced.dataVtr);
break;
}
}
#endif
// //
double x1 = _line1->point1->coords().x(); double x1 = _line1->point1->coords().x();
double x2 = _line2->point1->coords().x(); double x2 = _line2->point1->coords().x();
@ -349,6 +443,7 @@ void CentralWidget::slotDrawCustomText(const QString str)
void CentralWidget::slotDelCurve(QCPCurve *curve) void CentralWidget::slotDelCurve(QCPCurve *curve)
{ {
if(!curve){ if(!curve){
logde<<"current curve is nullptr.";
return; return;
} }
@ -490,7 +585,6 @@ void CentralWidget::uiLoadXlsxFileData()
_currentCurve->setObjectName(cfd.fileName); _currentCurve->setObjectName(cfd.fileName);
// Set axis range. // Set axis range.
QPair<float, float> minMaxXAxisPair; QPair<float, float> minMaxXAxisPair;
if(_axisMode == AxisMode::SingleY){ if(_axisMode == AxisMode::SingleY){
// Axis x is temperature value. // 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(), QString str = PointCalculate::textFormatGlassTranstion(intersection1.x(),
averagePoint.x(), averagePoint.x(),
intersection2.x()); intersection2.x());
if(_axisMode == AxisMode::DoubleY){ if(Global::_axisMode == Global::AxisMode::DoubleY){
Global::ExperimentData intersection1Ed = Global::ExperimentData intersection1Ed =
PointCalculate::getClosestDataByTemperature(intersection1.x()); PointCalculate::getClosestDataByTemperature(intersection1.x());
Global::ExperimentData averageEd = Global::ExperimentData averageEd =
@ -750,10 +844,10 @@ QPointF CentralWidget::onsetTemperaturePointHandle(const double x1,const double
{ {
Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2); Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2);
if(_axisMode == AxisMode::SingleY){ if(Global::_axisMode == Global::AxisMode::SingleY){
return QPointF(ed.sampleTemp,ed.dsc); return QPointF(ed.sampleTemp,ed.dsc);
}else{ }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); Global::ExperimentData ed = PointCalculate::findEndSetDataByTemperature(x1,x2);
if(_axisMode == AxisMode::SingleY){ if(Global::_axisMode == Global::AxisMode::SingleY){
return QPointF(ed.sampleTemp,ed.dsc); return QPointF(ed.sampleTemp,ed.dsc);
}else{ }else{
return QPointF(ed.runTime,ed.dsc); return QPointF(ed.runTime,ed.dsc);
} }
} }
@ -848,7 +942,7 @@ QPointF CentralWidget::getTheCoordinatesOfTheTextBox(const QPointF point)
QVector<double> ticks = _customPlot->xAxis->tickVector(); QVector<double> ticks = _customPlot->xAxis->tickVector();
int numTicks = ticks.size(); int numTicks = ticks.size();
// logde<<"ticks:"<<numTicks; // logde<<"ticks:"<<numTicks;
double distance = (xMax - xMin) / ticks.size(); double distance = (xMax - xMin) / ticks.size();
@ -970,6 +1064,8 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
_line2->setVisible(false); _line2->setVisible(false);
_currentCurve = nullptr; _currentCurve = nullptr;
Global::_smoothnessFlag = false;
case ClearDataMode::JustUi: case ClearDataMode::JustUi:
//ui //ui
clearAllUiData(); clearAllUiData();
@ -1317,3 +1413,6 @@ void CentralWidget::slotAxisModify(const float temp)
_customPlot->xAxis->setRange(10,value); _customPlot->xAxis->setRange(10,value);
_customPlot->yAxis->setRange(-5,5); _customPlot->yAxis->setRange(-5,5);
} }

View File

@ -31,16 +31,20 @@ public:
QPixmap getPixMap(); QPixmap getPixMap();
enum AxisMode{
SingleY,
DoubleY
};
void switchAxisMode(); void switchAxisMode();
struct AxisInfo{ struct AxisInfo{
bool visiable; bool visiable;
double lower; double lower;
double upper; double upper;
}; };
bool isCurrentCurve(QCPCurve* curve);
void deleteCurrentCurve();
void addSmoothnessCurveData(const QVector<Global::ExperimentData> &,const QString objectName);
QCPCurve * getCurrentCurve(){return _currentCurve;}
signals: signals:
void sigContextMenuShow(const QPoint); void sigContextMenuShow(const QPoint);
void sigSendLineXCoord(const int,const double); void sigSendLineXCoord(const int,const double);
@ -109,11 +113,10 @@ private:
private: private:
AnalysisOperationRecorder::AnalysisMode _analysisMode; AnalysisOperationRecorder::AnalysisMode _analysisMode;
LocalCustomPlot *_customPlot; LocalCustomPlot *_customPlot;
QCPCurve *_currentCurve; QCPCurve * _currentCurve;
EventHandler* _eventHandler; EventHandler* _eventHandler;
QCPItemStraightLine *_line1,*_line2; QCPItemStraightLine *_line1,*_line2;
QVector<QCPItemStraightLine*> _lineVtr; QVector<QCPItemStraightLine*> _lineVtr;
AxisMode _axisMode;
QVector<QString> _analysisFilePathVtr; QVector<QString> _analysisFilePathVtr;
double _x1Record; double _x1Record;