diff --git a/bin/minimsys/bash.exe b/bin/minimsys/bash.exe new file mode 100644 index 0000000..65d31bb Binary files /dev/null and b/bin/minimsys/bash.exe differ diff --git a/bin/minimsys/env.exe b/bin/minimsys/env.exe new file mode 100644 index 0000000..d3408cb Binary files /dev/null and b/bin/minimsys/env.exe differ diff --git a/bin/minimsys/head.exe b/bin/minimsys/head.exe new file mode 100644 index 0000000..3cd9f33 Binary files /dev/null and b/bin/minimsys/head.exe differ diff --git a/bin/minimsys/msys-2.0.dll b/bin/minimsys/msys-2.0.dll new file mode 100644 index 0000000..4ec83b6 Binary files /dev/null and b/bin/minimsys/msys-2.0.dll differ diff --git a/bin/minimsys/msys-gcc_s-seh-1.dll b/bin/minimsys/msys-gcc_s-seh-1.dll new file mode 100644 index 0000000..f17b29c Binary files /dev/null and b/bin/minimsys/msys-gcc_s-seh-1.dll differ diff --git a/bin/minimsys/msys-iconv-2.dll b/bin/minimsys/msys-iconv-2.dll new file mode 100644 index 0000000..42f6106 Binary files /dev/null and b/bin/minimsys/msys-iconv-2.dll differ diff --git a/bin/minimsys/msys-intl-8.dll b/bin/minimsys/msys-intl-8.dll new file mode 100644 index 0000000..8cb0997 Binary files /dev/null and b/bin/minimsys/msys-intl-8.dll differ diff --git a/bin/minimsys/sort.exe b/bin/minimsys/sort.exe new file mode 100644 index 0000000..67e1d2c Binary files /dev/null and b/bin/minimsys/sort.exe differ diff --git a/bin/minimsys/tail.exe b/bin/minimsys/tail.exe new file mode 100644 index 0000000..e89c17d Binary files /dev/null and b/bin/minimsys/tail.exe differ diff --git a/bin/theme.rcc b/bin/theme.rcc new file mode 100644 index 0000000..ab7b92a Binary files /dev/null and b/bin/theme.rcc differ diff --git a/src/BusyIndicator/BusyIndicator.cpp b/src/BusyIndicator/BusyIndicator.cpp new file mode 100644 index 0000000..2106cbb --- /dev/null +++ b/src/BusyIndicator/BusyIndicator.cpp @@ -0,0 +1,39 @@ +#include "BusyIndicator.h" +#include +#include +#include + +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(); +} diff --git a/src/BusyIndicator/BusyIndicator.h b/src/BusyIndicator/BusyIndicator.h new file mode 100644 index 0000000..6474421 --- /dev/null +++ b/src/BusyIndicator/BusyIndicator.h @@ -0,0 +1,20 @@ +#ifndef BUSYINDICATOR_H +#define BUSYINDICATOR_H + +#include +#include + +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 diff --git a/src/CountRateAnalysisView/CountRateAnalysisView.cpp b/src/CountRateAnalysisView/CountRateAnalysisView.cpp index 12dc733..c71b10b 100644 --- a/src/CountRateAnalysisView/CountRateAnalysisView.cpp +++ b/src/CountRateAnalysisView/CountRateAnalysisView.cpp @@ -22,7 +22,9 @@ CountRateAnalysisView::CountRateAnalysisView(QWidget *parent) : { ui->setupUi(this); this->setViewType(PlotFrame); + InitUi(); + } CountRateAnalysisView::~CountRateAnalysisView() @@ -96,7 +98,7 @@ QVector CountRateAnalysisView::getParticleInjectTimeData(QSt { QVector 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 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 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); } diff --git a/src/CustomQwtPlot.cpp b/src/CustomQwtPlot.cpp index 517bb8a..a53049e 100644 --- a/src/CustomQwtPlot.cpp +++ b/src/CustomQwtPlot.cpp @@ -13,11 +13,161 @@ #include #include #include +#include #include +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(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,18 +175,101 @@ CustomQwtPlot::~CustomQwtPlot() qDebug() << "~CustomQwtPlot"; } -void CustomQwtPlot::SetEventFilterFunc(std::function 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; + } + } + + } 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::SetXaxisDragScale(bool enable) +void CustomQwtPlot::SetAxisInitRange(Axis axis_id, double min, double max) { - QwtScaleWidget *x_scale = axisWidget(QwtPlot::xBottom); - x_scale->setMouseTracking(enable); - x_scale->installEventFilter(enable ? this : nullptr); + 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 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() { this->setAxisScale(QwtPlot::xBottom, _init_x_min, _init_x_max); @@ -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(obj) != this->axisWidget(QwtPlot::xBottom)) - return false; - QMouseEvent *me = static_cast(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(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) { diff --git a/src/CustomQwtPlot.h b/src/CustomQwtPlot.h index 713420f..0e59954 100644 --- a/src/CustomQwtPlot.h +++ b/src/CustomQwtPlot.h @@ -4,72 +4,33 @@ #include #include #include -#include +// #include #include 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 event_filter_func); - void SetXaxisDragScale(bool enable); - void ResetPlot(); - - QwtPlotCurve* GetCurve(const QString& curve_name); - QList GetCurveList() const; - void AddCurve(QwtPlotCurve* curve, bool auto_color = true); - - QwtPlotMarker* GetMarker(const QString& marker_name, const QString& postion); - QList 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 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 _event_filter_func = nullptr; -private: - QMap _curves; - QMap > _markers; - QMap _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 event_filter_func); + // void SetXaxisDragScale(bool enable); + void ResetPlot(); + + QwtPlotCurve* GetCurve(const QString& curve_name); + QList GetCurveList() const; + void AddCurve(QwtPlotCurve* curve, bool auto_color = true); + + QwtPlotMarker* GetMarker(const QString& marker_name, const QString& postion); + QList 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 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 > _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 _curves; + QMap > _markers; + QMap _zone_items; +}; + + + QColor getDistinctColorForManyCurves(int curve_index); diff --git a/src/EnergyCountPeakFitView/EnergyCountPeakFitView.cpp b/src/EnergyCountPeakFitView/EnergyCountPeakFitView.cpp index 8c407b4..4034865 100644 --- a/src/EnergyCountPeakFitView/EnergyCountPeakFitView.cpp +++ b/src/EnergyCountPeakFitView/EnergyCountPeakFitView.cpp @@ -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); } diff --git a/src/EnergyCountPlotView/EnergyCountPlotView.cpp b/src/EnergyCountPlotView/EnergyCountPlotView.cpp index f13c7cf..21a69f4 100644 --- a/src/EnergyCountPlotView/EnergyCountPlotView.cpp +++ b/src/EnergyCountPlotView/EnergyCountPlotView.cpp @@ -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); } diff --git a/src/ParticleCountPlotView/ParticleCountPlotView.cpp b/src/ParticleCountPlotView/ParticleCountPlotView.cpp index 6e40b66..a5537f3 100644 --- a/src/ParticleCountPlotView/ParticleCountPlotView.cpp +++ b/src/ParticleCountPlotView/ParticleCountPlotView.cpp @@ -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()); diff --git a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.cpp b/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.cpp index c4a9abd..deb2c4b 100644 --- a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.cpp +++ b/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.cpp @@ -1,5 +1,4 @@ #include "ParticleInjectTimeAnalysisView.h" -#include "ui_ParticleInjectTimeAnalysisView.h" #include #include #include @@ -12,22 +11,61 @@ #include #include #include "CustomQwtPlot.h" -#include #include +#include "csv.h" +#include +#include +#include "BusyIndicator.h" +#include +#include 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(_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 &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()); - - int board, channel; - double energy, time_count; - int lineNumber = 0; - QVector x; - QVector y; - double minValue = 0; - double maxValue = 0; - // 逐行读取 - while (in.read_row(board, channel, energy, time_count)) - { - // qDebug()< 32) - { - continue; - } - if(energy <= energyStart || energy >= energyEnd) - { - continue; - } - x.append(lineNumber); - 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); - - } -} - -void ParticleInjectTimeAnalysisView::setData(QVector data) -{ - int energyStart = ui->label_energyStart->text().toInt(); - int energyEnd = ui->label_energyEnd->text().toInt(); - - QVector x; - QVector y; - - double minValue = 0; - double maxValue = 0; - for(auto info : data) - { - if(info->dEnergy <= energyStart || info->dEnergy >= energyEnd) - { - continue; + 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); } - 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); +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(); - LOG_INFO(QStringLiteral(u"%1数据读取完毕.").arg(this->GetViewName())); + 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); +} - // 刷新绘图 - plot->replot(); +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 x; + QVector y; + + 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; + } + particle_num++; + x.append(particle_num); + y.append(time_count); + } + _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::onActionPlotConfigure() +{ } -QVector ParticleInjectTimeAnalysisView::getParticleInjectTimeData(QString path) +void ParticleInjectTimeAnalysisView::showEvent(QShowEvent *e) { - QVector 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()< 32) - { - continue; - } - ParticleInjectTime *rec = new ParticleInjectTime; - rec->index = lineNumber; - rec->dEnergy = energy; - rec->dTime = time_count; - records.append(rec); + Q_UNUSED(e); + if (_busy_indicator) { + _busy_indicator->setGeometry(this->rect()); + this->update(); } - 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(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); -} diff --git a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.h b/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.h index 3e5b500..603acb9 100644 --- a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.h +++ b/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.h @@ -1,43 +1,39 @@ #ifndef PARTICLEINJECTTIMEANALYSISVIEW_H #define PARTICLEINJECTTIMEANALYSISVIEW_H -#include -#include "qwt.h" -#include "CustomQwtPlot.h" -#include -#include #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& data_files_set); - void setData(QVector data); - - //获取数据 - QVector 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 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 diff --git a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.ui b/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.ui deleted file mode 100644 index e9d4bd5..0000000 --- a/src/ParticleInjectTimeView/ParticleInjectTimeAnalysisView.ui +++ /dev/null @@ -1,157 +0,0 @@ - - - ParticleInjectTimeAnalysisView - - - - 0 - 0 - 997 - 307 - - - - ParticleInjectTimeAnalysis - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 粒子入射设置 - - - - - - - 起始能量: - - - - - - - 50 - - - - - - - KeV - - - - - - - ~ - - - - - - - 终止能量: - - - - - - - 100 - - - - - - - KeV - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 感兴趣区域(ROI)选择 - - - - - - - - - - 0 - 0 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - diff --git a/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.cpp b/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.cpp index c2fcf93..204daa4 100644 --- a/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.cpp +++ b/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.cpp @@ -16,6 +16,11 @@ #include #include #include +#include +#include +#include +#include +#include "BusyIndicator.h" #include @@ -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_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 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 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(); + } } \ No newline at end of file diff --git a/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.h b/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.h index fb321b8..785dec8 100644 --- a/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.h +++ b/src/ParticleTimeDifferenceView/ParticleTimeDifferenceView.h @@ -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 diff --git a/src/src.pro b/src/src.pro index 4ed9271..3338fc7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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 \ diff --git a/style/Resources.qrc b/style/Resources.qrc new file mode 100644 index 0000000..eb793b9 --- /dev/null +++ b/style/Resources.qrc @@ -0,0 +1,7 @@ + + + stylesheet/default.qss + stylesheet/dock.qss + gif/BusyIndicator.gif + + diff --git a/style/gif/BusyIndicator.gif b/style/gif/BusyIndicator.gif new file mode 100644 index 0000000..68184a7 Binary files /dev/null and b/style/gif/BusyIndicator.gif differ diff --git a/style/stylesheet/default.qss b/style/stylesheet/default.qss new file mode 100644 index 0000000..ae25cdf --- /dev/null +++ b/style/stylesheet/default.qss @@ -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; +} +*/ diff --git a/style/stylesheet/dock.qss b/style/stylesheet/dock.qss new file mode 100644 index 0000000..f78f2fc --- /dev/null +++ b/style/stylesheet/dock.qss @@ -0,0 +1,13 @@ +/* +ads--CDockContainerWidget ads--CDockSplitter::handle { + background: #2a5caa; +} + +ads--CDockSplitter::handle:horizontal { + width: 1px; +} + +ads--CDockSplitter::handle:vertical { + height: 1px; +} +*/ \ No newline at end of file