Conflicts:
	src/CountRateAnalysisView/CountRateAnalysisView.cpp
	src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.cpp
This commit is contained in:
anxinglong 2026-03-30 18:30:11 +08:00
commit 7016f584b9
28 changed files with 721 additions and 594 deletions

BIN
bin/minimsys/bash.exe Normal file

Binary file not shown.

BIN
bin/minimsys/env.exe Normal file

Binary file not shown.

BIN
bin/minimsys/head.exe Normal file

Binary file not shown.

BIN
bin/minimsys/msys-2.0.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/minimsys/sort.exe Normal file

Binary file not shown.

BIN
bin/minimsys/tail.exe Normal file

Binary file not shown.

BIN
bin/theme.rcc Normal file

Binary file not shown.

View File

@ -0,0 +1,39 @@
#include "BusyIndicator.h"
#include <QLabel>
#include <QMovie>
#include <QVBoxLayout>
BusyIndicator::BusyIndicator(QWidget* parent)
: QWidget { parent }
{
setAttribute(Qt::WA_TransparentForMouseEvents);
QLabel* icon = new QLabel;
icon->resize(80, 80);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
icon->setSizePolicy(sizePolicy);
_busy_movie = new QMovie(":gif/BusyIndicator.gif"); // 转圈 GIF
icon->setMovie(_busy_movie);
_busy_movie->start();
QLabel* text = new QLabel(QStringLiteral(u"加载数据中......"));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addStretch();
layout->addWidget(icon, 0, Qt::AlignCenter);
layout->addWidget(text, 0, Qt::AlignCenter);
layout->addStretch();
setLayout(layout);
}
void BusyIndicator::Start()
{
// _busy_movie->start();
this->setVisible(true);
this->update();
}
void BusyIndicator::Stop()
{
// _busy_movie->stop();
this->setVisible(false);
this->update();
}

View File

@ -0,0 +1,20 @@
#ifndef BUSYINDICATOR_H
#define BUSYINDICATOR_H
#include <QObject>
#include <QWidget>
class QMovie;
class BusyIndicator : public QWidget
{
Q_OBJECT
public:
explicit BusyIndicator(QWidget *parent = nullptr);
void Start();
void Stop();
private:
QMovie* _busy_movie;
};
#endif // BUSYINDICATOR_H

View File

