Compare commits

..

No commits in common. "03225795ad710350e53995508b9aa0797bc5cf39" and "1cb0145073f36a12c672a828a9e93572381a2584" have entirely different histories.

2 changed files with 52 additions and 38 deletions

View File

@ -348,7 +348,6 @@ 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() ) {
@ -408,8 +407,6 @@ 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;
} }
@ -619,10 +616,8 @@ 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);
} }
} }
@ -645,16 +640,14 @@ 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, status_ok); this->SetNodeStatus(energy_scale_item, status);
} }
pro_model->SaveProjectModel(); pro_model->SaveProjectModel();
@ -676,22 +669,20 @@ 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, status_ok); this->SetNodeStatus(adrr_count_item, status);
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, status_ok); QStandardItem* node_item = AddChildNode(adrr_count_item, item_name, status, analys_type, true);
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;
@ -700,7 +691,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, status_ok); this->SetNodeStatus(adrr_count_spec_item, status);
} }
pro_model->SaveProjectModel(); pro_model->SaveProjectModel();
} }
@ -714,31 +705,30 @@ 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();
if (!particle_energy_data_filename.isEmpty()) { const QString& energy_total_count_filename = pro_model->GetAllChannelEnergyTotalCountDataFilename();
status_ok = true; if (!energy_total_count_filename.isEmpty()) {
status = QStringLiteral(u"有效"); status = QStringLiteral(u"有效");
const QString& count_rate_analysis_item_name = QStringLiteral(u"计数率分析"); const QString& energy_total_count_item_name = QStringLiteral(u"能量计数");
if (node_map.contains(count_rate_analysis_item_name)) { if (node_map.contains(energy_total_count_item_name)) {
auto energy_total_count_spec_item = node_map[count_rate_analysis_item_name]; auto energy_total_count_item = node_map[energy_total_count_item_name];
this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); this->SetNodeStatus(energy_total_count_item, status);
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& peak_fit_analysis_item_name = QStringLiteral(u"峰拟合分析"); const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱");
if (node_map.contains(peak_fit_analysis_item_name)) { if (node_map.contains(adrr_count_spec_item_name)) {
auto energy_total_count_spec_item = node_map[peak_fit_analysis_item_name]; auto adrr_count_spec_item = node_map[adrr_count_spec_item_name];
this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); this->SetNodeStatus(adrr_count_spec_item, status);
} }
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();
@ -783,11 +773,36 @@ 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, status_ok); 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(); pro_model->SaveProjectModel();
} }
} }

View File

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