2025-05-13T17:33:39
This commit is contained in:
parent
c6b02514d4
commit
5ef859ae63
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
experiment_data/analysis_state/ana-2new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-2new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/ana-3-new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-3-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/ana-4-new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-4-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/ana-5-new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-5-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/ana-6-new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-6-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/ana-new.xlsx
Normal file
BIN
experiment_data/analysis_state/ana-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/anapeak.xlsx
Normal file
BIN
experiment_data/analysis_state/anapeak.xlsx
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
experiment_data/analysis_state/~$ana-2new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-2new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$ana-3-new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-3-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$ana-4-new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-4-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$ana-5-new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-5-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$ana-6-new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-6-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$ana-new.xlsx
Normal file
BIN
experiment_data/analysis_state/~$ana-new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/analysis_state/~$anapeak.xlsx
Normal file
BIN
experiment_data/analysis_state/~$anapeak.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/sample_data/~$1.xlsx
Normal file
BIN
experiment_data/sample_data/~$1.xlsx
Normal file
Binary file not shown.
@ -1,6 +1,12 @@
|
|||||||
#include "xlsxhandler.h"
|
#include "xlsxhandler.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "analysisoperationrecorder.h"
|
#include "analysisoperationrecorder.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
namespace AnaOpRecorder = AnalysisOperationRecorder;
|
||||||
|
using AnaOpRecorderOperation = AnalysisOperationRecorder::AnalysisOperation;
|
||||||
|
|
||||||
|
QString XlsxHandler::_currentFilePath;
|
||||||
|
|
||||||
void XlsxHandler::test()
|
void XlsxHandler::test()
|
||||||
{
|
{
|
||||||
@ -9,9 +15,11 @@ void XlsxHandler::test()
|
|||||||
qDebug() << "fileName:" << sourceFilePath;
|
qDebug() << "fileName:" << sourceFilePath;
|
||||||
readFile(sourceFilePath);
|
readFile(sourceFilePath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx";
|
QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx";
|
||||||
writeFile(sourceFilePath);
|
writeFile(sourceFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &cfd)
|
int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &cfd)
|
||||||
{
|
{
|
||||||
if(!QFile::exists(sourceFilePath))
|
if(!QFile::exists(sourceFilePath))
|
||||||
@ -30,6 +38,8 @@ int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &c
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentFilePath = sourceFilePath;
|
||||||
|
|
||||||
QXlsx::Document xlsx(sourceFilePath);
|
QXlsx::Document xlsx(sourceFilePath);
|
||||||
|
|
||||||
QXlsx::Worksheet *workSheet = xlsx.currentWorksheet();
|
QXlsx::Worksheet *workSheet = xlsx.currentWorksheet();
|
||||||
@ -53,15 +63,20 @@ int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &c
|
|||||||
ei.phaseSize = workSheet->cellAt(index++, 2)->value().toInt();
|
ei.phaseSize = workSheet->cellAt(index++, 2)->value().toInt();
|
||||||
|
|
||||||
QVector<Global::PhaseTotalInfo>& phaseTotalVtr = cfd.phaseTotalVtr;
|
QVector<Global::PhaseTotalInfo>& phaseTotalVtr = cfd.phaseTotalVtr;
|
||||||
int startLineIndex = 9;
|
int dataIndex = 9;
|
||||||
for(int i = 0; i < ei.phaseSize; i++)
|
for(int i = 0; i < ei.phaseSize; i++)
|
||||||
{
|
{
|
||||||
Global::PhaseTotalInfo phaseTotal;
|
Global::PhaseTotalInfo phaseTotal;
|
||||||
phaseTotal.phaseIndex = i + 1;
|
phaseTotal.phaseIndex = i + 1;
|
||||||
|
|
||||||
readPhaseData(workSheet, startLineIndex, phaseTotal);
|
readPhaseData(workSheet, dataIndex, phaseTotal);
|
||||||
phaseTotalVtr.push_back(phaseTotal);
|
phaseTotalVtr.push_back(phaseTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logde<<"dataIndex:"<<dataIndex;
|
||||||
|
|
||||||
|
readAnalysisOperation(workSheet,dataIndex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +96,8 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex
|
|||||||
phaseTotal.phase.gas = static_cast<GasType>(workSheet->cellAt(startLineIndex++, 2)->value().toInt());
|
phaseTotal.phase.gas = static_cast<GasType>(workSheet->cellAt(startLineIndex++, 2)->value().toInt());
|
||||||
|
|
||||||
int dataSize = workSheet->cellAt(startLineIndex++, 2)->value().toInt();
|
int dataSize = workSheet->cellAt(startLineIndex++, 2)->value().toInt();
|
||||||
|
logde<<"data size:"<<dataSize;
|
||||||
|
|
||||||
for(int i = 0; i < dataSize; i++)
|
for(int i = 0; i < dataSize; i++)
|
||||||
{
|
{
|
||||||
Global::ExperimentData data;
|
Global::ExperimentData data;
|
||||||
@ -246,8 +263,181 @@ void XlsxHandler::writeFile(const QString filePath)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XlsxHandler::writeAnalysisOperation(const QString filePath)
|
||||||
void XlsxHandler::writeAnalysisOperation(QXlsx::Document xlsx)
|
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
QVector<AnalysisOperationRecorder::AnalysisOperation>& aoVtr =
|
||||||
|
AnalysisOperationRecorder::_ananlysisOperationVtr;
|
||||||
|
|
||||||
|
xlsx->write(row , 1, ConAnalysisOperationCount);
|
||||||
|
xlsx->write(row , 2, aoVtr.size());
|
||||||
|
row++;
|
||||||
|
|
||||||
|
for (AnaOpRecorderOperation& ao:aoVtr){
|
||||||
|
QString analysisOpName;
|
||||||
|
|
||||||
|
switch(ao.mode){
|
||||||
|
case Global::NumericalLabel:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::NumericalLabelStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::StartPoint:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::StartPointStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::StopPoint:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::StopPointStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::PeakSynthesisAnalysis:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::PeakSynthesisAnalysisStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::GlassTransition:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::GlassTransitionStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::OnsetTemperaturePoint:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::OnsetTemperaturePointStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Global::EndsetTemperaturePoint:
|
||||||
|
{
|
||||||
|
analysisOpName = AnalysisOperationRecorder::EndsetTemperaturePointStr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xlsx->write(row , 1, analysisOpName);
|
||||||
|
xlsx->write(row , 2, ao.x1);
|
||||||
|
xlsx->write(row , 3, ao.x2);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
#if 1
|
||||||
|
if (!xlsx->saveAs(filePath)) {
|
||||||
|
logde<<"Save xlsx failed.";
|
||||||
|
delete xlsx;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!xlsx->saveAs(filePath)) {
|
||||||
|
qDebug() << "Failed to save xlsx file:" << filePath;
|
||||||
|
// 检查和创建目录
|
||||||
|
QDir dir(filePath);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
qDebug() << "Directory does not exist. Creating directory...";
|
||||||
|
dir.mkpath(".");
|
||||||
|
}
|
||||||
|
// 检查权限
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
|
qDebug() << "Permission denied:" << file.errorString();
|
||||||
|
}
|
||||||
|
// 检查磁盘空间
|
||||||
|
QStorageInfo storageInfo(QDir::rootPath());
|
||||||
|
if (storageInfo.bytesFree() < 1024 * 1024 * 10) { // 假设文件大小至少为10MB
|
||||||
|
qDebug() << "Disk space is insufficient.";
|
||||||
|
}
|
||||||
|
// 尝试重新保存
|
||||||
|
if (!xlsx->saveAs(filePath)) {
|
||||||
|
qDebug() << "Save xlsx failed after retrying.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//
|
||||||
|
delete xlsx;
|
||||||
|
logde<<"Save xlsx succ.";
|
||||||
|
}
|
||||||
|
|
||||||
|
QXlsx::Document* XlsxHandler::openXlsxFile(const QString& sourceFilePath) {
|
||||||
|
// 检查文件是否存在
|
||||||
|
if (!QFile::exists(sourceFilePath)) {
|
||||||
|
qDebug() << "xlsx file not existed:" << sourceFilePath;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
QFileInfo fileInfo(sourceFilePath);
|
||||||
|
|
||||||
|
// 获取文件的后缀名并转换为小写,方便比较
|
||||||
|
QString fileSuffix = fileInfo.suffix().toLower();
|
||||||
|
|
||||||
|
// 判断后缀名是否为 "xlsx"
|
||||||
|
if (fileSuffix != "xlsx") {
|
||||||
|
std::cout << "该文件的后缀不是 xlsx" << std::endl;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QXlsx::Document* xlsx = new QXlsx::Document(sourceFilePath);
|
||||||
|
|
||||||
|
QXlsx::Worksheet* workSheet = xlsx->currentWorksheet();
|
||||||
|
if (!workSheet) {
|
||||||
|
qDebug() << "current sheet is empty.";
|
||||||
|
delete xlsx;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xlsx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XlsxHandler::readAnalysisOperation(QXlsx::Worksheet *sheet, int &startLineIndex)
|
||||||
|
{
|
||||||
|
int size = sheet->cellAt(startLineIndex++, 2)->value().toInt();
|
||||||
|
|
||||||
|
logde<<"ana op size:"<<size;
|
||||||
|
|
||||||
|
for(int i = 0;i < size; i++){
|
||||||
|
AnaOpRecorderOperation ao;
|
||||||
|
QString modeStr = sheet->cellAt(startLineIndex, 1)->value().toString();
|
||||||
|
|
||||||
|
if(modeStr == AnaOpRecorder::NumericalLabelStr){
|
||||||
|
ao.mode = Global::AnalysisMode::NumericalLabel;
|
||||||
|
}else if(modeStr == AnaOpRecorder::StartPointStr){
|
||||||
|
ao.mode = Global::AnalysisMode::StartPoint;
|
||||||
|
}else if(modeStr == AnaOpRecorder::StopPointStr){
|
||||||
|
ao.mode = Global::AnalysisMode::StopPoint;
|
||||||
|
}else if(modeStr == AnaOpRecorder::PeakSynthesisAnalysisStr){
|
||||||
|
ao.mode = Global::AnalysisMode::PeakSynthesisAnalysis;
|
||||||
|
}else if(modeStr == AnaOpRecorder::GlassTransitionStr){
|
||||||
|
ao.mode = Global::AnalysisMode::GlassTransition;
|
||||||
|
}else if(modeStr == AnaOpRecorder::OnsetTemperaturePointStr){
|
||||||
|
ao.mode = Global::AnalysisMode::OnsetTemperaturePoint;
|
||||||
|
}else if(modeStr == AnaOpRecorder::EndsetTemperaturePointStr){
|
||||||
|
ao.mode = Global::AnalysisMode::EndsetTemperaturePoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
ao.x1 = sheet->cellAt(startLineIndex, 2)->value().toDouble();
|
||||||
|
ao.x2 = sheet->cellAt(startLineIndex, 3)->value().toDouble();
|
||||||
|
|
||||||
|
AnaOpRecorder::_fileAnanlysisOperationVtr.push_back(ao);
|
||||||
|
|
||||||
|
startLineIndex++;
|
||||||
|
|
||||||
|
logde<<" ao mode:"<<modeStr.toStdString();
|
||||||
|
logde<<"x1:"<<ao.x1<<",x2:"<<ao.x2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,16 @@ namespace XlsxHandler {
|
|||||||
* 2:File not xlsx;
|
* 2:File not xlsx;
|
||||||
* 3:Sheet is empty.
|
* 3:Sheet is empty.
|
||||||
*/
|
*/
|
||||||
|
QXlsx::Document* openXlsxFile(const QString& sourceFilePath);
|
||||||
|
|
||||||
int readFile(const QString filePath,Global::CurveFileData&);
|
int readFile(const QString filePath,Global::CurveFileData&);
|
||||||
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
|
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
|
||||||
|
void readAnalysisOperation(QXlsx::Worksheet*,int& startLineIndex);
|
||||||
|
|
||||||
void writeFile(const QString filePath);
|
void writeFile(const QString filePath);
|
||||||
void writeAnalysisOperation(QXlsx::Document&);
|
void writeAnalysisOperation(const QString filePath);
|
||||||
|
|
||||||
|
extern QString _currentFilePath;
|
||||||
|
|
||||||
const QString ConUnitMg = "mg";
|
const QString ConUnitMg = "mg";
|
||||||
const QString ConUnitDegreeCentigrade = "℃";
|
const QString ConUnitDegreeCentigrade = "℃";
|
||||||
@ -49,6 +54,8 @@ namespace XlsxHandler {
|
|||||||
const QString ConPhaseConstantTempTime = "恒温时间:";
|
const QString ConPhaseConstantTempTime = "恒温时间:";
|
||||||
const QString ConPhaseAtmosphere = "气氛:";
|
const QString ConPhaseAtmosphere = "气氛:";
|
||||||
const QString ConPhaseDataSize = "数据个数:";
|
const QString ConPhaseDataSize = "数据个数:";
|
||||||
|
|
||||||
|
const QString ConAnalysisOperationCount = "AnalysisOperationCount";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XLSX_H
|
#endif // XLSX_H
|
||||||
|
11
src/global.h
11
src/global.h
@ -33,6 +33,17 @@ const QString RateStr("rate");
|
|||||||
const double DefaultParamter = 1.0;
|
const double DefaultParamter = 1.0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
enum AnalysisMode{
|
||||||
|
Null,
|
||||||
|
NumericalLabel,
|
||||||
|
StartPoint,
|
||||||
|
StopPoint,
|
||||||
|
PeakSynthesisAnalysis,
|
||||||
|
GlassTransition,
|
||||||
|
OnsetTemperaturePoint,
|
||||||
|
EndsetTemperaturePoint
|
||||||
|
};
|
||||||
|
|
||||||
enum Mode{
|
enum Mode{
|
||||||
Analysis,
|
Analysis,
|
||||||
ConnectedToDev,
|
ConnectedToDev,
|
||||||
|
@ -192,12 +192,12 @@ void MainWindow::setSubWidgetAttribute(QWidget *widget)
|
|||||||
|
|
||||||
widget->setFixedSize(widget->geometry().width(),widget->geometry().height());
|
widget->setFixedSize(widget->geometry().width(),widget->geometry().height());
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
bool MainWindow::saveExperimentFile(const QString fileName)
|
bool MainWindow::saveExperimentFile(const QString fileName)
|
||||||
{
|
{
|
||||||
QString localFileName = fileName;
|
QString localFileName = fileName;
|
||||||
if(fileName.isEmpty()){
|
if(fileName.isEmpty()){
|
||||||
localFileName = "new";
|
localFileName = "new";
|
||||||
}
|
}
|
||||||
QString xlsxfilePath = Global::SampleDataFloder + "/" + localFileName + ".xlsx";
|
QString xlsxfilePath = Global::SampleDataFloder + "/" + localFileName + ".xlsx";
|
||||||
QString filePath = QFileDialog::getSaveFileName(nullptr, "Save experiment file",
|
QString filePath = QFileDialog::getSaveFileName(nullptr, "Save experiment file",
|
||||||
@ -214,6 +214,60 @@ bool MainWindow::saveExperimentFile(const QString fileName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::saveAnalysisFile(const QString fileName)
|
||||||
|
{
|
||||||
|
QString localFileName = fileName;
|
||||||
|
if(fileName.isEmpty()){
|
||||||
|
localFileName = "new";
|
||||||
|
}
|
||||||
|
QString xlsxfilePath = Global::AnalysisStateFolder + "/" + localFileName + ".xlsx";
|
||||||
|
QString filePath = QFileDialog::getSaveFileName(nullptr, "Save experiment file",
|
||||||
|
xlsxfilePath, "Excel Files (*.xlsx)");
|
||||||
|
logde<<"filePath:"<<filePath.toStdString();
|
||||||
|
|
||||||
|
if (filePath.isEmpty()) {
|
||||||
|
qDebug() << "User cancel the operation.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
XlsxHandler::writeAnalysisOperation(filePath);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
bool MainWindow::saveFile(const QString fileName)
|
||||||
|
{
|
||||||
|
QString localFileName = fileName;
|
||||||
|
if(fileName.isEmpty()){
|
||||||
|
localFileName = "new";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString folder;
|
||||||
|
if(Global::_mode == Global::Mode::Analysis){
|
||||||
|
folder = Global::AnalysisStateFolder;
|
||||||
|
}else if(Global::_mode == Global::Mode::Experiment){
|
||||||
|
folder = Global::SampleDataFloder;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString xlsxfilePath = folder + "/" + localFileName + ".xlsx";
|
||||||
|
QString filePath = QFileDialog::getSaveFileName(nullptr, "Save experiment file",
|
||||||
|
xlsxfilePath, "Excel Files (*.xlsx)");
|
||||||
|
logde<<"filePath:"<<filePath.toStdString();
|
||||||
|
|
||||||
|
if (filePath.isEmpty()) {
|
||||||
|
qDebug() << "User cancel the operation.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Global::_mode == Global::Mode::Analysis){
|
||||||
|
XlsxHandler::writeAnalysisOperation(filePath);
|
||||||
|
}else if(Global::_mode == Global::Mode::Experiment){
|
||||||
|
XlsxHandler::writeFile(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionStop_triggered()
|
void MainWindow::on_actionStop_triggered()
|
||||||
{
|
{
|
||||||
if(Global::_mode == Global::Mode::Experiment)
|
if(Global::_mode == Global::Mode::Experiment)
|
||||||
@ -223,7 +277,10 @@ void MainWindow::on_actionStop_triggered()
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Save data.
|
// Save data.
|
||||||
if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
// if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
||||||
|
// _leftWidget->reloadFileName();
|
||||||
|
// }
|
||||||
|
if(saveFile(Global::_experimentInfo.sampleName)){
|
||||||
_leftWidget->reloadFileName();
|
_leftWidget->reloadFileName();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -375,13 +432,6 @@ void MainWindow::on_actionEnthalpyCorrectionSelection_triggered()
|
|||||||
_coefficientSelectionForm->show();
|
_coefficientSelectionForm->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSaveExperimentData_triggered()
|
|
||||||
{
|
|
||||||
if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
|
||||||
_leftWidget->reloadFileName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionPrintPreview_triggered()
|
void MainWindow::on_actionPrintPreview_triggered()
|
||||||
{
|
{
|
||||||
_printPreviewForm->setPixmap(_centralWidget->getPixMap());
|
_printPreviewForm->setPixmap(_centralWidget->getPixMap());
|
||||||
@ -402,10 +452,15 @@ void MainWindow::on_actionEndsetTemperaturePoint_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionYAxis_triggered()
|
void MainWindow::on_actionYAxis_triggered()
|
||||||
{
|
{
|
||||||
_centralWidget->switchAxisMode();
|
_centralWidget->switchAxisMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAxisSetting_triggered()
|
void MainWindow::on_actionAxisSetting_triggered()
|
||||||
{
|
{
|
||||||
_axisSettingForm->show();
|
_axisSettingForm->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionSaveData_triggered()
|
||||||
|
{
|
||||||
|
saveFile(Global::_experimentInfo.sampleName);
|
||||||
|
}
|
||||||
|
@ -80,8 +80,6 @@ private slots:
|
|||||||
|
|
||||||
void on_actionEnthalpyCorrectionSelection_triggered();
|
void on_actionEnthalpyCorrectionSelection_triggered();
|
||||||
|
|
||||||
void on_actionSaveExperimentData_triggered();
|
|
||||||
|
|
||||||
void on_actionPrintPreview_triggered();
|
void on_actionPrintPreview_triggered();
|
||||||
|
|
||||||
void on_actionOnsetTemperaturePoint_triggered();
|
void on_actionOnsetTemperaturePoint_triggered();
|
||||||
@ -92,11 +90,18 @@ private slots:
|
|||||||
|
|
||||||
void on_actionAxisSetting_triggered();
|
void on_actionAxisSetting_triggered();
|
||||||
|
|
||||||
|
void on_actionSaveData_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connections();
|
void connections();
|
||||||
void setActionEnable(const bool);
|
void setActionEnable(const bool);
|
||||||
void setSubWidgetAttribute(QWidget *);
|
void setSubWidgetAttribute(QWidget *);
|
||||||
|
#if 0
|
||||||
bool saveExperimentFile(const QString fileName);
|
bool saveExperimentFile(const QString fileName);
|
||||||
|
bool saveAnalysisFile(const QString fileName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool saveFile(const QString fileName);
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
CentralWidget *_centralWidget;
|
CentralWidget *_centralWidget;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<string>文件</string>
|
<string>文件</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionNew"/>
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionSaveExperimentData"/>
|
<addaction name="actionSaveData"/>
|
||||||
<addaction name="actionPrintPreview"/>
|
<addaction name="actionPrintPreview"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_2">
|
<widget class="QMenu" name="menu_2">
|
||||||
@ -282,12 +282,12 @@
|
|||||||
<string>热焓校正系数选择</string>
|
<string>热焓校正系数选择</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSaveExperimentData">
|
<action name="actionSaveData">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>保存实验数据</string>
|
<string>保存数据</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>保存实验数据</string>
|
<string>保存数据</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPrintPreview">
|
<action name="actionPrintPreview">
|
||||||
|
@ -14,5 +14,5 @@ void removeTheLastAnalysisOperation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVector<AnalysisOperation> _ananlysisOperationVtr;
|
QVector<AnalysisOperation> _ananlysisOperationVtr;
|
||||||
|
//QVector<AnalysisOperation> _fileAnanlysisOperationVtr;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
#ifndef ANALYSISOPERATIONRECORDER_H
|
#ifndef ANALYSISOPERATIONRECORDER_H
|
||||||
#define ANALYSISOPERATIONRECORDER_H
|
#define ANALYSISOPERATIONRECORDER_H
|
||||||
|
|
||||||
|
#include "centralwidget.h"
|
||||||
|
|
||||||
namespace AnalysisOperationRecorder {
|
namespace AnalysisOperationRecorder {
|
||||||
|
const QString NumericalLabelStr("NumericalLabel");
|
||||||
|
const QString StartPointStr("StartPoint");
|
||||||
|
const QString StopPointStr("StopPoint");
|
||||||
|
const QString PeakSynthesisAnalysisStr("PeakSynthesisAnalysis");
|
||||||
|
const QString GlassTransitionStr("GlassTransition");
|
||||||
|
const QString OnsetTemperaturePointStr("OnsetTemperaturePoint");
|
||||||
|
const QString EndsetTemperaturePointStr("EndsetTemperaturePoint");
|
||||||
|
|
||||||
|
#if 0
|
||||||
enum AnalysisMode{
|
enum AnalysisMode{
|
||||||
Null,
|
Null,
|
||||||
NumericalLabel,
|
NumericalLabel,
|
||||||
@ -12,15 +23,23 @@ enum AnalysisMode{
|
|||||||
OnsetTemperaturePoint,
|
OnsetTemperaturePoint,
|
||||||
EndsetTemperaturePoint
|
EndsetTemperaturePoint
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct AnalysisOperation{
|
struct AnalysisOperation{
|
||||||
AnalysisMode mode;
|
CentralWidget::AnalysisMode mode;
|
||||||
double x1,x2;
|
double x1,x2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The analysis operationes by user operating.
|
||||||
extern QVector<AnalysisOperation> _ananlysisOperationVtr;
|
extern QVector<AnalysisOperation> _ananlysisOperationVtr;
|
||||||
|
// The analysis operationes from xlsx file.
|
||||||
|
//extern QVector<AnalysisOperation> _fileAnanlysisOperationVtr;
|
||||||
|
|
||||||
void addAnalysisOperation(const AnalysisOperation);
|
void addAnalysisOperation(const AnalysisOperation);
|
||||||
void removeTheLastAnalysisOperation();
|
void removeTheLastAnalysisOperation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ANALYSISOPERATIONRECORDER_H
|
#endif // ANALYSISOPERATIONRECORDER_H
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "itemmanager.h"
|
#include "itemmanager.h"
|
||||||
|
|
||||||
namespace AnaOpRecorder = AnalysisOperationRecorder;
|
namespace AnaOpRecorder = AnalysisOperationRecorder;
|
||||||
|
using AnaOpRecorderOperation = AnalysisOperationRecorder::AnalysisOperation;
|
||||||
|
//using AnaOpAnalysisMode = AnalysisOperationRecorder::AnalysisMode;
|
||||||
|
|
||||||
CentralWidget::CentralWidget(QWidget *parent)
|
CentralWidget::CentralWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -249,9 +251,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
|||||||
if(_analysisFilePathVtr.contains(filePath)){
|
if(_analysisFilePathVtr.contains(filePath)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Read xlsx file.
|
||||||
// qDebug() << "slotRecvAnalysisFileName:" << filePath;
|
|
||||||
|
|
||||||
Global::CurveFileData cfd;
|
Global::CurveFileData cfd;
|
||||||
if(XlsxHandler::readFile(filePath,cfd) != 0){
|
if(XlsxHandler::readFile(filePath,cfd) != 0){
|
||||||
QMessageBox::warning((QWidget*)this->parent(), "warnning", "File parse error.");
|
QMessageBox::warning((QWidget*)this->parent(), "warnning", "File parse error.");
|
||||||
@ -264,7 +264,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
|||||||
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
||||||
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
||||||
|
|
||||||
logde<<"data Vtr size:"<<pti.dataVtr.size();
|
// logde<<"data Vtr size:"<<pti.dataVtr.size();
|
||||||
|
|
||||||
PointCalculate::setExperimentData(pti.dataVtr);
|
PointCalculate::setExperimentData(pti.dataVtr);
|
||||||
|
|
||||||
@ -299,11 +299,17 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
|||||||
pti.curve = _currentCurve;
|
pti.curve = _currentCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add data to global parameter.
|
// Add analysis operation data.
|
||||||
Global::_curveFileDataVtr.push_back(cfd);
|
//loadAnalysisData(_analysisMode,x1,x2);
|
||||||
|
for(AnaOpRecorder::AnalysisOperation& ao:AnalysisOperationRecorder::_ananlysisOperationVtr){
|
||||||
|
loadAnalysisData(ao.mode,ao.x1,ao.x2);
|
||||||
|
}
|
||||||
|
// Refresh ui.
|
||||||
_customPlot->rescaleAxes();
|
_customPlot->rescaleAxes();
|
||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
|
|
||||||
|
// Add data to global parameter.
|
||||||
|
Global::_curveFileDataVtr.push_back(cfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::slotAnalysisSettingApply()
|
void CentralWidget::slotAnalysisSettingApply()
|
||||||
@ -317,7 +323,12 @@ void CentralWidget::slotAnalysisSettingApply()
|
|||||||
_x1Record = x1;
|
_x1Record = x1;
|
||||||
_x2Record = x2;
|
_x2Record = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
loadAnalysisData(_analysisMode,x1,x2);
|
||||||
|
|
||||||
|
//
|
||||||
|
#if 0
|
||||||
switch (_analysisMode) {
|
switch (_analysisMode) {
|
||||||
case AnalysisMode::NumericalLabel:
|
case AnalysisMode::NumericalLabel:
|
||||||
{
|
{
|
||||||
@ -436,6 +447,14 @@ void CentralWidget::slotAnalysisSettingApply()
|
|||||||
{
|
{
|
||||||
glassTransitionHandle(x1,x2);
|
glassTransitionHandle(x1,x2);
|
||||||
|
|
||||||
|
//
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
ao.mode = AnaOpRecorder::GlassTransition;
|
||||||
|
ao.x1 = x1;
|
||||||
|
ao.x2 = x2;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AnalysisMode::OnsetTemperaturePoint:{
|
case AnalysisMode::OnsetTemperaturePoint:{
|
||||||
@ -468,6 +487,7 @@ void CentralWidget::slotAnalysisSettingApply()
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::slotAnalysisSettingConfirm()
|
void CentralWidget::slotAnalysisSettingConfirm()
|
||||||
@ -772,14 +792,7 @@ void CentralWidget::glassTransitionHandle(const double x1,const double x2)
|
|||||||
|
|
||||||
drawText(averagePoint,str);
|
drawText(averagePoint,str);
|
||||||
|
|
||||||
//
|
|
||||||
AnaOpRecorder::AnalysisOperation ao;
|
|
||||||
ao.mode = AnaOpRecorder::GlassTransition;
|
|
||||||
ao.point = averagePoint;
|
|
||||||
ao.str = str;
|
|
||||||
|
|
||||||
AnaOpRecorder::addAnalysisOperation(ao);
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
// 使用最小二乘法计算线性回归
|
// 使用最小二乘法计算线性回归
|
||||||
PointCalculate::Line CentralWidget::calculateLinearRegression(const QVector<double>& x, const QVector<double>& y) {
|
PointCalculate::Line CentralWidget::calculateLinearRegression(const QVector<double>& x, const QVector<double>& y) {
|
||||||
@ -1076,6 +1089,168 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
|||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CentralWidget::loadAnalysisData(const CentralWidget::AnalysisMode mode, const double x1, const double x2)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case AnalysisMode::NumericalLabel:
|
||||||
|
{
|
||||||
|
QPointF selectPoint = PointCalculate::getClosestPointByX(x1);
|
||||||
|
|
||||||
|
// logde<<"lin1 x:"<<x1;
|
||||||
|
|
||||||
|
if(selectPoint.isNull()){
|
||||||
|
QMessageBox::warning((QWidget*)this->parent(), "warnning", "曲线选择错误.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString str = PointCalculate::textFormatNumbericalLabel(selectPoint);
|
||||||
|
|
||||||
|
drawText(selectPoint,str);
|
||||||
|
|
||||||
|
//
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
ao.mode = AnalysisMode::NumericalLabel;
|
||||||
|
ao.x1 = x1;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnalysisMode::StartPoint:
|
||||||
|
case AnalysisMode::StopPoint:{
|
||||||
|
PointCalculate::setRegionPointX(x1,x2);
|
||||||
|
|
||||||
|
QPair<QPointF, QPointF> startEndPointPair =
|
||||||
|
PointCalculate::calculateStartAndEndPoint();
|
||||||
|
//
|
||||||
|
QPointF point;
|
||||||
|
QString str;
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
|
||||||
|
if(_analysisMode == AnalysisMode::StartPoint){
|
||||||
|
point = startEndPointPair.first;
|
||||||
|
str = PointCalculate::textFormatStartPoint(point);
|
||||||
|
ao.mode = AnalysisMode::StartPoint;
|
||||||
|
}else{
|
||||||
|
point = startEndPointPair.second;
|
||||||
|
str = PointCalculate::textFormatEndPoint(point);
|
||||||
|
ao.mode = AnalysisMode::StopPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawText(point,str);
|
||||||
|
//
|
||||||
|
ao.x1 = x1;
|
||||||
|
ao.x2 = x2;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnalysisMode::PeakSynthesisAnalysis:
|
||||||
|
{
|
||||||
|
fillGraph(x1,x2);
|
||||||
|
|
||||||
|
PointCalculate::setRegionPointX(x1,x2);
|
||||||
|
|
||||||
|
//enthalpy
|
||||||
|
double sampleWeight = 0.0f;
|
||||||
|
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
|
||||||
|
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
|
||||||
|
if(_currentCurve && _currentCurve == pti.curve){
|
||||||
|
sampleWeight = cfd.ei.sampleWeight.toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// logde<<"sample weight:"<<sampleWeight;
|
||||||
|
|
||||||
|
double enthalpyValue = PointCalculate::calculateArea() / sampleWeight;
|
||||||
|
|
||||||
|
// peak
|
||||||
|
QPointF peakPoint = PointCalculate::getPeakPoint();
|
||||||
|
|
||||||
|
// start point and end point
|
||||||
|
QPair<QPointF, QPointF> startEndPointPair =
|
||||||
|
PointCalculate::calculateStartAndEndPoint();
|
||||||
|
|
||||||
|
logde<<"start,end:"<<startEndPointPair.first.x()<<","
|
||||||
|
<<startEndPointPair.second.x();
|
||||||
|
|
||||||
|
QString str;
|
||||||
|
if(Global::_displayTimeValue){
|
||||||
|
double peakPointTime = PointCalculate::obtainTimeValueBasedOnTemperatureValue(peakPoint.x());
|
||||||
|
double startPointTime = PointCalculate::obtainTimeValueBasedOnTemperatureValue(startEndPointPair.first.x());
|
||||||
|
double endPointTime = PointCalculate::obtainTimeValueBasedOnTemperatureValue(startEndPointPair.second.x());
|
||||||
|
|
||||||
|
str = PointCalculate::textFormatPeakPointWithTime(
|
||||||
|
enthalpyValue,
|
||||||
|
peakPointTime,
|
||||||
|
startPointTime,
|
||||||
|
endPointTime);
|
||||||
|
drawText(peakPoint,str);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
str = PointCalculate::textFormatPeakPoint(enthalpyValue,
|
||||||
|
peakPoint.x(),
|
||||||
|
startEndPointPair.first.x(),
|
||||||
|
startEndPointPair.second.x());
|
||||||
|
drawText(peakPoint,str);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
ao.mode = AnalysisMode::PeakSynthesisAnalysis;
|
||||||
|
ao.x1 = x1;
|
||||||
|
ao.x2 = x2;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnalysisMode::GlassTransition:
|
||||||
|
{
|
||||||
|
glassTransitionHandle(x1,x2);
|
||||||
|
|
||||||
|
//
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
ao.mode = AnalysisMode::GlassTransition;
|
||||||
|
ao.x1 = x1;
|
||||||
|
ao.x2 = x2;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnalysisMode::OnsetTemperaturePoint:{
|
||||||
|
#if 0
|
||||||
|
QPointF point = OnsetTemperaturePointHandle(x1,x2);
|
||||||
|
|
||||||
|
QString str = QString::number(point.y(),'f',3);
|
||||||
|
|
||||||
|
drawText(point,str);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QPointF point = OnsetTemperaturePointHandle(x1,x2);
|
||||||
|
QString str = QString::number(point.x(),'f',3);
|
||||||
|
drawText(point,str);
|
||||||
|
|
||||||
|
//
|
||||||
|
AnaOpRecorder::AnalysisOperation ao;
|
||||||
|
ao.mode = AnalysisMode::OnsetTemperaturePoint;
|
||||||
|
ao.x1 = x1;
|
||||||
|
ao.x2 = x2;
|
||||||
|
|
||||||
|
AnaOpRecorder::addAnalysisOperation(ao);
|
||||||
|
//
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnalysisMode::EndsetTemperaturePoint:{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CentralWidget::clearAllData()
|
void CentralWidget::clearAllData()
|
||||||
{
|
{
|
||||||
clearData(ClearDataMode::All);
|
clearData(ClearDataMode::All);
|
||||||
|
@ -93,6 +93,7 @@ private:
|
|||||||
};
|
};
|
||||||
void clearData(const ClearDataMode);
|
void clearData(const ClearDataMode);
|
||||||
|
|
||||||
|
void loadAnalysisData(const AnalysisMode,const double x1,const double x2);
|
||||||
private:
|
private:
|
||||||
AnalysisMode _analysisMode;
|
AnalysisMode _analysisMode;
|
||||||
LocalCustomPlot *_customPlot;
|
LocalCustomPlot *_customPlot;
|
||||||
|
Loading…
Reference in New Issue
Block a user