From 3551a87337c980b667e35855325be159d310be7e Mon Sep 17 00:00:00 2001 From: yuntang <123@qq.com> Date: Thu, 26 Jun 2025 08:58:59 +0800 Subject: [PATCH] 2025-06-26T08:58:59 --- src/DSCAnalysisTool.pro | 2 +- src/data/confighandler.cpp | 1 + src/data/confighandler.h | 5 +++-- src/data/pointcalculate.cpp | 12 ++++++++---- src/global.h | 1 + src/ui/centralwidget.cpp | 13 +++++++------ src/ui/coefficientselectionform.cpp | 20 +++++++++++++++----- src/ui/enthalpydatacorrectionform.cpp | 1 + src/ui/enthalpydatacorrectionform.h | 2 +- src/ui/instrumentcoefficientform.cpp | 4 ++-- 10 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/DSCAnalysisTool.pro b/src/DSCAnalysisTool.pro index 971723a..b0496a3 100644 --- a/src/DSCAnalysisTool.pro +++ b/src/DSCAnalysisTool.pro @@ -9,7 +9,7 @@ CONFIG+=precompile_header PRECOMPILED_HEADER=stable.h # -VERSION = 1.0.6 +VERSION = 1.0.8 # 设置目标文件名,包含版本号 TARGET = DSCAnalysisTool_$${VERSION} diff --git a/src/data/confighandler.cpp b/src/data/confighandler.cpp index 74aa9d4..a0fac86 100644 --- a/src/data/confighandler.cpp +++ b/src/data/confighandler.cpp @@ -37,6 +37,7 @@ void ConfigHandler::reader() _configMap[ConInstrumentCoefficientStr] = QVariant(obj[ConInstrumentCoefficientStr].toDouble()); } + #if 0 void ConfigHandler::createDefaultFile() { diff --git a/src/data/confighandler.h b/src/data/confighandler.h index 7dde82a..899c86f 100644 --- a/src/data/confighandler.h +++ b/src/data/confighandler.h @@ -3,9 +3,9 @@ #include -const QString ConInstrumentCoefficientStr = "InstrumentCoefficient"; - namespace ConfigHandler { +const QString ConInstrumentCoefficientStr = "InstrumentCoefficient"; +const float ConInstrumentCoefficientDefaultValue = 1.0; const QString ConConfigFilePath = QDir::currentPath() + "/config.json"; const QMap ConDefaultMap = { @@ -17,6 +17,7 @@ extern QMap _configMap; // void reader(); //void createDefaultFile(); + /** * @brief writer * @param writeRealDataFlag diff --git a/src/data/pointcalculate.cpp b/src/data/pointcalculate.cpp index acb76bf..b8778b7 100644 --- a/src/data/pointcalculate.cpp +++ b/src/data/pointcalculate.cpp @@ -253,8 +253,8 @@ float PointCalculate::calculateArea() { /* * H = K * S / w; */ - float coefficient = ConfigHandler::_configMap.value(ConInstrumentCoefficientStr).toFloat(); - logde<<"coefficient:"<setupUi(this); @@ -17,7 +18,7 @@ CoefficientSelectionForm::CoefficientSelectionForm(QWidget *parent) : #if 1 ui->LineEditCoefficient->setText( QString::number( - ConfigHandler::_configMap[ConInstrumentCoefficientStr].toFloat(), + ConfigHandler::_configMap[ConfigHandler::ConInstrumentCoefficientStr].toFloat(), 'f',3)); #endif @@ -42,18 +43,25 @@ void CoefficientSelectionForm::showEvent(QShowEvent *event) void CoefficientSelectionForm::on_pushButtonCalculate_clicked() { - float theory = ui->LineEditTheory->text().toFloat(); - float measure = ui->LineEditActualMeasurement->text().toFloat(); + bool ok; + float theory = ui->LineEditTheory->text().toFloat(&ok); + if(!ok){ + theory = 1.0; + } + + float measure = ui->LineEditActualMeasurement->text().toFloat(&ok); + if(!ok){ + measure = 1.0; + } _instrumentCoefficient = theory/measure; ui->LineEditCoefficient->setText(QString::number(_instrumentCoefficient,'f',3)); - } void CoefficientSelectionForm::on_pushButtonConfirm_clicked() { if(ui->radioButtonSinglePointCoefficient->isChecked()){ - ConfigHandler::_configMap[ConInstrumentCoefficientStr] = _instrumentCoefficient; + ConfigHandler::_configMap[ConfigHandler::ConInstrumentCoefficientStr] = _instrumentCoefficient; ConfigHandler::writer(); Global::_enthalpyCoefficientEnableFlag = false; @@ -155,6 +163,8 @@ void CoefficientSelectionForm::on_pushButtonSelectFile_clicked() ui->labelFilePath->setToolTip(filePath); ui->textEditFileContent->setText(_jsonStr); + + _instrumentCoefficient = ConfigHandler::ConInstrumentCoefficientDefaultValue; } void CoefficientSelectionForm::on_radioButtonSinglePointCoefficient_toggled(bool checked) diff --git a/src/ui/enthalpydatacorrectionform.cpp b/src/ui/enthalpydatacorrectionform.cpp index bc10d40..0540859 100644 --- a/src/ui/enthalpydatacorrectionform.cpp +++ b/src/ui/enthalpydatacorrectionform.cpp @@ -185,6 +185,7 @@ void EnthalpyDataCorrectionForm::saveJson() QJsonArray jsonArray; for (const TheoryData &data : _theoryDataVtr) { QJsonObject jsonObj; + jsonObj[Global::ElementName] = data.elementName; jsonObj[Global::TemperatureStr] = data.temperature; jsonObj[Global::RateStr] = data.rate; jsonArray.append(jsonObj); diff --git a/src/ui/enthalpydatacorrectionform.h b/src/ui/enthalpydatacorrectionform.h index ba01760..cd9c567 100644 --- a/src/ui/enthalpydatacorrectionform.h +++ b/src/ui/enthalpydatacorrectionform.h @@ -25,7 +25,7 @@ private: double _atmosphere; double _heatingRate; struct TheoryData{ - QString sampleName; + QString elementName; double temperature; double rate; }; diff --git a/src/ui/instrumentcoefficientform.cpp b/src/ui/instrumentcoefficientform.cpp index f198c9b..8217c15 100644 --- a/src/ui/instrumentcoefficientform.cpp +++ b/src/ui/instrumentcoefficientform.cpp @@ -12,7 +12,7 @@ InstrumentCoefficientForm::InstrumentCoefficientForm(QWidget *parent) : ui->LineEditCoefficient->setText( QString::number( - ConfigHandler::_configMap[ConInstrumentCoefficientStr].toFloat(), + ConfigHandler::_configMap[ConfigHandler::ConInstrumentCoefficientStr].toFloat(), 'f',3)); ui->LineEditTheory->text().clear(); @@ -30,7 +30,7 @@ void InstrumentCoefficientForm::on_pushButtonCalculate_clicked() float measure = ui->LineEditActualMeasurement->text().toFloat(); float instrumentCoefficient = theory/measure; - ConfigHandler::_configMap[ConInstrumentCoefficientStr] = instrumentCoefficient; + ConfigHandler::_configMap[ConfigHandler::ConInstrumentCoefficientStr] = instrumentCoefficient; ConfigHandler::writer(); ui->LineEditCoefficient->setText(QString::number(instrumentCoefficient,'f',3));