From 31e7755e0f44fef1f53b1e693b9edf6bde7221a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B5=B7?= Date: Wed, 25 Mar 2026 11:45:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E8=83=BD=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E8=B0=B1=E8=A7=86=E5=9B=BE=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E8=B0=83=E6=95=B4=E5=91=BD=E5=90=8D=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DataProcessWorkPool.cpp | 37 ++- .../EnergyCountPlotView.cpp | 220 ++++++++++++++++++ src/EnergyCountPlotView/EnergyCountPlotView.h | 39 ++++ src/MeasureAnalysisProjectModel.cpp | 4 +- src/MeasureAnalysisTreeView.cpp | 45 ++++ src/MeasureAnalysisView.cpp | 9 +- .../BatchEnergyScaleDialog.cpp | 0 .../BatchEnergyScaleDialog.h | 0 .../BatchEnergyScaleDialog.ui | 0 .../FindPeaksResultDialog.cpp | 0 .../FindPeaksResultDialog.h | 0 .../ParticleCountPlotView.cpp} | 52 ++--- .../ParticleCountPlotView.h} | 12 +- src/src.pro | 26 ++- 14 files changed, 384 insertions(+), 60 deletions(-) create mode 100644 src/EnergyCountPlotView/EnergyCountPlotView.cpp create mode 100644 src/EnergyCountPlotView/EnergyCountPlotView.h rename src/{MeasureAnalysisParticleCountPlotView => ParticleCountPlotView}/BatchEnergyScaleDialog.cpp (100%) rename src/{MeasureAnalysisParticleCountPlotView => ParticleCountPlotView}/BatchEnergyScaleDialog.h (100%) rename src/{MeasureAnalysisParticleCountPlotView => ParticleCountPlotView}/BatchEnergyScaleDialog.ui (100%) rename src/{MeasureAnalysisParticleCountPlotView => ParticleCountPlotView}/FindPeaksResultDialog.cpp (100%) rename src/{MeasureAnalysisParticleCountPlotView => ParticleCountPlotView}/FindPeaksResultDialog.h (100%) rename src/{MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp => ParticleCountPlotView/ParticleCountPlotView.cpp} (89%) rename src/{MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h => ParticleCountPlotView/ParticleCountPlotView.h} (82%) diff --git a/src/DataProcessWorkPool.cpp b/src/DataProcessWorkPool.cpp index c76baf7..13aebd4 100644 --- a/src/DataProcessWorkPool.cpp +++ b/src/DataProcessWorkPool.cpp @@ -863,15 +863,17 @@ bool EnergyCountProcessTask::processTask() LOG_WARN(QStringLiteral(u"创建能量计数数据目录\"%1\"异常!").arg(out_path)); 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 stat_map; for (const uint& channel_num : ch_addr_count_filename_list.keys()) { const QString& channel_name = QStringLiteral(u"通道%1").arg(channel_num); const QString& data_filename = ch_addr_count_filename_list[channel_num]; - 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(); - const QString& out_filename = QDir(out_path).filePath(channel_name + ".csv"); - std::ofstream out(QStrToSysPath(out_filename)); - out << energy_str << "," << count_str << "\n" ; + const QString& ch_out_filename = QDir(out_path).filePath(channel_name + ".csv"); + std::ofstream ch_out(QStrToSysPath(ch_out_filename)); + ch_out << energy_str << "," << count_str << "\n" ; try { io::CSVReader< 2, @@ -887,18 +889,31 @@ bool EnergyCountProcessTask::processTask() auto coeffs = energy_scale_data_model.GetEnergyFitResultCoeffs(channel_name); if (!coeffs.empty()) { 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(); - project_model->SetChannelEnergyCountDataFilename(channel_num, out_filename); + ch_out.close(); + project_model->SetChannelEnergyCountDataFilename(channel_num, ch_out_filename); } catch (const std::exception& e) { - out.close(); - std::remove(QStrToSysPath(out_filename)); + ch_out.close(); + std::remove(QStrToSysPath(ch_out_filename)); const QString& e_what = QString::fromStdString(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"能量计数处理完成."); LOG_INFO(info); return true; diff --git a/src/EnergyCountPlotView/EnergyCountPlotView.cpp b/src/EnergyCountPlotView/EnergyCountPlotView.cpp new file mode 100644 index 0000000..68afb89 --- /dev/null +++ b/src/EnergyCountPlotView/EnergyCountPlotView.cpp @@ -0,0 +1,220 @@ +#include "EnergyCountPlotView.h" +#include "CustomQwtPlot.h" +#include "csv.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +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 &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(_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 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 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() +{ + +} diff --git a/src/EnergyCountPlotView/EnergyCountPlotView.h b/src/EnergyCountPlotView/EnergyCountPlotView.h new file mode 100644 index 0000000..72c838c --- /dev/null +++ b/src/EnergyCountPlotView/EnergyCountPlotView.h @@ -0,0 +1,39 @@ +#ifndef ENERGYCOUNTPLOTVIEW_H +#define ENERGYCOUNTPLOTVIEW_H + +#include +#include +#include + +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& 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 diff --git a/src/MeasureAnalysisProjectModel.cpp b/src/MeasureAnalysisProjectModel.cpp index c85a11b..64a8b98 100644 --- a/src/MeasureAnalysisProjectModel.cpp +++ b/src/MeasureAnalysisProjectModel.cpp @@ -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) { uint ch_num = it.key(); 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); node_item->setData(project_name, ProjectName); node_item->setData(ch_num, ChannelNum); @@ -983,7 +983,7 @@ void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProje node_map[item_name] = node_item; 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"无效"); analys_type = QVariant::fromValue(AnalysisType::EnergyCountSpectrumView); item_name = QStringLiteral(u"能量计数谱"); diff --git a/src/MeasureAnalysisTreeView.cpp b/src/MeasureAnalysisTreeView.cpp index 1dd0cb4..484a6b2 100644 --- a/src/MeasureAnalysisTreeView.cpp +++ b/src/MeasureAnalysisTreeView.cpp @@ -61,6 +61,9 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index) QStandardItem* item = _model->GetItemFromIndex(index); if (!item) return; + if (!_model->GetNodeStatus(item)) { + return; + } const QString& item_text = item->text(); QVariant project_name_data = _model->GetNodeUserData(item, ProjectList::ProjectName); if (!project_name_data.isValid()) @@ -107,6 +110,30 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index) } } } 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: { MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); if (project_model) { @@ -122,6 +149,24 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index) } } } 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: { MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name); if (project_model) { diff --git a/src/MeasureAnalysisView.cpp b/src/MeasureAnalysisView.cpp index 64f4518..35f8619 100644 --- a/src/MeasureAnalysisView.cpp +++ b/src/MeasureAnalysisView.cpp @@ -1,8 +1,9 @@ #include "MeasureAnalysisView.h" #include #include "MeasureAnalysisDataTableView.h" -#include "MeasureAnalysisParticleCountPlotView.h" +#include "ParticleCountPlotView.h" #include "ParticleInjectTimeAnalysis.h" +#include "EnergyCountPlotView.h" MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type) { @@ -49,12 +50,12 @@ MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type) new_view->setDeleteOnClose(true); } break; case AnalysisType::AddressCountSpectrumView: { - new_view = new MeasureAnalysisParticleCountPlotView; + new_view = new ParticleCountPlotView; new_view->setDeleteOnClose(false); } break; case AnalysisType::EnergyCountSpectrumView: { - // new_view = new MeasureAnalysisParticleCountPlotView; - // new_view->setDeleteOnClose(false); + new_view = new EnergyCountPlotView; + new_view->setDeleteOnClose(false); } break; case AnalysisType::CoincidenceParticleEnergySpectrum2DView: { // new_view = new MeasureAnalysisDataTableView; diff --git a/src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.cpp b/src/ParticleCountPlotView/BatchEnergyScaleDialog.cpp similarity index 100% rename from src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.cpp rename to src/ParticleCountPlotView/BatchEnergyScaleDialog.cpp diff --git a/src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.h b/src/ParticleCountPlotView/BatchEnergyScaleDialog.h similarity index 100% rename from src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.h rename to src/ParticleCountPlotView/BatchEnergyScaleDialog.h diff --git a/src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.ui b/src/ParticleCountPlotView/BatchEnergyScaleDialog.ui similarity index 100% rename from src/MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.ui rename to src/ParticleCountPlotView/BatchEnergyScaleDialog.ui diff --git a/src/MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.cpp b/src/ParticleCountPlotView/FindPeaksResultDialog.cpp similarity index 100% rename from src/MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.cpp rename to src/ParticleCountPlotView/FindPeaksResultDialog.cpp diff --git a/src/MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.h b/src/ParticleCountPlotView/FindPeaksResultDialog.h similarity index 100% rename from src/MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.h rename to src/ParticleCountPlotView/FindPeaksResultDialog.h diff --git a/src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp b/src/ParticleCountPlotView/ParticleCountPlotView.cpp similarity index 89% rename from src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp rename to src/ParticleCountPlotView/ParticleCountPlotView.cpp index c6d643c..1b7e590 100644 --- a/src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp +++ b/src/ParticleCountPlotView/ParticleCountPlotView.cpp @@ -1,4 +1,4 @@ -#include "MeasureAnalysisParticleCountPlotView.h" +#include "ParticleCountPlotView.h" #include "CustomQwtPlot.h" #include "DataProcessWorkPool.h" #include "MeasureAnalysisProjectModel.h" @@ -29,7 +29,7 @@ #include "BatchEnergyScaleDialog.h" #include "FindPeaksResultDialog.h" -MeasureAnalysisParticleCountPlotView::MeasureAnalysisParticleCountPlotView(QWidget* parent) +ParticleCountPlotView::ParticleCountPlotView(QWidget* parent) : MeasureAnalysisView { parent } { this->setViewType(PlotFrame); @@ -45,13 +45,13 @@ MeasureAnalysisParticleCountPlotView::MeasureAnalysisParticleCountPlotView(QWidg setupEnergyScaleDlg(); } -MeasureAnalysisParticleCountPlotView::~MeasureAnalysisParticleCountPlotView() +ParticleCountPlotView::~ParticleCountPlotView() { 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()) { return; @@ -81,7 +81,7 @@ void MeasureAnalysisParticleCountPlotView::InitViewWorkspace(const QString& proj _batch_energy_scale_dlg->SetPeakResultDataModel(_find_peaks_result_dlg->GetPeakResultDataModel()); } -void MeasureAnalysisParticleCountPlotView::SetAnalyzeDataFilename(const QMap& data_files_set) +void ParticleCountPlotView::SetAnalyzeDataFilename(const QMap& 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) { @@ -117,40 +117,40 @@ void MeasureAnalysisParticleCountPlotView::SetAnalyzeDataFilename(const QMapsetContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &MeasureAnalysisParticleCountPlotView::customContextMenuRequested, [this](const QPoint& pos) { + connect(this, &ParticleCountPlotView::customContextMenuRequested, [this](const QPoint& pos) { this->_menu->exec(this->mapToGlobal(pos)); }); 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]() { 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, &MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting); + connect(action_set_curve_show, &QAction::triggered, this, &ParticleCountPlotView::onActionCurveShowSetting); QMenu* menu_find_peaks = this->_menu->addMenu(QStringLiteral(u"寻峰")); QAction* action_find_peaks_result = menu_find_peaks->addAction(QStringLiteral(u"寻峰结果")); 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"自动寻峰")); 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"手动寻峰")); 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"能量刻度")); 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"图表配置")); 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"粒子计数谱"))); @@ -179,7 +179,7 @@ void MeasureAnalysisParticleCountPlotView::setupPlot() _data_selector->setEnabled(false); } -void MeasureAnalysisParticleCountPlotView::setupPeakResultDlg() +void ParticleCountPlotView::setupPeakResultDlg() { if (!_find_peaks_result_dlg) { _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) { _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 count_str = QString(QStringLiteral(u"计数")).toStdString(); @@ -229,7 +229,7 @@ void MeasureAnalysisParticleCountPlotView::loadDataFromFile(const QString& data_ _plot->AddCurve(curve); } -void MeasureAnalysisParticleCountPlotView::updatePlotPeakInfo(const QVariantMap &peak_infos) +void ParticleCountPlotView::updatePlotPeakInfo(const QVariantMap &peak_infos) { const QString& channel = peak_infos["channel"].toString(); int peak_pos = peak_infos["peak_pos"].toInt(); @@ -283,7 +283,7 @@ void MeasureAnalysisParticleCountPlotView::updatePlotPeakInfo(const QVariantMap 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(data); @@ -298,7 +298,7 @@ void MeasureAnalysisParticleCountPlotView::onAutoFindPeaksFinished(bool ok, cons } } -void MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting() +void ParticleCountPlotView::onActionCurveShowSetting() { if (!_curve_show_setting_dlg) { _curve_show_setting_dlg = new QDialog(this, Qt::Dialog | Qt::WindowCloseButtonHint); @@ -375,14 +375,14 @@ void MeasureAnalysisParticleCountPlotView::onActionCurveShowSetting() _curve_show_setting_dlg->show(); } -void MeasureAnalysisParticleCountPlotView::onActionFindPeaksResult() +void ParticleCountPlotView::onActionFindPeaksResult() { if (_find_peaks_result_dlg) { _find_peaks_result_dlg->show(); } } -void MeasureAnalysisParticleCountPlotView::onActionAutoFindPeaks() +void ParticleCountPlotView::onActionAutoFindPeaks() { 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); @@ -425,12 +425,12 @@ void MeasureAnalysisParticleCountPlotView::onActionAutoFindPeaks() } } -void MeasureAnalysisParticleCountPlotView::onActionManualFindPeaks() +void ParticleCountPlotView::onActionManualFindPeaks() { // _data_selector->setEnabled(true); } -void MeasureAnalysisParticleCountPlotView::onActionEnergyScale() +void ParticleCountPlotView::onActionEnergyScale() { if (_batch_energy_scale_dlg && _data_selector) { _batch_energy_scale_dlg->show(); @@ -438,6 +438,6 @@ void MeasureAnalysisParticleCountPlotView::onActionEnergyScale() } } -void MeasureAnalysisParticleCountPlotView::onActionPlotConfigure() +void ParticleCountPlotView::onActionPlotConfigure() { } diff --git a/src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h b/src/ParticleCountPlotView/ParticleCountPlotView.h similarity index 82% rename from src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h rename to src/ParticleCountPlotView/ParticleCountPlotView.h index 54d4a17..1673fa3 100644 --- a/src/MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h +++ b/src/ParticleCountPlotView/ParticleCountPlotView.h @@ -1,5 +1,5 @@ -#ifndef MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H -#define MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H +#ifndef PARTICLECOUNTPLOTVIEW_H +#define PARTICLECOUNTPLOTVIEW_H #include #include @@ -15,12 +15,12 @@ class CustomQwtPlotXaxisSelector; class BatchEnergyScaleDialog; class FindPeaksResultDialog; -class MeasureAnalysisParticleCountPlotView : public MeasureAnalysisView +class ParticleCountPlotView : public MeasureAnalysisView { Q_OBJECT public: - MeasureAnalysisParticleCountPlotView(QWidget *parent = nullptr); - virtual ~MeasureAnalysisParticleCountPlotView(); + ParticleCountPlotView(QWidget *parent = nullptr); + virtual ~ParticleCountPlotView(); virtual void InitViewWorkspace(const QString& project_name) override final; virtual void SetAnalyzeDataFilename(const QMap& data_files_set); @@ -58,4 +58,4 @@ private: BatchEnergyScaleDialog* _batch_energy_scale_dlg = nullptr; }; -#endif // MEASUREANALYSISPARTICLECOUNTPLOTVIEW_H +#endif // PARTICLECOUNTPLOTVIEW_H diff --git a/src/src.pro b/src/src.pro index cc96c2b..e8e80c7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -31,25 +31,28 @@ MOC_DIR = $${BUILD_MOC}/$${TARGET}/moc UI_DIR = $${BUILD_UI}/$${TARGET}/ui INCLUDEPATH += \ - $${PWD}/MeasureAnalysisParticleCountPlotView \ - $${PWD}/ParticleInjectTimeView + $${PWD}/ParticleCountPlotView \ + $${PWD}/ParticleInjectTimeView \ + $${PWD}/EnergyCountPlotView DEPENDPATH += \ - $${PWD}/MeasureAnalysisParticleCountPlotView \ - $${PWD}/ParticleInjectTimeView + $${PWD}/ParticleCountPlotView \ + $${PWD}/ParticleInjectTimeView \ + $${PWD}/EnergyCountPlotView SOURCES += \ AboutDlg.cpp \ CustomQwtPlot.cpp \ DataProcessWorkPool.cpp \ + EnergyCountPlotView/EnergyCountPlotView.cpp \ EnergyScaleDataModel.cpp \ EnergyScaleForm.cpp \ MainWindow.cpp \ MeasureAnalysisDataTableView.cpp \ MeasureAnalysisHistoryForm.cpp \ - MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.cpp \ - MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.cpp \ - MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.cpp \ + ParticleCountPlotView/BatchEnergyScaleDialog.cpp \ + ParticleCountPlotView/FindPeaksResultDialog.cpp \ + ParticleCountPlotView/ParticleCountPlotView.cpp \ MeasureAnalysisTreeView.cpp \ MeasureAnalysisView.cpp \ MeasureDeviceParamsCfgForm.cpp \ @@ -67,15 +70,16 @@ HEADERS += \ AnalysisTypeDefine.h \ CustomQwtPlot.h \ DataProcessWorkPool.h \ + EnergyCountPlotView/EnergyCountPlotView.h \ EnergyScaleDataModel.h \ EnergyScaleForm.h \ GlobalDefine.h \ MainWindow.h \ MeasureAnalysisDataTableView.h \ MeasureAnalysisHistoryForm.h \ - MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.h \ - MeasureAnalysisParticleCountPlotView/FindPeaksResultDialog.h \ - MeasureAnalysisParticleCountPlotView/MeasureAnalysisParticleCountPlotView.h \ + ParticleCountPlotView/BatchEnergyScaleDialog.h \ + ParticleCountPlotView/FindPeaksResultDialog.h \ + ParticleCountPlotView/ParticleCountPlotView.h \ MeasureAnalysisTreeView.h \ MeasureAnalysisView.h \ MeasureDeviceParamsCfgForm.h \ @@ -93,7 +97,7 @@ FORMS += \ EnergyScaleForm.ui \ MainWindow.ui \ MeasureAnalysisHistoryForm.ui \ - MeasureAnalysisParticleCountPlotView/BatchEnergyScaleDialog.ui \ + ParticleCountPlotView/BatchEnergyScaleDialog.ui \ MeasureDeviceParamsCfgForm.ui \ NewMeasureAnalysisDlg.ui\ ParticleInjectTimeView/ParticleInjectTimeAnalysis.ui