@ -22,7 +22,9 @@ CountRateAnalysisView::CountRateAnalysisView(QWidget *parent) :
{
ui->setupUi(this);
this->setViewType(PlotFrame);
InitUi();
}
CountRateAnalysisView::~CountRateAnalysisView()
@ -96,7 +98,7 @@ QVector<ParticleInjectTime> CountRateAnalysisView::getParticleInjectTimeData(QSt
{
QVector<ParticleInjectTime> records;
io::CSVReader<4> in(QStrToSysPath(path));
in.read_header(io::ignore_extra_column, QStringLiteral(u"板卡号").toStdString(), QStringLiteral(u"通道号").toStdString(), QStringLiteral(u"能量(KeV)").toStdString(), QStringLiteral(u"时间计数").toStdString());
in.read_header(io::ignore_extra_column, "板卡号", "通道号", "能量(KeV)", "时间计数");
int board, channel;
double energy, time_count;
@ -105,9 +107,9 @@ QVector<ParticleInjectTime> CountRateAnalysisView::getParticleInjectTimeData(QSt
// 逐行读取
while (in.read_row(board, channel, energy, time_count))
{
int detector = board * 4 + channel + 1;
int detector = board + channel * 8;
lineNumber++;
if(detector > 32)
if(detector >= 32)
{
continue;
}
@ -118,12 +120,13 @@ QVector<ParticleInjectTime> CountRateAnalysisView::getParticleInjectTimeData(QSt
records.append(rec);
}
return records;
return records;
}
void CountRateAnalysisView::InitUi()
{
plot = new CustomQwtPlot();
plot->SetXaxisDragScale(true);
setupPlot();
ui->verticalLayout_2->addWidget(plot);
}
@ -142,5 +145,11 @@ void CountRateAnalysisView::setupPlot()
// 启用网格线
plot->enableAxis(QwtPlot::xBottom);
plot->enableAxis(QwtPlot::yLeft);
plot->SetXaxisDragScale(true);
// 设置QWT图例
// QwtLegend* legend = new QwtLegend();
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
// plot->insertLegend(legend, QwtPlot::RightLegend);
plot->SetAxisDragScale(QwtPlot::xBottom, true);
}

View File

@ -13,11 +13,161 @@
#include <QwtPlotPicker>
#include <QwtPlotShapeItem>
#include <QwtPickerDragRectMachine>
#include <QwtPlotMagnifier>
#include <QDebug>
CustomQwtPlotAxisPanner::CustomQwtPlotAxisPanner(QwtScaleWidget *scale_widget)
: QwtPlotPanner(scale_widget)
{
if (scale_widget) {
if (scale_widget->alignment() == QwtScaleDraw::BottomScale) {
this->setOrientations(Qt::Horizontal);
} else if (scale_widget->alignment() == QwtScaleDraw::LeftScale) {
this->setOrientations(Qt::Vertical);
} else if (scale_widget->alignment() == QwtScaleDraw::TopScale) {
this->setOrientations(Qt::Horizontal);
} else if (scale_widget->alignment() == QwtScaleDraw::RightScale) {
this->setOrientations(Qt::Vertical);
}
}
}
CustomQwtPlotAxisPanner::~CustomQwtPlotAxisPanner()
{
qDebug() << "~CustomQwtPlotXaxisPanner";
}
void CustomQwtPlotAxisPanner::moveCanvas(int dx, int dy)
{
QwtScaleWidget* scale_widget = dynamic_cast<QwtScaleWidget*>(this->canvas());
if (scale_widget) {
if (scale_widget->alignment() == QwtScaleDraw::BottomScale) {
QwtPlotPanner::moveCanvas(dx, 0);
} else if (scale_widget->alignment() == QwtScaleDraw::LeftScale) {
QwtPlotPanner::moveCanvas(0, dy);
} else if (scale_widget->alignment() == QwtScaleDraw::TopScale) {
QwtPlotPanner::moveCanvas(dx, 0);
} else if (scale_widget->alignment() == QwtScaleDraw::RightScale) {
QwtPlotPanner::moveCanvas(0, dy);
}
}
}
// CustomQwtPlotXaxisMagnifier::CustomQwtPlotXaxisMagnifier(QWidget *canvas)
// : QwtPlotMagnifier(canvas)
// {
// }
// CustomQwtPlotXaxisMagnifier::~CustomQwtPlotXaxisMagnifier()
// {
// qDebug() << "~CustomQwtPlotXaxisMagnifier";
// }
// void CustomQwtPlotXaxisMagnifier::rescale(double factor)
// {
// factor = qBound(0.1, factor, 10.0);
// QwtScaleMap x_map = plot()->canvasMap(QwtPlot::xBottom);
// double center = x_map.invTransform(plot()->canvas()->width() / 2);
// plot()->setAxisScale(
// QwtPlot::xBottom,
// center - (center - x_map.s1()) * factor,
// center + (x_map.s2() - center) * factor
// );
// plot()->replot();
// }
CustomQwtPlotXaxisSelector::CustomQwtPlotXaxisSelector(QWidget *canvas)
: QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPicker::NoRubberBand,
QwtPicker::AlwaysOn,
canvas)
, _min_x(0.0)
, _max_x(0.0)
{
this->setStateMachine(new QwtPickerDragRectMachine());
this->setRubberBandPen(QPen(Qt::NoPen));
_overlay = new QwtPlotShapeItem;
_overlay->setRenderHint(QwtPlotItem::RenderAntialiased);
_overlay->setPen(QPen(Qt::red, 2));
_overlay->setBrush(QBrush(QColor(0, 120, 210, 50)));
_overlay->setZ(100);
_overlay->attach(plot());
_overlay->setVisible(false);
}
CustomQwtPlotXaxisSelector::~CustomQwtPlotXaxisSelector()
{
qDebug() << "~CustomQwtPlotXaxisSelector";
}
double CustomQwtPlotXaxisSelector::selectedMinX() const
{
return _min_x;
}
double CustomQwtPlotXaxisSelector::selectedMaxX() const
{
return _max_x;
}
void CustomQwtPlotXaxisSelector::clearSelection()
{
_min_x = 0.0;
_max_x = 0.0;
if (_overlay)
_overlay->setVisible(false);
}
void CustomQwtPlotXaxisSelector::move(const QPoint & pos)
{
QPolygon points = pickedPoints();
if (points.size() < 2) {
clearSelection();
return QwtPlotPicker::move(pos);
}
QPointF p1 = invTransform(points.first());
QPointF p2 = invTransform(points.last());
// 计算X范围
_min_x = qMin(p1.x(), p2.x());
_max_x = qMax(p1.x(), p2.x());
// Y轴铺满
double y_min = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double y_max = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
QRectF area(_min_x, y_min, _max_x - _min_x, y_max - y_min);
_overlay->setRect(area);
_overlay->setVisible(true);
plot()->replot();
QwtPlotPicker::move(pos);
}
bool CustomQwtPlotXaxisSelector::end(bool ok)
{
if (!ok) {
clearSelection();
return QwtPlotPicker::end(ok);
}
if (_overlay->isVisible()) {
_overlay->setVisible(false);
plot()->replot();
}
if ( (_max_x - _min_x) > 3 ) {
emit selectionFinished(_min_x, _max_x);
}
return QwtPlotPicker::end(ok);
}
CustomQwtPlot::CustomQwtPlot(QWidget *parent)
: QwtPlot(parent)
{
}
CustomQwtPlot::~CustomQwtPlot()
@ -25,17 +175,100 @@ CustomQwtPlot::~CustomQwtPlot()
qDebug() << "~CustomQwtPlot";
}
void CustomQwtPlot::SetEventFilterFunc(std::function<bool (QObject *, QEvent *)> event_filter_func)
void CustomQwtPlot::SetAxisDragScale(Axis axis_id, bool enable)
{
this->_event_filter_func = event_filter_func;
switch (axis_id) {
case xBottom: {
if ( enable ) {
if ( nullptr == _x_axis_panner ) {
_x_axis_panner = new CustomQwtPlotAxisPanner(this->axisWidget(QwtPlot::xBottom));
_x_axis_panner->setMouseButton(Qt::LeftButton);
_x_axis_panner->setAxisEnabled(QwtPlot::xBottom, true);
_x_axis_panner->setAxisEnabled(QwtPlot::yLeft, false);
} else {
_x_axis_panner->setAxisEnabled(QwtPlot::xBottom, true);
_x_axis_panner->setAxisEnabled(QwtPlot::yLeft, false);
}
if ( nullptr == _x_axis_magnifier ) {
_x_axis_magnifier = new QwtPlotMagnifier(this->axisWidget(QwtPlot::xBottom));
_x_axis_magnifier->setAxisEnabled(QwtPlot::xBottom, true);
_x_axis_magnifier->setAxisEnabled(QwtPlot::yLeft, false);
_x_axis_magnifier->setWheelFactor(1.1);
} else {
_x_axis_magnifier->setAxisEnabled(QwtPlot::xBottom, true);
_x_axis_magnifier->setAxisEnabled(QwtPlot::yLeft, false);
}
} else {
if (_x_axis_panner) {
delete _x_axis_panner;
_x_axis_panner = nullptr;
}
if (_x_axis_magnifier) {
delete _x_axis_magnifier;
_x_axis_magnifier = nullptr;
}
}
void CustomQwtPlot::SetXaxisDragScale(bool enable)
{
QwtScaleWidget *x_scale = axisWidget(QwtPlot::xBottom);
x_scale->setMouseTracking(enable);
x_scale->installEventFilter(enable ? this : nullptr);
} break;
case yLeft: {
if ( enable ) {
if (nullptr == _y_axis_panner) {
_y_axis_panner = new CustomQwtPlotAxisPanner(this->axisWidget(QwtPlot::yLeft));
_y_axis_panner->setMouseButton(Qt::LeftButton);
} else {
_y_axis_panner->setAxisEnabled(QwtPlot::xBottom, false);
_y_axis_panner->setAxisEnabled(QwtPlot::yLeft, true);
}
if (nullptr == _y_axis_magnifier) {
_y_axis_magnifier = new QwtPlotMagnifier(this->axisWidget(QwtPlot::yLeft));
_y_axis_magnifier->setAxisEnabled(QwtPlot::xBottom, false);
_y_axis_magnifier->setAxisEnabled(QwtPlot::yLeft, true);
_y_axis_magnifier->setWheelFactor(1.1);
} else {
_y_axis_magnifier->setAxisEnabled(QwtPlot::xBottom, false);
_y_axis_magnifier->setAxisEnabled(QwtPlot::yLeft, true);
}
} else {
if (_y_axis_panner) {
delete _y_axis_panner;
_y_axis_panner = nullptr;
}
if (_y_axis_magnifier) {
delete _y_axis_magnifier;
_y_axis_magnifier = nullptr;
}
}
} break;
default:
break;
}
}
void CustomQwtPlot::SetAxisInitRange(Axis axis_id, double min, double max)
{
this->setAxisScale(axis_id, min, max);
if ( axis_id == QwtPlot::xBottom ) {
_init_x_min = min;
_init_x_max = max;
}
if ( axis_id == QwtPlot::yLeft ) {
_init_y_min = min;
_init_y_max = max;
}
}
void CustomQwtPlot::RegisterEventFilterFunc(std::function<bool (QObject *, QEvent *)> event_filter_func)
{
this->_event_filter_func_list.push_back(event_filter_func);
}
// void CustomQwtPlot::SetXaxisDragScale(bool enable)
// {
// QwtScaleWidget *x_scale = axisWidget(QwtPlot::xBottom);
// x_scale->setMouseTracking(enable);
// x_scale->installEventFilter(enable ? this : nullptr);
// }
void CustomQwtPlot::ResetPlot()
{
@ -162,197 +395,33 @@ void CustomQwtPlot::CleanZoneItems()
bool CustomQwtPlot::eventFilter(QObject *obj, QEvent *event)
{
if (this->_event_filter_func) {
bool filted = this->_event_filter_func(obj, event);
if (filted) {
return filted;
bool has_filter = false;
for (auto filter : _event_filter_func_list) {
filter(obj, event);
has_filter = true;
}
}
if (dynamic_cast<QwtScaleWidget*>(obj) != this->axisWidget(QwtPlot::xBottom))
return false;
QMouseEvent *me = static_cast<QMouseEvent*>(event);
QwtScaleMap map = this->canvasMap(QwtPlot::xBottom);
// ===================== 1. 鼠标拖动 X 轴 =====================
if (event->type() == QEvent::MouseButtonPress) {
this->_is_dragging = true;
this->_last_pos = me->pos();
return true;
} else if (event->type() == QEvent::MouseMove && this->_is_dragging) {
// 计算坐标偏移
double old_x = map.invTransform(_last_pos.x());
double new_x = map.invTransform(me->pos().x());
double dx = old_x - new_x;
// 移动 X 轴
double x_min = axisScaleDiv(QwtPlot::xBottom).lowerBound() + dx;
double x_max = axisScaleDiv(QwtPlot::xBottom).upperBound() + dx;
this->setAxisScale(QwtPlot::xBottom, x_min, x_max);
this->replot();
this->_last_pos = me->pos();
return true;
} else if (event->type() == QEvent::MouseButtonRelease) {
this->_is_dragging = false;
return true;
}
// ===================== 2. 滚轮缩放 X 轴 =====================
if (event->type() == QEvent::Wheel) {
QWheelEvent *we = static_cast<QWheelEvent*>(event);
double scale = we->angleDelta().y() > 0 ? 0.8 : 1.25; // 放大/缩小
// 以鼠标所在位置为中心缩放
double mouse_x = map.invTransform(we->pos().x());
double x1 = this->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double x2 = this->axisScaleDiv(QwtPlot::xBottom).upperBound();
double new1 = mouse_x - (mouse_x - x1) * scale;
double new2 = mouse_x + (x2 - mouse_x) * scale;
this->setAxisScale(QwtPlot::xBottom, new1, new2);
this->replot();
if (has_filter) {
return true;
}
return QwtPlot::eventFilter(obj, event);
}
void CustomQwtPlot::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
this->updateAxes();
if ((0 == this->_init_x_max) && (0 == this->_init_y_max)) {
// double x_min = this->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double x_max = this->axisScaleDiv(QwtPlot::xBottom).upperBound();
double y_min = this->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double y_max = this->axisScaleDiv(QwtPlot::yLeft).upperBound();
this->_init_x_min = 0;
this->_init_x_max = x_max;
this->_init_y_min = y_min;
this->_init_y_max = y_max;
this->setAxisScale(QwtPlot::xBottom, 0, x_max);
}
}
CustomQwtPlotXaxisPanner::CustomQwtPlotXaxisPanner(QWidget *canvas)
: QwtPlotPanner(canvas)
{
}
CustomQwtPlotXaxisPanner::~CustomQwtPlotXaxisPanner()
{
qDebug() << "~CustomQwtPlotXaxisPanner";
}
void CustomQwtPlotXaxisPanner::moveCanvas(int dx, int dy)
{
QwtPlotPanner::moveCanvas(dx, 0);
}
CustomQwtPlotXaxisMagnifier::CustomQwtPlotXaxisMagnifier(QWidget *canvas)
: QwtPlotMagnifier(canvas)
{
}
CustomQwtPlotXaxisMagnifier::~CustomQwtPlotXaxisMagnifier()
{
qDebug() << "~CustomQwtPlotXaxisMagnifier";
}
void CustomQwtPlotXaxisMagnifier::rescale(double factor)
{
factor = qBound(0.1, factor, 10.0);
QwtScaleMap x_map = plot()->canvasMap(QwtPlot::xBottom);
double center = x_map.invTransform(plot()->canvas()->width() / 2);
plot()->setAxisScale(
QwtPlot::xBottom,
center - (center - x_map.s1()) * factor,
center + (x_map.s2() - center) * factor
);
plot()->replot();
}
CustomQwtPlotXaxisSelector::CustomQwtPlotXaxisSelector(QWidget *canvas)
: QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPicker::NoRubberBand,
QwtPicker::AlwaysOn,
canvas)
, _min_x(0.0)
, _max_x(0.0)
{
this->setStateMachine(new QwtPickerDragRectMachine());
this->setRubberBandPen(QPen(Qt::NoPen));
_overlay = new QwtPlotShapeItem;
_overlay->setRenderHint(QwtPlotItem::RenderAntialiased);
_overlay->setPen(QPen(Qt::red, 2));
_overlay->setBrush(QBrush(QColor(0, 120, 210, 50)));
_overlay->setZ(100);
_overlay->attach(plot());
_overlay->setVisible(false);
}
CustomQwtPlotXaxisSelector::~CustomQwtPlotXaxisSelector()
{
qDebug() << "~CustomQwtPlotXaxisSelector";
}
double CustomQwtPlotXaxisSelector::selectedMinX() const
{
return _min_x;
}
double CustomQwtPlotXaxisSelector::selectedMaxX() const
{
return _max_x;
}
void CustomQwtPlotXaxisSelector::clearSelection()
{
_min_x = 0.0;
_max_x = 0.0;
if (_overlay)
_overlay->setVisible(false);
}
void CustomQwtPlotXaxisSelector::move(const QPoint & pos)
{
QPolygon points = pickedPoints();
if (points.size() < 2) {
clearSelection();
return QwtPlotPicker::move(pos);
}
QPointF p1 = invTransform(points.first());
QPointF p2 = invTransform(points.last());
// 计算X范围
_min_x = qMin(p1.x(), p2.x());
_max_x = qMax(p1.x(), p2.x());
// Y轴铺满
double y_min = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double y_max = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
QRectF area(_min_x, y_min, _max_x - _min_x, y_max - y_min);
_overlay->setRect(area);
_overlay->setVisible(true);
plot()->replot();
QwtPlotPicker::move(pos);
}
bool CustomQwtPlotXaxisSelector::end(bool ok)
{
if (!ok) {
clearSelection();
return QwtPlotPicker::end(ok);
}
if (_overlay->isVisible()) {
_overlay->setVisible(false);
plot()->replot();
}
if ( (_max_x - _min_x) > 3 ) {
emit selectionFinished(_min_x, _max_x);
}
return QwtPlotPicker::end(ok);
}
// void CustomQwtPlot::showEvent(QShowEvent *event)
// {
// Q_UNUSED(event);
// this->updateAxes();
// if ((0 == this->_init_x_max) && (0 == this->_init_y_max)) {
// // double x_min = this->axisScaleDiv(QwtPlot::xBottom).lowerBound();
// double x_max = this->axisScaleDiv(QwtPlot::xBottom).upperBound();
// // double y_min = this->axisScaleDiv(QwtPlot::yLeft).lowerBound();
// double y_max = this->axisScaleDiv(QwtPlot::yLeft).upperBound();
// this->_init_x_min = 0;
// this->_init_x_max = x_max;
// this->_init_y_min = 0;
// this->_init_y_max = y_max;
// this->setAxisScale(QwtPlot::xBottom, 0, x_max);
// }
// }
QColor getDistinctColorForManyCurves(int curve_index)
{

View File

@ -4,72 +4,33 @@
#include <QMap>
#include <QwtPlot>
#include <QwtPlotPanner>
#include <QwtPlotMagnifier>
// #include <QwtPlotMagnifier>
#include <QwtPlotPicker>
class QwtPlotCurve;
class QwtPlotMarker;
class QwtPlotZoneItem;
class QwtPlotShapeItem;
class QwtScaleWidget;
class QwtPlotMagnifier;
class CustomQwtPlot : public QwtPlot
class CustomQwtPlotAxisPanner : public QwtPlotPanner
{
public:
explicit CustomQwtPlot(QWidget* parent = nullptr);
virtual ~CustomQwtPlot();
void SetEventFilterFunc(std::function<bool(QObject*, QEvent*)> event_filter_func);
void SetXaxisDragScale(bool enable);
void ResetPlot();
QwtPlotCurve* GetCurve(const QString& curve_name);
QList<QwtPlotCurve*> GetCurveList() const;
void AddCurve(QwtPlotCurve* curve, bool auto_color = true);
QwtPlotMarker* GetMarker(const QString& marker_name, const QString& postion);
QList<QwtPlotMarker*> GetMarkerList() const;
void AddMarker(QwtPlotMarker *marker, const QString &marker_name, const QString &postion);
void RemoveMarker(const QString& marker_name, const QString& postion);
void CleanMarkers();
QwtPlotZoneItem* GetZoneItem(const QString& zone_item_name);
QList<QwtPlotZoneItem*> GetZoneItemList() const;
void AddZoneItem(QwtPlotZoneItem *zone_item, const QString &zone_item_name);
void RemoveZoneItem(const QString& zone_item_name);
void CleanZoneItems();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
virtual void showEvent(QShowEvent *event) override;
private:
double _init_x_min = 0, _init_x_max = 0;
double _init_y_min = 0, _init_y_max = 0;
bool _is_dragging = false;
QPoint _last_pos;
std::function<bool(QObject*, QEvent*)> _event_filter_func = nullptr;
private:
QMap<QString, QwtPlotCurve*> _curves;
QMap<QString, QMap<QString, QwtPlotMarker*> > _markers;
QMap<QString, QwtPlotZoneItem*> _zone_items;
};
class CustomQwtPlotXaxisPanner : public QwtPlotPanner
{
public:
CustomQwtPlotXaxisPanner(QWidget *canvas);
virtual ~CustomQwtPlotXaxisPanner();
CustomQwtPlotAxisPanner(QwtScaleWidget *scale_widget);
virtual ~CustomQwtPlotAxisPanner();
protected:
virtual void moveCanvas(int dx, int dy) override;
};
class CustomQwtPlotXaxisMagnifier : public QwtPlotMagnifier
{
public:
CustomQwtPlotXaxisMagnifier(QWidget *canvas);
virtual ~CustomQwtPlotXaxisMagnifier();
protected:
virtual void rescale(double factor) override;
};
// class CustomQwtPlotXaxisMagnifier : public QwtPlotMagnifier
// {
// public:
// CustomQwtPlotXaxisMagnifier(QWidget *canvas);
// virtual ~CustomQwtPlotXaxisMagnifier();
// protected:
// virtual void rescale(double factor) override;
// };
class CustomQwtPlotXaxisSelector : public QwtPlotPicker
{
@ -95,6 +56,57 @@ private:
double _max_x;
};
class CustomQwtPlot : public QwtPlot
{
public:
explicit CustomQwtPlot(QWidget* parent = nullptr);
virtual ~CustomQwtPlot();
void SetAxisDragScale(QwtPlot::Axis axis_id, bool enable);
void SetAxisInitRange(QwtPlot::Axis axis_id, double min, double max);
void RegisterEventFilterFunc(std::function<bool(QObject*, QEvent*)> event_filter_func);
// void SetXaxisDragScale(bool enable);
void ResetPlot();
QwtPlotCurve* GetCurve(const QString& curve_name);
QList<QwtPlotCurve*> GetCurveList() const;
void AddCurve(QwtPlotCurve* curve, bool auto_color = true);
QwtPlotMarker* GetMarker(const QString& marker_name, const QString& postion);
QList<QwtPlotMarker*> GetMarkerList() const;
void AddMarker(QwtPlotMarker *marker, const QString &marker_name, const QString &postion);
void RemoveMarker(const QString& marker_name, const QString& postion);
void CleanMarkers();
QwtPlotZoneItem* GetZoneItem(const QString& zone_item_name);
QList<QwtPlotZoneItem*> GetZoneItemList() const;
void AddZoneItem(QwtPlotZoneItem *zone_item, const QString &zone_item_name);
void RemoveZoneItem(const QString& zone_item_name);
void CleanZoneItems();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
// virtual void showEvent(QShowEvent *event) override;
private:
double _init_x_min = 0, _init_x_max = 0;
double _init_y_min = 0, _init_y_max = 0;
// bool _is_dragging = false;
// QPoint _last_pos;
std::list<std::function<bool(QObject*, QEvent*)> > _event_filter_func_list = {};
private:
CustomQwtPlotAxisPanner* _x_axis_panner = nullptr;
CustomQwtPlotAxisPanner* _y_axis_panner = nullptr;
QwtPlotMagnifier* _x_axis_magnifier = nullptr;
QwtPlotMagnifier* _y_axis_magnifier = nullptr;
QMap<QString, QwtPlotCurve*> _curves;
QMap<QString, QMap<QString, QwtPlotMarker*> > _markers;
QMap<QString, QwtPlotZoneItem*> _zone_items;
};
QColor getDistinctColorForManyCurves(int curve_index);

View File

@ -78,7 +78,7 @@ void EnergyCountPeakFitView::setupPlot()
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
// _plot->insertLegend(legend, QwtPlot::RightLegend);
_plot->SetXaxisDragScale(true);
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
_data_selector->setEnabled(false);
}

View File

@ -82,7 +82,7 @@ void EnergyCountPlotView::setupPlot()
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
_plot->insertLegend(legend, QwtPlot::RightLegend);
_plot->SetXaxisDragScale(true);
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
_data_selector->setEnabled(false);
}

View File

@ -177,7 +177,7 @@ void ParticleCountPlotView::setupPlot()
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
_plot->insertLegend(legend, QwtPlot::RightLegend);
_plot->SetXaxisDragScale(true);
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
// new CustomQwtPlotXaxisPanner(_plot->canvas());
// new CustomQwtPlotXaxisMagnifier(_plot->canvas());
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());

