优化测量分析测量设备参数配置
This commit is contained in:
parent
adc67aac77
commit
ab742c6290
|
|
@ -86,6 +86,13 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
|
|||
view = _item_views[item];
|
||||
} else {
|
||||
switch(analysis_type) {
|
||||
case AnalysisType::DeviceParamsCfg: {
|
||||
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
QString file_name = project_model->GetMeasureDeviceParamsCfgFilename();
|
||||
data_files_set[QStringLiteral(u"设备参数配置")] = file_name;
|
||||
}
|
||||
} break;
|
||||
case AnalysisType::ParticleData: {
|
||||
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
|
|
@ -237,13 +244,6 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
|
|||
}
|
||||
}
|
||||
} break;
|
||||
case AnalysisType::DeviceParamsCfg: {
|
||||
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
QString file_name = project_model->GetMeasureDeviceParamsCfgFilename();
|
||||
data_files_set[QStringLiteral(u"设备参数配置")] = file_name;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "MeasureAnalysisView.h"
|
||||
#include "ConformityAnalysis.h"
|
||||
#include "CountRateAnalysisView.h"
|
||||
#include "DeviceConfigView.h"
|
||||
#include "MeasureDeviceParamsConfigView.h"
|
||||
#include "EnergyCountPeakFitView.h"
|
||||
#include "EnergyCountPlotView.h"
|
||||
#include "MeasureAnalysisDataTableView.h"
|
||||
|
|
@ -19,7 +19,7 @@ MeasureAnalysisView* MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type)
|
|||
// new_view->setDeleteOnClose(true);
|
||||
} break;
|
||||
case AnalysisType::DeviceParamsCfg: {
|
||||
new_view = new DeviceConfigView;
|
||||
new_view = new MeasureDeviceParamsConfigView;
|
||||
new_view->setDeleteOnClose(true);
|
||||
} break;
|
||||
case AnalysisType::EnergyScale: {
|
||||
|
|
|
|||
221
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.cpp
Normal file
221
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.cpp
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
#include "DeviceParamsTableForm.h"
|
||||
#include "ui_DeviceParamsTableForm.h"
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
DeviceParamsItemDelegate::DeviceParamsItemDelegate(QObject* parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* DeviceParamsItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
QWidget* editor = nullptr;
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 1: { // 多道分辨率
|
||||
QStringList value_list { "256", "512", "1024", "2048", "4096", "8192", "16384" };
|
||||
QComboBox *combobox = new QComboBox(parent);
|
||||
for (int index = 0; index < value_list.size(); ++index) {
|
||||
QString value = value_list.at(index);
|
||||
combobox->addItem(value, value.toInt());
|
||||
}
|
||||
editor = combobox;
|
||||
} break;
|
||||
case 2: { // 硬件增益
|
||||
QStringList value_list { "1", "2", "4", "8", "16" };
|
||||
QComboBox *combobox = new QComboBox(parent);
|
||||
for (int index = 0; index < value_list.size(); ++index) {
|
||||
QString value = value_list.at(index);
|
||||
combobox->addItem(value, index);
|
||||
}
|
||||
editor = combobox;
|
||||
} break;
|
||||
case 3: { // 软件增益
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(1, 2^32-1);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
case 4: { // 时间常数
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(1, 100);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
case 5: { // 直流偏移
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(-1000, 1000);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
case 6: { // 上升时间
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(1, 255);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
case 7: { // 平顶时间
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(1, 255);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
case 8: { // 最大能量范围
|
||||
QSpinBox* spinbox = new QSpinBox(parent);
|
||||
spinbox->setRange(0, 99999);
|
||||
editor = spinbox;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void DeviceParamsItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
QVariant value = index.data(Qt::EditRole);
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 1:
|
||||
case 2: {
|
||||
QComboBox *combo = qobject_cast<QComboBox*>(editor);
|
||||
if (combo) {
|
||||
int idx = combo->findText(value.toString());
|
||||
if (idx >= 0) combo->setCurrentIndex(idx);
|
||||
}
|
||||
} break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8: {
|
||||
QSpinBox *spinbox = qobject_cast<QSpinBox*>(editor);
|
||||
if (spinbox) {
|
||||
spinbox->setValue(value.toUInt());
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceParamsItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 1:
|
||||
case 2: {
|
||||
QComboBox *combobox = qobject_cast<QComboBox*>(editor);
|
||||
if (combobox) {
|
||||
model->setData(index, combobox->currentText());
|
||||
}
|
||||
} break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8: {
|
||||
QSpinBox *spinbox = qobject_cast<QSpinBox*>(editor);
|
||||
if (spinbox) {
|
||||
model->setData(index, spinbox->value());
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceParamsItemDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
bool DeviceParamsItemDelegate::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
return QStyledItemDelegate::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
DeviceParamsTableForm::DeviceParamsTableForm(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::DeviceParamsTableForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->params_cfg_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->params_cfg_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
ui->params_cfg_table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
|
||||
ui->params_cfg_table->setItemDelegate(new DeviceParamsItemDelegate(this));
|
||||
|
||||
for (int row = 0; row < 32; ++row) {
|
||||
ui->params_cfg_table->insertRow(row);
|
||||
const QString& channel_text = QStringLiteral(u"通道%1").arg(row + 1);
|
||||
ui->params_cfg_table->setItem(row, 0, new QTableWidgetItem(channel_text));
|
||||
ui->params_cfg_table->item(row, 0)->setCheckState(Qt::Unchecked);
|
||||
ui->params_cfg_table->setItem(row, 1, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 2, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 3, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 4, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 5, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 6, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 7, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 8, new QTableWidgetItem());
|
||||
ui->params_cfg_table->setItem(row, 9, new QTableWidgetItem());
|
||||
}
|
||||
|
||||
connect(ui->btn_channel_select, &QPushButton::clicked, this, &DeviceParamsTableForm::onCfgChannelSelectBtnClicked);
|
||||
}
|
||||
|
||||
DeviceParamsTableForm::~DeviceParamsTableForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DeviceParamsTableForm::onCfgChannelSelectBtnClicked()
|
||||
{
|
||||
QDialog cfg_channel_select_dlg(this, Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
cfg_channel_select_dlg.setWindowTitle(QString(QStringLiteral(u"设备测量参数配置通道选择")));
|
||||
cfg_channel_select_dlg.setWindowModality(Qt::WindowModal);
|
||||
cfg_channel_select_dlg.setModal(true);
|
||||
QVBoxLayout* layout = new QVBoxLayout(&cfg_channel_select_dlg);
|
||||
// 自动计算多列排布
|
||||
int num_columns = std::sqrt(32);
|
||||
if (num_columns == 0)
|
||||
num_columns = 1;
|
||||
QVBoxLayout* checkbox_layout = new QVBoxLayout();
|
||||
QHBoxLayout* checkbox_column_layout = new QHBoxLayout();
|
||||
for (int row = 0; row < 32; ++row) {
|
||||
QCheckBox* check_box = new QCheckBox(QStringLiteral(u"通道%1").arg(row + 1));
|
||||
check_box->setChecked(true);
|
||||
checkbox_column_layout->addWidget(check_box);
|
||||
connect(check_box, &QCheckBox::stateChanged, [this, row](int state) {
|
||||
ui->params_cfg_table->setRowHidden(row, state == Qt::Unchecked);
|
||||
});
|
||||
if (checkbox_column_layout->count() >= num_columns) {
|
||||
checkbox_layout->addLayout(checkbox_column_layout);
|
||||
checkbox_column_layout = new QHBoxLayout();
|
||||
}
|
||||
}
|
||||
if (checkbox_column_layout->count() < num_columns) {
|
||||
checkbox_column_layout->addStretch();
|
||||
}
|
||||
checkbox_layout->addLayout(checkbox_column_layout);
|
||||
// 全选和反选
|
||||
QHBoxLayout* button_layout = new QHBoxLayout();
|
||||
QPushButton* btn_all_select = new QPushButton(QString(QStringLiteral(u"全选")));
|
||||
connect(btn_all_select, &QPushButton::clicked, [this]() {
|
||||
for (int row = 0; row < 32; ++row) {
|
||||
ui->params_cfg_table->setRowHidden(row, true);
|
||||
}
|
||||
});
|
||||
button_layout->addWidget(btn_all_select);
|
||||
QPushButton* btn_reserve_select = new QPushButton(QString(QStringLiteral(u"反选")));
|
||||
connect(btn_reserve_select, &QPushButton::clicked, [this]() {
|
||||
for (int row = 0; row < 32; ++row) {
|
||||
ui->params_cfg_table->setRowHidden(row, !ui->params_cfg_table->isRowHidden(row));
|
||||
}
|
||||
});
|
||||
button_layout->addWidget(btn_reserve_select);
|
||||
|
||||
layout->addLayout(button_layout);
|
||||
layout->addLayout(checkbox_layout);
|
||||
cfg_channel_select_dlg.exec();
|
||||
}
|
||||
44
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.h
Normal file
44
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef DEVICEPARAMSTABLEFORM_H
|
||||
#define DEVICEPARAMSTABLEFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
namespace Ui {
|
||||
class DeviceParamsTableForm;
|
||||
}
|
||||
|
||||
class DeviceParamsItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceParamsItemDelegate(QObject *parent = nullptr);
|
||||
|
||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
};
|
||||
|
||||
class DeviceParamsTableForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeviceParamsTableForm(QWidget *parent = nullptr);
|
||||
~DeviceParamsTableForm();
|
||||
|
||||
private slots:
|
||||
void onCfgChannelSelectBtnClicked();
|
||||
|
||||
private:
|
||||
Ui::DeviceParamsTableForm *ui;
|
||||
};
|
||||
|
||||
#endif // DEVICEPARAMSTABLEFORM_H
|
||||
105
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.ui
Normal file
105
src/MeasureDeviceParamsConfigView/DeviceParamsTableForm.ui
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DeviceParamsTableForm</class>
|
||||
<widget class="QWidget" name="DeviceParamsTableForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>891</width>
|
||||
<height>474</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_channel_select">
|
||||
<property name="text">
|
||||
<string>配置通道选择</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="params_cfg_table">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>通道</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>道址数</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>硬件增益</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>软件增益</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>时间常数</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>直流偏移</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>上升时间</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>平顶时间</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>最大能量范围</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include "MeasureDeviceParamsConfigView.h"
|
||||
#include "DeviceParamsTableForm.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
MeasureDeviceParamsConfigView::MeasureDeviceParamsConfigView(QWidget *parent)
|
||||
: MeasureAnalysisView(parent)
|
||||
{
|
||||
_device_params_table = new DeviceParamsTableForm;
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(_device_params_table);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
MeasureDeviceParamsConfigView::~MeasureDeviceParamsConfigView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MeasureDeviceParamsConfigView::InitViewWorkspace(const QString &project_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MeasureDeviceParamsConfigView::SetAnalyzeDataFilename(const QMap<QString, QVariant> &data_files_set)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef MEASUREDEVICEPARAMSCONFIGVIEW_H
|
||||
#define MEASUREDEVICEPARAMSCONFIGVIEW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <MeasureAnalysisView.h>
|
||||
|
||||
class DeviceParamsTableForm;
|
||||
|
||||
class MeasureDeviceParamsConfigView : public MeasureAnalysisView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MeasureDeviceParamsConfigView(QWidget *parent = nullptr);
|
||||
virtual ~MeasureDeviceParamsConfigView();
|
||||
|
||||
virtual void InitViewWorkspace(const QString& project_name) override final;
|
||||
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
|
||||
|
||||
private:
|
||||
DeviceParamsTableForm* _device_params_table = nullptr;
|
||||
};
|
||||
|
||||
#endif // MEASUREDEVICEPARAMSCONFIGVIEW_H
|
||||
|
|
@ -42,6 +42,7 @@ INCLUDEPATH += \
|
|||
$${PWD}/MeasureAnalysisDataTableView \
|
||||
$${PWD}/ParticleTimeDifferenceView \
|
||||
$${PWD}/MeasureAnalysisHistoryForm \
|
||||
$${PWD}/MeasureDeviceParamsConfigView \
|
||||
$${PWD}/DeviceParameterConfig
|
||||
|
||||
|
||||
|
|
@ -57,6 +58,7 @@ DEPENDPATH += \
|
|||
$${PWD}/MeasureAnalysisDataTableView \
|
||||
$${PWD}/ParticleTimeDifferenceView \
|
||||
$${PWD}/MeasureAnalysisHistoryForm \
|
||||
$${PWD}/MeasureDeviceParamsConfigView \
|
||||
$${PWD}/DeviceParameterConfig
|
||||
|
||||
|
||||
|
|
@ -76,6 +78,8 @@ SOURCES += \
|
|||
MainWindow.cpp \
|
||||
MeasureAnalysisDataTableView/MeasureAnalysisDataTableView.cpp \
|
||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.cpp \
|
||||
MeasureDeviceParamsConfigView/DeviceParamsTableForm.cpp \
|
||||
MeasureDeviceParamsConfigView/MeasureDeviceParamsConfigView.cpp \
|
||||
ParticleCountPlotView/BatchEnergyScaleDialog.cpp \
|
||||
ParticleCountPlotView/FindPeaksResultDialog.cpp \
|
||||
ParticleCountPlotView/ParticleCountPlotView.cpp \
|
||||
|
|
@ -116,6 +120,8 @@ HEADERS += \
|
|||
MainWindow.h \
|
||||
MeasureAnalysisDataTableView/MeasureAnalysisDataTableView.h \
|
||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.h \
|
||||
MeasureDeviceParamsConfigView/DeviceParamsTableForm.h \
|
||||
MeasureDeviceParamsConfigView/MeasureDeviceParamsConfigView.h \
|
||||
ParticleCountPlotView/BatchEnergyScaleDialog.h \
|
||||
ParticleCountPlotView/FindPeaksResultDialog.h \
|
||||
ParticleCountPlotView/ParticleCountPlotView.h \
|
||||
|
|
@ -146,6 +152,7 @@ FORMS += \
|
|||
EnergyScaleForm.ui \
|
||||
MainWindow.ui \
|
||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.ui \
|
||||
MeasureDeviceParamsConfigView/DeviceParamsTableForm.ui \
|
||||
ParticleCountPlotView/BatchEnergyScaleDialog.ui \
|
||||
MeasureDeviceParamsCfgForm.ui \
|
||||
NewMeasureAnalysisDlg.ui \
|
||||
|
|
|
|||
1
style/logo.rc
Normal file
1
style/logo.rc
Normal file
|
|
@ -0,0 +1 @@
|
|||
IDI_ICON1 ICON DISCARDABLE "logo/logo.ico"
|
||||
Loading…
Reference in New Issue
Block a user