Conflicts:
	src/MeasureAnalysisView.cpp
	src/src.pro
This commit is contained in:
anxinglong 2026-03-25 11:51:13 +08:00
commit f0e254300a
14 changed files with 383 additions and 57 deletions

View File

@ -863,15 +863,17 @@ bool EnergyCountProcessTask::processTask()
LOG_WARN(QStringLiteral(u"创建能量计数数据目录\"%1\"异常!").arg(out_path)); LOG_WARN(QStringLiteral(u"创建能量计数数据目录\"%1\"异常!").arg(out_path));
return false; return false;
} }
std::string address_str = QString(QStringLiteral(u"道址")).toStdString();
std::string energy_str = QString(QStringLiteral(u"能量(KeV)")).toStdString();
std::string count_str = QString(QStringLiteral(u"计数")).toStdString();
double bin_width = 0.1f;
std::map<double, unsigned long long> stat_map;
for (const uint& channel_num : ch_addr_count_filename_list.keys()) { for (const uint& channel_num : ch_addr_count_filename_list.keys()) {
const QString& channel_name = QStringLiteral(u"通道%1").arg(channel_num); const QString& channel_name = QStringLiteral(u"通道%1").arg(channel_num);
const QString& data_filename = ch_addr_count_filename_list[channel_num]; const QString& data_filename = ch_addr_count_filename_list[channel_num];
std::string address_str = QString(QStringLiteral(u"道址")).toStdString(); const QString& ch_out_filename = QDir(out_path).filePath(channel_name + ".csv");
std::string energy_str = QString(QStringLiteral(u"能量(KeV)")).toStdString(); std::ofstream ch_out(QStrToSysPath(ch_out_filename));
std::string count_str = QString(QStringLiteral(u"计数")).toStdString(); ch_out << energy_str << "," << count_str << "\n" ;
const QString& out_filename = QDir(out_path).filePath(channel_name + ".csv");
std::ofstream out(QStrToSysPath(out_filename));
out << energy_str << "," << count_str << "\n" ;
try { try {
io::CSVReader< io::CSVReader<
2, 2,
@ -887,18 +889,31 @@ bool EnergyCountProcessTask::processTask()
auto coeffs = energy_scale_data_model.GetEnergyFitResultCoeffs(channel_name); auto coeffs = energy_scale_data_model.GetEnergyFitResultCoeffs(channel_name);
if (!coeffs.empty()) { if (!coeffs.empty()) {
double energy = GaussPolyCoe::Predict(coeffs, address); double energy = GaussPolyCoe::Predict(coeffs, address);
out << energy << "," << count << "\n"; ch_out << energy << "," << count << "\n";
// 计算属于哪个能量 bin
double bin_energy = floor(energy / bin_width) * bin_width;
// 统一保留 3 位
bin_energy = round(bin_energy * 1000) / 1000.0;
stat_map[bin_energy] += count;
} }
} }
out.close(); ch_out.close();
project_model->SetChannelEnergyCountDataFilename(channel_num, out_filename); project_model->SetChannelEnergyCountDataFilename(channel_num, ch_out_filename);
} catch (const std::exception& e) { } catch (const std::exception& e) {
out.close(); ch_out.close();
std::remove(QStrToSysPath(out_filename)); std::remove(QStrToSysPath(ch_out_filename));
const QString& e_what = QString::fromStdString(e.what()); const QString& e_what = QString::fromStdString(e.what());
LOG_WARN(QStringLiteral(u"%1能量计数异常:%2").arg(channel_name).arg(e_what)); LOG_WARN(QStringLiteral(u"%1能量计数异常:%2").arg(channel_name).arg(e_what));
} }
} }
const QString& out_filename = QDir(out_path).filePath(QStringLiteral(u"全通道.csv"));
std::ofstream out(QStrToSysPath(out_filename));
out << energy_str << "," << count_str << "\n" ;
for (const auto& [energy, count] : stat_map) {
out << energy << "," << count << "\n";
}
project_model->SetAllChannelEnergyTotalCountDataFilename(out_filename);
const QString& info = QStringLiteral(u"能量计数处理完成."); const QString& info = QStringLiteral(u"能量计数处理完成.");
LOG_INFO(info); LOG_INFO(info);
return true; return true;

View File

