调整框架项目管理为视图模型
This commit is contained in:
parent
412c80e71d
commit
f970d7f43e
|
|
@ -151,12 +151,12 @@ bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
|||
}
|
||||
|
||||
const QString& project_name = GetProjectName();
|
||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||
MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetProjectModel(project_name);
|
||||
if (project_model == nullptr) {
|
||||
ret_ok = false;
|
||||
}
|
||||
for (auto it = particle_data_filename_list.begin(); it != particle_data_filename_list.end(); ++it) {
|
||||
project_model->SetChannelParticleDataFilename(it.key(), it.value());
|
||||
// project_model->SetChannelParticleDataFilename(it.key(), it.value());
|
||||
}
|
||||
|
||||
return ret_ok;
|
||||
|
|
@ -300,13 +300,13 @@ bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
|||
}
|
||||
|
||||
const QString& project_name = GetProjectName();
|
||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||
MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetProjectModel(project_name);
|
||||
if (project_model == nullptr) {
|
||||
ret_ok = false;
|
||||
} else {
|
||||
// 更新项目模型中的通道粒子计数数据文件名
|
||||
for (auto it = particle_count_filename_list.begin(); it != particle_count_filename_list.end(); ++it) {
|
||||
project_model->SetChannelParticleCountDataFilename(it.key(), it.value());
|
||||
project_model->SetChannelAddressCountDataFilename(it.key(), it.value());
|
||||
}
|
||||
// 更新项目模型中的所有通道粒子总计数数据文件名
|
||||
// project_model->SetAllChannelParticleTotalCountDataFilename(all_channel_total_count_filename);
|
||||
|
|
@ -522,7 +522,7 @@ bool ParticleDataSortTask::processEveryChannelParticleData()
|
|||
}
|
||||
|
||||
const QString& project_name = GetProjectName();
|
||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||
MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetProjectModel(project_name);
|
||||
if (project_model == nullptr) {
|
||||
ret_ok = false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,10 @@
|
|||
#include "EneryScaleForm.h"
|
||||
#include "MeasureAnalysisHistoryForm.h"
|
||||
#include "MeasureAnalysisProjectModel.h"
|
||||
#include "MeasureAnalysisTree.h"
|
||||
#include "MeasureDeviceParamsCfgForm.h"
|
||||
#include "NewMeasureAnalysisDlg.h"
|
||||
#include "MeasureAnalysisView.h"
|
||||
#include "MeasureAnalysisActions.h"
|
||||
#include "MeasureAnalysisTreeView.h"
|
||||
|
||||
using namespace ads;
|
||||
|
||||
|
|
@ -117,16 +116,13 @@ void MainWindow::initMainWindow()
|
|||
ui->menu_view->addAction(_action_central_dock_widget);
|
||||
|
||||
// 构建测量分析工程树视图
|
||||
_tree_measure_analysis = new MeasureAnalysisTree::TreeWidget;
|
||||
_tree_measure_analysis = new MeasureAnalysisTreeView;
|
||||
_dockw_measure_analysis_tree = new ads::CDockWidget(QStringLiteral(u"测量分析工作空间"));
|
||||
_dockw_measure_analysis_tree->setWidget(_tree_measure_analysis);
|
||||
_dockw_measure_analysis_tree->setMinimumSizeHintMode(ads::CDockWidget::MinimumSizeHintFromContentMinimumSize);
|
||||
_dock_manager->addDockWidget(ads::DockWidgetArea::LeftDockWidgetArea, _dockw_measure_analysis_tree);
|
||||
ui->menu_view->addAction(_dockw_measure_analysis_tree->toggleViewAction());
|
||||
|
||||
_tree_actions = new MeasureAnalysisTree::MeasureAnalysisActions(_tree_measure_analysis);
|
||||
_tree_measure_analysis->SetConnectActions(_tree_actions);
|
||||
|
||||
_menu_view_data_table_list = ui->menu_view->addMenu(QStringLiteral(u"查看数据列表"));
|
||||
_menu_view_analysis_view_list = ui->menu_view->addMenu(QStringLiteral(u"分析视图列表"));
|
||||
|
||||
|
|
@ -144,36 +140,38 @@ void MainWindow::initAction()
|
|||
{
|
||||
auto new_measurement_analysis_handler = [this]() {
|
||||
NewMeasureAnalysisDlg new_measure_analysis_dlg;
|
||||
new_measure_analysis_dlg.exec();
|
||||
/*
|
||||
if (QDialog::Accepted == new_measure_analysis_dlg.exec()) {
|
||||
auto project_model = MeasureAnalysisProjectModelList::GetCurrentProjectModel();
|
||||
this->_tree_measure_analysis->AddProjectModel(project_model);
|
||||
if (project_model->GetIsMeasureComplete()) {
|
||||
const QString& project_name = project_model->GetProjectName();
|
||||
auto project_model = ProjectList::Instance()->GetCurrentProjectModel();
|
||||
// this->_tree_measure_analysis->AddProjectModel(project_model);
|
||||
// if (project_model->GetIsMeasureComplete()) {
|
||||
// const QString& project_name = project_model->GetProjectName();
|
||||
|
||||
/*
|
||||
const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
||||
auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
||||
separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
separate_task->SetResultDataDir(result_data_dir);
|
||||
separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
||||
separate_task->StartTask();
|
||||
*/
|
||||
//
|
||||
// // const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
||||
// // auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
||||
// // separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// // separate_task->SetResultDataDir(result_data_dir);
|
||||
// // separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
||||
// // separate_task->StartTask();
|
||||
//
|
||||
|
||||
auto separate_task = new DataProcessWorkPool::ParticleDataSortTask;
|
||||
separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
separate_task->SetSortedResultDir(project_model->GetProjectDir());
|
||||
separate_task->StartTask();
|
||||
// auto separate_task = new DataProcessWorkPool::ParticleDataSortTask;
|
||||
// separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// separate_task->SetSortedResultDir(project_model->GetProjectDir());
|
||||
// separate_task->StartTask();
|
||||
|
||||
const QString& all_ch_count_dir = project_model->GetProjectDir();
|
||||
const QString& every_ch_count_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleCountData");
|
||||
auto count_task = new DataProcessWorkPool::EveryChannelParticleCountDataTask;
|
||||
count_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
count_task->SetAllChannelCountResultDir(all_ch_count_dir);
|
||||
count_task->SetEveryChannelCountResultDir(every_ch_count_dir);
|
||||
count_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedParticleCountData", project_name);
|
||||
count_task->StartTask();
|
||||
}
|
||||
// const QString& all_ch_count_dir = project_model->GetProjectDir();
|
||||
// const QString& every_ch_count_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleCountData");
|
||||
// auto count_task = new DataProcessWorkPool::EveryChannelParticleCountDataTask;
|
||||
// count_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// count_task->SetAllChannelCountResultDir(all_ch_count_dir);
|
||||
// count_task->SetEveryChannelCountResultDir(every_ch_count_dir);
|
||||
// count_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedParticleCountData", project_name);
|
||||
// count_task->StartTask();
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
connect(ui->action_new_measurement_analysis, &QAction::triggered, this, new_measurement_analysis_handler);
|
||||
|
|
@ -205,6 +203,7 @@ void MainWindow::initAction()
|
|||
about_dlg.exec();
|
||||
});
|
||||
|
||||
/*
|
||||
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::currentItemViewWidget, [this](MeasureAnalysisView* view) {
|
||||
if (view && this->_dock_manager) {
|
||||
bool view_exist = false;
|
||||
|
|
@ -269,6 +268,7 @@ void MainWindow::initAction()
|
|||
});
|
||||
|
||||
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::newMeasureAnalysisProject, new_measurement_analysis_handler);
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::applyStyleSheet()
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@ class CDockAreaWidget;
|
|||
class CDockWidget;
|
||||
}
|
||||
class QPlainTextEdit;
|
||||
namespace MeasureAnalysisTree {
|
||||
class TreeWidget;
|
||||
class MeasureAnalysisActions;
|
||||
}
|
||||
class MeasureAnalysisTreeView;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
|
@ -59,8 +57,7 @@ private:
|
|||
ads::CDockManager* _dock_manager { nullptr };
|
||||
ads::CDockAreaWidget* _central_dock_area { nullptr };
|
||||
QAction* _action_central_dock_widget { nullptr };
|
||||
MeasureAnalysisTree::TreeWidget* _tree_measure_analysis { nullptr };
|
||||
MeasureAnalysisTree::MeasureAnalysisActions* _tree_actions { nullptr };
|
||||
MeasureAnalysisTreeView* _tree_measure_analysis { nullptr };
|
||||
ads::CDockWidget* _dockw_measure_analysis_tree { nullptr };
|
||||
QMenu* _menu_view_data_table_list { nullptr };
|
||||
QMenu* _menu_view_analysis_view_list { nullptr };
|
||||
|
|
|
|||
|
|
@ -1,124 +0,0 @@
|
|||
#include "MeasureAnalysisActions.h"
|
||||
#include "MeasureAnalysisTreeItem.h"
|
||||
#include <QAction>
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
MeasureAnalysisActions::MeasureAnalysisActions(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
_act_add_measure_analysis_project = new QAction(QStringLiteral(u"新建测量分析"), this);
|
||||
_act_add_measure_analysis_project->setStatusTip(QStringLiteral(u"新建测量分析"));
|
||||
_act_add_measure_analysis_project->setDisabled(false);
|
||||
connect(_act_add_measure_analysis_project, &QAction::triggered, [this]() {
|
||||
emit addMeasureAnalysisProject();
|
||||
});
|
||||
|
||||
_act_rm_measure_analysis_project = new QAction(QStringLiteral(u"删除测量分析"), this);
|
||||
_act_rm_measure_analysis_project->setStatusTip(QStringLiteral(u"删除测量分析"));
|
||||
_act_rm_measure_analysis_project->setDisabled(true);
|
||||
connect(_act_rm_measure_analysis_project, &QAction::triggered, [this]() {
|
||||
emit rmMeasureAnalysisProject();
|
||||
});
|
||||
|
||||
_act_modify_measure_analysis_project = new QAction(QStringLiteral(u"修改测量分析"), this);
|
||||
_act_modify_measure_analysis_project->setStatusTip(QStringLiteral(u"修改测量分析"));
|
||||
_act_modify_measure_analysis_project->setDisabled(true);
|
||||
connect(_act_modify_measure_analysis_project, &QAction::triggered, [this]() {
|
||||
emit modifyMeasureAnalysisProject();
|
||||
});
|
||||
|
||||
_act_group_measure_analysis_project = new QActionGroup(this);
|
||||
_act_group_measure_analysis_project->addAction(_act_add_measure_analysis_project);
|
||||
_act_group_measure_analysis_project->addAction(_act_rm_measure_analysis_project);
|
||||
_act_group_measure_analysis_project->addAction(_act_modify_measure_analysis_project);
|
||||
|
||||
_act_add_analyze_view = new QAction(QStringLiteral(u"添加分析视图"), this);
|
||||
_act_add_analyze_view->setStatusTip(QStringLiteral(u"添加分析视图"));
|
||||
_act_add_analyze_view->setDisabled(true);
|
||||
connect(_act_add_analyze_view, &QAction::triggered, [this]() {
|
||||
emit addAnalyzeView();
|
||||
});
|
||||
|
||||
_act_rm_analyze_view = new QAction(QStringLiteral(u"删除分析视图"), this);
|
||||
_act_rm_analyze_view->setStatusTip(QStringLiteral(u"删除分析视图"));
|
||||
_act_rm_analyze_view->setDisabled(true);
|
||||
connect(_act_rm_analyze_view, &QAction::triggered, [this]() {
|
||||
emit rmAnalyzeView();
|
||||
});
|
||||
|
||||
_act_modify_analyze_view = new QAction(QStringLiteral(u"修改分析视图"), this);
|
||||
_act_modify_analyze_view->setStatusTip(QStringLiteral(u"修改分析视图"));
|
||||
_act_modify_analyze_view->setDisabled(true);
|
||||
connect(_act_modify_analyze_view, &QAction::triggered, [this]() {
|
||||
emit modifyAnalyzeView();
|
||||
});
|
||||
|
||||
_act_group_analyze_view = new QActionGroup(this);
|
||||
_act_group_analyze_view->addAction(_act_add_analyze_view);
|
||||
_act_group_analyze_view->addAction(_act_rm_analyze_view);
|
||||
_act_group_analyze_view->addAction(_act_modify_analyze_view);
|
||||
}
|
||||
|
||||
QList<QActionGroup*> MeasureAnalysisActions::GetActionGroups()
|
||||
{
|
||||
QList<QActionGroup*> list_act_group;
|
||||
list_act_group.append(_act_group_measure_analysis_project);
|
||||
list_act_group.append(_act_group_analyze_view);
|
||||
return list_act_group;
|
||||
}
|
||||
|
||||
QActionGroup* MeasureAnalysisActions::GetProjectActionGroups()
|
||||
{
|
||||
return _act_group_measure_analysis_project;
|
||||
}
|
||||
|
||||
QActionGroup* MeasureAnalysisActions::GetViewActionGroups()
|
||||
{
|
||||
return _act_group_analyze_view;
|
||||
}
|
||||
|
||||
void MeasureAnalysisActions::SetActionsAvailable(const TreeItemType &item_type)
|
||||
{
|
||||
for (QActionGroup* act_group : this->GetActionGroups()) {
|
||||
for (QAction* act_item : act_group->actions()) {
|
||||
act_item->setDisabled(true);
|
||||
}
|
||||
}
|
||||
_act_add_measure_analysis_project->setEnabled(true);
|
||||
|
||||
switch (item_type) {
|
||||
case TreeItemType::MeasureAnalysisProject:
|
||||
for (QAction* act_item : _act_group_measure_analysis_project->actions()) {
|
||||
act_item->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
case TreeItemType::ParticleData:
|
||||
_act_add_analyze_view->setEnabled(true);
|
||||
break;
|
||||
case TreeItemType::AnalyzeDataGroup:
|
||||
_act_add_analyze_view->setEnabled(true);
|
||||
break;
|
||||
case TreeItemType::ParticleCountData:
|
||||
_act_add_analyze_view->setEnabled(true);
|
||||
break;
|
||||
case TreeItemType::ConformParticleData:
|
||||
_act_add_analyze_view->setEnabled(true);
|
||||
break;
|
||||
case TreeItemType::AnalyzeViewGroup:
|
||||
_act_add_analyze_view->setEnabled(true);
|
||||
break;
|
||||
case TreeItemType::AnalyzeView:
|
||||
for (QAction* act_item : _act_group_analyze_view->actions()) {
|
||||
act_item->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
case TreeItemType::None:
|
||||
break;
|
||||
default:
|
||||
_act_add_measure_analysis_project->setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#ifndef MEASUREANALYSISACTIONS_H
|
||||
#define MEASUREANALYSISACTIONS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
enum class TreeItemType;
|
||||
|
||||
class MeasureAnalysisActions : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MeasureAnalysisActions(QObject* parent = nullptr);
|
||||
|
||||
QList<QActionGroup*> GetActionGroups();
|
||||
QActionGroup* GetProjectActionGroups();
|
||||
QActionGroup *GetViewActionGroups();
|
||||
|
||||
|
||||
void SetActionsAvailable(const TreeItemType& item_type);
|
||||
|
||||
signals:
|
||||
void addMeasureAnalysisProject();
|
||||
void rmMeasureAnalysisProject();
|
||||
void modifyMeasureAnalysisProject();
|
||||
|
||||
void addAnalyzeView();
|
||||
void rmAnalyzeView();
|
||||
void modifyAnalyzeView();
|
||||
|
||||
private:
|
||||
QAction* _act_add_measure_analysis_project { nullptr };
|
||||
QAction* _act_rm_measure_analysis_project { nullptr };
|
||||
QAction* _act_modify_measure_analysis_project { nullptr };
|
||||
QActionGroup* _act_group_measure_analysis_project { nullptr };
|
||||
|
||||
QAction* _act_add_analyze_view { nullptr };
|
||||
QAction* _act_rm_analyze_view { nullptr };
|
||||
QAction* _act_modify_analyze_view { nullptr };
|
||||
QActionGroup* _act_group_analyze_view { nullptr };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MEASUREANALYSISACTIONS_H
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#include "MeasureAnalysisProjectModel.h"
|
||||
#include "AnalysisTypeDefine.h"
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
void MeasureAnalysisProjectModel::SetProjectDir(const QString& project_dir)
|
||||
{
|
||||
|
|
@ -65,12 +67,12 @@ void MeasureAnalysisProjectModel::SetSortedParticleDataFilename(const QString &f
|
|||
this->_sorted_particle_data_filename = filename;
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModel::SetChannelParticleDataFilename(uint channel, const QString& filename)
|
||||
{
|
||||
this->_channel_particle_data_filename_list[channel] = filename;
|
||||
}
|
||||
// void MeasureAnalysisProjectModel::SetChannelParticleDataFilename(uint channel, const QString& filename)
|
||||
// {
|
||||
// this->_channel_particle_data_filename_list[channel] = filename;
|
||||
// }
|
||||
|
||||
void MeasureAnalysisProjectModel::SetChannelParticleCountDataFilename(uint channel, const QString& filename)
|
||||
void MeasureAnalysisProjectModel::SetChannelAddressCountDataFilename(uint channel, const QString& filename)
|
||||
{
|
||||
this->_channel_particle_count_data_filename_list[channel] = filename;
|
||||
}
|
||||
|
|
@ -80,6 +82,16 @@ void MeasureAnalysisProjectModel::SetChannelParticleCountDataFilename(uint chann
|
|||
// this->_all_channel_particle_total_count_data_filename = filename;
|
||||
// }
|
||||
|
||||
void MeasureAnalysisProjectModel::SetChannelEneryCountDataFilename(uint channel, const QString &filename)
|
||||
{
|
||||
this->_channel_every_count_data_filename_list[channel] = filename;
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModel::SetAllChannelEneryTotalCountDataFilename(const QString &filename)
|
||||
{
|
||||
this->_all_channel_enery_total_count_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;
|
||||
|
|
@ -145,22 +157,22 @@ const QString& MeasureAnalysisProjectModel::GetAllChannelParticleDataFilename()
|
|||
return this->_all_channel_particle_data_filename;
|
||||
}
|
||||
|
||||
const QString &MeasureAnalysisProjectModel::GetSortParticleDataFilename() const
|
||||
const QString &MeasureAnalysisProjectModel::GetSortAllChannelParticleDataFilename() const
|
||||
{
|
||||
return this->_sorted_particle_data_filename;
|
||||
}
|
||||
|
||||
const QMap<uint, QString>& MeasureAnalysisProjectModel::GetChannelParticleDataFilenameList() const
|
||||
{
|
||||
return this->_channel_particle_data_filename_list;
|
||||
}
|
||||
// const QMap<uint, QString>& MeasureAnalysisProjectModel::GetChannelParticleDataFilenameList() const
|
||||
// {
|
||||
// return this->_channel_particle_data_filename_list;
|
||||
// }
|
||||
|
||||
const QString& MeasureAnalysisProjectModel::GetChannelParticleDataFilename(uint channel) const
|
||||
{
|
||||
return QString(this->_channel_particle_data_filename_list[channel]);
|
||||
}
|
||||
// const QString& MeasureAnalysisProjectModel::GetChannelParticleDataFilename(uint channel) const
|
||||
// {
|
||||
// return QString(this->_channel_particle_data_filename_list[channel]);
|
||||
// }
|
||||
|
||||
const QMap<uint, QString>& MeasureAnalysisProjectModel::GetChannelParticleCountDataFilenameList() const
|
||||
const QMap<uint, QString>& MeasureAnalysisProjectModel::GetChannelAddressCountDataFilenameList() const
|
||||
{
|
||||
return this->_channel_particle_count_data_filename_list;
|
||||
}
|
||||
|
|
@ -175,49 +187,372 @@ const QString& MeasureAnalysisProjectModel::GetChannelParticleCountDataFilename(
|
|||
// return this->_all_channel_particle_total_count_data_filename;
|
||||
// }
|
||||
|
||||
const QString& MeasureAnalysisProjectModel::GetTimeWinConformParticleDataFilename(uint time_win, uint conform_particle_count) const
|
||||
const QMap<uint, QString> &MeasureAnalysisProjectModel::GetChannelEneryCountDataFilenameList() const
|
||||
{
|
||||
return this->_time_win_conform_particle_data[time_win][conform_particle_count];
|
||||
return this->_channel_every_count_data_filename_list;
|
||||
}
|
||||
|
||||
const QString &MeasureAnalysisProjectModel::GetChannelEneryCountDataFilename(uint channel) const
|
||||
{
|
||||
return this->_all_channel_enery_total_count_data_filename[channel];
|
||||
}
|
||||
|
||||
const QString &MeasureAnalysisProjectModel::GetAllChannelEneryTotalCountDataFilename() const
|
||||
{
|
||||
return this->_all_channel_enery_total_count_data_filename;
|
||||
}
|
||||
|
||||
const QMap<uint, QString> &MeasureAnalysisProjectModel::GetTimeWinConformParticleDataFilenameList(uint time_win) const
|
||||
{
|
||||
return this->_time_win_conform_particle_data[time_win];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* MeasureAnalysisProjectModelList */
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QMap<QString, MeasureAnalysisProjectModel *> MeasureAnalysisProjectModelList::ProjectModels;
|
||||
MeasureAnalysisProjectModel* MeasureAnalysisProjectModelList::current_project_model{ nullptr };
|
||||
enum ColumnType {
|
||||
NameColumn,
|
||||
StatusColumn
|
||||
};
|
||||
|
||||
enum ItemDataType {
|
||||
UserData = Qt::UserRole,
|
||||
FixedData = Qt::UserRole + 1,
|
||||
ProjectData = Qt::UserRole + 2
|
||||
};
|
||||
|
||||
MeasureAnalysisProjectModelList* MeasureAnalysisProjectModelList::_s_instance { nullptr };
|
||||
|
||||
MeasureAnalysisProjectModelList* MeasureAnalysisProjectModelList::Instance()
|
||||
{
|
||||
if ( !_s_instance ) {
|
||||
_s_instance = new MeasureAnalysisProjectModelList();
|
||||
}
|
||||
return _s_instance;
|
||||
}
|
||||
|
||||
MeasureAnalysisProjectModelList::MeasureAnalysisProjectModelList(QObject *parent)
|
||||
: QStandardItemModel(parent),
|
||||
_current_project_model(nullptr)
|
||||
{
|
||||
setColumnCount(2);
|
||||
setHeaderData(NameColumn, Qt::Horizontal, QStringLiteral(u"项名"));
|
||||
setHeaderData(StatusColumn, Qt::Horizontal, QStringLiteral(u"状态"));
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::intiProjectNodeStruce()
|
||||
{
|
||||
MeasureAnalysisProjectModel* cur_pro_model = GetCurrentProjectModel();
|
||||
if ( !cur_pro_model ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<QString, QStandardItem*> node_map;
|
||||
QStandardItem *root_item = invisibleRootItem();
|
||||
|
||||
const QString& project_name = cur_pro_model->GetProjectName();
|
||||
QString status = cur_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);
|
||||
project_item->setData(project_name, ProjectData);
|
||||
|
||||
// 测量控制
|
||||
QString item_name = QStringLiteral(u"测量控制");
|
||||
QStandardItem *measure_ctrl_item = AddChildNode(project_item, item_name, QString(), QVariant(), true);
|
||||
measure_ctrl_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = measure_ctrl_item;
|
||||
|
||||
if (!cur_pro_model->GetIsMeasureComplete()) {
|
||||
const QString& measure_device_params_cfg_filename = cur_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(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
}
|
||||
|
||||
status = cur_pro_model->GetEneryScaleFilename().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);
|
||||
node_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetEfficiencyScaleFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
// 分析数据
|
||||
item_name = QStringLiteral(u"分析数据");
|
||||
QStandardItem *analysis_data_item = AddChildNode(project_item, item_name, QString(), QVariant(), true);
|
||||
analysis_data_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetAllChannelParticleDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
item_name = QStringLiteral(u"道址计数");
|
||||
status = cur_pro_model->GetChannelAddressCountDataFilenameList().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效");
|
||||
analys_type = QVariant::fromValue(AnalysisType::AddressCountData);
|
||||
node_item = AddChildNode(analysis_data_item, item_name, status, QVariant(), true);
|
||||
node_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
item_name = QStringLiteral(u"能量计数");
|
||||
status = cur_pro_model->GetAllChannelEneryTotalCountDataFilename().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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
uint conform_time_win = cur_pro_model->GetConformTimeWin();
|
||||
status = cur_pro_model->GetTimeWinConformParticleDataFilenameList(conform_time_win).isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
// 交互分析
|
||||
item_name = QStringLiteral(u"交互分析");
|
||||
QStandardItem *interactive_analysis_item = AddChildNode(project_item, item_name, QString(), QVariant(), true);
|
||||
interactive_analysis_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = interactive_analysis_item;
|
||||
|
||||
status = cur_pro_model->GetChannelAddressCountDataFilenameList().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效");
|
||||
analys_type = QVariant::fromValue(AnalysisType::CountSpectrumView);
|
||||
item_name = QStringLiteral(u"道址计数谱");
|
||||
node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true);
|
||||
node_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetChannelEneryCountDataFilenameList().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效");
|
||||
analys_type = QVariant::fromValue(AnalysisType::CountSpectrumView);
|
||||
item_name = QStringLiteral(u"通道能量计数谱");
|
||||
node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true);
|
||||
node_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetAllChannelEneryTotalCountDataFilename().isEmpty() ? QStringLiteral(u"无效") : QStringLiteral(u"有效");
|
||||
analys_type = QVariant::fromValue(AnalysisType::CountSpectrumView);
|
||||
item_name = QStringLiteral(u"能量计数谱");
|
||||
node_item = AddChildNode(interactive_analysis_item, item_name, status, analys_type, true);
|
||||
node_item->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetSortAllChannelParticleDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetAllChannelEneryTotalCountDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetAllChannelEneryTotalCountDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetSortAllChannelParticleDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetSortAllChannelParticleDataFilename().isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
status = cur_pro_model->GetTimeWinConformParticleDataFilenameList(conform_time_win).isEmpty() ? 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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
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->setData(item_name, ProjectData);
|
||||
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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
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->setData(item_name, ProjectData);
|
||||
node_map[item_name] = node_item;
|
||||
|
||||
_project_node_items[project_name] = node_map;
|
||||
|
||||
|
||||
LOG_INFO(QStringLiteral(u"测量分析项目\"%1\"创建成功.").arg(project_name));
|
||||
if (!cur_pro_model->GetIsMeasureComplete()) {
|
||||
if (cur_pro_model->GetMeasureDeviceParamsCfgFilename().isEmpty()) {
|
||||
LOG_WARN(QStringLiteral(u"测量分析项目\"%1\"测量设备参数未配置!").arg(project_name));
|
||||
}
|
||||
}
|
||||
if (cur_pro_model->GetEneryScaleFilename().isEmpty()) {
|
||||
LOG_WARN(QStringLiteral(u"测量分析项目\"%1\"能量刻度未配置!").arg(project_name));
|
||||
}
|
||||
if (cur_pro_model->GetEfficiencyScaleFilename().isEmpty()) {
|
||||
LOG_WARN(QStringLiteral(u"测量分析项目\"%1\"效率刻度未配置!").arg(project_name));
|
||||
}
|
||||
}
|
||||
|
||||
QStandardItem *MeasureAnalysisProjectModelList::GetItemFromIndex(const QModelIndex &index) const
|
||||
{
|
||||
QModelIndex nameIndex = index.sibling(index.row(), NameColumn);
|
||||
return itemFromIndex(nameIndex);
|
||||
}
|
||||
|
||||
QStandardItem* MeasureAnalysisProjectModelList::AddChildNode(
|
||||
QStandardItem* parent_item, const QString& node_name, const QString& status,
|
||||
const QVariant& user_data, bool is_fixed)
|
||||
{
|
||||
if (!parent_item)
|
||||
return nullptr;
|
||||
|
||||
QStandardItem* name_item = new QStandardItem(node_name);
|
||||
name_item->setData(user_data, UserData);
|
||||
name_item->setData(is_fixed, FixedData);
|
||||
|
||||
QStandardItem* status_item = new QStandardItem(status);
|
||||
|
||||
QList<QStandardItem*> row_items;
|
||||
row_items << name_item << status_item;
|
||||
parent_item->appendRow(row_items);
|
||||
|
||||
return name_item;
|
||||
}
|
||||
|
||||
bool MeasureAnalysisProjectModelList::RemoveNode(QStandardItem* item)
|
||||
{
|
||||
if (!item)
|
||||
return false;
|
||||
if (item->column() == NameColumn && item->data(FixedData).toBool())
|
||||
return false;
|
||||
|
||||
QStandardItem* parent_item = item->parent();
|
||||
if (!parent_item) {
|
||||
return false;
|
||||
}
|
||||
parent_item->removeRow(item->row());
|
||||
|
||||
const QString& project_name = item->data(ProjectData).toString();
|
||||
if (AnalysisType::Project == item->data(UserData).value<AnalysisType>()) {
|
||||
_project_node_items.remove(project_name);
|
||||
return true;
|
||||
} else {
|
||||
const QString& node_name = item->text();
|
||||
if ( _project_node_items.contains(project_name) ) {
|
||||
if ( _project_node_items[project_name].contains(node_name) ) {
|
||||
_project_node_items[project_name].remove(node_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::SetNodeUserData(QStandardItem* item, const QVariant& data)
|
||||
{
|
||||
if (item && item->column() == NameColumn)
|
||||
item->setData(data, UserData);
|
||||
}
|
||||
|
||||
QVariant MeasureAnalysisProjectModelList::GetNodeUserData(QStandardItem* item) const
|
||||
{
|
||||
return (item && item->column() == NameColumn) ? item->data(UserData) : QVariant();
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const QString& status)
|
||||
{
|
||||
if (!item || item->column() != NameColumn)
|
||||
return;
|
||||
QStandardItem* status_item = item->parent()
|
||||
? item->parent()->child(item->row(), StatusColumn)
|
||||
: invisibleRootItem()->child(item->row(), StatusColumn);
|
||||
if (status_item) {
|
||||
status_item->setText(status);
|
||||
}
|
||||
}
|
||||
|
||||
QString MeasureAnalysisProjectModelList::GetNodeStatus(QStandardItem* item) const
|
||||
{
|
||||
if (!item || item->column() != NameColumn)
|
||||
return QString();
|
||||
QStandardItem* status_item = item->parent()
|
||||
? item->parent()->child(item->row(), StatusColumn)
|
||||
: invisibleRootItem()->child(item->row(), StatusColumn);
|
||||
return status_item ? status_item->text() : QString();
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::AddProjectModel(MeasureAnalysisProjectModel *model)
|
||||
{
|
||||
const QString& project_name = model->GetProjectName();
|
||||
ProjectModels[project_name] = model;
|
||||
_project_models[project_name] = model;
|
||||
SetCurrentProjectModel(project_name);
|
||||
intiProjectNodeStruce();
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::RmProjectModel(const QString &project_name)
|
||||
{
|
||||
if (ProjectModels.contains(project_name)) {
|
||||
delete ProjectModels[project_name];
|
||||
ProjectModels.remove(project_name);
|
||||
if (_project_models.contains(project_name)) {
|
||||
delete _project_models[project_name];
|
||||
_project_models.remove(project_name);
|
||||
}
|
||||
}
|
||||
|
||||
MeasureAnalysisProjectModel *MeasureAnalysisProjectModelList::GetProjectModel(const QString &project_name)
|
||||
{
|
||||
if (ProjectModels.contains(project_name)) {
|
||||
return ProjectModels[project_name];
|
||||
if (_project_models.contains(project_name)) {
|
||||
return _project_models[project_name];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MeasureAnalysisProjectModel *MeasureAnalysisProjectModelList::GetCurrentProjectModel()
|
||||
{
|
||||
return current_project_model;
|
||||
return _current_project_model;
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::SetCurrentProjectModel(const QString &project_name)
|
||||
{
|
||||
if (ProjectModels.contains(project_name)) {
|
||||
current_project_model = ProjectModels[project_name];
|
||||
if (_project_models.contains(project_name)) {
|
||||
_current_project_model = _project_models[project_name];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class MeasureAnalysisProjectModel
|
||||
{
|
||||
|
|
@ -13,9 +14,6 @@ public:
|
|||
Background, // 本底谱
|
||||
};
|
||||
|
||||
// ConformParticleData, uint:符合粒子数, QString符合粒子数据文件名
|
||||
typedef QMap<uint, QString> ConformParticleData;
|
||||
|
||||
public:
|
||||
void SetProjectDir(const QString& project_dir);
|
||||
void SetProjectName(const QString& project_name);
|
||||
|
|
@ -25,14 +23,21 @@ public:
|
|||
void SetMeasurePresetTime(ulong measure_preset_time);
|
||||
void SetConformTimeWin(uint conform_time_win);
|
||||
void SetIsMeasureComplete(bool is_measure_complete);
|
||||
|
||||
void SetMeasureDeviceParamsCfgFilename(const QString& filename);
|
||||
void SetEneryScaleFilename(const QString& filename);
|
||||
void SetEfficiencyScaleFilename(const QString& filename);
|
||||
|
||||
void SetAllChannelParticleDataFilename(const QString& filename);
|
||||
void SetSortedParticleDataFilename(const QString& filename);
|
||||
void SetChannelParticleDataFilename(uint channel, const QString& filename);
|
||||
void SetChannelParticleCountDataFilename(uint channel, const QString& filename);
|
||||
// void SetChannelParticleDataFilename(uint channel, const QString& filename);
|
||||
|
||||
void SetChannelAddressCountDataFilename(uint channel, const QString& filename);
|
||||
// void SetAllChannelParticleTotalCountDataFilename(const QString& filename);
|
||||
|
||||
void SetChannelEneryCountDataFilename(uint channel, const QString& filename);
|
||||
void SetAllChannelEneryTotalCountDataFilename(const QString& filename);
|
||||
|
||||
void SetTimeWinConformParticleData(uint time_win, uint conform_particle_count, const QString& filename);
|
||||
|
||||
const QString& GetProjectDir() const;
|
||||
|
|
@ -46,14 +51,22 @@ public:
|
|||
const QString& GetMeasureDeviceParamsCfgFilename() const;
|
||||
const QString& GetEneryScaleFilename() const;
|
||||
const QString& GetEfficiencyScaleFilename() const;
|
||||
|
||||
const QString& GetAllChannelParticleDataFilename() const;
|
||||
const QString& GetSortParticleDataFilename() const;
|
||||
const QMap<uint, QString>& GetChannelParticleDataFilenameList() const;
|
||||
const QString& GetChannelParticleDataFilename(uint channel) const;
|
||||
const QMap<uint, QString>& GetChannelParticleCountDataFilenameList() const;
|
||||
const QString& GetSortAllChannelParticleDataFilename() const;
|
||||
|
||||
// const QMap<uint, QString>& GetChannelParticleDataFilenameList() const;
|
||||
// const QString& GetChannelParticleDataFilename(uint channel) const;
|
||||
|
||||
const QMap<uint, QString>& GetChannelAddressCountDataFilenameList() const;
|
||||
const QString& GetChannelParticleCountDataFilename(uint channel) const;
|
||||
// const QString& GetAllChannelParticleTotalCountDataFilename() const;
|
||||
const QString& GetTimeWinConformParticleDataFilename(uint time_win, uint conform_particle_count) const;
|
||||
|
||||
const QMap<uint, QString>& GetChannelEneryCountDataFilenameList() const;
|
||||
const QString& GetChannelEneryCountDataFilename(uint channel) const;
|
||||
const QString& GetAllChannelEneryTotalCountDataFilename() const;
|
||||
|
||||
const QMap<uint, QString>& GetTimeWinConformParticleDataFilenameList(uint time_win) const;
|
||||
|
||||
private:
|
||||
QString _project_dir;
|
||||
|
|
@ -72,27 +85,58 @@ private:
|
|||
|
||||
QString _all_channel_particle_data_filename;
|
||||
QString _sorted_particle_data_filename;
|
||||
QMap<uint, QString> _channel_particle_data_filename_list;
|
||||
// QMap<uint, QString> _channel_particle_data_filename_list;
|
||||
|
||||
QMap<uint, QString> _channel_particle_count_data_filename_list;
|
||||
// QString _all_channel_particle_total_count_data_filename;
|
||||
QMap<uint, ConformParticleData> _time_win_conform_particle_data;
|
||||
|
||||
QMap<uint, QString> _channel_every_count_data_filename_list;
|
||||
QString _all_channel_enery_total_count_data_filename;
|
||||
|
||||
QMap<uint, QMap<uint, QString> > _time_win_conform_particle_data;
|
||||
|
||||
};
|
||||
|
||||
class MeasureAnalysisProjectModelList
|
||||
|
||||
class MeasureAnalysisProjectModelList : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static QMap<QString, MeasureAnalysisProjectModel*> ProjectModels;
|
||||
static MeasureAnalysisProjectModelList* Instance();
|
||||
|
||||
static void AddProjectModel(MeasureAnalysisProjectModel* model);
|
||||
static void RmProjectModel(const QString& project_name);
|
||||
void AddProjectModel(MeasureAnalysisProjectModel* model);
|
||||
void RmProjectModel(const QString& project_name);
|
||||
|
||||
static MeasureAnalysisProjectModel* GetProjectModel(const QString& project_name);
|
||||
static MeasureAnalysisProjectModel* GetCurrentProjectModel();
|
||||
static void SetCurrentProjectModel(const QString& project_name);
|
||||
MeasureAnalysisProjectModel* GetProjectModel(const QString& project_name);
|
||||
MeasureAnalysisProjectModel* GetCurrentProjectModel();
|
||||
void SetCurrentProjectModel(const QString& project_name);
|
||||
|
||||
private:
|
||||
static MeasureAnalysisProjectModel* current_project_model;
|
||||
void intiProjectNodeStruce();
|
||||
|
||||
public:
|
||||
QStandardItem* GetItemFromIndex(const QModelIndex &index) const;
|
||||
QStandardItem* AddChildNode(QStandardItem *parent_item,
|
||||
const QString &node_name,
|
||||
const QString &status = QString(),
|
||||
const QVariant &user_data = QVariant(),
|
||||
bool is_fixed = false);
|
||||
bool RemoveNode(QStandardItem *item);
|
||||
void SetNodeUserData(QStandardItem* item, const QVariant& data);
|
||||
QVariant GetNodeUserData(QStandardItem* item) const;
|
||||
void SetNodeStatus(QStandardItem* item, const QString& status);
|
||||
QString GetNodeStatus(QStandardItem* item) const;
|
||||
|
||||
private:
|
||||
explicit MeasureAnalysisProjectModelList(QObject *parent = nullptr);
|
||||
static MeasureAnalysisProjectModelList* _s_instance;
|
||||
private:
|
||||
MeasureAnalysisProjectModel* _current_project_model;
|
||||
QMap<QString, MeasureAnalysisProjectModel*> _project_models;
|
||||
QMap<QString, QMap<QString, QStandardItem*> > _project_node_items;
|
||||
};
|
||||
|
||||
typedef MeasureAnalysisProjectModelList ProjectList;
|
||||
|
||||
#endif // MEASUREANALYSISPROJECTMODEL_H
|
||||
|
|
|
|||
|
|
@ -1,439 +0,0 @@
|
|||
#include "MeasureAnalysisTree.h"
|
||||
#include "MeasureAnalysisActions.h"
|
||||
#include "MeasureAnalysisTreeItem.h"
|
||||
#include <functional>
|
||||
#include "MeasureAnalysisProjectModel.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include "QsLog.h"
|
||||
#include <QAction>
|
||||
#include <QDropEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QHeaderView>
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
TreeWidget::TreeWidget(QWidget* parent)
|
||||
: QTreeWidget(parent)
|
||||
{
|
||||
this->setHeaderHidden(true);
|
||||
this->setDragDropMode(QTreeWidget::NoDragDrop);
|
||||
this->setDefaultDropAction(Qt::IgnoreAction);
|
||||
this->setDropIndicatorShown(true);
|
||||
this->setAlternatingRowColors(false);
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
this->setSelectionMode(QTreeWidget::SingleSelection);
|
||||
this->setExpandsOnDoubleClick(false);
|
||||
|
||||
// 设置两列,第一列显示项的名称,第二列显示项的描述
|
||||
this->setColumnCount(2);
|
||||
this->setHeaderLabels({
|
||||
QString(QStringLiteral(u"项名")),
|
||||
QString(QStringLiteral(u"状态"))
|
||||
});
|
||||
// 设置第一列宽度为自适应,第二列宽度为固定
|
||||
this->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
this->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
|
||||
// 设置鼠标落在项上,显示项的详细信息
|
||||
this->setMouseTracking(true);
|
||||
connect(this, &TreeWidget::itemEntered, [this](QTreeWidgetItem* item_tree_node) {
|
||||
TreeItem* item = dynamic_cast<TreeItem*>(item_tree_node);
|
||||
if (item) {
|
||||
STATUS_BAR_MSG(item->GetDescription());
|
||||
}
|
||||
});
|
||||
|
||||
connect(this, &TreeWidget::itemDoubleClicked, [this](QTreeWidgetItem* item_tree_node) {
|
||||
TreeItem* item = dynamic_cast<TreeItem*>(item_tree_node);
|
||||
if (item) {
|
||||
TreeItemType item_type = item->GetType();
|
||||
switch (item_type) {
|
||||
case TreeItemType::ParticleData:
|
||||
case TreeItemType::ParticleCountData:
|
||||
case TreeItemType::ConformParticleData: {
|
||||
const QString view_type_text = MeasureAnalysisView::GetAnalyzeViewTypeText(MeasureAnalysisViewType::DataTable);
|
||||
item->NewAnalyzeView(item->GetName(), item->GetDescription(), view_type_text);
|
||||
MeasureAnalysisView* view = item->GetAnalyzeView(true);
|
||||
if (view) {
|
||||
emit currentItemViewWidget(view);
|
||||
}
|
||||
} break;
|
||||
case TreeItemType::AnalyzeView: {
|
||||
MeasureAnalysisView* view = item->GetAnalyzeView();
|
||||
if (view) {
|
||||
emit currentItemViewWidget(view);
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TreeWidget::~TreeWidget()
|
||||
{
|
||||
// 遍历所有项,及其子项,删除它们
|
||||
std::function<void(TreeItem* item)> clean_treeitem_view = [this, &clean_treeitem_view](TreeItem* item){
|
||||
if (item) {
|
||||
for (int j = item->childCount() - 1; j >= 0; --j) {
|
||||
TreeItem* child_item = dynamic_cast<TreeItem*>(item->child(j));
|
||||
if (child_item) {
|
||||
clean_treeitem_view(child_item);
|
||||
}
|
||||
MeasureAnalysisView* view = child_item->GetAnalyzeView();
|
||||
if (view) {
|
||||
emit removeItemViewFromStack(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for (int i = this->topLevelItemCount() - 1; i >= 0; --i) {
|
||||
TreeItem* item = dynamic_cast<TreeItem*>(this->topLevelItem(i));
|
||||
if (item) {
|
||||
clean_treeitem_view(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::SetConnectActions(MeasureAnalysisActions* const actions_analyze)
|
||||
{
|
||||
auto updateAnalyzeActionsState = [actions_analyze, this](QTreeWidgetItem* item_tree_node) {
|
||||
TreeItemType item_type = TreeItemType::None;
|
||||
TreeItem* item = dynamic_cast<TreeItem*>(item_tree_node);
|
||||
if (item) {
|
||||
item_type = item->GetType();
|
||||
} else {
|
||||
this->setCurrentItem(nullptr);
|
||||
}
|
||||
actions_analyze->SetActionsAvailable(item_type);
|
||||
};
|
||||
|
||||
connect(this, &TreeWidget::currentItemChanged,
|
||||
[updateAnalyzeActionsState](QTreeWidgetItem* current) {
|
||||
updateAnalyzeActionsState(current);
|
||||
});
|
||||
|
||||
QMenu* pop_menu_analyze_mrg = new QMenu(this);
|
||||
QList<QActionGroup*> list_act_group = actions_analyze->GetActionGroups();
|
||||
if (list_act_group.size() > 0) {
|
||||
pop_menu_analyze_mrg->addActions(list_act_group.at(0)->actions());
|
||||
for (int i = 1; i < list_act_group.size(); ++i) {
|
||||
pop_menu_analyze_mrg->addSeparator();
|
||||
pop_menu_analyze_mrg->addActions(list_act_group.at(i)->actions());
|
||||
}
|
||||
}
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &TreeWidget::customContextMenuRequested,
|
||||
[updateAnalyzeActionsState, pop_menu_analyze_mrg, this](const QPoint& pos) {
|
||||
updateAnalyzeActionsState(this->itemAt(pos));
|
||||
pop_menu_analyze_mrg->exec(QCursor::pos());
|
||||
});
|
||||
|
||||
connect(actions_analyze, &MeasureAnalysisActions::addMeasureAnalysisProject, [this]() {
|
||||
emit newMeasureAnalysisProject();
|
||||
});
|
||||
connect(actions_analyze, &MeasureAnalysisActions::rmMeasureAnalysisProject, [this]() {
|
||||
removeTreeItem(this->currentItem());
|
||||
});
|
||||
connect(actions_analyze, &MeasureAnalysisActions::modifyMeasureAnalysisProject, [this]() {
|
||||
});
|
||||
|
||||
connect(actions_analyze, &MeasureAnalysisActions::addAnalyzeView, [this]() {
|
||||
onNewMeasureAnalysisView();
|
||||
});
|
||||
|
||||
connect(actions_analyze, &MeasureAnalysisActions::rmAnalyzeView, [this]() {
|
||||
removeTreeItem(this->currentItem());
|
||||
});
|
||||
connect(actions_analyze, &MeasureAnalysisActions::modifyAnalyzeView, [this]() {
|
||||
});
|
||||
}
|
||||
|
||||
void TreeWidget::AddProjectModel(MeasureAnalysisProjectModel* model)
|
||||
{
|
||||
if (model) {
|
||||
auto new_item = new TreeMeasureAnalysisProjectItem(model->GetProjectName(), model->GetDescriptionInfo());
|
||||
if (model) {
|
||||
TreeItem* tree_item_ctrl_group = new_item->GetMeasureCtrlGroupItem();
|
||||
if (tree_item_ctrl_group) {
|
||||
const QString& measure_device_params_cfg_filename = model->GetMeasureDeviceParamsCfgFilename();
|
||||
QMap<QString, QVariant> data_files_set;
|
||||
data_files_set[QStringLiteral(u"设备参数")] = measure_device_params_cfg_filename;
|
||||
TreeItem* new_item_dev_params_cfg_data = new TreeItem;
|
||||
new_item_dev_params_cfg_data->SetName(QStringLiteral(u"测量设备参数"));
|
||||
new_item_dev_params_cfg_data->SetType(TreeItemType::DeviceConfig);
|
||||
new_item_dev_params_cfg_data->SetDescription(measure_device_params_cfg_filename);
|
||||
new_item_dev_params_cfg_data->setData(0, Qt::UserRole, data_files_set);
|
||||
tree_item_ctrl_group->addChild(new_item_dev_params_cfg_data);
|
||||
|
||||
const QString& enery_scale_filename = model->GetEneryScaleFilename();
|
||||
data_files_set.clear();
|
||||
data_files_set[QStringLiteral(u"能量刻度")] = enery_scale_filename;
|
||||
TreeItem* new_item_enery_scale = new TreeItem;
|
||||
new_item_enery_scale->SetName(QStringLiteral(u"能量刻度"));
|
||||
new_item_enery_scale->SetType(TreeItemType::EneryScale);
|
||||
new_item_enery_scale->SetDescription(enery_scale_filename);
|
||||
new_item_enery_scale->setData(0, Qt::UserRole, data_files_set);
|
||||
tree_item_ctrl_group->addChild(new_item_enery_scale);
|
||||
|
||||
const QString& efficiency_scale_filename = model->GetEfficiencyScaleFilename();
|
||||
data_files_set.clear();
|
||||
data_files_set[QStringLiteral(u"效率刻度")] = efficiency_scale_filename;
|
||||
TreeItem* new_item_efficiency_scale = new TreeItem;
|
||||
new_item_efficiency_scale->SetName(QStringLiteral(u"效率刻度"));
|
||||
new_item_efficiency_scale->SetType(TreeItemType::EfficiencyScale);
|
||||
new_item_efficiency_scale->SetDescription(efficiency_scale_filename);
|
||||
new_item_efficiency_scale->setData(0, Qt::UserRole, data_files_set);
|
||||
tree_item_ctrl_group->addChild(new_item_efficiency_scale);
|
||||
|
||||
this->expandItem(tree_item_ctrl_group);
|
||||
}
|
||||
|
||||
TreeItem* tree_item_analyze_data_group = new_item->GetAnalyzeDataGroupItem();
|
||||
if (tree_item_analyze_data_group) {
|
||||
const QString& all_ch_particle_data_filename = model->GetAllChannelParticleDataFilename();
|
||||
QMap<QString, QVariant> data_files_set;
|
||||
data_files_set[QStringLiteral(u"测量粒子数据")] = all_ch_particle_data_filename;
|
||||
|
||||
TreeItem* new_item_particle_data = new TreeItem;
|
||||
new_item_particle_data->SetName(QStringLiteral(u"测量粒子数据"));
|
||||
new_item_particle_data->SetType(TreeItemType::ParticleData);
|
||||
new_item_particle_data->SetDescription(all_ch_particle_data_filename);
|
||||
new_item_particle_data->setData(0, Qt::UserRole, data_files_set);
|
||||
tree_item_analyze_data_group->insertChild(0, new_item_particle_data);
|
||||
this->expandItem(tree_item_analyze_data_group);
|
||||
}
|
||||
}
|
||||
this->addTopLevelItem(new_item);
|
||||
this->setCurrentItem(new_item);
|
||||
this->expandItem(new_item);
|
||||
setCurrentItemHighlight();
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::onFinishedParticleSortData(const QString &project_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void TreeWidget::onFinishedSeparateEveryChannelParticleData(const QString& project_name)
|
||||
{
|
||||
for (int i = 0; i < this->topLevelItemCount(); i++) {
|
||||
QTreeWidgetItem* item = this->topLevelItem(i);
|
||||
TreeMeasureAnalysisProjectItem* tree_item_analyze = dynamic_cast<TreeMeasureAnalysisProjectItem*>(item);
|
||||
if (tree_item_analyze && (tree_item_analyze->GetName() == project_name)) {
|
||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
TreeItem* tree_item_analyze_data_group = tree_item_analyze->GetAnalyzeDataGroupItem();
|
||||
if (tree_item_analyze_data_group) {
|
||||
const QString& all_ch_particle_data_filename = project_model->GetAllChannelParticleDataFilename();
|
||||
TreeItem* new_item_particle_data = new TreeItem;
|
||||
new_item_particle_data->SetName(QStringLiteral(u"测量粒子数据"));
|
||||
new_item_particle_data->SetType(TreeItem::TreeItemType::ParticleData);
|
||||
new_item_particle_data->SetDescription(all_ch_particle_data_filename);
|
||||
new_item_particle_data->setData(0, Qt::UserRole, all_ch_particle_data_filename);
|
||||
tree_item_analyze_data_group->insertChild(0, new_item_particle_data);
|
||||
|
||||
auto ch_particle_data_filename_list = project_model->GetChannelParticleDataFilenameList();
|
||||
for (auto it = ch_particle_data_filename_list.begin(); it != ch_particle_data_filename_list.end(); ++it) {
|
||||
uint ch_num = it.key();
|
||||
const QString& ch_particle_data_filename = it.value();
|
||||
TreeItem* new_item_every_channel_particle_data = new TreeItem;
|
||||
new_item_every_channel_particle_data->SetName(QStringLiteral(u"通道%1粒子数据").arg(ch_num));
|
||||
new_item_every_channel_particle_data->SetType(TreeItem::TreeItemType::ParticleData);
|
||||
new_item_every_channel_particle_data->SetDescription(ch_particle_data_filename);
|
||||
new_item_every_channel_particle_data->setData(0, Qt::UserRole, ch_particle_data_filename);
|
||||
new_item_particle_data->addChild(new_item_every_channel_particle_data);
|
||||
}
|
||||
this->expandItem(tree_item_analyze_data_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void TreeWidget::onFinishedParticleCountData(const QString& project_name)
|
||||
{
|
||||
for (int i = 0; i < this->topLevelItemCount(); i++) {
|
||||
QTreeWidgetItem* item = this->topLevelItem(i);
|
||||
TreeMeasureAnalysisProjectItem* tree_item_analyze = dynamic_cast<TreeMeasureAnalysisProjectItem*>(item);
|
||||
if (tree_item_analyze && (tree_item_analyze->GetName() == project_name)) {
|
||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
TreeItem* tree_item_analyze_data_group = tree_item_analyze->GetAnalyzeDataGroupItem();
|
||||
if (tree_item_analyze_data_group) {
|
||||
// const QString& all_ch_count_filename = project_model->GetAllChannelParticleTotalCountDataFilename();
|
||||
// QMap<QString, QVariant> data_files_set;
|
||||
// data_files_set[QStringLiteral(u"所有通道道址计数数据")] = all_ch_count_filename;
|
||||
|
||||
TreeItem* new_item_all_ch_count = new TreeItem;
|
||||
new_item_all_ch_count->SetName(QStringLiteral(u"道址计数数据组"));
|
||||
new_item_all_ch_count->SetType(TreeItemType::AnalyzeDataGroup);
|
||||
new_item_all_ch_count->SetDescription(QStringLiteral(u"道址计数数据组,子节点包含所有通道道址的计数数据"));
|
||||
// new_item_all_ch_count->setData(0, Qt::UserRole, data_files_set);
|
||||
tree_item_analyze_data_group->addChild(new_item_all_ch_count);
|
||||
|
||||
auto ch_particle_count_filename_list = project_model->GetChannelParticleCountDataFilenameList();
|
||||
for (auto it = ch_particle_count_filename_list.begin(); it != ch_particle_count_filename_list.end(); ++it) {
|
||||
uint ch_num = it.key();
|
||||
const QString& ch_count_filename = it.value();
|
||||
QMap<QString, QVariant> data_files_set;
|
||||
data_files_set[QStringLiteral(u"通道%1").arg(ch_num)] = ch_count_filename;
|
||||
|
||||
TreeItem* new_item_every_ch_count_data = new TreeItem;
|
||||
new_item_every_ch_count_data->SetName(QStringLiteral(u"通道%1道址计数").arg(ch_num));
|
||||
new_item_every_ch_count_data->SetType(TreeItemType::ParticleCountData);
|
||||
new_item_every_ch_count_data->SetDescription(ch_count_filename);
|
||||
new_item_every_ch_count_data->setData(0, Qt::UserRole, data_files_set);
|
||||
new_item_all_ch_count->addChild(new_item_every_ch_count_data);
|
||||
}
|
||||
this->expandItem(tree_item_analyze_data_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::onNewMeasureAnalysisView()
|
||||
{
|
||||
TreeItem* current_item = dynamic_cast<TreeItem*>(this->currentItem());
|
||||
if (!current_item) {
|
||||
return;
|
||||
}
|
||||
TreeMeasureAnalysisProjectItem * project_item = getProjectItem(current_item);
|
||||
if (!project_item) {
|
||||
return;
|
||||
}
|
||||
TreeItem* new_item_analyze_view = nullptr;
|
||||
MeasureAnalysisViewType view_type = MeasureAnalysisViewType::None;
|
||||
TreeItem* tree_item_analyze_view_group = project_item->GetAnalyzeViewGroupItem();
|
||||
if (tree_item_analyze_view_group) {
|
||||
MeasureAnalysisTree::TreeItemType item_type = current_item->GetType();
|
||||
switch (item_type) {
|
||||
case MeasureAnalysisTree::TreeItemType::ParticleCountData: {
|
||||
new_item_analyze_view = new TreeItem;
|
||||
const QString& view_name = QStringLiteral(u"%1谱图表").arg(current_item->GetName());
|
||||
new_item_analyze_view->SetName(view_name);
|
||||
new_item_analyze_view->SetDescription(view_name);
|
||||
new_item_analyze_view->setData(0, Qt::UserRole, current_item->data(0, Qt::UserRole));
|
||||
|
||||
const QString& view_type_text = MeasureAnalysisView::GetAnalyzeViewTypeText(MeasureAnalysisViewType::CountSpectrum);
|
||||
new_item_analyze_view->NewAnalyzeView(view_name, view_name, view_type_text);
|
||||
} break;
|
||||
case MeasureAnalysisTree::TreeItemType::AnalyzeDataGroup: {
|
||||
if ( current_item->childCount() ) {
|
||||
TreeItem* child_item = dynamic_cast<TreeItem*>(current_item->child(0));
|
||||
if ( child_item ) {
|
||||
if ( MeasureAnalysisTree::TreeItemType::ParticleCountData == child_item->GetType() ) {
|
||||
new_item_analyze_view = new TreeItem;
|
||||
const QString& view_name = QStringLiteral(u"道址计数谱图表");
|
||||
new_item_analyze_view->SetName(view_name);
|
||||
new_item_analyze_view->SetDescription(QStringLiteral(u"32通道的道址计数谱图表"));
|
||||
|
||||
auto project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_item->GetName());
|
||||
QMap<QString, QVariant> data_files_set;
|
||||
const QMap<uint, QString>& count_data_list = project_model->GetChannelParticleCountDataFilenameList();
|
||||
for (auto it = count_data_list.begin(); it != count_data_list.end(); ++it) {
|
||||
uint ch_num = it.key();
|
||||
const QString& ch_count_filename = it.value();
|
||||
data_files_set[QStringLiteral(u"通道%1").arg(ch_num)] = ch_count_filename;
|
||||
}
|
||||
new_item_analyze_view->setData(0, Qt::UserRole, data_files_set);
|
||||
|
||||
const QString& view_type_text = MeasureAnalysisView::GetAnalyzeViewTypeText(MeasureAnalysisViewType::CountSpectrum);
|
||||
new_item_analyze_view->NewAnalyzeView(view_name, view_name, view_type_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( new_item_analyze_view ) {
|
||||
new_item_analyze_view->SetType(TreeItemType::AnalyzeView);
|
||||
MeasureAnalysisView* view = new_item_analyze_view->GetAnalyzeView();
|
||||
if (view) {
|
||||
emit currentItemViewWidget(view);
|
||||
}
|
||||
tree_item_analyze_view_group->addChild(new_item_analyze_view);
|
||||
this->expandItem(tree_item_analyze_view_group);
|
||||
} else {
|
||||
const QString& view_type_text = MeasureAnalysisView::GetAnalyzeViewTypeText(view_type);
|
||||
if ( !view_type_text.isEmpty() ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::setCurrentItemHighlight()
|
||||
{
|
||||
// 清除之前的高亮
|
||||
for (int i = 0; i < this->topLevelItemCount(); i++) {
|
||||
QTreeWidgetItem* item = this->topLevelItem(i);
|
||||
QFont font = item->font(0);
|
||||
font.setBold(false);
|
||||
item->setFont(0, font);
|
||||
item->setSelected(false);
|
||||
item->setExpanded(false);
|
||||
}
|
||||
// 再设置当前项为选中项
|
||||
auto current_item = this->currentItem();
|
||||
if (current_item) {
|
||||
QFont font = current_item->font(0);
|
||||
font.setBold(true);
|
||||
current_item->setFont(0, font);
|
||||
current_item->setSelected(true);
|
||||
current_item->setExpanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::removeTreeItem(QTreeWidgetItem* const item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
int count = item->childCount();
|
||||
if (count > 0) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
TreeItem* child_item = dynamic_cast<TreeItem*>(item->child(0));
|
||||
if (child_item) {
|
||||
MeasureAnalysisView* view = child_item->GetAnalyzeView();
|
||||
if (view) {
|
||||
emit removeItemViewFromStack(view);
|
||||
}
|
||||
}
|
||||
removeTreeItem(child_item);
|
||||
}
|
||||
}
|
||||
TreeItem* tree_item = dynamic_cast<TreeItem*>(item);
|
||||
if (tree_item) {
|
||||
MeasureAnalysisView* view = tree_item->GetAnalyzeView();
|
||||
if (view) {
|
||||
emit removeItemViewFromStack(view);
|
||||
}
|
||||
}
|
||||
delete item;
|
||||
}
|
||||
|
||||
MeasureAnalysisTree::TreeMeasureAnalysisProjectItem *MeasureAnalysisTree::TreeWidget::getProjectItem(TreeItem *item)
|
||||
{
|
||||
if (item) {
|
||||
TreeItemType item_type = item->GetType();
|
||||
if (TreeItemType::MeasureAnalysisProject == item_type) {
|
||||
return dynamic_cast<TreeMeasureAnalysisProjectItem*>(item);
|
||||
} else {
|
||||
item = dynamic_cast<TreeItem*>(item->parent());
|
||||
if (item) {
|
||||
return getProjectItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace MeasureAnalysisTree
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#ifndef MEASUREANALYSISTREE_TREEWIDGET_H
|
||||
#define MEASUREANALYSISTREE_TREEWIDGET_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
class QActionGroup;
|
||||
class MeasureAnalysisView;
|
||||
class MeasureAnalysisProjectModel;
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
class MeasureAnalysisActions;
|
||||
class TreeAnalyzeItem;
|
||||
class TreeItem;
|
||||
class TreeMeasureAnalysisProjectItem;
|
||||
|
||||
class TreeWidget : public QTreeWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeWidget(QWidget* parent = nullptr);
|
||||
~TreeWidget();
|
||||
|
||||
void SetConnectActions(MeasureAnalysisActions* const actions_analyze);
|
||||
void AddProjectModel(MeasureAnalysisProjectModel* model);
|
||||
|
||||
private:
|
||||
TreeMeasureAnalysisProjectItem* getProjectItem(TreeItem* item);
|
||||
|
||||
private slots:
|
||||
// void onFinishedSeparateEveryChannelParticleData(const QString& project_name);
|
||||
void onFinishedParticleSortData(const QString& project_name);
|
||||
void onFinishedParticleCountData(const QString& project_name);
|
||||
void onNewMeasureAnalysisView();
|
||||
|
||||
|
||||
signals:
|
||||
void currentItemViewWidget(MeasureAnalysisView* view);
|
||||
void removeItemViewFromStack(MeasureAnalysisView* view);
|
||||
void newMeasureAnalysisProject();
|
||||
|
||||
private:
|
||||
void setCurrentItemHighlight();
|
||||
void removeTreeItem(QTreeWidgetItem* const item);
|
||||
|
||||
};
|
||||
|
||||
} // namespace MeasureAnalysisTree
|
||||
#endif // MEASUREANALYSISTREE_TREEWIDGET_H
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
#include "MeasureAnalysisTreeItem.h"
|
||||
#include "MeasureAnalysisView.h"
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
TreeItemType TreeItem::GetType()
|
||||
{
|
||||
return this->_type;
|
||||
}
|
||||
|
||||
void TreeItem::SetType(const TreeItemType& type)
|
||||
{
|
||||
this->_type = type;
|
||||
}
|
||||
|
||||
TreeItem::TreeItem()
|
||||
{
|
||||
this->_type = TreeItemType::None;
|
||||
}
|
||||
|
||||
TreeItem::~TreeItem()
|
||||
{
|
||||
if (this->_ptr_analyze_view) {
|
||||
delete this->_ptr_analyze_view;
|
||||
this->_ptr_analyze_view = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const QString& TreeItem::GetName()
|
||||
{
|
||||
return this->_name;
|
||||
}
|
||||
|
||||
void TreeItem::SetName(const QString& name)
|
||||
{
|
||||
this->_name = name;
|
||||
this->setText(0, name);
|
||||
}
|
||||
|
||||
const QString& TreeItem::GetDescription()
|
||||
{
|
||||
return this->_description;
|
||||
}
|
||||
|
||||
void TreeItem::SetDescription(const QString& desc)
|
||||
{
|
||||
this->_description = desc;
|
||||
this->setStatusTip(0, desc);
|
||||
}
|
||||
|
||||
MeasureAnalysisView* TreeItem::GetAnalyzeView(bool b_take)
|
||||
{
|
||||
MeasureAnalysisView* view = this->_ptr_analyze_view;
|
||||
if ( b_take ) {
|
||||
this->_ptr_analyze_view = nullptr;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
void TreeItem::NewAnalyzeView(const QString &name, const QString &description, const QString &view_type_text)
|
||||
{
|
||||
if (this->_ptr_analyze_view) {
|
||||
return;
|
||||
}
|
||||
this->_ptr_analyze_view = MeasureAnalysisView::NewAnalyzeView(view_type_text);
|
||||
this->_ptr_analyze_view->SetViewName(name);
|
||||
this->_ptr_analyze_view->SetViewDescription(description);
|
||||
const QMap<QString, QVariant>& data_files_set = this->data(0, Qt::UserRole).toMap();
|
||||
this->_ptr_analyze_view->SetAnalyzeDataFilename(data_files_set);
|
||||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream& out, const TreeItem& item)
|
||||
{
|
||||
// quint64 id = item.data(0, Qt::UserRole).toULongLong();
|
||||
// out << item._type << item._name << item._description << id << item.isExpanded();
|
||||
// bool has_view = item._ptr_analyze_view ? true : false;
|
||||
// out << has_view;
|
||||
// if (has_view) {
|
||||
// out << *item._ptr_analyze_view;
|
||||
// }
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream& operator>>(QDataStream& in, TreeItem& item)
|
||||
{
|
||||
// quint64 id = 0;
|
||||
// bool item_expanded = false;
|
||||
// in >> item._type >> item._name >> item._description >> id >> item_expanded;
|
||||
// item.setText(0, item._name);
|
||||
// item.setStatusTip(0, item._description);
|
||||
// item.setData(0, Qt::UserRole, id);
|
||||
// item.setExpanded(item_expanded);
|
||||
// bool has_view = false;
|
||||
// in >> has_view;
|
||||
// if (has_view) {
|
||||
// QString view_type_text;
|
||||
// in >> view_type_text;
|
||||
// if (!view_type_text.isEmpty()) {
|
||||
// item._ptr_analyze_view = MeasureAnalysisView::NewAnalyzeView(view_type_text);
|
||||
// if (item._ptr_analyze_view) {
|
||||
// in >> *(item._ptr_analyze_view);
|
||||
// item._ptr_analyze_view->UpdateAnalyzeView();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return in;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TreeMeasureAnalysisProjectItem::TreeMeasureAnalysisProjectItem(const QString& project_name, const QString& description)
|
||||
{
|
||||
this->SetType(TreeItemType::MeasureAnalysisProject);
|
||||
this->SetName(project_name);
|
||||
this->SetDescription(description);
|
||||
|
||||
TreeItem* tree_group_item = new TreeItem;
|
||||
tree_group_item->SetType(TreeItemType::MeasureCtrlGroup);
|
||||
tree_group_item->SetName(QStringLiteral(u"测量控制"));
|
||||
tree_group_item->SetDescription(QStringLiteral(u"测量控制组:包括测量设备参数设置、测量时间设置、能量刻度、效率刻度等配置管理"));
|
||||
this->insertChild(0, tree_group_item);
|
||||
|
||||
tree_group_item = new TreeItem;
|
||||
tree_group_item->SetType(TreeItemType::AnalyzeDataGroup);
|
||||
tree_group_item->SetName(QStringLiteral(u"分析数据"));
|
||||
tree_group_item->SetDescription(QStringLiteral(u"分析数据组:包括粒子数据、谱计数数据、符合粒子数据等管理"));
|
||||
this->insertChild(1, tree_group_item);
|
||||
|
||||
tree_group_item = new TreeItem;
|
||||
tree_group_item->SetType(TreeItemType::AnalyzeViewGroup);
|
||||
tree_group_item->SetName(QStringLiteral(u"分析视图"));
|
||||
tree_group_item->SetDescription(QStringLiteral(u"分析视图组:包括粒子数据视图、谱计数数据视图、符合粒子数据视图等管理"));
|
||||
this->insertChild(2, tree_group_item);
|
||||
}
|
||||
|
||||
TreeItem* TreeMeasureAnalysisProjectItem::GetMeasureCtrlGroupItem()
|
||||
{
|
||||
return dynamic_cast<TreeItem*>(this->child(0));
|
||||
}
|
||||
|
||||
TreeItem* TreeMeasureAnalysisProjectItem::GetAnalyzeDataGroupItem()
|
||||
{
|
||||
return dynamic_cast<TreeItem*>(this->child(1));
|
||||
}
|
||||
|
||||
TreeItem* TreeMeasureAnalysisProjectItem::GetAnalyzeViewGroupItem()
|
||||
{
|
||||
return dynamic_cast<TreeItem*>(this->child(2));
|
||||
}
|
||||
|
||||
} // namespace MeasureAnalysisTree
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#ifndef MEASUREANALYSISTREE_TREEITEM_H
|
||||
#define MEASUREANALYSISTREE_TREEITEM_H
|
||||
|
||||
#include "MeasureAnalysisView.h"
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
namespace MeasureAnalysisTree {
|
||||
|
||||
class TreeAnalyzeViewItem;
|
||||
|
||||
enum class TreeItemType {
|
||||
None,
|
||||
MeasureAnalysisProject,
|
||||
MeasureCtrlGroup,
|
||||
DeviceConfig,
|
||||
EneryScale,
|
||||
EfficiencyScale,
|
||||
AnalyzeDataGroup,
|
||||
ParticleData,
|
||||
ParticleCountData,
|
||||
ConformParticleData,
|
||||
AnalyzeViewGroup,
|
||||
AnalyzeView
|
||||
};
|
||||
|
||||
class TreeItem : public QTreeWidgetItem {
|
||||
public:
|
||||
|
||||
TreeItemType GetType();
|
||||
void SetType(const TreeItemType& type);
|
||||
|
||||
public:
|
||||
TreeItem();
|
||||
virtual ~TreeItem();
|
||||
|
||||
const QString& GetName();
|
||||
void SetName(const QString& name);
|
||||
const QString& GetDescription();
|
||||
void SetDescription(const QString& desc);
|
||||
|
||||
public:
|
||||
MeasureAnalysisView* GetAnalyzeView(bool b_take = false);
|
||||
void NewAnalyzeView(const QString& name, const QString& description, const QString& view_type_text);
|
||||
|
||||
public:
|
||||
friend QDataStream& operator<<(QDataStream& out, const TreeItem& item);
|
||||
friend QDataStream& operator>>(QDataStream& in, TreeItem& item);
|
||||
|
||||
protected:
|
||||
MeasureAnalysisView* _ptr_analyze_view { nullptr };
|
||||
|
||||
private:
|
||||
TreeItemType _type;
|
||||
QString _name;
|
||||
QString _description;
|
||||
};
|
||||
|
||||
class TreeMeasureAnalysisProjectItem : public TreeItem {
|
||||
public:
|
||||
TreeMeasureAnalysisProjectItem(const QString& project_name, const QString& description);
|
||||
TreeItem* GetMeasureCtrlGroupItem();
|
||||
TreeItem* GetAnalyzeDataGroupItem();
|
||||
TreeItem* GetAnalyzeViewGroupItem();
|
||||
};
|
||||
|
||||
} // namespace MeasureAnalysisTree
|
||||
|
||||
#endif // MEASUREANALYSISTREE_TREEITEM_H
|
||||
|
|
@ -161,7 +161,7 @@ void NewMeasureAnalysisDlg::on_btn_ok_clicked()
|
|||
model->SetAllChannelParticleDataFilename(all_channel_particle_data_filename);
|
||||
model->SetIsMeasureComplete(is_measure_complete);
|
||||
|
||||
MeasureAnalysisProjectModelList::AddProjectModel(model);
|
||||
ProjectList::Instance()->AddProjectModel(model);
|
||||
|
||||
NewMeasureAnalysisDlg::accept();
|
||||
}
|
||||
|
|
|
|||
13
src/src.pro
13
src/src.pro
|
|
@ -33,16 +33,14 @@ SOURCES += \
|
|||
DataProcessWorkPool.cpp \
|
||||
EneryScaleForm.cpp \
|
||||
MainWindow.cpp \
|
||||
MeasureAnalysisActions.cpp \
|
||||
MeasureAnalysisDataTableView.cpp \
|
||||
MeasureAnalysisHistoryForm.cpp \
|
||||
MeasureAnalysisParticleCountPlotView.cpp \
|
||||
MeasureAnalysisProjectModel.cpp \
|
||||
MeasureAnalysisTree.cpp \
|
||||
MeasureAnalysisTreeItem.cpp \
|
||||
MeasureAnalysisTreeView.cpp \
|
||||
MeasureAnalysisView.cpp \
|
||||
MeasureDeviceParamsCfgForm.cpp \
|
||||
NewMeasureAnalysisDlg.cpp \
|
||||
MeasureAnalysisProjectModel.cpp \
|
||||
VirtualTable/CsvDataSource.cpp \
|
||||
VirtualTable/SampleDataSource.cpp \
|
||||
VirtualTable/VirtualTableModel.cpp \
|
||||
|
|
@ -51,20 +49,19 @@ SOURCES += \
|
|||
|
||||
HEADERS += \
|
||||
AboutDlg.h \
|
||||
AnalysisTypeDefine.h \
|
||||
DataProcessWorkPool.h \
|
||||
EneryScaleForm.h \
|
||||
GlobalDefine.h \
|
||||
MainWindow.h \
|
||||
MeasureAnalysisActions.h \
|
||||
MeasureAnalysisDataTableView.h \
|
||||
MeasureAnalysisHistoryForm.h \
|
||||
MeasureAnalysisParticleCountPlotView.h \
|
||||
MeasureAnalysisProjectModel.h \
|
||||
MeasureAnalysisTree.h \
|
||||
MeasureAnalysisTreeItem.h \
|
||||
MeasureAnalysisTreeView.h \
|
||||
MeasureAnalysisView.h \
|
||||
MeasureDeviceParamsCfgForm.h \
|
||||
NewMeasureAnalysisDlg.h \
|
||||
MeasureAnalysisProjectModel.h \
|
||||
VirtualTable/CsvDataSource.h \
|
||||
VirtualTable/DataSource.h \
|
||||
VirtualTable/SampleDataSource.h \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user