Compare commits
No commits in common. "5d8caba6f078b3d5ae6bc70837b687a99e9d7397" and "a3bfaa3333ec3428b9b66bacb748eb311d0fc32f" have entirely different histories.
5d8caba6f0
...
a3bfaa3333
|
|
@ -1,212 +0,0 @@
|
||||||
#include "EnergyCountPeakFitView.h"
|
|
||||||
#include "CustomQwtPlot.h"
|
|
||||||
#include "csv.h"
|
|
||||||
#include <GlobalDefine.h>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QwtLegend>
|
|
||||||
#include <QwtPlotCanvas>
|
|
||||||
#include <QwtPlotCurve>
|
|
||||||
#include <QwtPlotMarker>
|
|
||||||
#include <QwtScaleMap>
|
|
||||||
#include <QwtText>
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QwtScaleDiv>
|
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
|
|
||||||
EnergyCountPeakFitView::EnergyCountPeakFitView(QWidget *parent)
|
|
||||||
: MeasureAnalysisView { parent }
|
|
||||||
{
|
|
||||||
this->setViewType(PlotFrame);
|
|
||||||
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
|
||||||
this->_plot = new CustomQwtPlot(this);
|
|
||||||
layout->addWidget(this->_plot);
|
|
||||||
setupPlot();
|
|
||||||
this->_menu = new QMenu(this);
|
|
||||||
setupMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
EnergyCountPeakFitView::~EnergyCountPeakFitView()
|
|
||||||
{
|
|
||||||
LOG_DEBUG(QStringLiteral(u"%1析构.").arg(this->GetViewName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::InitViewWorkspace(const QString &project_name)
|
|
||||||
{
|
|
||||||
Q_UNUSED(project_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::SetAnalyzeDataFilename(const QMap<QString, QVariant> &data_files_set)
|
|
||||||
{
|
|
||||||
if ( !data_files_set.isEmpty() ) {
|
|
||||||
const QString& data_name = data_files_set.firstKey();
|
|
||||||
const QString& data_filename = data_files_set.first().toString();
|
|
||||||
if (QFileInfo(data_filename).exists()) {
|
|
||||||
loadDataFromFile(data_name, data_filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::setupPlot()
|
|
||||||
{
|
|
||||||
_plot->setCanvasBackground(Qt::white);
|
|
||||||
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(_plot->canvas());
|
|
||||||
canvas->setFrameStyle(QFrame::NoFrame);
|
|
||||||
|
|
||||||
QFont font = this->font();
|
|
||||||
font.setBold(false);
|
|
||||||
QwtText energy_label = QStringLiteral(u"能量(KeV)");
|
|
||||||
energy_label.setFont(font);
|
|
||||||
QwtText count_label = QStringLiteral(u"计数");
|
|
||||||
count_label.setFont(font);
|
|
||||||
_plot->setAxisTitle(QwtPlot::xBottom, energy_label);
|
|
||||||
_plot->setAxisTitle(QwtPlot::yLeft, count_label);
|
|
||||||
|
|
||||||
// set axis auto scale
|
|
||||||
_plot->setAxisAutoScale(QwtPlot::xBottom, true);
|
|
||||||
_plot->setAxisAutoScale(QwtPlot::yLeft, true);
|
|
||||||
|
|
||||||
_plot->enableAxis(QwtPlot::xBottom);
|
|
||||||
_plot->enableAxis(QwtPlot::yLeft);
|
|
||||||
|
|
||||||
// 设置QWT图例
|
|
||||||
// QwtLegend* legend = new QwtLegend();
|
|
||||||
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
|
||||||
// _plot->insertLegend(legend, QwtPlot::RightLegend);
|
|
||||||
|
|
||||||
_plot->SetXaxisDragScale(true);
|
|
||||||
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
|
||||||
_data_selector->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::setupMenu()
|
|
||||||
{
|
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(this, &EnergyCountPeakFitView::customContextMenuRequested, [this](const QPoint& pos) {
|
|
||||||
this->_menu->exec(this->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
QAction* action_plot_reset = this->_menu->addAction(QStringLiteral(u"还原"));
|
|
||||||
action_plot_reset->setObjectName("plot_reset");
|
|
||||||
connect(action_plot_reset, &QAction::triggered, [this]() {
|
|
||||||
this->_plot->ResetPlot();
|
|
||||||
});
|
|
||||||
this->_menu->addSeparator();
|
|
||||||
QAction* action_set_curve_show = this->_menu->addAction(QStringLiteral(u"选择曲线"));
|
|
||||||
action_set_curve_show->setObjectName("curve_show_setting");
|
|
||||||
connect(action_set_curve_show, &QAction::triggered, this, &EnergyCountPeakFitView::onActionCurveShowSetting);
|
|
||||||
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
|
||||||
action_plot_config->setObjectName("plot_config");
|
|
||||||
connect(action_plot_config, &QAction::triggered, this, &EnergyCountPeakFitView::onActionPlotConfigure);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::loadDataFromFile(const QString &data_name, const QString &filename)
|
|
||||||
{
|
|
||||||
std::string address_str = QString(QStringLiteral(u"能量(KeV)")).toStdString();
|
|
||||||
std::string count_str = QString(QStringLiteral(u"计数")).toStdString();
|
|
||||||
|
|
||||||
io::CSVReader<
|
|
||||||
2,
|
|
||||||
io::trim_chars<' ', '\t'>,
|
|
||||||
io::double_quote_escape<',', '"'>,
|
|
||||||
io::throw_on_overflow,
|
|
||||||
io::empty_line_comment>
|
|
||||||
reader(QStrToSysPath(filename));
|
|
||||||
reader.read_header(io::ignore_extra_column, address_str, count_str);
|
|
||||||
|
|
||||||
double energy;
|
|
||||||
unsigned long long energy_count;
|
|
||||||
QVector<double> x, y;
|
|
||||||
while (reader.read_row(energy, energy_count)) {
|
|
||||||
x.push_back(energy);
|
|
||||||
y.push_back(energy_count);
|
|
||||||
}
|
|
||||||
// 绘制曲线
|
|
||||||
QwtPlotCurve* curve = new QwtPlotCurve(data_name);
|
|
||||||
curve->setSamples(x, y);
|
|
||||||
_plot->AddCurve(curve);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::onActionCurveShowSetting()
|
|
||||||
{
|
|
||||||
if (!_curve_show_setting_dlg) {
|
|
||||||
_curve_show_setting_dlg = new QDialog(this, Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
_curve_show_setting_dlg->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
_curve_show_setting_dlg->setSizeGripEnabled(false);
|
|
||||||
_curve_show_setting_dlg->setWindowTitle(QString(QStringLiteral(u"选择%1曲线显示").arg(this->_plot->title().text())));
|
|
||||||
_curve_show_setting_dlg->setWindowModality(Qt::WindowModal);
|
|
||||||
_curve_show_setting_dlg->setModal(false);
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(_curve_show_setting_dlg);
|
|
||||||
|
|
||||||
QStringList curve_name_list;
|
|
||||||
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
|
|
||||||
curve_name_list.append(curve->title().text());
|
|
||||||
}
|
|
||||||
// 自动计算多列排布
|
|
||||||
int num_columns = std::sqrt(this->_plot->GetCurveList().size());
|
|
||||||
if (num_columns == 0)
|
|
||||||
num_columns = 1;
|
|
||||||
QVBoxLayout* checkbox_layout = new QVBoxLayout();
|
|
||||||
QHBoxLayout* checkbox_column_layout = new QHBoxLayout();
|
|
||||||
QMap<QwtPlotCurve*, QCheckBox*> curve_checkbox_map;
|
|
||||||
auto addCurveToLayout = [&](const QString& curve_name){
|
|
||||||
QwtPlotCurve* curve = this->_plot->GetCurve(curve_name);
|
|
||||||
QCheckBox* check_box = new QCheckBox(curve->title().text());
|
|
||||||
check_box->setChecked(curve->isVisible());
|
|
||||||
checkbox_column_layout->addWidget(check_box);
|
|
||||||
connect(check_box, &QCheckBox::stateChanged, [curve](int state) {
|
|
||||||
curve->setVisible(state == Qt::Checked);
|
|
||||||
curve->plot()->replot();
|
|
||||||
});
|
|
||||||
curve_checkbox_map[curve] = check_box;
|
|
||||||
if (checkbox_column_layout->count() >= num_columns) {
|
|
||||||
checkbox_layout->addLayout(checkbox_column_layout);
|
|
||||||
checkbox_column_layout = new QHBoxLayout();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
for (const QString& ch_name : curve_name_list) {
|
|
||||||
addCurveToLayout(ch_name);
|
|
||||||
}
|
|
||||||
if (checkbox_column_layout->count() < num_columns) {
|
|
||||||
checkbox_column_layout->addStretch();
|
|
||||||
}
|
|
||||||
checkbox_layout->addLayout(checkbox_column_layout);
|
|
||||||
// 全选和反选
|
|
||||||
auto curveCheckboxUpdate = [this, curve_checkbox_map]() {
|
|
||||||
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
|
|
||||||
curve_checkbox_map[curve]->setChecked(curve->isVisible());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
QHBoxLayout* button_layout = new QHBoxLayout();
|
|
||||||
QPushButton* btn_all_select = new QPushButton(QString(QStringLiteral(u"全选")));
|
|
||||||
connect(btn_all_select, &QPushButton::clicked, [this, curveCheckboxUpdate]() {
|
|
||||||
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
|
|
||||||
curve->setVisible(true);
|
|
||||||
}
|
|
||||||
curveCheckboxUpdate();
|
|
||||||
this->_plot->replot();
|
|
||||||
});
|
|
||||||
button_layout->addWidget(btn_all_select);
|
|
||||||
QPushButton* btn_reserve_select = new QPushButton(QString(QStringLiteral(u"反选")));
|
|
||||||
connect(btn_reserve_select, &QPushButton::clicked, [this, curveCheckboxUpdate]() {
|
|
||||||
for (QwtPlotCurve* curve : this->_plot->GetCurveList()) {
|
|
||||||
curve->setVisible(!curve->isVisible());
|
|
||||||
}
|
|
||||||
curveCheckboxUpdate();
|
|
||||||
this->_plot->replot();
|
|
||||||
});
|
|
||||||
button_layout->addWidget(btn_reserve_select);
|
|
||||||
|
|
||||||
layout->addLayout(button_layout);
|
|
||||||
layout->addLayout(checkbox_layout);
|
|
||||||
}
|
|
||||||
_curve_show_setting_dlg->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnergyCountPeakFitView::onActionPlotConfigure()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
#ifndef ENERGYCOUNTPEAKFITVIEW_H
|
|
||||||
#define ENERGYCOUNTPEAKFITVIEW_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <MeasureAnalysisView.h>
|
|
||||||
|
|
||||||
class QMenu;
|
|
||||||
class CustomQwtPlot;
|
|
||||||
class CustomQwtPlotXaxisSelector;
|
|
||||||
|
|
||||||
class EnergyCountPeakFitView : public MeasureAnalysisView
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
EnergyCountPeakFitView(QWidget *parent = nullptr);
|
|
||||||
virtual ~EnergyCountPeakFitView();
|
|
||||||
|
|
||||||
virtual void InitViewWorkspace(const QString& project_name) override final;
|
|
||||||
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupPlot();
|
|
||||||
void setupMenu();
|
|
||||||
void loadDataFromFile(const QString &data_name, const QString& filename);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onActionCurveShowSetting();
|
|
||||||
void onActionPlotConfigure();
|
|
||||||
|
|
||||||
private:
|
|
||||||
CustomQwtPlot* _plot = nullptr;
|
|
||||||
QMenu* _menu = nullptr;
|
|
||||||
QDialog* _curve_show_setting_dlg = nullptr;
|
|
||||||
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ENERGYCOUNTPEAKFITVIEW_H
|
|
||||||
|
|
@ -6,23 +6,9 @@ MeasureAnalysisHistoryForm::MeasureAnalysisHistoryForm(QWidget *parent)
|
||||||
, ui(new Ui::MeasureAnalysisHistoryForm)
|
, ui(new Ui::MeasureAnalysisHistoryForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->btn_query, &QPushButton::clicked, [this](){
|
|
||||||
queryHistory();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeasureAnalysisHistoryForm::~MeasureAnalysisHistoryForm()
|
MeasureAnalysisHistoryForm::~MeasureAnalysisHistoryForm()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeasureAnalysisHistoryForm::loadHistoryInfo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeasureAnalysisHistoryForm::queryHistory()
|
|
||||||
{
|
|
||||||
const QString& query_text = ui->linedit_query->text();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -15,10 +15,6 @@ public:
|
||||||
explicit MeasureAnalysisHistoryForm(QWidget *parent = nullptr);
|
explicit MeasureAnalysisHistoryForm(QWidget *parent = nullptr);
|
||||||
~MeasureAnalysisHistoryForm();
|
~MeasureAnalysisHistoryForm();
|
||||||
|
|
||||||
private:
|
|
||||||
void loadHistoryInfo();
|
|
||||||
void queryHistory();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MeasureAnalysisHistoryForm *ui;
|
Ui::MeasureAnalysisHistoryForm *ui;
|
||||||
};
|
};
|
||||||
|
|
@ -51,14 +51,14 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_query_title">
|
<widget class="QLabel" name="label_title_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>模糊查询:</string>
|
<string>模糊查询:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="linedit_query"/>
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_query">
|
<widget class="QPushButton" name="btn_query">
|
||||||
18
src/src.pro
18
src/src.pro
|
|
@ -38,9 +38,7 @@ INCLUDEPATH += \
|
||||||
$${PWD}/CountRateAnalysisView \
|
$${PWD}/CountRateAnalysisView \
|
||||||
$${PWD}/ParticleTimePoorView \
|
$${PWD}/ParticleTimePoorView \
|
||||||
$${PWD}/ThreeDimensionalConformityAnalysisView \
|
$${PWD}/ThreeDimensionalConformityAnalysisView \
|
||||||
$${PWD}/EnergyCountPeakFitView \
|
$${PWD}/EnergyCountPeakFitView
|
||||||
$${PWD}/MeasureAnalysisDataTableView \
|
|
||||||
$${PWD}/MeasureAnalysisHistoryForm
|
|
||||||
|
|
||||||
DEPENDPATH += \
|
DEPENDPATH += \
|
||||||
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
||||||
|
|
@ -50,9 +48,7 @@ DEPENDPATH += \
|
||||||
$${PWD}/CountRateAnalysisView \
|
$${PWD}/CountRateAnalysisView \
|
||||||
$${PWD}/ParticleTimePoorView \
|
$${PWD}/ParticleTimePoorView \
|
||||||
$${PWD}/ThreeDimensionalConformityAnalysisView \
|
$${PWD}/ThreeDimensionalConformityAnalysisView \
|
||||||
$${PWD}/EnergyCountPeakFitView \
|
$${PWD}/EnergyCountPeakFitView
|
||||||
$${PWD}/MeasureAnalysisDataTableView \
|
|
||||||
$${PWD}/MeasureAnalysisHistoryForm
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
AboutDlg.cpp \
|
AboutDlg.cpp \
|
||||||
|
|
@ -64,8 +60,8 @@ SOURCES += \
|
||||||
EnergyScaleDataModel.cpp \
|
EnergyScaleDataModel.cpp \
|
||||||
EnergyScaleForm.cpp \
|
EnergyScaleForm.cpp \
|
||||||
MainWindow.cpp \
|
MainWindow.cpp \
|
||||||
MeasureAnalysisDataTableView/MeasureAnalysisDataTableView.cpp \
|
MeasureAnalysisDataTableView.cpp \
|
||||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.cpp \
|
MeasureAnalysisHistoryForm.cpp \
|
||||||
ParticleCountPlotView/BatchEnergyScaleDialog.cpp \
|
ParticleCountPlotView/BatchEnergyScaleDialog.cpp \
|
||||||
ParticleCountPlotView/FindPeaksResultDialog.cpp \
|
ParticleCountPlotView/FindPeaksResultDialog.cpp \
|
||||||
ParticleCountPlotView/ParticleCountPlotView.cpp \
|
ParticleCountPlotView/ParticleCountPlotView.cpp \
|
||||||
|
|
@ -99,8 +95,8 @@ HEADERS += \
|
||||||
EnergyScaleForm.h \
|
EnergyScaleForm.h \
|
||||||
GlobalDefine.h \
|
GlobalDefine.h \
|
||||||
MainWindow.h \
|
MainWindow.h \
|
||||||
MeasureAnalysisDataTableView/MeasureAnalysisDataTableView.h \
|
MeasureAnalysisDataTableView.h \
|
||||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.h \
|
MeasureAnalysisHistoryForm.h \
|
||||||
ParticleCountPlotView/BatchEnergyScaleDialog.h \
|
ParticleCountPlotView/BatchEnergyScaleDialog.h \
|
||||||
ParticleCountPlotView/FindPeaksResultDialog.h \
|
ParticleCountPlotView/FindPeaksResultDialog.h \
|
||||||
ParticleCountPlotView/ParticleCountPlotView.h \
|
ParticleCountPlotView/ParticleCountPlotView.h \
|
||||||
|
|
@ -128,7 +124,7 @@ FORMS += \
|
||||||
CountRateAnalysisView/CountRateAnalysisView.ui \
|
CountRateAnalysisView/CountRateAnalysisView.ui \
|
||||||
EnergyScaleForm.ui \
|
EnergyScaleForm.ui \
|
||||||
MainWindow.ui \
|
MainWindow.ui \
|
||||||
MeasureAnalysisHistoryForm/MeasureAnalysisHistoryForm.ui \
|
MeasureAnalysisHistoryForm.ui \
|
||||||
ParticleCountPlotView/BatchEnergyScaleDialog.ui \
|
ParticleCountPlotView/BatchEnergyScaleDialog.ui \
|
||||||
MeasureDeviceParamsCfgForm.ui \
|
MeasureDeviceParamsCfgForm.ui \
|
||||||
NewMeasureAnalysisDlg.ui \
|
NewMeasureAnalysisDlg.ui \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user