@ -0,0 +1,220 @@
#include "EnergyCountPlotView.h"
#include "CustomQwtPlot.h"
#include "csv.h"
#include <GlobalDefine.h>
#include <QHBoxLayout>
#include <QMenu>
#include <QwtLegend>
#include <QwtPlotCanvas>
#include <QwtPlotCurve>
#include <QwtPlotMarker>
#include <QwtScaleMap>
#include <QwtText>
#include <QDialog>
#include <QPushButton>
#include <QCheckBox>
EnergyCountPlotView::EnergyCountPlotView(QWidget *parent)
: MeasureAnalysisView { parent }
{
this->setViewType(PlotFrame);
QHBoxLayout* layout = new QHBoxLayout(this);
this->_plot = new CustomQwtPlot(this);
layout->addWidget(this->_plot);
setupPlot();
this->_menu = new QMenu(this);
setupMenu();
}
EnergyCountPlotView::~EnergyCountPlotView()
{
LOG_DEBUG(QStringLiteral(u"%1析构.").arg(this->GetViewName()));
}
void EnergyCountPlotView::InitViewWorkspace(const QString &project_name)
{
Q_UNUSED(project_name);
}
void EnergyCountPlotView::SetAnalyzeDataFilename(const QMap<QString, QVariant> &data_files_set)
{
QStringList ch_count_data_name = data_files_set.keys();
std::sort(ch_count_data_name.begin(), ch_count_data_name.end(), [](const QString& a, const QString& b) {
int num_a = ExtractNumberFromString(a);
int num_b = ExtractNumberFromString(b);
return num_a < num_b;
});
for (const QString& ch_count_data_name : ch_count_data_name) {
if (ch_count_data_name.contains(ch_count_data_name)) {
const QString ch_count_data_filename = data_files_set[ch_count_data_name].toString();
loadDataFromFile(ch_count_data_name, ch_count_data_filename);
}
}
}
void EnergyCountPlotView::setupPlot()
{
_plot->setTitle(QString(QStringLiteral(u"能量计数谱")));
_plot->setCanvasBackground(Qt::white);
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(_plot->canvas());
canvas->setFrameStyle(QFrame::NoFrame);
_plot->setAxisTitle(QwtPlot::xBottom, QString(QStringLiteral(u"能量")));
_plot->setAxisTitle(QwtPlot::yLeft, QString(QStringLiteral(u"计数")));
// set axis auto scale
_plot->setAxisAutoScale(QwtPlot::xBottom, true);
_plot->setAxisAutoScale(QwtPlot::yLeft, true);
// 启用网格线
_plot->enableAxis(QwtPlot::xBottom);
_plot->enableAxis(QwtPlot::yLeft);
// 设置QWT图例
QwtLegend* legend = new QwtLegend();
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
_plot->insertLegend(legend, QwtPlot::RightLegend);
_plot->SetXaxisDragScale(true);
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
_data_selector->setEnabled(false);
}
void EnergyCountPlotView::setupMenu()
{
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &EnergyCountPlotView::customContextMenuRequested, [this](const QPoint& pos) {
this->_menu->exec(this->mapToGlobal(pos));
});
QAction* action_plot_reset = this->_menu->addAction(QStringLiteral(u"还原"));
action_plot_reset->setObjectName("plot_reset");
connect(action_plot_reset, &QAction::triggered, [this]() {
this->_plot->ResetPlot();
});
this->_menu->addSeparator();
QAction* action_set_curve_show = this->_menu->addAction(QStringLiteral(u"选择曲线"));
action_set_curve_show->setObjectName("curve_show_setting");
connect(action_set_curve_show, &QAction::triggered, this, &EnergyCountPlotView::onActionCurveShowSetting);
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
action_plot_config->setObjectName("plot_config");
connect(action_plot_config, &QAction::triggered, this, &EnergyCountPlotView::onActionPlotConfigure);
}
void EnergyCountPlotView::loadDataFromFile(const QString &data_name, const QString &filename)
{
std::string address_str = QString(QStringLiteral(u"能量(KeV)")).toStdString();
std::string count_str = QString(QStringLiteral(u"计数")).toStdString();
io::CSVReader<
2,
io::trim_chars<' ', '\t'>,
io::double_quote_escape<',', '"'>,
io::throw_on_overflow,
io::empty_line_comment>
reader(QStrToSysPath(filename));
reader.read_header(io::ignore_extra_column, address_str, count_str);
double energy;
unsigned long long energy_count;
QVector<double> x, y;
while (reader.read_row(energy, energy_count)) {
x.push_back(energy);
y.push_back(energy_count);
}
// 绘制曲线
QwtPlotCurve* curve = new QwtPlotCurve(data_name);
curve->setSamples(x, y);
_plot->AddCurve(curve);
}
void EnergyCountPlotView::onActionCurveShowSetting()
{
if (!_curve_show_setting_dlg) {
_curve_show_setting_dlg = new QDialog(this, Qt::Dialog | Qt::WindowCloseButtonHint);
_curve_show_setting_dlg->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_curve_show_setting_dlg->setSizeGripEnabled(false);
_curve_show_setting_dlg->setWindowTitle(QString(QStringLiteral(u"选择%1曲线显示").arg(this->_plot->title().text())));
_curve_show_setting_dlg->setWindowModality(Qt::WindowModal);
_curve_show_setting_dlg->setModal(false);
QVBoxLayout* layout = new QVBoxLayout(_curve_show_setting_dlg);
const QString& all_ch_text = QStringLiteral(u"全通道");
QStringList list_ch_names;
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
const QString& every_ch_text = curve->title().text();
if ( all_ch_text != every_ch_text ) {
list_ch_names.append(every_ch_text);
}
}
std::sort(list_ch_names.begin(), list_ch_names.end(), [](const QString& a, const QString& b) {
int num_a = ExtractNumberFromString(a);
int num_b = ExtractNumberFromString(b);
return num_a < num_b;
});
// 自动计算多列排布
int num_columns = std::sqrt(this->_plot->GetCurveList().size());
if (num_columns == 0)
num_columns = 1;
QVBoxLayout* checkbox_layout = new QVBoxLayout();
QHBoxLayout* checkbox_column_layout = new QHBoxLayout();
QMap<QwtPlotCurve*, QCheckBox*> curve_checkbox_map;
auto addCurveToLayout = [&](const QString& curve_name){
QwtPlotCurve* curve = this->_plot->GetCurve(curve_name);
QCheckBox* check_box = new QCheckBox(curve->title().text());
check_box->setChecked(curve->isVisible());
checkbox_column_layout->addWidget(check_box);
connect(check_box, &QCheckBox::stateChanged, [curve](int state) {
curve->setVisible(state == Qt::Checked);
curve->plot()->replot();
});
curve_checkbox_map[curve] = check_box;
if (checkbox_column_layout->count() >= num_columns) {
checkbox_layout->addLayout(checkbox_column_layout);
checkbox_column_layout = new QHBoxLayout();
}
};
addCurveToLayout(all_ch_text);
for (const QString& ch_name : list_ch_names) {
addCurveToLayout(ch_name);
}
if (checkbox_column_layout->count() < num_columns) {
checkbox_column_layout->addStretch();
}
checkbox_layout->addLayout(checkbox_column_layout);
// 全选和反选
auto curveCheckboxUpdate = [this, curve_checkbox_map]() {
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
curve_checkbox_map[curve]->setChecked(curve->isVisible());
}
};
QHBoxLayout* button_layout = new QHBoxLayout();
QPushButton* btn_all_select = new QPushButton(QString(QStringLiteral(u"全选")));
connect(btn_all_select, &QPushButton::clicked, [this, curveCheckboxUpdate]() {
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
curve->setVisible(true);
}
curveCheckboxUpdate();
this->_plot->replot();
});
button_layout->addWidget(btn_all_select);
QPushButton* btn_reserve_select = new QPushButton(QString(QStringLiteral(u"反选")));
connect(btn_reserve_select, &QPushButton::clicked, [this, curveCheckboxUpdate]() {
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
curve->setVisible(!curve->isVisible());
}
curveCheckboxUpdate();
this->_plot->replot();
});
button_layout->addWidget(btn_reserve_select);
layout->addLayout(button_layout);
layout->addLayout(checkbox_layout);
}
_curve_show_setting_dlg->show();
}
void EnergyCountPlotView::onActionPlotConfigure()
{
}

