感兴趣区全局应用
This commit is contained in:
parent
ad111584f7
commit
e83492e7a9
|
|
@ -62,6 +62,10 @@ TwoDSpectralCompliance::TwoDSpectralCompliance(QWidget* parent)
|
|||
this->_plot = new CustomQwtPlot(this);
|
||||
layout->addWidget(this->_plot);
|
||||
setupPlot();
|
||||
|
||||
_roi = new RegionOfInterest();
|
||||
connect(_roi, &RegionOfInterest::roiSelected,this, &TwoDSpectralCompliance::slot_roi_data);
|
||||
|
||||
createFloatingInfoWidget();
|
||||
_busy_indicator = new BusyIndicatorWidget(this);
|
||||
}
|
||||
|
|
@ -163,6 +167,10 @@ void TwoDSpectralCompliance::setupMenu()
|
|||
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
||||
action_plot_config->setObjectName("plot_config");
|
||||
connect(action_plot_config, &QAction::triggered, this, &TwoDSpectralCompliance::onActionPlotConfigure);
|
||||
|
||||
QAction* action_roi = this->_menu->addAction(QStringLiteral(u"感兴趣区"));
|
||||
action_roi->setObjectName("roi");
|
||||
connect(action_roi,&QAction::triggered,this,&TwoDSpectralCompliance::onActionRoiTriggered);
|
||||
}
|
||||
|
||||
QVector<EventData> TwoDSpectralCompliance::readCsv(const QStringList& filename)
|
||||
|
|
@ -434,6 +442,18 @@ void TwoDSpectralCompliance::updateShowButtonPosition()
|
|||
}
|
||||
}
|
||||
|
||||
QwtPlotMarker *TwoDSpectralCompliance::createVLine(double x, Qt::GlobalColor color, double lineWidth)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setXValue(x);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
QPen pen(color);
|
||||
pen.setWidthF(lineWidth);
|
||||
marker->setLinePen(pen);
|
||||
marker->attach(_plot);
|
||||
return marker;
|
||||
}
|
||||
|
||||
void TwoDSpectralCompliance::onSelection(const QRectF& rect)
|
||||
{
|
||||
// 忽略过小的选区(可能是误点击)
|
||||
|
|
@ -472,6 +492,27 @@ void TwoDSpectralCompliance::onActionPlotConfigure()
|
|||
|
||||
}
|
||||
|
||||
void TwoDSpectralCompliance::onActionRoiTriggered()
|
||||
{
|
||||
_roi->show();
|
||||
}
|
||||
|
||||
void TwoDSpectralCompliance::slot_roi_data(ROIItem &item)
|
||||
{
|
||||
// 第一组:起始1、结束1 红色竖线,必须存在才插入,所以一定绘制
|
||||
createVLine(item.s1, Qt::red, 1.2);
|
||||
createVLine(item.e1, Qt::red, 1.2);
|
||||
|
||||
// 第二组:起始2、结束2 有有效数值才绘制,无值跳过
|
||||
bool secondGroupValid = !(qIsNaN(item.s2) || qIsNaN(item.e2) || (item.s2 == 0 && item.e2 == 0));
|
||||
if (secondGroupValid)
|
||||
{
|
||||
createVLine(item.s2, Qt::blue, 1.2);
|
||||
createVLine(item.e2, Qt::blue, 1.2);
|
||||
}
|
||||
_plot->replot();
|
||||
}
|
||||
|
||||
void TwoDSpectralCompliance:: updateInfoContent()
|
||||
{
|
||||
if (!m_totalEventsEdit)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QVector>
|
||||
#include <QWidget>
|
||||
#include <QMenu>
|
||||
#include "RegionOfInterest.h"
|
||||
class CustomQwtPlot;
|
||||
class QwtPlotSpectrogram;
|
||||
class QwtPlotPicker;
|
||||
|
|
@ -59,13 +60,15 @@ private:
|
|||
void updateFloatingWidgetPosition();
|
||||
void updateToggleButtonPosition();
|
||||
void updateShowButtonPosition();
|
||||
QwtPlotMarker* createVLine(double x, Qt::GlobalColor color, double lineWidth = 1.0); // 创建垂直标记竖线
|
||||
|
||||
private slots:
|
||||
void showFloatingWidget();
|
||||
void hideFloatingWidget();
|
||||
void onSelection(const QRectF& rect);
|
||||
void onActionPlotConfigure();
|
||||
|
||||
void onActionRoiTriggered();
|
||||
void slot_roi_data(ROIItem& item);
|
||||
private:
|
||||
Ui::TwoDSpectralCompliance* ui;
|
||||
QMenu* _menu = nullptr;
|
||||
|
|
@ -107,6 +110,8 @@ private:
|
|||
// 保存全局轴范围(用于重置放大)
|
||||
double m_globalXMin = 0.0, m_globalXMax = 0.0;
|
||||
double m_globalYMin = 0.0, m_globalYMax = 0.0;
|
||||
|
||||
RegionOfInterest *_roi;
|
||||
};
|
||||
|
||||
#endif // TWODSPECTRALCOMPLIANCE_H
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
//反符合能谱
|
||||
AntiConformEnergySpectrumView::AntiConformEnergySpectrumView(QWidget* parent)
|
||||
: MeasureAnalysisView(parent)
|
||||
{
|
||||
|
|
@ -32,6 +32,8 @@ AntiConformEnergySpectrumView::AntiConformEnergySpectrumView(QWidget* parent)
|
|||
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(_plot->canvas());
|
||||
canvas->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
_roi = new RegionOfInterest();
|
||||
connect(_roi, &RegionOfInterest::roiSelected,this, &AntiConformEnergySpectrumView::slot_roi_data);
|
||||
QFont font = this->font();
|
||||
font.setBold(false);
|
||||
QwtText x_label = QStringLiteral(u"能量(KeV)");
|
||||
|
|
@ -74,6 +76,18 @@ void AntiConformEnergySpectrumView::SetAnalyzeDataFilename(const QMap<QString, Q
|
|||
}
|
||||
}
|
||||
|
||||
QwtPlotMarker *AntiConformEnergySpectrumView::createVLine(double x, Qt::GlobalColor color, double lineWidth)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setXValue(x);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
QPen pen(color);
|
||||
pen.setWidthF(lineWidth);
|
||||
marker->setLinePen(pen);
|
||||
marker->attach(_plot);
|
||||
return marker;
|
||||
}
|
||||
|
||||
void AntiConformEnergySpectrumView::loadAndProcess()
|
||||
{
|
||||
_busy_indicator->Start();
|
||||
|
|
@ -132,6 +146,29 @@ void AntiConformEnergySpectrumView::onActionPlotConfigure()
|
|||
{
|
||||
}
|
||||
|
||||
void AntiConformEnergySpectrumView::onActionRoiTriggered()
|
||||
{
|
||||
_roi->show();
|
||||
}
|
||||
|
||||
void AntiConformEnergySpectrumView::slot_roi_data(ROIItem &item)
|
||||
{
|
||||
// 第一组:起始1、结束1 红色竖线,必须存在才插入,所以一定绘制
|
||||
createVLine(item.s1, Qt::red, 1.2);
|
||||
createVLine(item.e1, Qt::red, 1.2);
|
||||
|
||||
// 第二组:起始2、结束2 有有效数值才绘制,无值跳过
|
||||
bool secondGroupValid = !(qIsNaN(item.s2) || qIsNaN(item.e2) || (item.s2 == 0 && item.e2 == 0));
|
||||
if (secondGroupValid)
|
||||
{
|
||||
createVLine(item.s2, Qt::blue, 1.2);
|
||||
createVLine(item.e2, Qt::blue, 1.2);
|
||||
}
|
||||
_plot->replot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AntiConformEnergySpectrumView::showEvent(QShowEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
|
@ -156,4 +193,8 @@ void AntiConformEnergySpectrumView::setupMenu()
|
|||
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
||||
action_plot_config->setObjectName("plot_config");
|
||||
connect(action_plot_config, &QAction::triggered, this, &AntiConformEnergySpectrumView::onActionPlotConfigure);
|
||||
|
||||
QAction* action_roi = this->_menu->addAction(QStringLiteral(u"感兴趣区"));
|
||||
action_roi->setObjectName("roi");
|
||||
connect(action_roi,&QAction::triggered,this,&AntiConformEnergySpectrumView::onActionRoiTriggered);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define ANTICONFORMENERGYSPECTRUMVIEW_H
|
||||
|
||||
#include "MeasureAnalysisView.h"
|
||||
#include "RegionOfInterest.h"
|
||||
|
||||
class QMenu;
|
||||
class CustomQwtPlot;
|
||||
|
|
@ -15,6 +16,7 @@ public:
|
|||
virtual ~AntiConformEnergySpectrumView();
|
||||
virtual void InitViewWorkspace(const QString& project_name) override final;
|
||||
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set) override;
|
||||
QwtPlotMarker* createVLine(double x, Qt::GlobalColor color, double lineWidth = 1.0); // 创建垂直标记竖线
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent* e) override final;
|
||||
|
|
@ -25,13 +27,15 @@ private:
|
|||
|
||||
private slots:
|
||||
void onActionPlotConfigure();
|
||||
|
||||
void onActionRoiTriggered();
|
||||
void slot_roi_data(ROIItem& item);
|
||||
private:
|
||||
QMenu* _menu = nullptr;
|
||||
BusyIndicatorWidget* _busy_indicator = nullptr;
|
||||
CustomQwtPlot* _plot = nullptr;
|
||||
QwtPlotCurve* _curve = nullptr;
|
||||
QString _data_filename;
|
||||
RegionOfInterest *_roi;
|
||||
};
|
||||
|
||||
#endif // ANTICONFORMENERGYSPECTRUMVIEW_H
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include <cstdint>
|
||||
#include <QPen>
|
||||
#include <QMenu>
|
||||
|
||||
//符合能谱
|
||||
struct SpectrumData
|
||||
{
|
||||
int event_id;
|
||||
|
|
@ -42,6 +42,9 @@ ConformToTheEnergySpectrum::ConformToTheEnergySpectrum(QWidget *parent) :
|
|||
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(_plot->canvas());
|
||||
canvas->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
_roi = new RegionOfInterest();
|
||||
connect(_roi, &RegionOfInterest::roiSelected,this, &ConformToTheEnergySpectrum::slot_roi_data);
|
||||
|
||||
QFont font = this->font();
|
||||
font.setBold(false);
|
||||
QwtText x_label = QStringLiteral(u"能量(KeV)");
|
||||
|
|
@ -90,6 +93,18 @@ void ConformToTheEnergySpectrum::SetAnalyzeDataFilename(const QMap<QString, QVar
|
|||
}
|
||||
}
|
||||
|
||||
QwtPlotMarker *ConformToTheEnergySpectrum::createVLine(double x, Qt::GlobalColor color, double lineWidth)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setXValue(x);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
QPen pen(color);
|
||||
pen.setWidthF(lineWidth);
|
||||
marker->setLinePen(pen);
|
||||
marker->attach(_plot);
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
void ConformToTheEnergySpectrum::loadAndProcess()
|
||||
{
|
||||
|
|
@ -171,6 +186,27 @@ void ConformToTheEnergySpectrum::onActionPlotConfigure()
|
|||
|
||||
}
|
||||
|
||||
void ConformToTheEnergySpectrum::slot_roi_data(ROIItem &item)
|
||||
{
|
||||
// 第一组:起始1、结束1 红色竖线,必须存在才插入,所以一定绘制
|
||||
createVLine(item.s1, Qt::red, 1.2);
|
||||
createVLine(item.e1, Qt::red, 1.2);
|
||||
|
||||
// 第二组:起始2、结束2 有有效数值才绘制,无值跳过
|
||||
bool secondGroupValid = !(qIsNaN(item.s2) || qIsNaN(item.e2) || (item.s2 == 0 && item.e2 == 0));
|
||||
if (secondGroupValid)
|
||||
{
|
||||
createVLine(item.s2, Qt::blue, 1.2);
|
||||
createVLine(item.e2, Qt::blue, 1.2);
|
||||
}
|
||||
_plot->replot();
|
||||
}
|
||||
|
||||
void ConformToTheEnergySpectrum::onActionRoiTriggered()
|
||||
{
|
||||
_roi->show();
|
||||
}
|
||||
|
||||
void ConformToTheEnergySpectrum::showEvent(QShowEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
|
@ -196,6 +232,9 @@ void ConformToTheEnergySpectrum::setupMenu()
|
|||
action_plot_config->setObjectName("plot_config");
|
||||
connect(action_plot_config, &QAction::triggered, this, &ConformToTheEnergySpectrum::onActionPlotConfigure);
|
||||
|
||||
QAction* action_roi = this->_menu->addAction(QStringLiteral(u"感兴趣区"));
|
||||
action_roi->setObjectName("roi");
|
||||
connect(action_roi,&QAction::triggered,this,&ConformToTheEnergySpectrum::onActionRoiTriggered);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define CONFORMTOTHEENERGYSPECTRUM_H
|
||||
|
||||
#include "MeasureAnalysisView.h"
|
||||
|
||||
#include "RegionOfInterest.h"
|
||||
class QMenu;
|
||||
class CustomQwtPlot;
|
||||
class QwtPlotCurve;
|
||||
|
|
@ -16,6 +16,7 @@ public:
|
|||
virtual ~ConformToTheEnergySpectrum();
|
||||
virtual void InitViewWorkspace(const QString& project_name) override final;
|
||||
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set) override;
|
||||
QwtPlotMarker* createVLine(double x, Qt::GlobalColor color, double lineWidth = 1.0); // 创建垂直标记竖线
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent* e) override final;
|
||||
|
|
@ -26,13 +27,16 @@ private:
|
|||
|
||||
private slots:
|
||||
void onActionPlotConfigure();
|
||||
|
||||
void slot_roi_data(ROIItem& item);
|
||||
void onActionRoiTriggered();
|
||||
private:
|
||||
QMenu* _menu = nullptr;
|
||||
BusyIndicatorWidget* _busy_indicator = nullptr;
|
||||
CustomQwtPlot* _plot = nullptr;
|
||||
QwtPlotCurve* _curve = nullptr;
|
||||
QStringList _data_filenames;
|
||||
|
||||
RegionOfInterest *_roi;
|
||||
};
|
||||
|
||||
#endif // CONFORMTOTHEENERGYSPECTRUM_H
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include "MeasureAnalysisProjectModel.h"
|
||||
#include "BusyIndicator.h"
|
||||
|
||||
|
||||
//峰拟合分析
|
||||
QJsonObject PeakFitHistoryItem::toJson() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
|
@ -115,10 +115,12 @@ EnergyCountPeakFitView::EnergyCountPeakFitView(QWidget* parent)
|
|||
this->_plot = new CustomQwtPlot(this);
|
||||
layout->addWidget(this->_plot);
|
||||
setupPlot();
|
||||
_roi = new RegionOfInterest();
|
||||
connect(_roi, &RegionOfInterest::roiSelected,this, &EnergyCountPeakFitView::slot_roi_data);
|
||||
|
||||
this->_menu = new QMenu(this);
|
||||
setupMenu();
|
||||
connect(this, &EnergyCountPeakFitView::newFitResultAdded, this, &EnergyCountPeakFitView::onNewFitResultAdded);
|
||||
|
||||
}
|
||||
|
||||
EnergyCountPeakFitView::~EnergyCountPeakFitView()
|
||||
|
|
@ -185,6 +187,18 @@ void EnergyCountPeakFitView::SetAnalyzeDataFilename(const QMap<QString, QVariant
|
|||
}
|
||||
}
|
||||
|
||||
QwtPlotMarker *EnergyCountPeakFitView::createVLine(double x, Qt::GlobalColor color, double lineWidth)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setXValue(x);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
QPen pen(color);
|
||||
pen.setWidthF(lineWidth);
|
||||
marker->setLinePen(pen);
|
||||
marker->attach(_plot);
|
||||
return marker;
|
||||
}
|
||||
|
||||
void EnergyCountPeakFitView::setupPlot()
|
||||
{
|
||||
_plot->setCanvasBackground(Qt::white);
|
||||
|
|
@ -261,6 +275,10 @@ void EnergyCountPeakFitView::setupMenu()
|
|||
QAction* action_delete_hovered_rect = this->_menu->addAction(QStringLiteral(u"删除当前框选区域"));
|
||||
connect(action_delete_hovered_rect, &QAction::triggered, this, &EnergyCountPeakFitView::onActionDeleteHoveredRect);
|
||||
|
||||
QAction* action_roi = this->_menu->addAction(QStringLiteral(u"感兴趣区"));
|
||||
action_roi->setObjectName("roi");
|
||||
connect(action_roi,&QAction::triggered,this,&EnergyCountPeakFitView::onActionRoiTriggered);
|
||||
|
||||
}
|
||||
|
||||
void EnergyCountPeakFitView::loadDataFromFile(const QString& data_name, const QString& filename)
|
||||
|
|
@ -1578,3 +1596,24 @@ void EnergyCountPeakFitView::onHistoryDlgClosed()
|
|||
LOG_DEBUG(QStringLiteral(u"峰拟合结果对话框已关闭"));
|
||||
|
||||
}
|
||||
|
||||
void EnergyCountPeakFitView::onActionRoiTriggered()
|
||||
{
|
||||
_roi->show();
|
||||
}
|
||||
|
||||
void EnergyCountPeakFitView::slot_roi_data(ROIItem &item)
|
||||
{
|
||||
// 第一组:起始1、结束1 红色竖线,必须存在才插入,所以一定绘制
|
||||
createVLine(item.s1, Qt::red, 1.2);
|
||||
createVLine(item.e1, Qt::red, 1.2);
|
||||
|
||||
// 第二组:起始2、结束2 有有效数值才绘制,无值跳过
|
||||
bool secondGroupValid = !(qIsNaN(item.s2) || qIsNaN(item.e2) || (item.s2 == 0 && item.e2 == 0));
|
||||
if (secondGroupValid)
|
||||
{
|
||||
createVLine(item.s2, Qt::blue, 1.2);
|
||||
createVLine(item.e2, Qt::blue, 1.2);
|
||||
}
|
||||
_plot->replot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <QwtPickerDragRectMachine>
|
||||
#include <QwtPlotPicker>
|
||||
#include <qwt_plot_shapeitem.h>
|
||||
|
||||
#include "RegionOfInterest.h"
|
||||
#include "DataCalcProcess/AdaptiveSimpsonIntegrate.h"
|
||||
#include "DataCalcProcess/FindPeaksBySvd.h"
|
||||
#include "DataCalcProcess/MathModelDefine.h"
|
||||
|
|
@ -87,6 +87,7 @@ public:
|
|||
|
||||
virtual void InitViewWorkspace(const QString& project_name) override final;
|
||||
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
|
||||
QwtPlotMarker* createVLine(double x, Qt::GlobalColor color, double lineWidth = 1.0); // 创建垂直标记竖线
|
||||
|
||||
private:
|
||||
void setupPlot();
|
||||
|
|
@ -115,7 +116,8 @@ private slots:
|
|||
|
||||
void onNewFitResultAdded(); // 新拟合结果同步刷新槽
|
||||
void onHistoryDlgClosed(); // 历史对话框关闭清理槽
|
||||
|
||||
void onActionRoiTriggered();
|
||||
void slot_roi_data(ROIItem& item);
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event) override; // 事件过滤器
|
||||
|
||||
|
|
@ -167,6 +169,9 @@ private:
|
|||
PlotRectItem* _hoveredRectItem = nullptr;
|
||||
QList<DisplayedCurveRef> _displayedHistoryCurves;
|
||||
QDialog* _historyDlg = nullptr; // 跟踪当前打开的峰拟合结果对话框
|
||||
|
||||
RegionOfInterest *_roi;
|
||||
|
||||
};
|
||||
|
||||
#endif // ENERGYCOUNTPEAKFITVIEW_H
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QwtScaleDiv>
|
||||
|
||||
|
||||
#include <QPen>
|
||||
//能量计数谱
|
||||
EnergyCountPlotView::EnergyCountPlotView(QWidget *parent)
|
||||
: MeasureAnalysisView { parent }
|
||||
{
|
||||
|
|
@ -23,6 +23,9 @@ EnergyCountPlotView::EnergyCountPlotView(QWidget *parent)
|
|||
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
this->_plot = new CustomQwtPlot(this);
|
||||
_roi = new RegionOfInterest();
|
||||
connect(_roi, &RegionOfInterest::roiSelected,this, &EnergyCountPlotView::slot_roi_data);
|
||||
|
||||
layout->addWidget(this->_plot);
|
||||
setupPlot();
|
||||
this->_menu = new QMenu(this);
|
||||
|
|
@ -111,6 +114,9 @@ void EnergyCountPlotView::setupMenu()
|
|||
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
||||
action_plot_config->setObjectName("plot_config");
|
||||
connect(action_plot_config, &QAction::triggered, this, &EnergyCountPlotView::onActionPlotConfigure);
|
||||
QAction* action_roi = this->_menu->addAction(QStringLiteral(u"感兴趣区"));
|
||||
action_roi->setObjectName("roi");
|
||||
connect(action_roi,&QAction::triggered,this,&EnergyCountPlotView::onActionRoiTriggered);
|
||||
}
|
||||
|
||||
void EnergyCountPlotView::loadDataFromFile(const QString &data_name, const QString &filename)
|
||||
|
|
@ -147,6 +153,18 @@ void EnergyCountPlotView::loadDataFromFile(const QString &data_name, const QStri
|
|||
_plot->AddCurve(curve);
|
||||
}
|
||||
|
||||
QwtPlotMarker *EnergyCountPlotView::createVLine(double x, Qt::GlobalColor color, double lineWidth)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setXValue(x);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
QPen pen(color);
|
||||
pen.setWidthF(lineWidth);
|
||||
marker->setLinePen(pen);
|
||||
marker->attach(_plot);
|
||||
return marker;
|
||||
}
|
||||
|
||||
void EnergyCountPlotView::updateView(const QMap<QString, QVariant>& data_files_set)
|
||||
{
|
||||
// 清除现有所有曲线
|
||||
|
|
@ -258,3 +276,24 @@ void EnergyCountPlotView::onActionPlotConfigure()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
void EnergyCountPlotView::onActionRoiTriggered()
|
||||
{
|
||||
_roi->show();
|
||||
}
|
||||
|
||||
void EnergyCountPlotView::slot_roi_data(ROIItem &item)
|
||||
{
|
||||
// 第一组:起始1、结束1 红色竖线,必须存在才插入,所以一定绘制
|
||||
createVLine(item.s1, Qt::red, 1.2);
|
||||
createVLine(item.e1, Qt::red, 1.2);
|
||||
|
||||
// 第二组:起始2、结束2 有有效数值才绘制,无值跳过
|
||||
bool secondGroupValid = !(qIsNaN(item.s2) || qIsNaN(item.e2) || (item.s2 == 0 && item.e2 == 0));
|
||||
if (secondGroupValid)
|
||||
{
|
||||
createVLine(item.s2, Qt::blue, 1.2);
|
||||
createVLine(item.e2, Qt::blue, 1.2);
|
||||
}
|
||||
_plot->replot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <MeasureAnalysisView.h>
|
||||
|
||||
#include "RegionOfInterest.h"
|
||||
class QMenu;
|
||||
class CustomQwtPlot;
|
||||
class CustomQwtPlotXaxisSelector;
|
||||
|
|
@ -25,11 +25,13 @@ private:
|
|||
void setupPlot();
|
||||
void setupMenu();
|
||||
void loadDataFromFile(const QString &data_name, const QString& filename);
|
||||
QwtPlotMarker* createVLine(double x, Qt::GlobalColor color, double lineWidth = 1.0); // 创建垂直标记竖线
|
||||
|
||||
private slots:
|
||||
void onActionCurveShowSetting();
|
||||
void onActionPlotConfigure();
|
||||
|
||||
void onActionRoiTriggered();
|
||||
void slot_roi_data(ROIItem& item);
|
||||
private:
|
||||
CustomQwtPlot* _plot = nullptr;
|
||||
QMenu* _menu = nullptr;
|
||||
|
|
@ -37,6 +39,7 @@ private:
|
|||
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
|
||||
double _x_max = 0.0f;
|
||||
double _y_max = 0.0f;
|
||||
RegionOfInterest *_roi;
|
||||
};
|
||||
|
||||
#endif // ENERGYCOUNTPLOTVIEW_H
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ RegionOfInterest::RegionOfInterest(QWidget *parent)
|
|||
, m_tempEndMarker(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->_plot = new CustomQwtPlot(this);
|
||||
ui->layout_Curve->addWidget(_plot);
|
||||
setupPlot();
|
||||
// this->_plot = new CustomQwtPlot(this);
|
||||
// ui->layout_Curve->addWidget(_plot);
|
||||
// setupPlot();
|
||||
ui->widget->hide();
|
||||
ui->tableWidget->setColumnCount(6);
|
||||
QStringList headers = {"序号","描述文本", "起始1", "结束1", "起始2", "结束2"};
|
||||
ui->tableWidget->verticalHeader()->setVisible(false);
|
||||
|
|
@ -185,7 +186,7 @@ void RegionOfInterest::on_pBtn_insert_clicked()
|
|||
m_roiList.append(newRoi);
|
||||
|
||||
// 刷新绘图竖线
|
||||
refreshROILines();
|
||||
// refreshROILines();
|
||||
|
||||
saveAllRoiToJson();
|
||||
}
|
||||
|
|
@ -225,7 +226,7 @@ void RegionOfInterest::on_pBtn_update_clicked()
|
|||
break;
|
||||
}
|
||||
}
|
||||
refreshROILines();
|
||||
// refreshROILines();
|
||||
saveAllRoiToJson();
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +244,7 @@ void RegionOfInterest::on_pBtn_clear_clicked()
|
|||
{
|
||||
ui->tableWidget->setRowCount(0);
|
||||
m_roiList.clear(); // 清空数据缓存
|
||||
refreshROILines(); // 清除所有竖线
|
||||
// refreshROILines(); // 清除所有竖线
|
||||
saveAllRoiToJson();
|
||||
}
|
||||
}
|
||||
|
|
@ -264,78 +265,83 @@ void RegionOfInterest::on_tableWidget_cellClicked(int row, int col)
|
|||
ui->lineEdit_end1->setText(e1);
|
||||
ui->lineEdit_start2->setText(s2);
|
||||
ui->lineEdit_end2->setText(e2);
|
||||
|
||||
if(row >= 0 && row < m_roiList.size())
|
||||
{
|
||||
emit roiSelected(m_roiList[row]);
|
||||
}
|
||||
}
|
||||
|
||||
bool RegionOfInterest::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
// 只处理绘图画布的鼠标事件
|
||||
if (obj == _plot->canvas())
|
||||
{
|
||||
QMouseEvent* mouseEv = dynamic_cast<QMouseEvent*>(event);
|
||||
if (!mouseEv)
|
||||
return QWidget::eventFilter(obj, event);
|
||||
// if (obj == _plot->canvas())
|
||||
// {
|
||||
// QMouseEvent* mouseEv = dynamic_cast<QMouseEvent*>(event);
|
||||
// if (!mouseEv)
|
||||
// return QWidget::eventFilter(obj, event);
|
||||
|
||||
// 鼠标按下
|
||||
if (event->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
m_bMouseSelect = true;
|
||||
m_selectStartX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
// 创建临时虚线标记
|
||||
QPen dashPen(Qt::red);
|
||||
dashPen.setStyle(Qt::DashLine);
|
||||
dashPen.setWidthF(1.5);
|
||||
// // 鼠标按下
|
||||
// if (event->type() == QEvent::MouseButtonPress)
|
||||
// {
|
||||
// m_bMouseSelect = true;
|
||||
// m_selectStartX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
// // 创建临时虚线标记
|
||||
// QPen dashPen(Qt::red);
|
||||
// dashPen.setStyle(Qt::DashLine);
|
||||
// dashPen.setWidthF(1.5);
|
||||
|
||||
m_tempStartMarker = new QwtPlotMarker();
|
||||
m_tempStartMarker->setXValue(m_selectStartX);
|
||||
m_tempStartMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
m_tempStartMarker->setLinePen(dashPen);
|
||||
m_tempStartMarker->attach(_plot);
|
||||
// m_tempStartMarker = new QwtPlotMarker();
|
||||
// m_tempStartMarker->setXValue(m_selectStartX);
|
||||
// m_tempStartMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
// m_tempStartMarker->setLinePen(dashPen);
|
||||
// m_tempStartMarker->attach(_plot);
|
||||
|
||||
m_tempEndMarker = new QwtPlotMarker();
|
||||
m_tempEndMarker->setXValue(m_selectStartX);
|
||||
m_tempEndMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
m_tempEndMarker->setLinePen(dashPen);
|
||||
m_tempEndMarker->attach(_plot);
|
||||
_plot->replot();
|
||||
}
|
||||
// 鼠标移动:实时更新结束竖线位置
|
||||
else if (event->type() == QEvent::MouseMove && m_bMouseSelect)
|
||||
{
|
||||
m_selectEndX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
m_tempEndMarker->setXValue(m_selectEndX);
|
||||
_plot->replot();
|
||||
}
|
||||
// 鼠标松开
|
||||
else if (event->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
if (!m_bMouseSelect)
|
||||
return QWidget::eventFilter(obj, event);
|
||||
m_bMouseSelect = false;
|
||||
// m_tempEndMarker = new QwtPlotMarker();
|
||||
// m_tempEndMarker->setXValue(m_selectStartX);
|
||||
// m_tempEndMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
// m_tempEndMarker->setLinePen(dashPen);
|
||||
// m_tempEndMarker->attach(_plot);
|
||||
// _plot->replot();
|
||||
// }
|
||||
// // 鼠标移动:实时更新结束竖线位置
|
||||
// else if (event->type() == QEvent::MouseMove && m_bMouseSelect)
|
||||
// {
|
||||
// m_selectEndX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
// m_tempEndMarker->setXValue(m_selectEndX);
|
||||
// _plot->replot();
|
||||
// }
|
||||
// // 鼠标松开
|
||||
// else if (event->type() == QEvent::MouseButtonRelease)
|
||||
// {
|
||||
// if (!m_bMouseSelect)
|
||||
// return QWidget::eventFilter(obj, event);
|
||||
// m_bMouseSelect = false;
|
||||
|
||||
m_selectEndX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
// m_selectEndX = _plot->invTransform(QwtPlot::xBottom, mouseEv->pos().x());
|
||||
|
||||
// 销毁临时虚线
|
||||
if(m_tempStartMarker)
|
||||
{
|
||||
m_tempStartMarker->detach();
|
||||
delete m_tempStartMarker;
|
||||
m_tempStartMarker = nullptr;
|
||||
}
|
||||
if(m_tempEndMarker)
|
||||
{
|
||||
m_tempEndMarker->detach();
|
||||
delete m_tempEndMarker;
|
||||
m_tempEndMarker = nullptr;
|
||||
}
|
||||
_plot->replot();
|
||||
double s = qMin(m_selectStartX, m_selectEndX);
|
||||
double e = qMax(m_selectStartX, m_selectEndX);
|
||||
// // 销毁临时虚线
|
||||
// if(m_tempStartMarker)
|
||||
// {
|
||||
// m_tempStartMarker->detach();
|
||||
// delete m_tempStartMarker;
|
||||
// m_tempStartMarker = nullptr;
|
||||
// }
|
||||
// if(m_tempEndMarker)
|
||||
// {
|
||||
// m_tempEndMarker->detach();
|
||||
// delete m_tempEndMarker;
|
||||
// m_tempEndMarker = nullptr;
|
||||
// }
|
||||
// _plot->replot();
|
||||
// double s = qMin(m_selectStartX, m_selectEndX);
|
||||
// double e = qMax(m_selectStartX, m_selectEndX);
|
||||
|
||||
// 回填到起始1、结束1输入框
|
||||
ui->lineEdit_start1->setText(QString::number(s, 'f', 2));
|
||||
ui->lineEdit_end1->setText(QString::number(e, 'f', 2));
|
||||
}
|
||||
}
|
||||
// // 回填到起始1、结束1输入框
|
||||
// ui->lineEdit_start1->setText(QString::number(s, 'f', 2));
|
||||
// ui->lineEdit_end1->setText(QString::number(e, 'f', 2));
|
||||
// }
|
||||
// }
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
|
@ -389,6 +395,41 @@ void RegionOfInterest::loadROIFromFile()
|
|||
ui->tableWidget->setItem(row, 4, new QTableWidgetItem(s2Str));
|
||||
ui->tableWidget->setItem(row, 5, new QTableWidgetItem(e2Str));
|
||||
}
|
||||
refreshROILines();
|
||||
// refreshROILines();
|
||||
}
|
||||
|
||||
|
||||
void RegionOfInterest::on_pBtn_delete_clicked()
|
||||
{
|
||||
int curRow = ui->tableWidget->currentRow();
|
||||
if(curRow < 0)
|
||||
{
|
||||
QMessageBox::information(this,"提示","请选中要删除的行!");
|
||||
return;
|
||||
}
|
||||
int ret = QMessageBox::question(this,"确认","是否删除当前选中ROI?",QMessageBox::Yes|QMessageBox::No);
|
||||
if(ret != QMessageBox::Yes) return;
|
||||
|
||||
int targetSeq = curRow + 1;
|
||||
// 从内存列表移除
|
||||
for(auto it = m_roiList.begin(); it != m_roiList.end();)
|
||||
{
|
||||
if(it->rowNo == targetSeq)
|
||||
{
|
||||
it = m_roiList.erase(it);
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
// 删除表格行
|
||||
ui->tableWidget->removeRow(curRow);
|
||||
// 重新刷新序号
|
||||
for(int r=0; r<ui->tableWidget->rowCount(); r++)
|
||||
{
|
||||
int newSeq = r+1;
|
||||
ui->tableWidget->item(r,0)->setText(QString::number(newSeq));
|
||||
m_roiList[r].rowNo = newSeq;
|
||||
}
|
||||
saveAllRoiToJson();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ struct ROIItem
|
|||
double s2, e2; // 第二组区间:起始2、结束2
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ROIItem)
|
||||
|
||||
|
||||
class RegionOfInterest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -46,6 +49,9 @@ private slots:
|
|||
|
||||
void on_tableWidget_cellClicked(int row, int col);
|
||||
|
||||
void on_pBtn_delete_clicked();
|
||||
signals:
|
||||
void roiSelected(ROIItem& item);
|
||||
private:
|
||||
Ui::RegionOfInterest *ui;
|
||||
CustomQwtPlot* _plot = nullptr;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pBtn_delete">
|
||||
<property name="text">
|
||||
<string>删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user