EnergySpectrumAnalyer/src/MeasureAnalysisTreeItem.cpp

154 lines
4.6 KiB
C++

#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 QString& data_filename = this->data(0, Qt::UserRole).toString();
QMap<QString, QString> data_files_set;
data_files_set[name] = data_filename;
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