View File

@ -0,0 +1,39 @@
#ifndef ENERGYCOUNTPLOTVIEW_H
#define ENERGYCOUNTPLOTVIEW_H
#include <QObject>
#include <QWidget>
#include <MeasureAnalysisView.h>
class QMenu;
class CustomQwtPlot;
class CustomQwtPlotXaxisSelector;
class EnergyCountPlotView : public MeasureAnalysisView
{
Q_OBJECT
public:
EnergyCountPlotView(QWidget *parent = nullptr);
virtual ~EnergyCountPlotView();
virtual void InitViewWorkspace(const QString& project_name) override final;
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
private:
void setupPlot();
void setupMenu();
void loadDataFromFile(const QString &data_name, const QString& filename);
private slots:
void onActionCurveShowSetting();
void onActionPlotConfigure();
private:
CustomQwtPlot* _plot = nullptr;
QMenu* _menu = nullptr;
QDialog* _curve_show_setting_dlg = nullptr;
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
};
#endif // ENERGYCOUNTPLOTVIEW_H

View File

@ -952,7 +952,7 @@ void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProje
for (auto it = ch_energy_count_data_filename_list.begin(); it != ch_energy_count_data_filename_list.end(); ++it) { for (auto it = ch_energy_count_data_filename_list.begin(); it != ch_energy_count_data_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::EnergyCountData); const QVariant& analys_type = QVariant::fromValue(AnalysisType::ChannelEnergyCountData);
QStandardItem* node_item = AddChildNode(energy_count_item, item_name, status, analys_type, true, state_ok); QStandardItem* node_item = AddChildNode(energy_count_item, item_name, status, analys_type, true, state_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);
@ -983,7 +983,7 @@ void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProje
node_map[item_name] = node_item; node_map[item_name] = node_item;
state_ok = !pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty(); state_ok = !pro_model->GetAllChannelEnergyTotalCountDataFilename().isEmpty();
state_ok &= pro_model->GetChannelEnergyCountDataFilenameList().isEmpty(); state_ok &= !pro_model->GetChannelEnergyCountDataFilenameList().isEmpty();
status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效"); status = state_ok ? QStringLiteral(u"有效") : QStringLiteral(u"无效");
analys_type = QVariant::fromValue(AnalysisType::EnergyCountSpectrumView); analys_type = QVariant::fromValue(AnalysisType::EnergyCountSpectrumView);
item_name = QStringLiteral(u"能量计数谱"); item_name = QStringLiteral(u"能量计数谱");

View File

@ -61,6 +61,9 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
QStandardItem* item = _model->GetItemFromIndex(index); QStandardItem* item = _model->GetItemFromIndex(index);
if (!item) if (!item)
return; return;
if (!_model->GetNodeStatus(item)) {
return;
}
const QString& item_text = item->text(); const QString& item_text = item->text();
QVariant project_name_data = _model->GetNodeUserData(item, ProjectList::ProjectName); QVariant project_name_data = _model->GetNodeUserData(item, ProjectList::ProjectName);
if (!project_name_data.isValid()) if (!project_name_data.isValid())
@ -107,6 +110,30 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
} }
} }
} break; } break;
case AnalysisType::EnergyCountData: {
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
if (project_model) {
auto file_name = project_model->GetAllChannelEnergyTotalCountDataFilename();
if ( !file_name.isEmpty() ) {
data_files_set[QStringLiteral(u"能量计数数据")] = file_name;
}
}
} break;
case AnalysisType::ChannelEnergyCountData: {
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
if (project_model) {
auto file_name_list = project_model->GetChannelEnergyCountDataFilenameList();
if ( !file_name_list.isEmpty() ) {
auto ch_num_list = file_name_list.keys();
for(auto ch_num : ch_num_list) {
auto file_name = file_name_list[ch_num];
if ( !file_name.isEmpty() ) {
data_files_set[QStringLiteral(u"通道%1").arg(ch_num)] = file_name;
}
}
}
}
} break;
case AnalysisType::AddressCountSpectrumView: { case AnalysisType::AddressCountSpectrumView: {
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
if (project_model) { if (project_model) {
@ -122,6 +149,24 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
} }
} }
} break; } break;
case AnalysisType::EnergyCountSpectrumView: {
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
if (project_model) {
auto all_ch_energy_count_file_name = project_model->GetAllChannelEnergyTotalCountDataFilename();
if (!all_ch_energy_count_file_name.isEmpty()) {
data_files_set[QStringLiteral(u"全通道")] = all_ch_energy_count_file_name;
}
auto ch_energy_count_file_name_list = project_model->GetChannelEnergyCountDataFilenameList();
if ( !ch_energy_count_file_name_list.isEmpty() ) {
auto ch_num_list = ch_energy_count_file_name_list.keys();
for(auto ch_num : ch_num_list) {
auto ch_file_name = ch_energy_count_file_name_list[ch_num];
if ( !ch_file_name.isEmpty() ) {
data_files_set[QStringLiteral(u"通道%1").arg(ch_num)] = ch_file_name; }
}
}
}
} break;
case AnalysisType::ParticleInTimeView: { case AnalysisType::ParticleInTimeView: {
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
if (project_model) { if (project_model) {

View File

@ -1,9 +1,11 @@
#include "MeasureAnalysisView.h" #include "MeasureAnalysisView.h"
#include <QMap> #include <QMap>
#include "MeasureAnalysisDataTableView.h" #include "MeasureAnalysisDataTableView.h"
#include "MeasureAnalysisParticleCountPlotView.h" #include "ParticleCountPlotView.h"
#include "ParticleInjectTimeAnalysis.h" #include "ParticleInjectTimeAnalysis.h"
#include "CountRateAnalysis.h" #include "CountRateAnalysis.h"
#include "EnergyCountPlotView.h"
MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type) MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type)
{ {
MeasureAnalysisView* new_view = nullptr; MeasureAnalysisView* new_view = nullptr;
@ -49,12 +51,12 @@ MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type)
new_view->setDeleteOnClose(true); new_view->setDeleteOnClose(true);
} break; } break;
case AnalysisType::AddressCountSpectrumView: { case AnalysisType::AddressCountSpectrumView: {
new_view = new MeasureAnalysisParticleCountPlotView; new_view = new ParticleCountPlotView;
new_view->setDeleteOnClose(false); new_view->setDeleteOnClose(false);
} break; } break;
case AnalysisType::EnergyCountSpectrumView: { case AnalysisType::EnergyCountSpectrumView: {
// new_view = new MeasureAnalysisParticleCountPlotView; new_view = new EnergyCountPlotView;
// new_view->setDeleteOnClose(false); new_view->setDeleteOnClose(false);
} break; } break;
case AnalysisType::CoincidenceParticleEnergySpectrum2DView: { case AnalysisType::CoincidenceParticleEnergySpectrum2DView: {
// new_view = new MeasureAnalysisDataTableView; // new_view = new MeasureAnalysisDataTableView;

View File

@ -1,4 +1,4 @@
#include "MeasureAnalysisParticleCountPlotView.h" #include "ParticleCountPlotView.h"
#include "CustomQwtPlot.h" #include "CustomQwtPlot.h"
#include "DataProcessWorkPool.h" #include "DataProcessWorkPool.h"
#include "MeasureAnalysisProjectModel.h" #include "MeasureAnalysisProjectModel.h"
@ -29,7 +29,7 @@
#include "BatchEnergyScaleDialog.h" #include "BatchEnergyScaleDialog.h"
#include "FindPeaksResultDialog.h" #include "FindPeaksResultDialog.h"
MeasureAnalysisParticleCountPlotView::MeasureAnalysisParticleCountPlotView(QWidget* parent) ParticleCountPlotView::ParticleCountPlotView(QWidget* parent)
: MeasureAnalysisView { parent } : MeasureAnalysisView { parent }
{ {
this->setViewType(PlotFrame); this->setViewType(PlotFrame);
@ -45,13 +45,13 @@ MeasureAnalysisParticleCountPlotView::MeasureAnalysisParticleCountPlotView(QWidg
setupEnergyScaleDlg(); setupEnergyScaleDlg();
} }
MeasureAnalysisParticleCountPlotView::~MeasureAnalysisParticleCountPlotView() ParticleCountPlotView::~ParticleCountPlotView()
{ {
LOG_DEBUG(QStringLiteral(u"%1析构.").arg(this->GetViewName())); LOG_DEBUG(QStringLiteral(u"%1析构.").arg(this->GetViewName()));
} }
void MeasureAnalysisParticleCountPlotView::InitViewWorkspace(const QString& project_name) void ParticleCountPlotView::InitViewWorkspace(const QString& project_name)
{ {
if (project_name.isEmpty()) { if (project_name.isEmpty()) {
return; return;
@ -81,7 +81,7 @@ void MeasureAnalysisParticleCountPlotView::InitViewWorkspace(const QString& proj
_batch_energy_scale_dlg->SetPeakResultDataModel(_find_peaks_result_dlg->GetPeakResultDataModel()); _batch_energy_scale_dlg->SetPeakResultDataModel(_find_peaks_result_dlg->GetPeakResultDataModel());
} }
void MeasureAnalysisParticleCountPlotView::SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set) void ParticleCountPlotView::SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set)
{ {
QStringList ch_count_data_name = data_files_set.keys(); QStringList ch_count_data_name = data_files_set.keys();
std::sort(ch_count_data_name.begin(), ch_count_data_name.end(), [](const QString& a, const QString& b) { std::sort(ch_count_data_name.begin(), ch_count_data_name.end(), [](const QString& a, const QString& b) {
@ -117,40 +117,40 @@ void MeasureAnalysisParticleCountPlotView::SetAnalyzeDataFilename(const QMap<QSt
} }
} }
void MeasureAnalysisParticleCountPlotView::setupMenu() void ParticleCountPlotView::setupMenu()
{ {
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &MeasureAnalysisParticleCountPlotView::customContextMenuRequested, [this](const QPoint& pos) { connect(this, &ParticleCountPlotView::customContextMenuRequested, [this](const QPoint& pos) {
this->_menu->exec(this->mapToGlobal(pos)); this->_menu->exec(this->mapToGlobal(pos));
}); });
QAction* action_plot_reset = this->_menu->addAction(QStringLiteral(u"还原")); QAction* action_plot_reset = this->_menu->addAction(QStringLiteral(u"还原"));
action_plot_reset->setObjectName("curve_show_setting"); action_plot_reset->setObjectName("plot_reset");
connect(action_plot_reset, &QAction::triggered, [this]() { connect(action_plot_reset, &QAction::triggered, [this]() {
this->_plot->ResetPlot(); this->_plot->ResetPlot();
}); });
this->_menu->addSeparator(); this->_menu->addSeparator();
QAction* action_set_curve_show = this->_menu->addAction(QStringLiteral(u"选择曲线")); QAction* action_set_curve_show = this->_menu->addAction(QStringLiteral(u"选择曲线"));
action_set_curve_show->setObjectName("curve_show_setting"); action_set_curve_show->setObjectName("curve_show_setting");
connect(action_set_curve_show, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting); connect(action_set_curve_show, &QAction::triggered, this, &ParticleCountPlotView::onActionCurveShowSetting);
QMenu* menu_find_peaks = this->_menu->addMenu(QStringLiteral(u"寻峰")); QMenu* menu_find_peaks = this->_menu->addMenu(QStringLiteral(u"寻峰"));
QAction* action_find_peaks_result = menu_find_peaks->addAction(QStringLiteral(u"寻峰结果")); QAction* action_find_peaks_result = menu_find_peaks->addAction(QStringLiteral(u"寻峰结果"));
action_find_peaks_result->setObjectName("manual_find_peaks"); action_find_peaks_result->setObjectName("manual_find_peaks");
connect(action_find_peaks_result, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionFindPeaksResult); connect(action_find_peaks_result, &QAction::triggered, this, &ParticleCountPlotView::onActionFindPeaksResult);
QAction* action_auto_find_peaks = menu_find_peaks->addAction(QStringLiteral(u"自动寻峰")); QAction* action_auto_find_peaks = menu_find_peaks->addAction(QStringLiteral(u"自动寻峰"));
action_auto_find_peaks->setObjectName("auto_find_peaks"); action_auto_find_peaks->setObjectName("auto_find_peaks");
connect(action_auto_find_peaks, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionAutoFindPeaks); connect(action_auto_find_peaks, &QAction::triggered, this, &ParticleCountPlotView::onActionAutoFindPeaks);
QAction* action_manual_find_peaks = menu_find_peaks->addAction(QStringLiteral(u"手动寻峰")); QAction* action_manual_find_peaks = menu_find_peaks->addAction(QStringLiteral(u"手动寻峰"));
action_manual_find_peaks->setObjectName("manual_find_peaks"); action_manual_find_peaks->setObjectName("manual_find_peaks");
connect(action_auto_find_peaks, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionManualFindPeaks); connect(action_auto_find_peaks, &QAction::triggered, this, &ParticleCountPlotView::onActionManualFindPeaks);
QAction* action_set_energy_scale = this->_menu->addAction(QStringLiteral(u"能量刻度")); QAction* action_set_energy_scale = this->_menu->addAction(QStringLiteral(u"能量刻度"));
action_set_energy_scale->setObjectName("energy_scale"); action_set_energy_scale->setObjectName("energy_scale");
connect(action_set_energy_scale, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionEnergyScale); connect(action_set_energy_scale, &QAction::triggered, this, &ParticleCountPlotView::onActionEnergyScale);
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置")); QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
action_plot_config->setObjectName("plot_config"); action_plot_config->setObjectName("plot_config");
connect(action_plot_config, &QAction::triggered, this, &MeasureAnalysisParticleCountPlotView::onActionPlotConfigure); connect(action_plot_config, &QAction::triggered, this, &ParticleCountPlotView::onActionPlotConfigure);
} }
void MeasureAnalysisParticleCountPlotView::setupPlot() void ParticleCountPlotView::setupPlot()
{ {
_plot->setTitle(QString(QStringLiteral(u"粒子计数谱"))); _plot->setTitle(QString(QStringLiteral(u"粒子计数谱")));
@ -179,7 +179,7 @@ void MeasureAnalysisParticleCountPlotView::setupPlot()
_data_selector->setEnabled(false); _data_selector->setEnabled(false);
} }
void MeasureAnalysisParticleCountPlotView::setupPeakResultDlg() void ParticleCountPlotView::setupPeakResultDlg()
{ {
if (!_find_peaks_result_dlg) { if (!_find_peaks_result_dlg) {
_find_peaks_result_dlg = new FindPeaksResultDialog(this); _find_peaks_result_dlg = new FindPeaksResultDialog(this);
@ -189,7 +189,7 @@ void MeasureAnalysisParticleCountPlotView::setupPeakResultDlg()
} }
} }
void MeasureAnalysisParticleCountPlotView::setupEnergyScaleDlg() void ParticleCountPlotView::setupEnergyScaleDlg()
{ {
if (!_batch_energy_scale_dlg) { if (!_batch_energy_scale_dlg) {
_batch_energy_scale_dlg = new BatchEnergyScaleDialog(this); _batch_energy_scale_dlg = new BatchEnergyScaleDialog(this);
@ -200,7 +200,7 @@ void MeasureAnalysisParticleCountPlotView::setupEnergyScaleDlg()
} }
} }
void MeasureAnalysisParticleCountPlotView::loadDataFromFile(const QString& data_name, const QString& filename) void ParticleCountPlotView::loadDataFromFile(const QString& data_name, const QString& filename)
{ {
std::string address_str = QString(QStringLiteral(u"道址")).toStdString(); std::string address_str = QString(QStringLiteral(u"道址")).toStdString();
std::string count_str = QString(QStringLiteral(u"计数")).toStdString(); std::string count_str = QString(QStringLiteral(u"计数")).toStdString();
@ -229,7 +229,7 @@ void MeasureAnalysisParticleCountPlotView::loadDataFromFile(const QString& data_
_plot->AddCurve(curve); _plot->AddCurve(curve);
} }
void MeasureAnalysisParticleCountPlotView::updatePlotPeakInfo(const QVariantMap &peak_infos) void ParticleCountPlotView::updatePlotPeakInfo(const QVariantMap &peak_infos)
{ {
const QString& channel = peak_infos["channel"].toString(); const QString& channel = peak_infos["channel"].toString();
int peak_pos = peak_infos["peak_pos"].toInt(); int peak_pos = peak_infos["peak_pos"].toInt();
@ -283,7 +283,7 @@ void MeasureAnalysisParticleCountPlotView::updatePlotPeakInfo(const QVariantMap
this->_plot->replot(); this->_plot->replot();
} }
void MeasureAnalysisParticleCountPlotView::onAutoFindPeaksFinished(bool ok, const QString &project_name, const QVariant& data) void ParticleCountPlotView::onAutoFindPeaksFinished(bool ok, const QString &project_name, const QVariant& data)
{ {
Q_UNUSED(project_name); Q_UNUSED(project_name);
Q_UNUSED(data); Q_UNUSED(data);
@ -298,7 +298,7 @@ void MeasureAnalysisParticleCountPlotView::onAutoFindPeaksFinished(bool ok, cons
} }
} }
void MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting() void ParticleCountPlotView::onActionCurveShowSetting()
{ {
if (!_curve_show_setting_dlg) { if (!_curve_show_setting_dlg) {
_curve_show_setting_dlg = new QDialog(this, Qt::Dialog | Qt::WindowCloseButtonHint); _curve_show_setting_dlg = new QDialog(this, Qt::Dialog | Qt::WindowCloseButtonHint);
@ -375,14 +375,14 @@ void MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting()
_curve_show_setting_dlg->show(); _curve_show_setting_dlg->show();
} }
void MeasureAnalysisParticleCountPlotView::onActionFindPeaksResult() void ParticleCountPlotView::onActionFindPeaksResult()
{ {
if (_find_peaks_result_dlg) { if (_find_peaks_result_dlg) {
_find_peaks_result_dlg->show(); _find_peaks_result_dlg->show();
} }
} }
void MeasureAnalysisParticleCountPlotView::onActionAutoFindPeaks() void ParticleCountPlotView::onActionAutoFindPeaks()
{ {
QDialog set_find_peak_step_win_width_dlg(this, Qt::Dialog | Qt::WindowCloseButtonHint); QDialog set_find_peak_step_win_width_dlg(this, Qt::Dialog | Qt::WindowCloseButtonHint);
set_find_peak_step_win_width_dlg.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); set_find_peak_step_win_width_dlg.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@ -425,12 +425,12 @@ void MeasureAnalysisParticleCountPlotView::onActionAutoFindPeaks()
} }
} }
void MeasureAnalysisParticleCountPlotView::onActionManualFindPeaks() void ParticleCountPlotView::onActionManualFindPeaks()
{ {
// _data_selector->setEnabled(true); // _data_selector->setEnabled(true);
} }
void MeasureAnalysisParticleCountPlotView::onActionEnergyScale() void ParticleCountPlotView::onActionEnergyScale()
{ {
if (_batch_energy_scale_dlg && _data_selector) { if (_batch_energy_scale_dlg && _data_selector) {
_batch_energy_scale_dlg->show(); _batch_energy_scale_dlg->show();
@ -438,6 +438,6 @@ void MeasureAnalysisParticleCountPlotView::onActionEnergyScale()
} }
} }
void MeasureAnalysisParticleCountPlotView::onActionPlotConfigure() void ParticleCountPlotView::onActionPlotConfigure()
{ {
} }

View File

@ -1,5 +1,5 @@
#ifndef MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H #ifndef PARTICLECOUNTPLOTVIEW_H
#define MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H #define PARTICLECOUNTPLOTVIEW_H
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
@ -15,12 +15,12 @@ class CustomQwtPlotXaxisSelector;
class BatchEnergyScaleDialog; class BatchEnergyScaleDialog;
class FindPeaksResultDialog; class FindPeaksResultDialog;
class MeasureAnalysisParticleCountPlotView : public MeasureAnalysisView class ParticleCountPlotView : public MeasureAnalysisView
{ {
Q_OBJECT Q_OBJECT
public: public:
MeasureAnalysisParticleCountPlotView(QWidget *parent = nullptr); ParticleCountPlotView(QWidget *parent = nullptr);
virtual ~MeasureAnalysisParticleCountPlotView(); virtual ~ParticleCountPlotView();
virtual void InitViewWorkspace(const QString& project_name) override final; virtual void InitViewWorkspace(const QString& project_name) override final;
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set); virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
@ -58,4 +58,4 @@ private:
BatchEnergyScaleDialog* _batch_energy_scale_dlg = nullptr; BatchEnergyScaleDialog* _batch_energy_scale_dlg = nullptr;
}; };
#endif // MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H #endif // PARTICLECOUNTPLOTVIEW_H

View File

@ -32,27 +32,31 @@ UI_DIR = $${BUILD_UI}/$${TARGET}/ui
INCLUDEPATH += \ INCLUDEPATH += \
$${PWD}/MeasureAnalysisParticleCountPlotView \ $${PWD}/MeasureAnalysisParticleCountPlotView \
$${PWD}/ParticleCountPlotView \
$${PWD}/ParticleInjectTimeView \ $${PWD}/ParticleInjectTimeView \
$${PWD}/EnergyCountPlotView \
$${PWD}/CountRateAnalysis $${PWD}/CountRateAnalysis
DEPENDPATH += \ DEPENDPATH += \
$${PWD}/MeasureAnalysisParticleCountPlotView \ $${PWD}/MeasureAnalysisParticleCountPlotView \
$${PWD}/ParticleCountPlotView \
$${PWD}/ParticleInjectTimeView\ $${PWD}/ParticleInjectTimeView\
$${PWD}/EnergyCountPlotView \
$${PWD}/CountRateAnalysis $${PWD}/CountRateAnalysis
SOURCES += \ SOURCES += \
AboutDlg.cpp \ AboutDlg.cpp \
CustomQwtPlot.cpp \ CustomQwtPlot.cpp \
DataProcessWorkPool.cpp \ DataProcessWorkPool.cpp \
EnergyCountPlotView/EnergyCountPlotView.cpp \
EnergyScaleDataModel.cpp \ EnergyScaleDataModel.cpp \
EnergyScaleForm.cpp \ EnergyScaleForm.cpp \
MainWindow.cpp \ MainWindow.cpp \
MeasureAnalysisDataTableView.cpp \ MeasureAnalysisDataTableView.cpp \
MeasureAnalysisHistoryForm.cpp \ MeasureAnalysisHistoryForm.cpp \
MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.cpp \ ParticleCountPlotView/BatchEnergyScaleDialog.cpp \
MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.cpp \ ParticleCountPlotView/FindPeaksResultDialog.cpp \
MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp \ ParticleCountPlotView/ParticleCountPlotView.cpp \
MeasureAnalysisTreeView.cpp \ MeasureAnalysisTreeView.cpp \
MeasureAnalysisView.cpp \ MeasureAnalysisView.cpp \
MeasureDeviceParamsCfgForm.cpp \ MeasureDeviceParamsCfgForm.cpp \
@ -71,15 +75,16 @@ HEADERS += \
AnalysisTypeDefine.h \ AnalysisTypeDefine.h \
CustomQwtPlot.h \ CustomQwtPlot.h \
DataProcessWorkPool.h \ DataProcessWorkPool.h \
EnergyCountPlotView/EnergyCountPlotView.h \
EnergyScaleDataModel.h \ EnergyScaleDataModel.h \
EnergyScaleForm.h \ EnergyScaleForm.h \
GlobalDefine.h \ GlobalDefine.h \
MainWindow.h \ MainWindow.h \
MeasureAnalysisDataTableView.h \ MeasureAnalysisDataTableView.h \
MeasureAnalysisHistoryForm.h \ MeasureAnalysisHistoryForm.h \
MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.h \ ParticleCountPlotView/BatchEnergyScaleDialog.h \
MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.h \ ParticleCountPlotView/FindPeaksResultDialog.h \
MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h \ ParticleCountPlotView/ParticleCountPlotView.h \
MeasureAnalysisTreeView.h \ MeasureAnalysisTreeView.h \
MeasureAnalysisView.h \ MeasureAnalysisView.h \
MeasureDeviceParamsCfgForm.h \ MeasureDeviceParamsCfgForm.h \
@ -99,7 +104,7 @@ FORMS += \
EnergyScaleForm.ui \ EnergyScaleForm.ui \
MainWindow.ui \ MainWindow.ui \
MeasureAnalysisHistoryForm.ui \ MeasureAnalysisHistoryForm.ui \
MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.ui \ ParticleCountPlotView/BatchEnergyScaleDialog.ui \
MeasureDeviceParamsCfgForm.ui \ MeasureDeviceParamsCfgForm.ui \
NewMeasureAnalysisDlg.ui\ NewMeasureAnalysisDlg.ui\
ParticleInjectTimeView/ParticleInjectTimeAnalysis.ui\ ParticleInjectTimeView/ParticleInjectTimeAnalysis.ui\