View File

@ -1,5 +1,4 @@
#include "ParticleInjectTimeAnalysisView.h"
#include "ui_ParticleInjectTimeAnalysisView.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QMessageBox>
@ -12,22 +11,61 @@
#include <cmath>
#include <QtMath>
#include "CustomQwtPlot.h"
#include <QDebug>
#include <GlobalDefine.h>
#include "csv.h"
#include <QFileInfo>
#include <QThread>
#include "BusyIndicator.h"
#include <QMenu>
#include <QAction>
ParticleInjectTimeAnalysisView::ParticleInjectTimeAnalysisView(QWidget *parent) :
MeasureAnalysisView(parent),
ui(new Ui::ParticleInjectTimeAnalysisView)
MeasureAnalysisView(parent)
{
this->setViewType(PlotFrame);
ui->setupUi(this);
InitUi();
_plot = new CustomQwtPlot();
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(_plot);
_plot->setCanvasBackground(Qt::white);
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(_plot->canvas());
canvas->setFrameStyle(QFrame::NoFrame);
QFont font = this->font();
font.setBold(false);
QwtText particle_num_label = QStringLiteral(u"粒子序号");
particle_num_label.setFont(font);
QwtText time_label = QStringLiteral(u"粒子时间(ns)");
time_label.setFont(font);
_plot->setAxisTitle(QwtPlot::xBottom, particle_num_label);
_plot->setAxisTitle(QwtPlot::yLeft, time_label);
// set axis auto scale
_plot->setAxisAutoScale(QwtPlot::xBottom, true);
_plot->setAxisAutoScale(QwtPlot::yLeft, true);
// 启用网格线
_plot->enableAxis(QwtPlot::xBottom);
_plot->enableAxis(QwtPlot::yLeft);
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
// // 设置QWT图例
// QwtLegend* legend = new QwtLegend();
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
// _plot->insertLegend(legend, QwtPlot::RightLegend);
_curve = new QwtPlotCurve();
_plot->AddCurve(_curve);
this->_menu = new QMenu(this);
setupMenu();
_busy_indicator = new BusyIndicator(this);
}
ParticleInjectTimeAnalysisView::~ParticleInjectTimeAnalysisView()
{
delete ui;
}
void ParticleInjectTimeAnalysisView::InitViewWorkspace(const QString &project_name)
@ -37,154 +75,83 @@ void ParticleInjectTimeAnalysisView::InitViewWorkspace(const QString &project_na
void ParticleInjectTimeAnalysisView::SetAnalyzeDataFilename(const QMap<QString, QVariant> &data_files_set)
{
int energyStart = ui->label_energyStart->text().toInt();
int energyEnd = ui->label_energyEnd->text().toInt();
if(!data_files_set.isEmpty())
{
io::CSVReader<4> in(QStrToSysPath(data_files_set.first().toString()));
in.read_header(io::ignore_extra_column, QStringLiteral(u"板卡号").toStdString(), QStringLiteral(u"通道号").toStdString(), QStringLiteral(u"能量(KeV)").toStdString(), QStringLiteral(u"时间计数").toStdString());
const QString& data_filename = data_files_set.first().toString();
if ( !data_filename.isEmpty() ) {
if (QFileInfo(data_filename).exists()) {
this->_data_filename = data_filename;
this->updateData(true);
}
}
}
int board, channel;
double energy, time_count;
int lineNumber = 0;
void ParticleInjectTimeAnalysisView::setupMenu()
{
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &ParticleInjectTimeAnalysisView::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();
this->_menu->addSeparator();
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
action_plot_config->setObjectName("plot_config");
connect(action_plot_config, &QAction::triggered, this, &ParticleInjectTimeAnalysisView::onActionPlotConfigure);
}
void ParticleInjectTimeAnalysisView::updateData(bool b_init_update)
{
auto functionToRun = [this, b_init_update](){
if(!_data_filename.isEmpty()) {
_busy_indicator->Start();
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
std::string channel_id_str = QString(QStringLiteral(u"通道号")).toStdString();
std::string energy_str = QString(QStringLiteral(u"能量(KeV)")).toStdString();
std::string time_str = QString(QStringLiteral(u"时间计数")).toStdString();
io::CSVReader<4> in(QStrToSysPath(_data_filename));
in.read_header(io::ignore_extra_column, board_id_str, channel_id_str, energy_str, time_str);
int particle_num = 0;
QVector<double> x;
QVector<double> y;
double minValue = 0;
double maxValue = 0;
// 逐行读取
while (in.read_row(board, channel, energy, time_count))
{
// qDebug()<<QStringLiteral(u"板卡号:")<<board<<QStringLiteral(u"通道号")<<channel<<QStringLiteral(u"能量(KeV)")<<energy<<QStringLiteral(u"时间计数")<<time_count;
int detector = board + channel * 8;
lineNumber++;
if(detector > 32)
{
int board, channel;
double energy;
unsigned long long time_count;
while (in.read_row(board, channel, energy, time_count)) {
if ( !b_init_update && (energy <= _begin_enery || energy >= _end_energy)) {
continue;
}
if(energy <= energyStart || energy >= energyEnd)
{
continue;
}
x.append(lineNumber);
particle_num++;
x.append(particle_num);
y.append(time_count);
minValue = qMin(minValue, time_count);
maxValue = qMax(maxValue, time_count);
}
// 创建曲线并设置数据
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setSamples(x, y);
// 将曲线添加到 CustomQwtPlot 中(会自动分配颜色)
plot->AddCurve(curve);
// 设置坐标轴范围和标题
// plot->setAxisScale(QwtPlot::xBottom, 0, x.last());
// plot->setAxisScale(QwtPlot::yLeft,minValue , maxValue);
LOG_INFO(QStringLiteral(u"%1数据读取完毕.").arg(this->GetViewName()));
// 刷新绘图
plot->replot();
// m_AllData = getParticleInjectTimeData(data_files_set.first().toString());
// setData(m_AllData);
_curve->setSamples(x, y);
_plot->replot();
LOG_INFO(QStringLiteral(u"%1数据更新完毕.").arg(this->GetViewName()));
_busy_indicator->Stop();
}
};
QThread* load_data_thread = QThread::create(functionToRun);
load_data_thread->start();
}
void ParticleInjectTimeAnalysisView::setData(QVector<ParticleInjectTime *> data)
void ParticleInjectTimeAnalysisView::onActionPlotConfigure()
{
int energyStart = ui->label_energyStart->text().toInt();
int energyEnd = ui->label_energyEnd->text().toInt();
QVector<double> x;
QVector<double> y;
}
double minValue = 0;
double maxValue = 0;
for(auto info : data)
void ParticleInjectTimeAnalysisView::showEvent(QShowEvent *e)
{
if(info->dEnergy <= energyStart || info->dEnergy >= energyEnd)
{
continue;
Q_UNUSED(e);
if (_busy_indicator) {
_busy_indicator->setGeometry(this->rect());
this->update();
}
x.append(info->index);
y.append(info->dTime);
minValue = qMin(minValue, info->dTime);
maxValue = qMax(maxValue, info->dTime);
}
// 创建曲线并设置数据
QwtPlotCurve *curve = new QwtPlotCurve();
// curve->setRawSamples(x.data(),y.data(),x.size());
curve->setSamples(x, y);
// 将曲线添加到 CustomQwtPlot 中(会自动分配颜色)
plot->AddCurve(curve);
// 设置坐标轴范围和标题
// plot->setAxisScale(QwtPlot::xBottom, 0, x.last());
// plot->setAxisScale(QwtPlot::yLeft,minValue , maxValue);
LOG_INFO(QStringLiteral(u"%1数据读取完毕.").arg(this->GetViewName()));
// 刷新绘图
plot->replot();
}
QVector<ParticleInjectTime *> ParticleInjectTimeAnalysisView::getParticleInjectTimeData(QString path)
{
QVector<ParticleInjectTime *> records;
io::CSVReader<4> in(QStrToSysPath(path));
in.read_header(io::ignore_extra_column, "板卡号", "通道号", "能量(KeV)", "时间计数");
int board, channel;
double energy, time_count;
int lineNumber = 0;
// 逐行读取
while (in.read_row(board, channel, energy, time_count))
{
// qDebug()<<QStringLiteral(u"板卡号:")<<board<<QStringLiteral(u"通道号")<<channel<<QStringLiteral(u"能量(KeV)")<<energy<<QStringLiteral(u"时间计数")<<time_count;
int detector = board + channel * 8;
lineNumber++;
if(detector > 32)
{
continue;
}
ParticleInjectTime *rec = new ParticleInjectTime;
rec->index = lineNumber;
rec->dEnergy = energy;
rec->dTime = time_count;
records.append(rec);
}
return records;
}
void ParticleInjectTimeAnalysisView::InitUi()
{
plot = new CustomQwtPlot();
plot->SetXaxisDragScale(true);
setupPlot();
ui->verticalLayout_2->addWidget(plot);
}
void ParticleInjectTimeAnalysisView::setupPlot()
{
plot->setCanvasBackground(Qt::white);
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(plot->canvas());
canvas->setFrameStyle(QFrame::NoFrame);
plot->setAxisTitle(QwtPlot::xBottom, QStringLiteral(u"粒子序号"));
plot->setAxisTitle(QwtPlot::yLeft, QStringLiteral(u"粒子时间"));
// 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);
}

View File

@ -1,43 +1,39 @@
#ifndef PARTICLEINJECTTIMEANALYSISVIEW_H
#define PARTICLEINJECTTIMEANALYSISVIEW_H
#include <QWidget>
#include "qwt.h"
#include "CustomQwtPlot.h"
#include <QFile>
#include <QTextStream>
#include "MeasureAnalysisView.h"
#include "csv.h"
namespace Ui {
class ParticleInjectTimeAnalysisView;
}
class CustomQwtPlot;
class QwtPlotCurve;
class BusyIndicator;
class QMenu;
class ParticleInjectTimeAnalysisView : public MeasureAnalysisView
{
Q_OBJECT
public:
explicit ParticleInjectTimeAnalysisView(QWidget *parent = nullptr);
virtual ~ParticleInjectTimeAnalysisView();
virtual void InitViewWorkspace(const QString& project_name) override final;
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
void setData(QVector<ParticleInjectTime *> data);
//获取数据
QVector<ParticleInjectTime *> getParticleInjectTimeData(QString path);
private:
void InitUi();
void setupPlot();
void setupMenu();
void updateData(bool b_init_update);
private slots:
void onActionPlotConfigure();
protected:
virtual void showEvent(QShowEvent* e) override final;
private:
Ui::ParticleInjectTimeAnalysisView *ui;
CustomQwtPlot *plot;
QVector<ParticleInjectTime *> m_AllData;//存储的所有的粒子入射时间数据
BusyIndicator* _busy_indicator = nullptr;
CustomQwtPlot *_plot = nullptr;
QwtPlotCurve *_curve = nullptr;
QMenu* _menu = nullptr;
double _begin_enery = 0.0f;
double _end_energy = 0.0f;
QString _data_filename;
};
#endif // PARTICLEINJECTTIMEANALYSIS_H

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ParticleInjectTimeAnalysisView</class>
<widget class="QWidget" name="ParticleInjectTimeAnalysisView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>997</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle">
<string>ParticleInjectTimeAnalysis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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="QLabel" name="label">
<property name="text">
<string>粒子入射设置</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>起始能量:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_energyStart">
<property name="text">
<string>50</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>KeV</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>~</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>终止能量:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_energyEnd">
<property name="text">
<string>100</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>KeV</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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="pushButton">
<property name="text">
<string>感兴趣区域(ROI)选择</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -16,6 +16,11 @@
#include <QwtPlotHistogram>
#include <QwtIntervalSample>
#include <QwtLogScaleEngine>
#include <QwtPlotPanner>
#include <QwtPlotMagnifier>
#include <QwtScaleWidget>
#include <QThreadPool>
#include "BusyIndicator.h"
#include <QDebug>
@ -30,6 +35,8 @@ ParticleTimeDifferenceView::ParticleTimeDifferenceView(QWidget *parent)
setupPlot();
this->_menu = new QMenu(this);
setupMenu();
_busy_indicator = new BusyIndicator(this);
}
ParticleTimeDifferenceView::~ParticleTimeDifferenceView()
@ -48,7 +55,12 @@ void ParticleTimeDifferenceView::SetAnalyzeDataFilename(const QMap<QString, QVar
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);
this->_data_filename = data_filename;
auto functionToRun = [this](){
this->loadDataFromFile();
};
QThread* load_data_thread = QThread::create(functionToRun);
load_data_thread->start();
}
}
}
@ -69,15 +81,14 @@ void ParticleTimeDifferenceView::setupPlot()
_plot->setAxisTitle(QwtPlot::yLeft, count_label);
// set axis auto scale
_plot->setAxisAutoScale(QwtPlot::xBottom, true);
_plot->setAxisAutoScale(QwtPlot::yLeft, true);
_plot->setAxisAutoScale(QwtPlot::xBottom, false);
_plot->setAxisAutoScale(QwtPlot::yLeft, false);
_plot->enableAxis(QwtPlot::xBottom);
_plot->enableAxis(QwtPlot::yLeft);
_plot->SetXaxisDragScale(true);
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
_data_selector->setEnabled(false);
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
_plot->SetAxisDragScale(QwtPlot::yLeft, true);
_histogram = new QwtPlotHistogram("粒子时间差分布");
_histogram->setStyle(QwtPlotHistogram::Columns);
@ -95,14 +106,17 @@ void ParticleTimeDifferenceView::setupMenu()
connect(action_plot_reset, &QAction::triggered, [this]() {
this->_plot->ResetPlot();
});
this->_menu->addSeparator();
this->_menu->addSeparator();
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
action_plot_config->setObjectName("plot_config");
connect(action_plot_config, &QAction::triggered, this, &ParticleTimeDifferenceView::onActionPlotConfigure);
}
void ParticleTimeDifferenceView::loadDataFromFile(const QString &data_name, const QString &filename)
void ParticleTimeDifferenceView::loadDataFromFile()
{
_busy_indicator->Start();
try {
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
std::string channel_id_str = QString(QStringLiteral(u"通道号")).toStdString();
@ -115,7 +129,7 @@ void ParticleTimeDifferenceView::loadDataFromFile(const QString &data_name, cons
io::double_quote_escape<',', '"'>,
io::throw_on_overflow,
io::empty_line_comment>
reader(QStrToSysPath(filename));
reader(QStrToSysPath(this->_data_filename));
reader.read_header(io::ignore_extra_column, board_id_str, channel_id_str, address_str, time_str);
QMap<double, unsigned long long> hist_map;
@ -131,26 +145,42 @@ void ParticleTimeDifferenceView::loadDataFromFile(const QString &data_name, cons
hist_map[bin]++;
time1 = time2;
}
unsigned long long max_count = 1;
double x_max = 0.0f, y_max = 0.0f;
QVector<QwtIntervalSample> samples;
for (const double& bin : hist_map.keys()) {
const unsigned long long& count = hist_map.value(bin);
samples.append(QwtIntervalSample(count, bin, bin + _bin_width));
if ( max_count < count ) {
max_count = count;
}
double bin_max = bin + _bin_width;
samples.append(QwtIntervalSample(count, bin, bin_max));
if ( x_max < bin_max )
x_max = bin_max;
if ( y_max < count )
y_max = count;
// if ( _max_diff <= bin ) {
// break;
// }
}
_histogram->setData(new QwtIntervalSeriesData(samples));
_plot->SetAxisInitRange(QwtPlot::xBottom, 0.0f, _x_max);
_plot->SetAxisInitRange(QwtPlot::yLeft, 0.0f, y_max);
_plot->replot();
const QString& info = QStringLiteral(u"能谱数据处理完成.");
const QString& info = QStringLiteral(u"粒子时间差分析处理完成.");
LOG_INFO(info);
} catch (const std::exception& e) {
const QString& e_what = QString::fromStdString(e.what());
LOG_WARN(QStringLiteral(u"能谱数据异常:%1").arg(e_what));
LOG_WARN(QStringLiteral(u"粒子时间差分析处理异常:%1").arg(e_what));
}
_busy_indicator->Stop();
}
void ParticleTimeDifferenceView::onActionPlotConfigure()
{
}
void ParticleTimeDifferenceView::showEvent(QShowEvent *e)
{
Q_UNUSED(e);
if (_busy_indicator) {
_busy_indicator->setGeometry(this->rect());
this->update();
}
}

View File

@ -9,6 +9,7 @@ class QMenu;
class CustomQwtPlot;
class CustomQwtPlotXaxisSelector;
class QwtPlotHistogram;
class BusyIndicator;
class ParticleTimeDifferenceView : public MeasureAnalysisView
{
@ -23,18 +24,25 @@ public:
private:
void setupPlot();
void setupMenu();
void loadDataFromFile(const QString &data_name, const QString& filename);
void loadDataFromFile();
private slots:
void onActionPlotConfigure();
protected:
virtual void showEvent(QShowEvent* e) override final;
private:
BusyIndicator* _busy_indicator = nullptr;
CustomQwtPlot* _plot = nullptr;
QMenu* _menu = nullptr;
QDialog* _curve_show_setting_dlg = nullptr;
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
double _bin_width = 50.0f;
double _x_max = 200.0f * 1e3;
double _y_max = 0.0f;
QwtPlotHistogram* _histogram = nullptr;
QString _data_filename;
};
#endif // PARTICLETIMEDIFFERENCEVIEW_H

View File

@ -31,6 +31,7 @@ MOC_DIR = $${BUILD_MOC}/$${TARGET}/moc
UI_DIR = $${BUILD_UI}/$${TARGET}/ui
INCLUDEPATH += \
$${PWD}/BusyIndicator \
$${PWD}/MeasureAnalysisParticleCountPlotView \
$${PWD}/ParticleCountPlotView \
$${PWD}/ParticleInjectTimeView \
@ -45,6 +46,7 @@ INCLUDEPATH += \
DEPENDPATH += \
$${PWD}/BusyIndicator \
$${PWD}/MeasureAnalysisParticleCountPlotView \
$${PWD}/ParticleCountPlotView \
$${PWD}/ParticleInjectTimeView \
@ -60,6 +62,7 @@ DEPENDPATH += \
SOURCES += \
AboutDlg.cpp \
BusyIndicator/BusyIndicator.cpp \
CountRateAnalysisView/CountRateAnalysisView.cpp \
CustomQwtPlot.cpp \
DataProcessWorkPool.cpp \
@ -98,6 +101,7 @@ SOURCES += \
HEADERS += \
AboutDlg.h \
AnalysisTypeDefine.h \
BusyIndicator/BusyIndicator.h \
CountRateAnalysisView/CountRateAnalysisView.h \
CustomQwtPlot.h \
DataProcessWorkPool.h \
@ -145,7 +149,6 @@ FORMS += \
ParticleCountPlotView/BatchEnergyScaleDialog.ui \
MeasureDeviceParamsCfgForm.ui \
NewMeasureAnalysisDlg.ui \
ParticleInjectTimeView/ParticleInjectTimeAnalysisView.ui\
ThreeDimensionalConformityAnalysisView/DetectorStatusSummary.ui \
ThreeDimensionalConformityAnalysisView/ParticleDataStatistics.ui \
ThreeDimensionalConformityAnalysisView/ThreeDDisplay.ui \

7
style/Resources.qrc Normal file
View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>stylesheet/default.qss</file>
<file>stylesheet/dock.qss</file>
<file>gif/BusyIndicator.gif</file>
</qresource>
</RCC>

BIN
style/gif/BusyIndicator.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

View File

@ -0,0 +1,111 @@
/*
QwtPlot {
background-color: white;
}
QAbstractItemView {
border: 0px;
}
QPlainTextEdit {
border: 0px;
}
QTreeView::item:selected:active{
color: black;
background: #7bbfea;
}
QTreeView::item:selected:!active {
color: black;
background: #7bbfea;
}
QTableView {
selection-color: black;
selection-background-color: #7bbfea;
}
QTableView QTableCornerButton::section {
background: #f0f0f0;
}
QHeaderView {
background-color: white;
}
QHeaderView::section {
font-weight: normal;
color: black;
padding-left: 4px;
border-bottom: 1px solid #d8d8d8;
border-left: 0px;
border-right: 1px solid #d8d8d8;
border-top: 0px;
}
QHeaderView::section:checked
{
font-weight: normal;
}
QScrollBar {
background-color: #f6f5ec;
padding: 0px;
border-radius: 3px;
}
QScrollBar:vertical {
width: 6px;
min-height: 30px;
}
QScrollBar::horizontal {
height:6px;
min-width: 30px;
}
QScrollBar::handle {
border: none;
border-radius: 3px;
background-color: #7bbfea;
}
QScrollBar::handle:hover {
background-color: #2a5caa;
}
QScrollBar::sub-line {
border: none;
}
QScrollBar::add-line {
border: none;
}
QScrollBar::add-page {
background: rgba(0, 0, 0, 0);
}
QScrollBar::sub-page {
background: rgba(0, 0, 0, 0);
}
*/
/*
QTreeView[Checkable="false"]::indicator:unchecked {
background: blue;
}
QTreeView[Checkable="false"]::indicator:checked {
background: blue;
}
QTreeView[Checkable="true"]::unchecked {
background: red; }
QTreeView[Checkable="true"]::checked {
background: green;
}
*/

13
style/stylesheet/dock.qss Normal file
View File

@ -0,0 +1,13 @@
/*
ads--CDockContainerWidget ads--CDockSplitter::handle {
background: #2a5caa;
}
ads--CDockSplitter::handle:horizontal {
width: 1px;
}
ads--CDockSplitter::handle:vertical {
height: 1px;
}
*/