From 9d433baf32f5165f8bbf7892a7457b789915d960 Mon Sep 17 00:00:00 2001 From: anxinglong <2910824064@qq.com> Date: Fri, 31 Jul 2026 17:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=88=E7=8E=87=E5=88=BB=E5=BA=A6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E8=87=B3=E9=A1=B9=E7=9B=AE=E4=B8=AD=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=BC=E5=87=BA=E6=B5=8B=E9=87=8F=E5=88=86=E6=9E=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EfficiencyScale.cpp | 32 ++- src/EfficiencyScale.h | 6 +- src/EfficiencyScale.ui | 2 +- src/MainWindow.cpp | 365 +++++++++++++++++++++++++++++++- src/MainWindow.h | 2 + src/MeasureAnalysisTreeView.cpp | 10 + src/MeasureAnalysisView.cpp | 5 +- src/NewMeasureAnalysisDlg.cpp | 24 +++ 8 files changed, 439 insertions(+), 7 deletions(-) diff --git a/src/EfficiencyScale.cpp b/src/EfficiencyScale.cpp index 474399e..fddf270 100644 --- a/src/EfficiencyScale.cpp +++ b/src/EfficiencyScale.cpp @@ -20,7 +20,7 @@ EfficiencyScale::EfficiencyScale(QWidget *parent) - : QDialog(parent) + : MeasureAnalysisView(parent) , ui(new Ui::EfficiencyScale) { ui->setupUi(this); @@ -82,6 +82,7 @@ EfficiencyScale::~EfficiencyScale() delete ui; } + void EfficiencyScale::setupPlot() { _plot->setCanvasBackground(Qt::white); @@ -854,3 +855,32 @@ void EfficiencyScale::on_pBtn_Delete_File_clicked() QStringLiteral(u"删除失败:%1").arg(filePath)); } } + +void EfficiencyScale::InitViewWorkspace(const QString &project_name) +{ + +} + +void EfficiencyScale::SetAnalyzeDataFilename(const QMap &data_files_set) +{ + if (!data_files_set.isEmpty()) { + const QString& data_name = data_files_set.firstKey(); + const QString& data_filename = data_files_set.first().toString(); + QFileInfo info(data_filename); + QDir dir = info.dir(); + if (QFileInfo(data_filename).exists()) { + ui->groupBox_7->hide(); + QFileInfo fileInfo(data_filename); + QString baseName =QString("[%1]%2").arg(dir.dirName()).arg(fileInfo.baseName()); + ui->lineEdit_name->setText(baseName); + ui->lineEdit_name->setReadOnly(true); + ui->groupBox_5->hide(); + ui->pBtn_SaveAs->setText(QStringLiteral(u"保存到系统")); + m_currentFilePath = data_filename; + QString errorMsg; + loadFromJsonFile(data_filename); + on_comboBox_channel_currentIndexChanged(0); + } + } +} + diff --git a/src/EfficiencyScale.h b/src/EfficiencyScale.h index bce971c..9989076 100644 --- a/src/EfficiencyScale.h +++ b/src/EfficiencyScale.h @@ -8,6 +8,7 @@ #include #include #include +#include namespace Ui { class EfficiencyScale; @@ -57,14 +58,15 @@ struct ChannelEfficiencyData ChannelEfficiencyData() : inflectionEnergy(0.0) {} }; -class EfficiencyScale : public QDialog +class EfficiencyScale : public MeasureAnalysisView { Q_OBJECT public: explicit EfficiencyScale(QWidget *parent = nullptr); ~EfficiencyScale(); - + virtual void InitViewWorkspace(const QString& project_name) override final; + virtual void SetAnalyzeDataFilename(const QMap& data_files_set); private: void setupPlot(); //加载能量刻度文件夹下所有的文件 diff --git a/src/EfficiencyScale.ui b/src/EfficiencyScale.ui index 279fa86..290f7e5 100644 --- a/src/EfficiencyScale.ui +++ b/src/EfficiencyScale.ui @@ -1,7 +1,7 @@ EfficiencyScale - + 0 diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 6ce01fe..d061f3f 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -11,6 +11,15 @@ #include #include #include + +#include +#include +#include +#include +#include +#include +#include + #include "DockAreaWidget.h" #include "DockComponentsFactory.h" #include "DockManager.h" @@ -459,6 +468,7 @@ void MainWindow::initAction() } } }); + } void MainWindow::initStatusBar() @@ -965,6 +975,359 @@ void MainWindow::on_action_efficiency_scale_mrg_triggered() // QHBoxLayout* hlayout = new QHBoxLayout; // hlayout->addWidget(efficiency_scale_mrg_form); // efficiency_scale_mrg_form.setLayout(hlayout); - efficiency_scale_mrg_form->exec(); + efficiency_scale_mrg_form->show(); } +void MainWindow::on_action_output_measurement_analysis_triggered() +{ + MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetCurrentProjectModel(); + if (project_model == nullptr) { + QMessageBox::information(this, QStringLiteral(u"提示"), QStringLiteral(u"请先新建或打开测量分析项目!")); + return; + } + + const QString& project_name = project_model->GetProjectName(); + const QString& project_dir = project_model->GetProjectDir(); + + // 构建导出选择对话框 + QDialog dlg(this); + dlg.setWindowTitle(QStringLiteral(u"导出测量分析数据")); + dlg.setMinimumWidth(320); + + QVBoxLayout* main_layout = new QVBoxLayout(&dlg); + + // 项目信息标签 + QLabel* info_label = new QLabel(QStringLiteral(u"当前项目:%1").arg(project_name), &dlg); + info_label->setStyleSheet("font-weight:bold; padding:4px;"); + main_layout->addWidget(info_label); + + main_layout->addWidget(new QLabel(QStringLiteral(u"请选择要导出的数据类别:"), &dlg)); + + // 全选/全不选按钮 + QHBoxLayout* btn_layout = new QHBoxLayout; + QPushButton* btn_select_all = new QPushButton(QStringLiteral(u"全选"), &dlg); + QPushButton* btn_select_none = new QPushButton(QStringLiteral(u"全不选"), &dlg); + btn_layout->addWidget(btn_select_all); + btn_layout->addWidget(btn_select_none); + btn_layout->addStretch(); + main_layout->addLayout(btn_layout); + + // 复选框列表 + QCheckBox* chk_readme = new QCheckBox(QStringLiteral(u"导出说明文件(项目信息+目录说明)"), &dlg); + QCheckBox* chk_particle = new QCheckBox(QStringLiteral(u"原始粒子数据"), &dlg); + QCheckBox* chk_addr_count = new QCheckBox(QStringLiteral(u"道址计数"), &dlg); + QCheckBox* chk_energy_count = new QCheckBox(QStringLiteral(u"能量计数"), &dlg); + QCheckBox* chk_spectrum = new QCheckBox(QStringLiteral(u"能谱数据(粒子能量数据)"), &dlg); + QCheckBox* chk_conform = new QCheckBox(QStringLiteral(u"符合数据"), &dlg); + QCheckBox* chk_anti_conform = new QCheckBox(QStringLiteral(u"反符合数据"), &dlg); + QCheckBox* chk_scale = new QCheckBox(QStringLiteral(u"刻度配置数据"), &dlg); + + // 默认全选 + chk_readme->setChecked(true); + chk_particle->setChecked(true); + chk_addr_count->setChecked(true); + chk_energy_count->setChecked(true); + chk_spectrum->setChecked(true); + chk_conform->setChecked(true); + chk_anti_conform->setChecked(true); + chk_scale->setChecked(true); + + QList all_checkboxes = { + chk_readme, chk_particle, chk_addr_count, chk_energy_count, + chk_spectrum, chk_conform, chk_anti_conform, chk_scale + }; + + QGroupBox* group_box = new QGroupBox(QStringLiteral(u"导出数据类别"), &dlg); + QVBoxLayout* group_layout = new QVBoxLayout(group_box); + for (auto cb : all_checkboxes) { + group_layout->addWidget(cb); + } + main_layout->addWidget(group_box); + + // 全选/全不选 槽连接 + connect(btn_select_all, &QPushButton::clicked, [&](){ + for (auto cb : all_checkboxes) cb->setChecked(true); + }); + connect(btn_select_none, &QPushButton::clicked, [&](){ + for (auto cb : all_checkboxes) cb->setChecked(false); + }); + + // 确定/取消按钮 + QDialogButtonBox* button_box = new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dlg); + connect(button_box, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); + connect(button_box, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); + main_layout->addWidget(button_box); + + // 弹出选择对话框 + if (dlg.exec() != QDialog::Accepted) { + return; + } + + // 检查是否有选中项 + bool has_selection = false; + for (auto cb : all_checkboxes) { + if (cb->isChecked()) { has_selection = true; break; } + } + if (!has_selection) { + QMessageBox::information(this, QStringLiteral(u"提示"), QStringLiteral(u"请至少选择一项要导出的数据!")); + return; + } + + // 选择导出目录 + QString default_export_dir = QDir::homePath(); + QString export_root_dir = QFileDialog::getExistingDirectory( + this, + QStringLiteral(u"选择导出目录"), + default_export_dir, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks + ); + if (export_root_dir.isEmpty()) { + return; + } + + // 在导出目录下创建以项目名命名的子目录 + QString export_dir = QDir(export_root_dir).filePath(project_name + QStringLiteral(u"_导出数据")); + QDir export_qdir(export_dir); + if (!export_qdir.mkpath(export_dir)) { + QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"创建导出目录失败:%1").arg(export_dir)); + return; + } + + int export_count = 0; + QStringList export_log; + + // 复制单个文件到目标目录,返回是否成功 + auto copyFileToDir = [&](const QString& src_file, const QString& dst_dir, const QString& dst_filename = QString()) -> bool { + if (src_file.isEmpty() || !QFile::exists(src_file)) { + return false; + } + QDir().mkpath(dst_dir); + QString dst_name = dst_filename.isEmpty() ? QFileInfo(src_file).fileName() : dst_filename; + QString dst_path = QDir(dst_dir).filePath(dst_name); + if (QFile::exists(dst_path)) { + QFile::remove(dst_path); + } + bool ok = QFile::copy(src_file, dst_path); + if (ok) { + export_count++; + export_log << QStringLiteral(u" ✓ %1").arg(dst_name); + } + return ok; + }; + + // 批量复制目录中的文件 + auto copyFileMapToDir = [&](const QMap& file_map, const QString& dst_dir, const QString& name_prefix) -> int { + int count = 0; + QList keys = file_map.keys(); + qSort(keys.begin(), keys.end()); + for (uint ch : keys) { + const QString& src_file = file_map.value(ch); + QString dst_name = QStringLiteral(u"%1%2.csv").arg(name_prefix).arg(ch); + if (copyFileToDir(src_file, dst_dir, dst_name)) { + count++; + } + } + return count; + }; + + //导出说明文件 + if (chk_readme->isChecked()) { + QString sub_dir = export_dir; + export_log << QStringLiteral(u"[导出说明]"); + QString readme_path = QDir(sub_dir).filePath(QStringLiteral(u"导出说明.txt")); + QFile readme_file(readme_path); + if (readme_file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { + QTextStream out(&readme_file); + out.setCodec("UTF-8"); + out << QStringLiteral(u"========================================\n"); + out << QStringLiteral(u" 测量分析数据导出报告\n"); + out << QStringLiteral(u"========================================\n\n"); + out << QStringLiteral(u"项目名称:%1\n").arg(project_name); + out << QStringLiteral(u"导出时间:%1\n").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); + out << QStringLiteral(u"项目目录:%1\n").arg(project_dir); + out << QStringLiteral(u"设备GUID:%1\n").arg(project_model->GetDeviceGuid()); + out << QStringLiteral(u"开始时间:%1\n").arg(project_model->GetStartTime()); + out << QStringLiteral(u"结束时间:%1\n").arg(project_model->GetEndTime()); + out << QStringLiteral(u"预设时间:%1 秒\n").arg(project_model->GetMeasurePresetTime()); + out << QStringLiteral(u"符合时间窗:%1 ns\n").arg(project_model->GetConformTimeWin()); + out << QStringLiteral(u"测量状态:%1\n").arg(project_model->GetIsMeasureComplete() ? QStringLiteral(u"已完成") : QStringLiteral(u"未完成")); + out << QStringLiteral(u"\n----------------------------------------\n"); + out << QStringLiteral(u" 目录结构说明\n"); + out << QStringLiteral(u"----------------------------------------\n"); + out << QStringLiteral(u"01_原始粒子数据/ — 全通道粒子原始数据(板卡号,通道号,道址,时间计数)\n"); + out << QStringLiteral(u"02_道址计数/ — 各通道道址计数谱(道址,计数)\n"); + out << QStringLiteral(u"03_能量计数/ — 各通道能量计数谱(能量KeV,计数)\n"); + out << QStringLiteral(u"04_能谱数据/ — 粒子能量数据(板卡号,通道号,道址,能量KeV,时间计数)\n"); + out << QStringLiteral(u"05_符合数据/ — 符合事件数据(粒子符合 + 能量符合)\n"); + out << QStringLiteral(u"06_反符合数据/ — 反符合事件数据(粒子反符合 + 能量反符合)\n"); + out << QStringLiteral(u"07_刻度配置/ — 能量刻度、效率刻度、设备参数配置\n"); + out << QStringLiteral(u"\n----------------------------------------\n"); + out << QStringLiteral(u" 数据格式说明\n"); + out << QStringLiteral(u"----------------------------------------\n"); + out << QStringLiteral(u"所有数据文件均为 CSV 格式,UTF-8 编码,逗号分隔。\n"); + out << QStringLiteral(u"计数值均为普通十进制表示,无科学计数法。\n"); + readme_file.close(); + export_count++; + export_log << QStringLiteral(u" ✓ 导出说明.txt"); + } + } + + //原始粒子数据 + if (chk_particle->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"01_原始粒子数据")); + export_log << QStringLiteral(u"\n[01_原始粒子数据]"); + const QString& particle_file = project_model->GetAllChannelParticleDataFilename(); + copyFileToDir(particle_file, sub_dir, QStringLiteral(u"粒子数据.csv")); + if (!QFile::exists(particle_file)) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 道址计数 + if (chk_addr_count->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"02_道址计数")); + export_log << QStringLiteral(u"\n[02_道址计数]"); + const auto& addr_count_map = project_model->GetChannelAddressCountDataFilenameList(); + int cnt = copyFileMapToDir(addr_count_map, sub_dir, QStringLiteral(u"通道")); + if (cnt == 0) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 能量计数 + if (chk_energy_count->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"03_能量计数")); + export_log << QStringLiteral(u"\n[03_能量计数]"); + // 全通道能量计数 + const QString& all_ch_file = project_model->GetAllChannelEnergyTotalCountDataFilename(); + copyFileToDir(all_ch_file, sub_dir, QStringLiteral(u"全通道能量计数.csv")); + // 各通道能量计数 + const auto& energy_count_map = project_model->GetChannelEnergyCountDataFilenameList(); + int cnt = copyFileMapToDir(energy_count_map, sub_dir, QStringLiteral(u"通道")); + if (!QFile::exists(all_ch_file) && cnt == 0) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 能谱数据(粒子能量数据) + if (chk_spectrum->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"04_能谱数据")); + export_log << QStringLiteral(u"\n[04_能谱数据]"); + const QString& energy_file = project_model->GetParticleEnergyDataFilename(); + copyFileToDir(energy_file, sub_dir, QStringLiteral(u"粒子能量数据.csv")); + if (!QFile::exists(energy_file)) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 符合数据 + if (chk_conform->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"05_符合数据")); + export_log << QStringLiteral(u"\n[05_符合数据]"); + int total = 0; + + // 粒子符合数据 + QString particle_sub_dir = QDir(sub_dir).filePath(QStringLiteral(u"粒子符合")); + const auto& conform_particle_map = project_model->GetConformParticleDataFilenameList(); + for (auto it = conform_particle_map.constBegin(); it != conform_particle_map.constEnd(); ++it) { + uint time_win = it.key(); + const auto& order_map = it.value(); + for (auto order_it = order_map.constBegin(); order_it != order_map.constEnd(); ++order_it) { + uint order = order_it.key(); + const QString& src_file = order_it.value(); + QString dst_name = QStringLiteral(u"[%1ns]%2个粒子符合事件.csv").arg(time_win).arg(order); + if (copyFileToDir(src_file, particle_sub_dir, dst_name)) { + total++; + } + } + } + + // 能量符合数据 + QString energy_sub_dir = QDir(sub_dir).filePath(QStringLiteral(u"能量符合")); + const auto& conform_energy_map = project_model->GetConformParticleEnergyDataFilenameList(); + for (auto it = conform_energy_map.constBegin(); it != conform_energy_map.constEnd(); ++it) { + uint time_win = it.key(); + const auto& order_map = it.value(); + for (auto order_it = order_map.constBegin(); order_it != order_map.constEnd(); ++order_it) { + uint order = order_it.key(); + const QString& src_file = order_it.value(); + QString dst_name = QStringLiteral(u"[%1ns]%2个粒子符合能谱.csv").arg(time_win).arg(order); + if (copyFileToDir(src_file, energy_sub_dir, dst_name)) { + total++; + } + } + } + + if (total == 0) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 反符合数据 + if (chk_anti_conform->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"06_反符合数据")); + export_log << QStringLiteral(u"\n[06_反符合数据]"); + int total = 0; + + // 反符合粒子数据 + const auto& anti_particle_map = project_model->GetAntiConformParticleData(); + for (auto it = anti_particle_map.constBegin(); it != anti_particle_map.constEnd(); ++it) { + uint time_win = it.key(); + const QString& src_file = it.value(); + QString dst_name = QStringLiteral(u"反符合粒子事件_%1ns.csv").arg(time_win); + if (copyFileToDir(src_file, sub_dir, dst_name)) { + total++; + } + } + + // 反符合能量数据 + const auto& anti_energy_map = project_model->GetAntiConformEnergyData(); + for (auto it = anti_energy_map.constBegin(); it != anti_energy_map.constEnd(); ++it) { + uint time_win = it.key(); + const QString& src_file = it.value(); + QString dst_name = QStringLiteral(u"反符合能量能谱_%1ns.csv").arg(time_win); + if (copyFileToDir(src_file, sub_dir, dst_name)) { + total++; + } + } + + if (total == 0) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 刻度配置数据 + if (chk_scale->isChecked()) { + QString sub_dir = QDir(export_dir).filePath(QStringLiteral(u"07_刻度配置")); + export_log << QStringLiteral(u"\n[07_刻度配置]"); + + // 能量刻度 + const QString& energy_scale_file = project_model->GetEnergyScaleFilename(); + copyFileToDir(energy_scale_file, sub_dir, QStringLiteral(u"能量刻度.json")); + + // 效率刻度 + const QString& efficiency_scale_file = project_model->GetEfficiencyScaleFilename(); + copyFileToDir(efficiency_scale_file, sub_dir, QStringLiteral(u"效率刻度.json")); + + // 设备参数配置 + const QString& device_cfg_file = project_model->GetMeasureDeviceParamsCfgFilename(); + copyFileToDir(device_cfg_file, sub_dir, QStringLiteral(u"设备参数配置.json")); + + if (!QFile::exists(energy_scale_file) && !QFile::exists(efficiency_scale_file) && !QFile::exists(device_cfg_file)) { + export_log << QStringLiteral(u" (无数据)"); + } + } + + // 导出完成提示 + QString info_text = QStringLiteral(u"导出测量分析项目\"%1\"完成,共导出 %2 个文件。\n导出目录:%3") + .arg(project_name).arg(export_count).arg(export_dir); + LOG_INFO(info_text); + + // 拼接日志文本 + QString log_text = export_log.join("\n"); + QString full_msg = QStringLiteral(u"导出完成!\n\n项目:%1\n导出文件数:%2\n导出目录:%3\n\n---- 导出清单 ----\n%4") + .arg(project_name).arg(export_count).arg(export_dir).arg(log_text); + + QMessageBox::information(this, QStringLiteral(u"导出完成"), full_msg); +} \ No newline at end of file diff --git a/src/MainWindow.h b/src/MainWindow.h index 9db8fa3..8011a28 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -91,6 +91,8 @@ private slots: void on_action_device_connect_cfg_triggered(); //感兴趣区 void on_action_roi_triggered(); + //导出测量分析数据 + void on_action_output_measurement_analysis_triggered(); void onParticleDatarefresh(); void onAddressCountViewNeedRefresh(); diff --git a/src/MeasureAnalysisTreeView.cpp b/src/MeasureAnalysisTreeView.cpp index b917b87..e3bee4d 100644 --- a/src/MeasureAnalysisTreeView.cpp +++ b/src/MeasureAnalysisTreeView.cpp @@ -110,6 +110,16 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index) } } ;break; + case AnalysisType::EfficiencyScale:{ + MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); + if (project_model) { + auto file_name = project_model->GetEfficiencyScaleFilename(); + if ( !file_name.isEmpty() ) { + data_files_set[QStringLiteral(u"效率刻度")] = file_name; + } + } + } + ;break; case AnalysisType::ParticleData: { MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); if (project_model) { diff --git a/src/MeasureAnalysisView.cpp b/src/MeasureAnalysisView.cpp index 8e2012f..122a1b0 100644 --- a/src/MeasureAnalysisView.cpp +++ b/src/MeasureAnalysisView.cpp @@ -14,6 +14,7 @@ #include "CoincidenceEventTimeView.h" #include "NuclideAnalysisView.h" #include "EnergyScaleForm.h" +#include "EfficiencyScale.h" #include MeasureAnalysisView* MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type) @@ -33,8 +34,8 @@ MeasureAnalysisView* MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type) new_view->setDeleteOnClose(true); } break; case AnalysisType::EfficiencyScale: { - // new_view = new MeasureAnalysisDataTableView; - // new_view->setDeleteOnClose(true); + new_view = new EfficiencyScale; + new_view->setDeleteOnClose(true); } break; case AnalysisType::ParticleData: { new_view = new MeasureAnalysisDataTableView; diff --git a/src/NewMeasureAnalysisDlg.cpp b/src/NewMeasureAnalysisDlg.cpp index 053eaf4..c7bea55 100644 --- a/src/NewMeasureAnalysisDlg.cpp +++ b/src/NewMeasureAnalysisDlg.cpp @@ -107,6 +107,20 @@ void NewMeasureAnalysisDlg::initialization() ui->comboBox_energy_scale->addItem(energy_scale_file_info.baseName(), energy_scale_file_info.absoluteFilePath()); } } + //遍历可执行文件目录中configure/EfficiencyScale + const QString &efficiency_scale_dir_path = QDir(qApp->applicationDirPath()).filePath("configure/EfficiencyScale"); + QDir efficiency_scale_dir(efficiency_scale_dir_path); + if (!efficiency_scale_dir.exists(efficiency_scale_dir_path)) { + return; + } + QList efficiency_scale_basenames = efficiency_scale_dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::Time); + for (const QString& efficiency_scale_basename : efficiency_scale_basenames) { + const QString& efficiency_scale_filename = efficiency_scale_dir.filePath(efficiency_scale_basename); + QFileInfo efficiency_scale_file_info(efficiency_scale_filename); + if ("json" == efficiency_scale_file_info.suffix()) { + ui->comboBox_efficiency_scale->addItem(efficiency_scale_file_info.baseName(), efficiency_scale_file_info.absoluteFilePath()); + } + } ui->btn_ok->setEnabled(false); auto turnStackPageBtnState = [this](){ @@ -181,6 +195,13 @@ void NewMeasureAnalysisDlg::newProject(const QString& particle_data_filename) readJsonAsSave(energy_scale_filename,project_energy_scale_filename); // QFile::copy(energy_scale_filename, project_energy_scale_filename); } + //效率刻度拷贝至当前项目下 + QString efficiency_scale_filename = ui->comboBox_efficiency_scale->currentData().toString(); + QString project_efficiency_scale_filename = QDir(project_dir_path).filePath(QStringLiteral(u"效率刻度.json")); + QFileInfo efficiency_scale_file_info(efficiency_scale_filename); + if (efficiency_scale_file_info.exists()) { + QFile::copy(efficiency_scale_filename, project_efficiency_scale_filename); + } bool is_measure_complete = !particle_data_filename.isEmpty(); @@ -196,6 +217,9 @@ void NewMeasureAnalysisDlg::newProject(const QString& particle_data_filename) model->SetMeasureDeviceParamsCfgFilename(project_measure_param_filename); if(measure_param_file_info.exists(project_energy_scale_filename)) model->SetEnergyScaleFilename(project_energy_scale_filename); + if(measure_param_file_info.exists(project_efficiency_scale_filename)) + model->SetEfficiencyScaleFilename(project_efficiency_scale_filename); + model->SetAllChannelParticleDataFilename(particle_data_filename); model->SetIsMeasureComplete(is_measure_complete); ProjectList::Instance()->AddProjectModel(model);