diff --git a/src/DSCAnalysisTool.pro b/src/DSCAnalysisTool.pro index 4fef804..bd82139 100644 --- a/src/DSCAnalysisTool.pro +++ b/src/DSCAnalysisTool.pro @@ -9,7 +9,7 @@ CONFIG+=precompile_header PRECOMPILED_HEADER=stable.h # -VERSION = 1.3.4 +VERSION = 1.3.5.1 # 设置目标文件名,包含版本号 TARGET = DSCAnalysisTool_$${VERSION} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2c8b0f0..18bc6bb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,7 +17,20 @@ MainWindow::MainWindow(QWidget *parent) _leftWidget(new LeftWidget(this)), _expertmentSettingForm(new ExperimentSettingForm(this)), _realTimeDataForm(new RealTimeDataForm(this)), - _rightWidget(new QDockWidget(this)), _analysisSettingWidget(new AnalysisSettingForm(this)), _contextMenu(new QMenu(this)), _specificHeatComparisonMethodForm(new SpecificHeatComparisonMethodForm(this)), _instrumentCoefficientForm(new InstrumentCoefficientForm(this)), _degreeOfCureForm(new DegreeOfCureForm(this)), _OITAutoAnalysisParamForm(new OITAutoAnalysisParamForm(this)), _degreeOfCrystallinityForm(new DegreeOfCrystallinityForm(this)), _aboutForm(new AboutForm(this)), _enthalpyDataCorrectionForm(new EnthalpyDataCorrectionForm(this)), _coefficientSelectionForm(new CoefficientSelectionForm(this)), _printPreviewForm(new PrintPreviewForm(this)), _axisSettingForm(new AxisSettingForm(this)), _manuallyStopTheExperimentFlag(false) { + _rightWidget(new QDockWidget(this)), + _analysisSettingWidget(new AnalysisSettingForm(this)), + _contextMenu(new QMenu(this)), + _specificHeatComparisonMethodForm(new SpecificHeatComparisonMethodForm(this)), + _instrumentCoefficientForm(new InstrumentCoefficientForm(this)), + _degreeOfCureForm(new DegreeOfCureForm(this)), + _OITAutoAnalysisParamForm(new OITAutoAnalysisParamForm(this)), + _degreeOfCrystallinityForm(new DegreeOfCrystallinityForm(this)), + _aboutForm(new AboutForm(this)), + _enthalpyDataCorrectionForm(new EnthalpyDataCorrectionForm(this)), + _coefficientSelectionForm(new CoefficientSelectionForm(this)), + _printPreviewForm(new PrintPreviewForm(this)), + _axisSettingForm(new AxisSettingForm(this)), + _manuallyStopTheExperimentFlag(false) { ui->setupUi(this); ui->actionOITAutoAnalysisMode->setVisible(false); this->setToolTip("....."); @@ -418,6 +431,11 @@ void MainWindow::startExperiment() { Global::_mode = Global::Mode::Experiment; _manuallyStopTheExperimentFlag = false; _centralWidget->startExperiment(); + + // 清除数据action变灰 + ui->actionClearAllData->setEnabled(false); + // 分析menu变灰 + ui->menu_4->menuAction()->setEnabled(false); } void MainWindow::startExperimentByDeviceInfo() { @@ -460,6 +478,11 @@ void MainWindow::on_actionStop_triggered() { } #endif } + + // 清除数据action恢复功能 + ui->actionClearAllData->setEnabled(true); + // 分析menu恢复功能 + ui->menu_4->menuAction()->setEnabled(true); } void MainWindow::on_actionNew_triggered() { @@ -809,10 +832,10 @@ void MainWindow::showMesgBox(const QString str) { } void MainWindow::slotDeviceDisconnected() { - // logde<<"slotDeviceDisconnected...1"; + // logde<<"slotDeviceDisconnected...1"; // 如果当前是实验模式时,需要先停止实验。 if (SerialPort::instance()->isOpen()) { - // logde<<"slotDeviceDisconnected...2"; + // logde<<"slotDeviceDisconnected...2"; // ui更新,断开连接 ui->actionConnectToDev->setIcon(QIcon(":/images/connect.png")); ui->actionConnectToDev->setText("连接设备"); @@ -820,6 +843,5 @@ void MainWindow::slotDeviceDisconnected() { on_actionStop_triggered(); SerialPort::instance()->closeSp(); - } } diff --git a/src/serialport/serialport.cpp b/src/serialport/serialport.cpp index d9dd557..d934b69 100644 --- a/src/serialport/serialport.cpp +++ b/src/serialport/serialport.cpp @@ -240,7 +240,8 @@ void SerialPort::updateStatus(const CommonData &cd) { if (experimentEnded) { msg = QString("设备运行状态:%2 实验阶段:%3 实验进行中").arg(devRunModeStr).arg(cd.current_phase); } else { - msg = QString("设备运行状态:%2 实验阶段:%3 实验结束").arg(devRunModeStr).arg(cd.current_phase); + // msg = QString("设备运行状态:%2 实验阶段:%3 实验结束").arg(devRunModeStr).arg(cd.current_phase); + msg = QString("设备运行状态:%2 实验结束").arg(devRunModeStr); } emit sigUpdateStatusbarMsg(msg); diff --git a/src/ui/centralwidget.cpp b/src/ui/centralwidget.cpp index fc40796..ca2d3bb 100644 --- a/src/ui/centralwidget.cpp +++ b/src/ui/centralwidget.cpp @@ -351,6 +351,8 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd) { } void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) { + logde<<"slotRecvAnalysisFileName, filePath:" << filePath.toStdString(); + if (_analysisFilePathVtr.contains(filePath)) { return; } else { @@ -363,7 +365,16 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath) { QMessageBox::warning((QWidget *)this->parent(), "warnning", "File parse error."); return; } - // Add data to global parameter. + + // 把文件数据存储到全局变量中。 + for (int i = Global::_curveFileDataVtr.size() - 1; i >= 0; --i) { + if (Global::_curveFileDataVtr[i].filePath == filePath) { + // 已经存在该文件数据,直接返回 + logde<<"file exist...return."; + return; + } + } + Global::_curveFileDataVtr.push_back(cfd); // @@ -524,7 +535,7 @@ void CentralWidget::slotDelCurve(QCPCurve *curve) { return; } - logde << "deltel curve object name:" << curve->objectName().toStdString(); + logde << "delete curve object name:" << curve->objectName().toStdString(); deleteCurveByObjectName(curve->objectName()); } @@ -729,8 +740,10 @@ void CentralWidget::uiLoadXlsxFileData() { newYAxisPair.second); // Add analysis operation data. +#if 0 logde << "analysis operation vtr size:" << cfd.analysisOperationVtr.size(); +#endif if (!cfd.analysisOperationVtr.empty()) { for (AnaOpRecorder::AnalysisOperation &ao : cfd.analysisOperationVtr) { @@ -1282,6 +1295,8 @@ void CentralWidget::clearAllUiData() { } void CentralWidget::deleteCurveByObjectName(const QString objectName) { + logde << "deleteCurveByObjectName..." << objectName.toStdString(); + for (int i = _analysisFilePathVtr.size() - 1; i >= 0; --i) { if (_analysisFilePathVtr[i].startsWith(objectName)) { _analysisFilePathVtr.removeAt(i); // 从后往前删除避免索引错乱 @@ -1292,12 +1307,20 @@ void CentralWidget::deleteCurveByObjectName(const QString objectName) { AnalysisOperationRecorder::removeAnalysisOperationByObjectName(objectName); + // Global::_curveFileDataVtr 从全局文件数据中删除制定文件数据。 + for (int i = Global::_curveFileDataVtr.size() - 1; i >= 0; --i) { + if (Global::_curveFileDataVtr[i].filePath == objectName) { + Global::_curveFileDataVtr.removeAt(i); // 从后往前删除避免索引错乱 + } + } + // Clear the data of graph. for (int i = _customPlot->plottableCount() - 1; i >= 0; --i) { QCPAbstractPlottable *plottable = _customPlot->plottable(i); if (auto curve = dynamic_cast(plottable)) { - logde << "clear data,curve object Name:" << curve->objectName().toStdString(); if (curve->objectName().contains(objectName)) { + logde << "1 clear data,curve object Name:" << curve->objectName().toStdString(); + _customPlot->removePlottable(curve); ItemManager::removeItem(curve); diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index e414332..d7f7a30 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -65,7 +65,7 @@ public slots: // experiment void slotAxisModify(const float temp); void slotModeModify(const Global::Mode); - // 接受串口传递过来的数据,保存到缓存中,并且更新ui显示。 + // 接收串口传递过来的数据,保存到缓存中,并且更新ui显示。 void slotRecvCommonData(const CommonData&); void slotRecvAnalysisFileName(const QString&); @@ -78,7 +78,7 @@ public slots: void slotAnalysisSettingLineXPoint(const int index,const double); void slotDrawCustomText(const QString); - + // 右键菜单,删除曲线 void slotDelCurve(QCPCurve*); // void slotGetAxisInfo();