From ee794cfccc69156e2805c6281b90ee7e48102bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B5=B7?= Date: Tue, 24 Mar 2026 13:58:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E9=87=8F=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=A0=91=E5=88=86=E6=9E=90=E8=8A=82=E7=82=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeasureAnalysisProjectModel.cpp | 312 ++++++++++++++++++++-------- src/MeasureAnalysisProjectModel.h | 12 +- 2 files changed, 236 insertions(+), 88 deletions(-) diff --git a/src/MeasureAnalysisProjectModel.cpp b/src/MeasureAnalysisProjectModel.cpp index c18c0b8..6d1d01b 100644 --- a/src/MeasureAnalysisProjectModel.cpp +++ b/src/MeasureAnalysisProjectModel.cpp @@ -98,6 +98,11 @@ void MeasureAnalysisProjectModel::SetAllChannelEnergyTotalCountDataFilename(cons this->_all_channel_energy_total_count_data_filename = filename; } +void MeasureAnalysisProjectModel::SetParticleEnergyDataFilename(const QString &filename) +{ + this->_particle_energy_data_filename = filename; +} + void MeasureAnalysisProjectModel::SetTimeWinConformParticleData(uint time_win, uint conform_particle_count, const QString& filename) { this->_time_win_conform_particle_data[time_win][conform_particle_count] = filename; @@ -221,6 +226,11 @@ const QString& MeasureAnalysisProjectModel::GetAllChannelEnergyTotalCountDataFil return this->_all_channel_energy_total_count_data_filename; } +const QString MeasureAnalysisProjectModel::GetParticleEnergyDataFilename() const +{ + return this->_particle_energy_data_filename; +} + const QMap MeasureAnalysisProjectModel::GetTimeWinConformParticleDataFilenameList(uint time_win) const { QMap conform_particle_data; @@ -309,23 +319,19 @@ bool MeasureAnalysisProjectModel::LoadProjectModel(const QString& project_filena this->_measure_device_params_cfg_filename = ProjectAbsFilename(json_obj["MeasureDeviceParamsCfgFilename"].toString()); this->_energy_scale_filename = ProjectAbsFilename(json_obj["EnergyScaleFilename"].toString()); this->_efficiency_scale_filename = ProjectAbsFilename(json_obj["EfficiencyScaleFilename"].toString()); - this->_all_channel_particle_data_filename = ProjectAbsFilename(json_obj["AllChannelParticleDataFilename"].toString()); - const auto& address_count_data_filename_list = json_obj["ChannelAddressCountDataFilenameList"].toObject().toVariantMap(); for (auto it = address_count_data_filename_list.constBegin(); it!=address_count_data_filename_list.constEnd(); ++it) { uint channel_num = it.key().toUInt(); this->_channel_address_count_data_filename_list[channel_num] = ProjectAbsFilename(it.value().toString()); } - const auto& energy_count_data_filename_list = json_obj["ChannelEnergyCountDataFilenameList"].toObject().toVariantMap(); for (auto it = energy_count_data_filename_list.constBegin(); it!=energy_count_data_filename_list.constEnd(); ++it) { uint channel_num = it.key().toUInt(); this->_channel_energy_count_data_filename_list[channel_num] = ProjectAbsFilename(it.value().toString()); } - this->_all_channel_energy_total_count_data_filename = ProjectAbsFilename(json_obj["AllChannelEnergyTotalCountDataFilename"].toString()); - + this->_particle_energy_data_filename = ProjectAbsFilename(json_obj["ParticleEnergyDataFilename"].toString()); const auto& time_win_conform_particle_data = json_obj["TimeWinConformParticleData"].toObject().toVariantMap(); for (auto it = time_win_conform_particle_data.constBegin(); it!=time_win_conform_particle_data.constEnd(); ++it) { uint time_win = it.key().toUInt(); @@ -337,7 +343,6 @@ bool MeasureAnalysisProjectModel::LoadProjectModel(const QString& project_filena // } this->_time_win_conform_particle_data[time_win] = conform_particle_data; } - return true; } @@ -391,6 +396,7 @@ bool MeasureAnalysisProjectModel::SaveProjectModel() } time_win_conform_particle_data[QString::number(it.key())] = conform_particle_data; } + project_json_obj_map["ParticleEnergyDataFilename"] = ProjectRelativeFilename(this->_particle_energy_data_filename); project_json_obj_map["TimeWinConformParticleData"] = time_win_conform_particle_data; // 将项目模型保存到json文件 @@ -536,8 +542,8 @@ QStandardItem* MeasureAnalysisProjectModelList::GetItemFromIndex(const QModelInd } QStandardItem* MeasureAnalysisProjectModelList::AddChildNode( - QStandardItem* parent_item, const QString& node_name, const QString& status, - const QVariant& user_data, bool is_fixed) + QStandardItem* parent_item, const QString& node_name, const QString& status_text, + const QVariant& user_data, bool is_fixed, bool state_ok) { if (!parent_item) return nullptr; @@ -545,9 +551,15 @@ QStandardItem* MeasureAnalysisProjectModelList::AddChildNode( QStandardItem* name_item = new QStandardItem(node_name); name_item->setData(user_data, NodeType); name_item->setData(is_fixed, Fixed); - - QStandardItem* status_item = new QStandardItem(status); - + QStandardItem* status_item = new QStandardItem(status_text); + status_item->setData(state_ok, Qt::UserRole); + if (state_ok) { + name_item->setForeground(Qt::black); + status_item->setForeground(Qt::black); + } else { + name_item->setForeground(Qt::gray); + status_item->setForeground(Qt::gray); + } QList row_items; row_items << name_item << status_item; parent_item->appendRow(row_items); @@ -593,7 +605,7 @@ QVariant MeasureAnalysisProjectModelList::GetNodeUserData(QStandardItem* item, U return (item && item->column() == NameColumn) ? item->data(data_type) : QVariant(); } -void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const QString& status) +void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const QString& status, bool state_ok) { if (!item || item->column() != NameColumn) return; @@ -602,17 +614,25 @@ void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const Q : invisibleRootItem()->child(item->row(), StatusColumn); if (status_item) { status_item->setText(status); + status_item->setData(state_ok, Qt::UserRole); + if (state_ok) { + status_item->setForeground(Qt::black); + } else { + status_item->setForeground(Qt::gray); + } } } -QString MeasureAnalysisProjectModelList::GetNodeStatus(QStandardItem* item) const +bool MeasureAnalysisProjectModelList::GetNodeStatus(QStandardItem* item) const { if (!item || item->column() != NameColumn) - return QString(); + return false; QStandardItem* status_item = item->parent() ? item->parent()->child(item->row(), StatusColumn) : invisibleRootItem()->child(item->row(), StatusColumn); - return status_item ? status_item->text() : QString(); + if ( !status_item ) + return false; + return status_item->data(Qt::UserRole).toBool(); } void MeasureAnalysisProjectModelList::ApplyEnergyScale(const QString &project_name) @@ -649,18 +669,15 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool if (this->_project_models.contains(project_name)) { auto pro_model = this->_project_models[project_name]; const QMap& filename_list = pro_model->GetChannelAddressCountDataFilenameList(); - QString status = QStringLiteral(u"无效"); if (!filename_list.isEmpty()) { status = QStringLiteral(u"有效"); } - auto& node_map = this->_project_node_items[project_name]; const QString& adrr_count_item_name = QStringLiteral(u"道址计数"); if (node_map.contains(adrr_count_item_name)) { auto adrr_count_item = node_map[adrr_count_item_name]; this->SetNodeStatus(adrr_count_item, status); - for (auto it = filename_list.begin(); it != filename_list.end(); ++it) { uint ch_num = it.key(); QString item_name = QStringLiteral(u"通道%1道址计数").arg(ch_num); @@ -671,23 +688,16 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool node_map[item_name] = node_item; } } - const QString& adrr_count_spec_item_name = QStringLiteral(u"道址计数谱"); if (node_map.contains(adrr_count_spec_item_name)) { auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; this->SetNodeStatus(adrr_count_spec_item, status); } - pro_model->SaveProjectModel(); } } void MeasureAnalysisProjectModelList::onEnergyScaleParticleDataFinished(bool ok, const QString &project_name, const QVariant &data) -{ - -} - -void MeasureAnalysisProjectModelList::onEnergyCountProcessFinished(bool ok, const QString &project_name, const QVariant &data) { Q_UNUSED(data); if ( !ok ) @@ -725,9 +735,121 @@ void MeasureAnalysisProjectModelList::onEnergyCountProcessFinished(bool ok, cons } } +void MeasureAnalysisProjectModelList::onEnergyCountProcessFinished(bool ok, const QString &project_name, const QVariant &data) +{ + Q_UNUSED(data); + if ( !ok ) + return; + if (this->_project_models.contains(project_name)) { + auto pro_model = this->_project_models[project_name]; + auto& node_map = this->_project_node_items[project_name]; + bool status_ok = false; + QString status = QStringLiteral(u"无效"); + const QString& energy_total_count_filename = pro_model->GetAllChannelEnergyTotalCountDataFilename(); + if (!energy_total_count_filename.isEmpty()) { + status_ok = true; + status = QStringLiteral(u"有效"); + const QString& energy_total_count_item_name = QStringLiteral(u"能量计数"); + if (node_map.contains(energy_total_count_item_name)) { + auto energy_total_count_item = node_map[energy_total_count_item_name]; + this->SetNodeStatus(energy_total_count_item, status, status_ok); + const QMap& channel_energy_count_filename_list = pro_model->GetChannelEnergyCountDataFilenameList(); + for (auto it = channel_energy_count_filename_list.constBegin(); it != channel_energy_count_filename_list.constEnd(); ++it) { + uint ch_num = it.key(); + QString item_name = QStringLiteral(u"通道%1能量计数").arg(ch_num); + if ( !node_map.contains(item_name) ) { + const QVariant& analys_type = QVariant::fromValue(AnalysisType::EnergyCountData); + QStandardItem* node_item = AddChildNode(energy_total_count_item, item_name, status, analys_type, true, status_ok); + node_item->setData(project_name, ProjectName); + node_item->setData(ch_num, ChannelNum); + node_map[item_name] = node_item; + } else { + auto ch_energy_count_item = node_map[item_name]; + this->SetNodeStatus(ch_energy_count_item, status, status_ok); + } + } + const auto& ch_energy_count_data_list = pro_model->GetChannelEnergyCountDataFilenameList(); + if (!ch_energy_count_data_list.isEmpty()) { + const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱"); + if (node_map.contains(adrr_count_spec_item_name)) { + auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; + this->SetNodeStatus(adrr_count_spec_item, status); + } + } + } + } + const QString& particle_energy_data_filename = pro_model->GetParticleEnergyDataFilename(); + if (!particle_energy_data_filename.isEmpty()) { + status_ok = true; + status = QStringLiteral(u"有效"); + const QString& count_rate_analysis_item_name = QStringLiteral(u"计数率分析"); + if (node_map.contains(count_rate_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[count_rate_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& peak_fit_analysis_item_name = QStringLiteral(u"峰拟合分析"); + if (node_map.contains(peak_fit_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[peak_fit_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& nuclide_analysis_item_name = QStringLiteral(u"核素分析"); + if (node_map.contains(nuclide_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[nuclide_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& particle_in_time_analysis_item_name = QStringLiteral(u"粒子入射时间分析"); + if (node_map.contains(particle_in_time_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[particle_in_time_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + } + pro_model->SaveProjectModel(); + } +} + void MeasureAnalysisProjectModelList::onCoincidenceProcessFinished(bool ok, const QString &project_name, const QVariant &data) { - + Q_UNUSED(data); + if ( !ok ) + return; + if (this->_project_models.contains(project_name)) { + auto pro_model = this->_project_models[project_name]; + auto& node_map = this->_project_node_items[project_name]; + bool status_ok = false; + QString status = QStringLiteral(u"无效"); + uint conform_time_win = pro_model->GetConformTimeWin(); + const auto& Conform_energy_data_filename_list = pro_model->GetTimeWinConformEnergyDataFilenameList(conform_time_win); + if (!Conform_energy_data_filename_list.isEmpty()) { + status_ok = true; + status = QStringLiteral(u"有效"); + QString item_name = QStringLiteral(u"符合事件时间分析"); + if (node_map.contains(item_name)) { + auto energy_total_count_item = node_map[item_name]; + this->SetNodeStatus(energy_total_count_item, status, status_ok); + } + item_name = QStringLiteral(u"符合能谱[%1ns]").arg(conform_time_win); + if (node_map.contains(item_name)) { + auto energy_total_count_spec_item = node_map[item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + item_name = QStringLiteral(u"反符合能谱[%1ns]").arg(conform_time_win); + if (node_map.contains(item_name)) { + auto energy_total_count_spec_item = node_map[item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + item_name = QStringLiteral(u"二维符合能谱[%1ns]").arg(conform_time_win); + if (node_map.contains(item_name)) { + auto energy_total_count_spec_item = node_map[item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + item_name = QStringLiteral(u"三维符合能谱[%1ns]").arg(conform_time_win); + if (node_map.contains(item_name)) { + auto energy_total_count_spec_item = node_map[item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + } + pro_model->SaveProjectModel(); + } } void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProjectModel* pro_model) @@ -742,57 +864,60 @@ void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProje const QString& project_name = pro_model->GetProjectName(); QString status = pro_model->GetIsMeasureComplete() ? QStringLiteral(u"测量完成") : QStringLiteral(u"未测量"); QVariant analys_type = QVariant::fromValue(AnalysisType::Project); - QStandardItem* project_item = AddChildNode(root_item, project_name, status, analys_type, false); + QStandardItem* project_item = AddChildNode(root_item, project_name, status, analys_type, false, true); project_item->setData(project_name, ProjectName); node_map[project_name] = project_item; // 测量控制 QString item_name = QStringLiteral(u"测量控制"); - QStandardItem* measure_ctrl_item = AddChildNode(project_item, item_name, QString(), QVariant(), true); + QStandardItem* measure_ctrl_item = AddChildNode(project_item, item_name, QString(), QVariant(), true, true); measure_ctrl_item->setData(project_name, ProjectName); node_map[item_name] = measure_ctrl_item; - if (!pro_model->GetIsMeasureComplete()) { - const QString& measure_device_params_cfg_filename = pro_model->GetMeasureDeviceParamsCfgFilename(); - status = measure_device_params_cfg_filename.isEmpty() ? QStringLiteral(u"未配置") : QStringLiteral(u"已配置"); - analys_type = QVariant::fromValue(AnalysisType::DeviceParamsCfg); - item_name = QStringLiteral(u"设备配置参数"); - QStandardItem* node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true); - node_item->setData(project_name, ProjectName); - node_map[item_name] = node_item; - } - - status = pro_model->GetEnergyScaleFilename().isEmpty() ? QStringLiteral(u"未配置") : QStringLiteral(u"已配置"); - analys_type = QVariant::fromValue(AnalysisType::EnergyScale); - item_name = QStringLiteral(u"能量刻度"); - QStandardItem* node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true); + const QString& measure_device_params_cfg_filename = pro_model->GetMeasureDeviceParamsCfgFilename(); + bool state_ok = !measure_device_params_cfg_filename.isEmpty(); + status = state_ok ? QStringLiteral(u"已配置") : QStringLiteral(u"未配置"); + analys_type = QVariant::fromValue(AnalysisType::DeviceParamsCfg); + item_name = QStringLiteral(u"设备配置参数"); + QStandardItem* node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetEfficiencyScaleFilename().isEmpty() ? QStringLiteral(u"未配置") : QStringLiteral(u"已配置"); + state_ok = !pro_model->GetEnergyScaleFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"已配置") : QStringLiteral(u"未配置"); + analys_type = QVariant::fromValue(AnalysisType::EnergyScale); + item_name = QStringLiteral(u"能量刻度"); + node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true, state_ok); + node_item->setData(project_name, ProjectName); + node_map[item_name] = node_item; + + state_ok = !pro_model->GetEfficiencyScaleFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"已配置") : QStringLiteral(u"未配置"); analys_type = QVariant::fromValue(AnalysisType::EfficiencyScale); item_name = QStringLiteral(u"效率刻度"); - node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true); + node_item = AddChildNode(measure_ctrl_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; // 分析数据 item_name = QStringLiteral(u"分析数据"); - QStandardItem* analysis_data_item = AddChildNode(project_item, item_name, QString(), QVariant(), true); + QStandardItem* analysis_data_item = AddChildNode(project_item, item_name, QString(), QVariant(), true, true); analysis_data_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelParticleDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetAllChannelParticleDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::ParticleData); item_name = QStringLiteral(u"测量粒子数据"); - node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true); + node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - item_name = QStringLiteral(u"道址计数"); const auto& ch_addr_count_data_filename_list = pro_model->GetChannelAddressCountDataFilenameList(); - status = ch_addr_count_data_filename_list.isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); - node_item = AddChildNode(analysis_data_item, item_name, status, QVariant(), true); + state_ok = !ch_addr_count_data_filename_list.isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); + item_name = QStringLiteral(u"道址计数"); + node_item = AddChildNode(analysis_data_item, item_name, status, QVariant(), true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; QStandardItem* adrr_count_item = node_item; @@ -800,128 +925,147 @@ void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProje uint ch_num = it.key(); QString item_name = QStringLiteral(u"通道%1道址计数").arg(ch_num); const QVariant& analys_type = QVariant::fromValue(AnalysisType::AddressCountData); - QStandardItem* node_item = AddChildNode(adrr_count_item, item_name, status, analys_type, true); + QStandardItem* node_item = AddChildNode(adrr_count_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_item->setData(ch_num, ChannelNum); node_map[item_name] = node_item; } + state_ok = !pro_model->GetParticleEnergyDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); + analys_type = QVariant::fromValue(AnalysisType::CoincidenceParticleEnergyData); + item_name = QStringLiteral(u"粒子能量数据"); + node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true, state_ok); + node_item->setData(project_name, ProjectName); + node_map[item_name] = node_item; + + state_ok = !pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); item_name = QStringLiteral(u"能量计数"); - status = pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); analys_type = QVariant::fromValue(AnalysisType::EnergyCountData); - node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true); + node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; QStandardItem* energy_count_item = node_item; const auto& ch_energy_count_data_filename_list = pro_model->GetChannelEnergyCountDataFilenameList(); + state_ok = !ch_energy_count_data_filename_list.isEmpty(); for (auto it = ch_energy_count_data_filename_list.begin(); it != ch_energy_count_data_filename_list.end(); ++it) { uint ch_num = it.key(); QString item_name = QStringLiteral(u"通道%1能量计数").arg(ch_num); const QVariant& analys_type = QVariant::fromValue(AnalysisType::EnergyCountData); - QStandardItem* node_item = AddChildNode(energy_count_item, item_name, status, analys_type, true); + QStandardItem* node_item = AddChildNode(energy_count_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_item->setData(ch_num, ChannelNum); node_map[item_name] = node_item; } uint conform_time_win = pro_model->GetConformTimeWin(); - status = pro_model->GetTimeWinConformParticleDataFilenameList(conform_time_win).isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetTimeWinConformParticleDataFilenameList(conform_time_win).isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CoincidenceParticleEnergyData); item_name = QStringLiteral(u"符合粒子数据[%1ns]").arg(conform_time_win); - node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true); + node_item = AddChildNode(analysis_data_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; // 交互分析 item_name = QStringLiteral(u"交互分析"); - QStandardItem* interactive_analysis_item = AddChildNode(project_item, item_name, QString(), QVariant(), true); + QStandardItem* interactive_analysis_item = AddChildNode(project_item, item_name, QString(), QVariant(), true, true); interactive_analysis_item->setData(project_name, ProjectName); node_map[item_name] = interactive_analysis_item; - status = pro_model->GetChannelAddressCountDataFilenameList().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetChannelAddressCountDataFilenameList().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::AddressCountSpectrumView); item_name = QStringLiteral(u"道址计数谱"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetChannelEnergyCountDataFilenameList().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); - analys_type = QVariant::fromValue(AnalysisType::EnergyCountSpectrumView); - item_name = QStringLiteral(u"通道能量计数谱"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); - node_item->setData(project_name, ProjectName); - node_map[item_name] = node_item; - - status = pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty(); + state_ok &= pro_model->GetChannelEnergyCountDataFilenameList().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::EnergyCountSpectrumView); item_name = QStringLiteral(u"能量计数谱"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelParticleDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetParticleEnergyDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CountingRateView); item_name = QStringLiteral(u"计数率分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetParticleEnergyDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::EnergyPeakFitView); item_name = QStringLiteral(u"峰拟合分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetParticleEnergyDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::NuclideAnalysisView); item_name = QStringLiteral(u"核素分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelParticleDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetParticleEnergyDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::ParticleInTimeView); item_name = QStringLiteral(u"粒子入射时间分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetAllChannelParticleDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetAllChannelParticleDataFilename().isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::ParticleTimeDiffView); item_name = QStringLiteral(u"粒子时间差分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; - status = pro_model->GetTimeWinConformParticleDataFilenameList(conform_time_win).isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效"); + state_ok = !pro_model->GetTimeWinConformEnergyDataFilenameList(conform_time_win).isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CoincidenceEventTimeView); item_name = QStringLiteral(u"符合事件时间分析"); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; + state_ok = !pro_model->GetTimeWinConformEnergyDataFilenameList(conform_time_win).isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CoincidenceParticleEnergySpectrumView); item_name = QStringLiteral(u"符合能谱[%1ns]").arg(conform_time_win); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; analys_type = QVariant::fromValue(AnalysisType::AntiCoincidenceSpectrumView); item_name = QStringLiteral(u"反符合能谱[%1ns]").arg(conform_time_win); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; + state_ok = !pro_model->GetTimeWinConformEnergyDataFilenameList(conform_time_win).isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CoincidenceParticleEnergySpectrum2DView); item_name = QStringLiteral(u"二维符合能谱[%1ns]").arg(conform_time_win); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; + state_ok = !pro_model->GetTimeWinConformEnergyDataFilenameList(conform_time_win).isEmpty(); + status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); analys_type = QVariant::fromValue(AnalysisType::CoincidenceParticleEnergySpectrum3DView); item_name = QStringLiteral(u"三维符合能谱[%1ns]").arg(conform_time_win); - node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true); + node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true, state_ok); node_item->setData(project_name, ProjectName); node_map[item_name] = node_item; diff --git a/src/MeasureAnalysisProjectModel.h b/src/MeasureAnalysisProjectModel.h index 53325bc..74801ab 100644 --- a/src/MeasureAnalysisProjectModel.h +++ b/src/MeasureAnalysisProjectModel.h @@ -37,6 +37,7 @@ public: // void SetAllChannelParticleTotalCountDataFilename(const QString& filename); void SetChannelEnergyCountDataFilename(uint channel, const QString& filename); void SetAllChannelEnergyTotalCountDataFilename(const QString& filename); + void SetParticleEnergyDataFilename(const QString& filename); void SetTimeWinConformParticleData(uint time_win, uint conform_particle_count, const QString& filename); void SetTimeWinConformEnergyData(uint time_win, uint conform_particle_count, const QString& filename); void SetAnalysisCustomData(AnalysisType analysis_type, const QString& data_item_name, const QString& data_filename); @@ -61,6 +62,7 @@ public: const QMap& GetChannelEnergyCountDataFilenameList() const; const QString GetChannelEnergyCountDataFilename(uint channel) const; const QString& GetAllChannelEnergyTotalCountDataFilename() const; + const QString GetParticleEnergyDataFilename() const; const QMap GetTimeWinConformParticleDataFilenameList(uint time_win) const; const QMap GetTimeWinConformEnergyDataFilenameList(uint time_win) const; const QString GetAnalysisCustomData(AnalysisType analysis_type, const QString& data_item_name); @@ -84,6 +86,7 @@ private: // QString _all_channel_particle_total_count_data_filename; QMap _channel_energy_count_data_filename_list; QString _all_channel_energy_total_count_data_filename; + QString _particle_energy_data_filename; QMap > _time_win_conform_particle_data; QMap > _time_win_conform_energy_data; QMap > _analysis_custom_data_set; @@ -125,14 +128,15 @@ public: QStandardItem* GetItemFromIndex(const QModelIndex &index) const; QStandardItem* AddChildNode(QStandardItem *parent_item, const QString &node_name, - const QString &status = QString(), + const QString &status_text = QString(), const QVariant &user_data = QVariant(), - bool is_fixed = false); + bool is_fixed = false, + bool state_ok = false); bool RemoveNode(QStandardItem *item); void SetNodeUserData(QStandardItem* item, const QVariant& data); QVariant GetNodeUserData(QStandardItem* item, UserDataType data_type = NodeType) const; - void SetNodeStatus(QStandardItem* item, const QString& status); - QString GetNodeStatus(QStandardItem* item) const; + void SetNodeStatus(QStandardItem* item, const QString& status, bool state_ok = false); + bool GetNodeStatus(QStandardItem* item) const; void ApplyEnergyScale(const QString& project_name);