diff --git a/experiment_data/analysis_state/21-new.xlsx b/experiment_data/analysis_state/21-new.xlsx new file mode 100644 index 0000000..7f0f4e7 Binary files /dev/null and b/experiment_data/analysis_state/21-new.xlsx differ diff --git a/experiment_data/analysis_state/铟分析后.xlsx b/experiment_data/analysis_state/铟分析后.xlsx new file mode 100644 index 0000000..ba40432 Binary files /dev/null and b/experiment_data/analysis_state/铟分析后.xlsx differ diff --git a/experiment_data/sample_data/铟测试1.xlsx b/experiment_data/sample_data/铟测试1.xlsx new file mode 100644 index 0000000..72c3701 Binary files /dev/null and b/experiment_data/sample_data/铟测试1.xlsx differ diff --git a/src/data/pointcalculate.cpp b/src/data/pointcalculate.cpp index cd733ce..9e65835 100644 --- a/src/data/pointcalculate.cpp +++ b/src/data/pointcalculate.cpp @@ -9,7 +9,7 @@ QVectorPointCalculate:: _dataVtr; QPointF PointCalculate::_peakPoint; QPointF PointCalculate::_leftSelectedPoint,PointCalculate::_rightSelectedPoint; -void PointCalculate::setExperimentData(const QVector &dataVtr) +void PointCalculate::setAnalysisData(const QVector &dataVtr) { _dataVtr = dataVtr; @@ -263,6 +263,8 @@ float PointCalculate::calculateArea() { float b = Global::_enthalpyCoefficientVtr.at(1); float c = Global::_enthalpyCoefficientVtr.at(2); + logde<<"a,b,c:"<&); +void setAnalysisData(const QVector&); QPair getStartAndEndPoint(); QVector getDataInXRange(const float, const float); diff --git a/src/data/xlsxhandler.cpp b/src/data/xlsxhandler.cpp index 6cbf792..9210afc 100644 --- a/src/data/xlsxhandler.cpp +++ b/src/data/xlsxhandler.cpp @@ -213,6 +213,7 @@ void XlsxHandler::writeFile(const QString filePath) xlsx.write(row , 1, ConPhaseIndex); xlsx.write(row , 2, i + 1); row++; + // phase info xlsx.write(row , 1, ConPhaseCutoffTemp); xlsx.write(row , 2, phase.cutoff_temp); diff --git a/src/global.h b/src/global.h index 0021b5c..3ae66b4 100644 --- a/src/global.h +++ b/src/global.h @@ -32,18 +32,6 @@ const QString RateStr("rate"); const double DefaultParamter = 8.177; // -#if 0 -enum AnalysisMode{ - Null, - NumericalLabel, - StartPoint, - StopPoint, - PeakSynthesisAnalysis, - GlassTransition, - OnsetTemperaturePoint, - EndsetTemperaturePoint -}; -#endif enum Mode{ Analysis, ConnectedToDev, @@ -126,10 +114,6 @@ extern bool _displayTimeValue; QString converDoubleToStr(const double); void quadraticLeastSquaresFit(double x[], double y[], int n, double coeff[]); double findNegativeStartPoint(double m, double b, double start, double end); - }; - - - #endif // GLOBAL_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0a9ab9f..9d747c8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -348,6 +348,7 @@ void MainWindow::slotSaveExperimentalDataMsgBox() QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment); + _leftWidget->reloadFileName(); } else { on_actionClearAllData_triggered(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 4f55603..144f2ec 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -98,10 +98,6 @@ private: void connections(); void setActionEnable(const bool); void setSubWidgetAttribute(QWidget *); -#if 0 - bool saveExperimentFile(const QString fileName); - bool saveAnalysisFile(const QString fileName); -#endif bool saveFile(const QString fileName,const Global::Mode); private: diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index 14037d8..c1a6bb7 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -110,6 +110,12 @@ void CentralWidget::switchAxisMode() if(_axisMode == AxisMode::SingleY){ _axisMode = AxisMode::DoubleY; + _customPlot->yAxis2->setVisible(true); + _customPlot->yAxis2->setLabel(XlsxHandler::ConPhaseHeaderTemp); + + _customPlot->yAxis->setLabel(XlsxHandler::ConPhaseHeaderTime); + +#if 0 _customPlot->yAxis2->setVisible(true); _customPlot->yAxis2->setLabel("Time/min"); @@ -142,6 +148,7 @@ void CentralWidget::switchAxisMode() // logde<<"plottableCount count:"<<_customPlot->plottableCount(); } } +#endif }else{ _axisMode = AxisMode::SingleY; @@ -272,7 +279,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) for(int i = 0;i < cfd.phaseTotalVtr.size();i++){ Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i]; - PointCalculate::setExperimentData(pti.dataVtr); + PointCalculate::setAnalysisData(pti.dataVtr); QPairstartEndPointPair = PointCalculate::getStartAndEndPoint(); @@ -306,6 +313,9 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) pti.curve = _currentCurve; } + // Add data to global parameter. + Global::_curveFileDataVtr.push_back(cfd); + // Add analysis operation data. if(cfd.analysisOperationVtr.size() > 0){ for(AnaOpRecorder::AnalysisOperation& ao @@ -316,13 +326,26 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) // Refresh ui. _customPlot->rescaleAxes(); _customPlot->replot(); - - // Add data to global parameter. - Global::_curveFileDataVtr.push_back(cfd); } void CentralWidget::slotAnalysisSettingApply() { + //Set the analysis data corresponding current curve. + if(!_currentCurve){ + logde<<"failed. current curve is nullptr."; + return; + } + + QVector dataVtr; + for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ + if(pti.curve == _currentCurve){ + PointCalculate::setAnalysisData(pti.dataVtr); + break; + } + } + } + // double x1 = _line1->point1->coords().x(); double x2 = _line2->point1->coords().x(); @@ -1097,16 +1120,33 @@ void CentralWidget::loadAnalysisData( //enthalpy double sampleWeight = 0.0f; for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ +#if 0 if(_currentCurve && _currentCurve == pti.curve){ sampleWeight = cfd.ei.sampleWeight.toDouble(); } +#endif + if(_currentCurve){ + if(_currentCurve == pti.curve){ + sampleWeight = cfd.ei.sampleWeight.toDouble(); + }else{ + } + }else{ +// logde<<"current curve nullptr."; + } } } - // logde<<"sample weight:"< +#include #include "experimentsettingform.h" #include "ui_experimentsettingform.h" @@ -22,6 +23,13 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent), ui->setupUi(this); uiReset(); + ui->checkBox_phase_1->setTristate(false); + ui->checkBox_phase_2->setTristate(false); + ui->checkBox_phase_3->setTristate(false); + ui->checkBox_phase_4->setTristate(false); + ui->checkBox_phase_5->setTristate(false); + ui->checkBox_phase_6->setTristate(false); + connect(ui->checkBox_phase_2, &QCheckBox::clicked, this, &ExperimentSettingForm::slotPhase2StateChanged); connect(ui->checkBox_phase_3, &QCheckBox::clicked, @@ -217,9 +225,10 @@ void ExperimentSettingForm::slotPhase2StateChanged(int state) } else { + // unchecked if (ui->checkBox_phase_3->isChecked()) { - ui->checkBox_phase_2->setCheckState(Qt::Checked); + ui->checkBox_phase_2->setChecked(true); } else { @@ -281,10 +290,17 @@ void ExperimentSettingForm::slotPhase4StateChanged(int state) } else { - ui->phase_4_cutoff_temp->setEnabled(false); - ui->phase_4_scan_rate->setEnabled(false); - ui->phase_4_constant_temp->setEnabled(false); - ui->comboBox_phase_4_atmosphere->setEnabled(false); + if (ui->checkBox_phase_5->isChecked()) + { + ui->checkBox_phase_4->setChecked(true); + } + else + { + ui->phase_4_cutoff_temp->setEnabled(false); + ui->phase_4_scan_rate->setEnabled(false); + ui->phase_4_constant_temp->setEnabled(false); + ui->comboBox_phase_4_atmosphere->setEnabled(false); + } } } @@ -306,15 +322,24 @@ void ExperimentSettingForm::slotPhase5StateChanged(int state) } else { - ui->phase_5_cutoff_temp->setEnabled(false); - ui->phase_5_scan_rate->setEnabled(false); - ui->phase_5_constant_temp->setEnabled(false); - ui->comboBox_phase_5_atmosphere->setEnabled(false); + if (ui->checkBox_phase_6->isChecked()) + { + ui->checkBox_phase_5->setChecked(true); + } + else + { + ui->phase_5_cutoff_temp->setEnabled(false); + ui->phase_5_scan_rate->setEnabled(false); + ui->phase_5_constant_temp->setEnabled(false); + ui->comboBox_phase_5_atmosphere->setEnabled(false); + } } } void ExperimentSettingForm::slotPhase6StateChanged(int state) { + qDebug() << "slotPhase2StateChanged:" << state; + if (state == Qt::PartiallyChecked) { if (ui->checkBox_phase_5->isChecked()) @@ -340,6 +365,13 @@ void ExperimentSettingForm::slotPhase6StateChanged(int state) void ExperimentSettingForm::on_pushButton_deliverData_clicked() { + float phase1CutoffTemp = 0.0; + float phase2CutoffTemp = 0.0; + float phase3CutoffTemp = 0.0; + float phase4CutoffTemp = 0.0; + float phase5CutoffTemp = 0.0; + float phase6CutoffTemp = 0.0; + QVector phaseVtr; { Phase phase; @@ -351,6 +383,13 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase1CutoffTemp = phase.cutoff_temp; + // + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(1); + return; + } } { Phase phase; @@ -362,6 +401,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase2CutoffTemp = phase.cutoff_temp; + if(phase2CutoffTemp < phase1CutoffTemp){ + phaseCufoffTempErrorMesgBox(2); + return; + } + + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(2); + return; + } } { @@ -373,6 +423,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase3CutoffTemp = phase.cutoff_temp; + if(phase3CutoffTemp < phase2CutoffTemp){ + phaseCufoffTempErrorMesgBox(3); + return; + } + + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(3); + return; + } } { @@ -384,6 +445,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() // phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex(); phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase4CutoffTemp = phase.cutoff_temp; + if(phase4CutoffTemp < phase3CutoffTemp){ + phaseCufoffTempErrorMesgBox(4); + return; + } + + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(4); + return; + } } { @@ -396,6 +468,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase5CutoffTemp = phase.cutoff_temp; + if(phase5CutoffTemp < phase4CutoffTemp){ + phaseCufoffTempErrorMesgBox(5); + return; + } + + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(5); + return; + } } { @@ -408,6 +491,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked() phase.gas = GasType::N2; phaseVtr.push_back(phase); + // + phase6CutoffTemp = phase.cutoff_temp; + if(phase6CutoffTemp < phase5CutoffTemp){ + phaseCufoffTempErrorMesgBox(6); + return; + } + + if(phase.temp_flow <= 0){ + phaseScanRateErrorMesgBox(6); + return; + } } // Global::ExperimentInfo& ei = Global::_experimentInfo; @@ -451,6 +545,22 @@ void ExperimentSettingForm::slotCancel() { hide(); } + +void ExperimentSettingForm::phaseCufoffTempErrorMesgBox(const int phaseNum) +{ + QString title = QString("阶段%1截止温度错误").arg(QString::number(phaseNum)); + QString text = QString("阶段%1截止温度不能小于上一阶段截止温度! ").arg(QString::number(phaseNum)); + QMessageBox::question(this, title, text, + QMessageBox::Yes); +} + +void ExperimentSettingForm::phaseScanRateErrorMesgBox(const int phaseNum) +{ + QString title = QString("阶段%1扫描速率错误").arg(QString::number(phaseNum)); + QString text = QString("阶段%1扫描速率必须大于0! ").arg(QString::number(phaseNum)); + QMessageBox::question(this, title, text, + QMessageBox::Yes); +} void ExperimentSettingForm::slotPhaseCheck() { if (sender() == ui->checkBox_phase_2) @@ -605,7 +715,7 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba) Global::_experimentInfo.phaseVtr = phaseVtr; //ui update -// logde<<"phaseVtr size:"<(this->findChild(checkBoxName)); if (checkBox_phase) { checkBox_phase->setChecked(true); -// qDebug()<<"found..."; + // qDebug()<<"found..."; }else{ -// qDebug()<<"not found..."; + // qDebug()<<"not found..."; } QString cutOffTempLineEditName = QString("phase_%1_cutoff_temp").arg(i); @@ -703,3 +813,11 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba) } + +void ExperimentSettingForm::showEvent(QShowEvent *event) +{ + QDateTime currentDateTime = QDateTime::currentDateTime(); + QString internationalFormat = currentDateTime.toString("yyyy/MM/dd hh:mm:ss"); + + ui->dateTimeLineEdit->setText(internationalFormat); +} diff --git a/src/ui/experimentsettingform.h b/src/ui/experimentsettingform.h index ff9c72a..2844315 100644 --- a/src/ui/experimentsettingform.h +++ b/src/ui/experimentsettingform.h @@ -23,6 +23,8 @@ signals: void sigDeliverData(const QByteArray &); public slots: void slotRecvPhaseInfo(const QByteArray &); +protected: + void showEvent(QShowEvent *event) override; private slots: void on_pushButton_deliverData_clicked(); private: @@ -38,6 +40,9 @@ private: void slotPhase6StateChanged(int state); void slotCancel(); + + void phaseCufoffTempErrorMesgBox(const int); + void phaseScanRateErrorMesgBox(const int); private: Ui::ExperimentSettingForm *ui; }; diff --git a/src/ui/printpreviewform.cpp b/src/ui/printpreviewform.cpp index 9b554a2..6b64127 100644 --- a/src/ui/printpreviewform.cpp +++ b/src/ui/printpreviewform.cpp @@ -10,13 +10,15 @@ PrintPreviewForm::PrintPreviewForm(QWidget *parent) : QWidget(parent), ui(new Ui::PrintPreviewForm) ,_printer(new QPrinter(QPrinter::HighResolution)) - ,_customPrintPreviewDialog(new QPrintPreviewDialog(_printer,this)) + // ,_customPrintPreviewDialog(new QPrintPreviewDialog(_printer,this)) { ui->setupUi(this); _printer->setPageSize(QPageSize(QPageSize::A4)); _printer->setOrientation(QPrinter::Landscape); + _customPrintPreviewDialog = new QPrintPreviewDialog(_printer,this); + QObject::connect(_customPrintPreviewDialog, &QPrintPreviewDialog::paintRequested, this,&PrintPreviewForm::slotPaintRequested); diff --git a/src/ui/realtimedataform.cpp b/src/ui/realtimedataform.cpp index 00008ac..ee3593b 100644 --- a/src/ui/realtimedataform.cpp +++ b/src/ui/realtimedataform.cpp @@ -3,7 +3,7 @@ #include "ui_realtimedataform.h" RealTimeDataForm::RealTimeDataForm(QWidget *parent) : QWidget(parent), - ui(new Ui::RealTimeDataForm) + ui(new Ui::RealTimeDataForm) { ui->setupUi(this); } @@ -100,5 +100,20 @@ void RealTimeDataForm::slotRevCommonData(const CommonData &data) // 扫描速率 ui->scanRateLineEdit->setText("--"); // 当前气氛 - ui->currentAtmosphereLineEdit->setText(QString::number(data.current_gas)); + QString gasName; + switch(data.current_gas){ + case GasType::NC: + gasName = "NC"; + break; + case GasType::N2: + gasName = "N2"; + break; + case GasType::O2: + gasName = "O2"; + break; + default: + gasName = "NC"; + break; + } + ui->currentAtmosphereLineEdit->setText(gasName); } diff --git a/src/ui/specificheatcomparisonmethodform.cpp b/src/ui/specificheatcomparisonmethodform.cpp index d1e3ac7..06f0282 100644 --- a/src/ui/specificheatcomparisonmethodform.cpp +++ b/src/ui/specificheatcomparisonmethodform.cpp @@ -144,13 +144,13 @@ void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked() // float targetTemperature = ui->LineEditTemperature->text().toFloat(); - PointCalculate::setExperimentData(*_baseLineDataVtr); + PointCalculate::setAnalysisData(*_baseLineDataVtr); QPointF baseLinePoint = PointCalculate::getClosestPointByX(targetTemperature); - PointCalculate::setExperimentData(*_standardSampleDataVtr); + PointCalculate::setAnalysisData(*_standardSampleDataVtr); QPointF standardSamplePoint = PointCalculate::getClosestPointByX(targetTemperature); - PointCalculate::setExperimentData(*_sampleDataVtr); + PointCalculate::setAnalysisData(*_sampleDataVtr); QPointF samplePoint = PointCalculate::getClosestPointByX(targetTemperature); logde<<"baseLinePoint:"<