Compare commits

...

2 Commits

2 changed files with 38 additions and 52 deletions

View File

@ -348,6 +348,7 @@ bool MeasureAnalysisProjectModel::LoadProjectModel(const QString& project_filena
bool MeasureAnalysisProjectModel::SaveProjectModel() bool MeasureAnalysisProjectModel::SaveProjectModel()
{ {
_save_mutex.lock();
auto ProjectRelativeFilename = [this](const QString& abs_filename) { auto ProjectRelativeFilename = [this](const QString& abs_filename) {
QString project_relative_filename; QString project_relative_filename;
if ( !abs_filename.isEmpty() ) { if ( !abs_filename.isEmpty() ) {
@ -407,6 +408,8 @@ bool MeasureAnalysisProjectModel::SaveProjectModel()
} }
json_file.write(json_doc.toJson()); json_file.write(json_doc.toJson());
json_file.close(); json_file.close();
_save_mutex.unlock();
return true; return true;
} }
@ -616,8 +619,10 @@ void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const Q
status_item->setText(status); status_item->setText(status);
status_item->setData(state_ok, Qt::UserRole); status_item->setData(state_ok, Qt::UserRole);
if (state_ok) { if (state_ok) {
item->setForeground(Qt::black);
status_item->setForeground(Qt::black); status_item->setForeground(Qt::black);
} else { } else {
item->setForeground(Qt::gray);
status_item->setForeground(Qt::gray); status_item->setForeground(Qt::gray);
} }
} }
@ -640,14 +645,16 @@ void MeasureAnalysisProjectModelList::ApplyEnergyScale(const QString &project_na
if (this->_project_models.contains(project_name)) { if (this->_project_models.contains(project_name)) {
auto pro_model = this->_project_models[project_name]; auto pro_model = this->_project_models[project_name];
const QString& energy_scale_filename = pro_model->GetEnergyScaleFilename(); const QString& energy_scale_filename = pro_model->GetEnergyScaleFilename();
bool status_ok = false;
QString status = QStringLiteral(u"未配置"); QString status = QStringLiteral(u"未配置");
if (!energy_scale_filename.isEmpty()) { if (!energy_scale_filename.isEmpty()) {
status_ok = true;
status = QStringLiteral(u"已配置"); status = QStringLiteral(u"已配置");
auto& node_map = this->_project_node_items[project_name]; auto& node_map = this->_project_node_items[project_name];
const QString& energy_scale_item_name = QStringLiteral(u"能量刻度"); const QString& energy_scale_item_name = QStringLiteral(u"能量刻度");
if (node_map.contains(energy_scale_item_name)) { if (node_map.contains(energy_scale_item_name)) {
auto energy_scale_item = node_map[energy_scale_item_name]; auto energy_scale_item = node_map[energy_scale_item_name];
this->SetNodeStatus(energy_scale_item, status); this->SetNodeStatus(energy_scale_item, status, status_ok);
} }
pro_model->SaveProjectModel(); pro_model->SaveProjectModel();
@ -669,20 +676,22 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool
if (this->_project_models.contains(project_name)) { if (this->_project_models.contains(project_name)) {
auto pro_model = this->_project_models[project_name]; auto pro_model = this->_project_models[project_name];
const QMap<uint, QString>& filename_list = pro_model->GetChannelAddressCountDataFilenameList(); const QMap<uint, QString>& filename_list = pro_model->GetChannelAddressCountDataFilenameList();
bool status_ok = false;
QString status = QStringLiteral(u"无效"); QString status = QStringLiteral(u"无效");
if (!filename_list.isEmpty()) { if (!filename_list.isEmpty()) {
status_ok = true;
status = QStringLiteral(u"有效"); status = QStringLiteral(u"有效");
} }
auto& node_map = this->_project_node_items[project_name]; auto& node_map = this->_project_node_items[project_name];
const QString& adrr_count_item_name = QStringLiteral(u"道址计数"); const QString& adrr_count_item_name = QStringLiteral(u"道址计数");
if (node_map.contains(adrr_count_item_name)) { if (node_map.contains(adrr_count_item_name)) {
auto adrr_count_item = node_map[adrr_count_item_name]; auto adrr_count_item = node_map[adrr_count_item_name];
this->SetNodeStatus(adrr_count_item, status); this->SetNodeStatus(adrr_count_item, status, status_ok);
for (auto it = filename_list.begin(); it != filename_list.end(); ++it) { for (auto it = filename_list.begin(); it != filename_list.end(); ++it) {
uint ch_num = it.key(); uint ch_num = it.key();
QString item_name = QStringLiteral(u"通道%1道址计数").arg(ch_num); QString item_name = QStringLiteral(u"通道%1道址计数").arg(ch_num);
const QVariant& analys_type = QVariant::fromValue(AnalysisType::AddressCountData); 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, status_ok);
node_item->setData(project_name, ProjectName); node_item->setData(project_name, ProjectName);
node_item->setData(ch_num, ChannelNum); node_item->setData(ch_num, ChannelNum);
node_map[item_name] = node_item; node_map[item_name] = node_item;
@ -691,7 +700,7 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool
const QString& adrr_count_spec_item_name = QStringLiteral(u"道址计数谱"); const QString& adrr_count_spec_item_name = QStringLiteral(u"道址计数谱");
if (node_map.contains(adrr_count_spec_item_name)) { if (node_map.contains(adrr_count_spec_item_name)) {
auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; auto adrr_count_spec_item = node_map[adrr_count_spec_item_name];
this->SetNodeStatus(adrr_count_spec_item, status); this->SetNodeStatus(adrr_count_spec_item, status, status_ok);
} }
pro_model->SaveProjectModel(); pro_model->SaveProjectModel();
} }
@ -705,30 +714,31 @@ void MeasureAnalysisProjectModelList::onEnergyScaleParticleDataFinished(bool ok,
if (this->_project_models.contains(project_name)) { if (this->_project_models.contains(project_name)) {
auto pro_model = this->_project_models[project_name]; auto pro_model = this->_project_models[project_name];
auto& node_map = this->_project_node_items[project_name]; auto& node_map = this->_project_node_items[project_name];
bool status_ok = false;
QString status = QStringLiteral(u"无效"); QString status = QStringLiteral(u"无效");
const QString& particle_energy_data_filename = pro_model->GetParticleEnergyDataFilename();
const QString& energy_total_count_filename = pro_model->GetAllChannelEnergyTotalCountDataFilename(); if (!particle_energy_data_filename.isEmpty()) {
if (!energy_total_count_filename.isEmpty()) { status_ok = true;
status = QStringLiteral(u"有效"); status = QStringLiteral(u"有效");
const QString& energy_total_count_item_name = QStringLiteral(u"能量计数"); const QString& count_rate_analysis_item_name = QStringLiteral(u"计数率分析");
if (node_map.contains(energy_total_count_item_name)) { if (node_map.contains(count_rate_analysis_item_name)) {
auto energy_total_count_item = node_map[energy_total_count_item_name]; auto energy_total_count_spec_item = node_map[count_rate_analysis_item_name];
this->SetNodeStatus(energy_total_count_item, status); this->SetNodeStatus(energy_total_count_spec_item, status, status_ok);
const QMap<uint, QString>& 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);
const QVariant& analys_type = QVariant::fromValue(AnalysisType::EnergyCountData);
QStandardItem* node_item = AddChildNode(energy_total_count_item, item_name, status, analys_type, true);
node_item->setData(project_name, ProjectName);
node_item->setData(ch_num, ChannelNum);
node_map[item_name] = node_item;
} }
const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱"); const QString& peak_fit_analysis_item_name = QStringLiteral(u"峰拟合分析");
if (node_map.contains(adrr_count_spec_item_name)) { if (node_map.contains(peak_fit_analysis_item_name)) {
auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; auto energy_total_count_spec_item = node_map[peak_fit_analysis_item_name];
this->SetNodeStatus(adrr_count_spec_item, status); 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(); pro_model->SaveProjectModel();
@ -773,36 +783,11 @@ void MeasureAnalysisProjectModelList::onEnergyCountProcessFinished(bool ok, cons
const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱"); const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱");
if (node_map.contains(adrr_count_spec_item_name)) { if (node_map.contains(adrr_count_spec_item_name)) {
auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; auto adrr_count_spec_item = node_map[adrr_count_spec_item_name];
this->SetNodeStatus(adrr_count_spec_item, status); this->SetNodeStatus(adrr_count_spec_item, status, status_ok);
} }
} }
} }
} }
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(); pro_model->SaveProjectModel();
} }
} }

View File

@ -4,6 +4,7 @@
#include <QObject> #include <QObject>
#include <QMap> #include <QMap>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QMutex>
#include "AnalysisTypeDefine.h" #include "AnalysisTypeDefine.h"
class MeasureAnalysisView; class MeasureAnalysisView;