1、优化粒子时间差数据加载,添加交互动画; 2、优化图表轴拖动缩放
This commit is contained in:
parent
5e4d8f943f
commit
829b22d74e
BIN
bin/minimsys/bash.exe
Normal file
BIN
bin/minimsys/bash.exe
Normal file
Binary file not shown.
BIN
bin/minimsys/env.exe
Normal file
BIN
bin/minimsys/env.exe
Normal file
Binary file not shown.
BIN
bin/minimsys/head.exe
Normal file
BIN
bin/minimsys/head.exe
Normal file
Binary file not shown.
BIN
bin/minimsys/msys-2.0.dll
Normal file
BIN
bin/minimsys/msys-2.0.dll
Normal file
Binary file not shown.
BIN
bin/minimsys/msys-gcc_s-seh-1.dll
Normal file
BIN
bin/minimsys/msys-gcc_s-seh-1.dll
Normal file
Binary file not shown.
BIN
bin/minimsys/msys-iconv-2.dll
Normal file
BIN
bin/minimsys/msys-iconv-2.dll
Normal file
Binary file not shown.
BIN
bin/minimsys/msys-intl-8.dll
Normal file
BIN
bin/minimsys/msys-intl-8.dll
Normal file
Binary file not shown.
BIN
bin/minimsys/sort.exe
Normal file
BIN
bin/minimsys/sort.exe
Normal file
Binary file not shown.
BIN
bin/minimsys/tail.exe
Normal file
BIN
bin/minimsys/tail.exe
Normal file
Binary file not shown.
BIN
bin/theme.rcc
Normal file
BIN
bin/theme.rcc
Normal file
Binary file not shown.
36
src/BusyIndicator/BusyIndicator.cpp
Normal file
36
src/BusyIndicator/BusyIndicator.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include "BusyIndicator.h"
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMovie>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
BusyIndicator::BusyIndicator(QWidget* parent)
|
||||||
|
: QWidget { parent }
|
||||||
|
{
|
||||||
|
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
|
QLabel* icon = new QLabel;
|
||||||
|
_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();
|
||||||
|
}
|
||||||
20
src/BusyIndicator/BusyIndicator.h
Normal file
20
src/BusyIndicator/BusyIndicator.h
Normal 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
|
||||||
|
|
@ -127,7 +127,6 @@ QVector<ParticleInjectTime> CountRateAnalysisView::getParticleInjectTimeData(QSt
|
||||||
void CountRateAnalysisView::InitUi()
|
void CountRateAnalysisView::InitUi()
|
||||||
{
|
{
|
||||||
plot = new CustomQwtPlot();
|
plot = new CustomQwtPlot();
|
||||||
plot->SetXaxisDragScale(true);
|
|
||||||
setupPlot();
|
setupPlot();
|
||||||
ui->verticalLayout_2->addWidget(plot);
|
ui->verticalLayout_2->addWidget(plot);
|
||||||
}
|
}
|
||||||
|
|
@ -152,5 +151,5 @@ void CountRateAnalysisView::setupPlot()
|
||||||
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||||
// plot->insertLegend(legend, QwtPlot::RightLegend);
|
// plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||||
|
|
||||||
plot->SetXaxisDragScale(true);
|
plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,161 @@
|
||||||
#include <QwtPlotPicker>
|
#include <QwtPlotPicker>
|
||||||
#include <QwtPlotShapeItem>
|
#include <QwtPlotShapeItem>
|
||||||
#include <QwtPickerDragRectMachine>
|
#include <QwtPickerDragRectMachine>
|
||||||
|
#include <QwtPlotMagnifier>
|
||||||
#include <QDebug>
|
#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)
|
CustomQwtPlot::CustomQwtPlot(QWidget *parent)
|
||||||
: QwtPlot(parent)
|
: QwtPlot(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomQwtPlot::~CustomQwtPlot()
|
CustomQwtPlot::~CustomQwtPlot()
|
||||||
|
|
@ -25,18 +175,101 @@ CustomQwtPlot::~CustomQwtPlot()
|
||||||
qDebug() << "~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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} 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);
|
this->setAxisScale(axis_id, min, max);
|
||||||
x_scale->setMouseTracking(enable);
|
if ( axis_id == QwtPlot::xBottom ) {
|
||||||
x_scale->installEventFilter(enable ? this : nullptr);
|
_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()
|
void CustomQwtPlot::ResetPlot()
|
||||||
{
|
{
|
||||||
this->setAxisScale(QwtPlot::xBottom, _init_x_min, _init_x_max);
|
this->setAxisScale(QwtPlot::xBottom, _init_x_min, _init_x_max);
|
||||||
|
|
@ -162,197 +395,33 @@ void CustomQwtPlot::CleanZoneItems()
|
||||||
|
|
||||||
bool CustomQwtPlot::eventFilter(QObject *obj, QEvent *event)
|
bool CustomQwtPlot::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (this->_event_filter_func) {
|
bool has_filter = false;
|
||||||
bool filted = this->_event_filter_func(obj, event);
|
for (auto filter : _event_filter_func_list) {
|
||||||
if (filted) {
|
filter(obj, event);
|
||||||
return filted;
|
has_filter = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (dynamic_cast<QwtScaleWidget*>(obj) != this->axisWidget(QwtPlot::xBottom))
|
if (has_filter) {
|
||||||
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();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return QwtPlot::eventFilter(obj, event);
|
return QwtPlot::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomQwtPlot::showEvent(QShowEvent *event)
|
// void CustomQwtPlot::showEvent(QShowEvent *event)
|
||||||
{
|
// {
|
||||||
Q_UNUSED(event);
|
// Q_UNUSED(event);
|
||||||
this->updateAxes();
|
// this->updateAxes();
|
||||||
if ((0 == this->_init_x_max) && (0 == this->_init_y_max)) {
|
// if ((0 == this->_init_x_max) && (0 == this->_init_y_max)) {
|
||||||
// double x_min = this->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
// // double x_min = this->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||||
double x_max = this->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
// double x_max = this->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||||
double y_min = this->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
// // double y_min = this->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||||
double y_max = this->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
// double y_max = this->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||||
this->_init_x_min = 0;
|
// this->_init_x_min = 0;
|
||||||
this->_init_x_max = x_max;
|
// this->_init_x_max = x_max;
|
||||||
this->_init_y_min = y_min;
|
// this->_init_y_min = 0;
|
||||||
this->_init_y_max = y_max;
|
// this->_init_y_max = y_max;
|
||||||
this->setAxisScale(QwtPlot::xBottom, 0, x_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QColor getDistinctColorForManyCurves(int curve_index)
|
QColor getDistinctColorForManyCurves(int curve_index)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,72 +4,33 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QwtPlot>
|
#include <QwtPlot>
|
||||||
#include <QwtPlotPanner>
|
#include <QwtPlotPanner>
|
||||||
#include <QwtPlotMagnifier>
|
// #include <QwtPlotMagnifier>
|
||||||
#include <QwtPlotPicker>
|
#include <QwtPlotPicker>
|
||||||
|
|
||||||
class QwtPlotCurve;
|
class QwtPlotCurve;
|
||||||
class QwtPlotMarker;
|
class QwtPlotMarker;
|
||||||
class QwtPlotZoneItem;
|
class QwtPlotZoneItem;
|
||||||
class QwtPlotShapeItem;
|
class QwtPlotShapeItem;
|
||||||
|
class QwtScaleWidget;
|
||||||
|
class QwtPlotMagnifier;
|
||||||
|
|
||||||
class CustomQwtPlot : public QwtPlot
|
class CustomQwtPlotAxisPanner : public QwtPlotPanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CustomQwtPlot(QWidget* parent = nullptr);
|
CustomQwtPlotAxisPanner(QwtScaleWidget *scale_widget);
|
||||||
virtual ~CustomQwtPlot();
|
virtual ~CustomQwtPlotAxisPanner();
|
||||||
|
|
||||||
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();
|
|
||||||
protected:
|
protected:
|
||||||
virtual void moveCanvas(int dx, int dy) override;
|
virtual void moveCanvas(int dx, int dy) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomQwtPlotXaxisMagnifier : public QwtPlotMagnifier
|
// class CustomQwtPlotXaxisMagnifier : public QwtPlotMagnifier
|
||||||
{
|
// {
|
||||||
public:
|
// public:
|
||||||
CustomQwtPlotXaxisMagnifier(QWidget *canvas);
|
// CustomQwtPlotXaxisMagnifier(QWidget *canvas);
|
||||||
virtual ~CustomQwtPlotXaxisMagnifier();
|
// virtual ~CustomQwtPlotXaxisMagnifier();
|
||||||
protected:
|
// protected:
|
||||||
virtual void rescale(double factor) override;
|
// virtual void rescale(double factor) override;
|
||||||
};
|
// };
|
||||||
|
|
||||||
class CustomQwtPlotXaxisSelector : public QwtPlotPicker
|
class CustomQwtPlotXaxisSelector : public QwtPlotPicker
|
||||||
{
|
{
|
||||||
|
|
@ -95,6 +56,57 @@ private:
|
||||||
double _max_x;
|
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);
|
QColor getDistinctColorForManyCurves(int curve_index);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ void EnergyCountPeakFitView::setupPlot()
|
||||||
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||||
// _plot->insertLegend(legend, QwtPlot::RightLegend);
|
// _plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||||
|
|
||||||
_plot->SetXaxisDragScale(true);
|
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
||||||
_data_selector->setEnabled(false);
|
_data_selector->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ void EnergyCountPlotView::setupPlot()
|
||||||
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||||
_plot->insertLegend(legend, QwtPlot::RightLegend);
|
_plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||||
|
|
||||||
_plot->SetXaxisDragScale(true);
|
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
||||||
_data_selector->setEnabled(false);
|
_data_selector->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ void ParticleCountPlotView::setupPlot()
|
||||||
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||||
_plot->insertLegend(legend, QwtPlot::RightLegend);
|
_plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||||
|
|
||||||
_plot->SetXaxisDragScale(true);
|
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
// new CustomQwtPlotXaxisPanner(_plot->canvas());
|
// new CustomQwtPlotXaxisPanner(_plot->canvas());
|
||||||
// new CustomQwtPlotXaxisMagnifier(_plot->canvas());
|
// new CustomQwtPlotXaxisMagnifier(_plot->canvas());
|
||||||
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,6 @@ QVector<ParticleInjectTime *> ParticleInjectTimeAnalysisView::getParticleInjectT
|
||||||
void ParticleInjectTimeAnalysisView::InitUi()
|
void ParticleInjectTimeAnalysisView::InitUi()
|
||||||
{
|
{
|
||||||
plot = new CustomQwtPlot();
|
plot = new CustomQwtPlot();
|
||||||
plot->SetXaxisDragScale(true);
|
|
||||||
setupPlot();
|
setupPlot();
|
||||||
ui->verticalLayout_2->addWidget(plot);
|
ui->verticalLayout_2->addWidget(plot);
|
||||||
}
|
}
|
||||||
|
|
@ -186,5 +185,5 @@ void ParticleInjectTimeAnalysisView::setupPlot()
|
||||||
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
// legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||||
// plot->insertLegend(legend, QwtPlot::RightLegend);
|
// plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||||
|
|
||||||
plot->SetXaxisDragScale(true);
|
plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@
|
||||||
#include <QwtPlotHistogram>
|
#include <QwtPlotHistogram>
|
||||||
#include <QwtIntervalSample>
|
#include <QwtIntervalSample>
|
||||||
#include <QwtLogScaleEngine>
|
#include <QwtLogScaleEngine>
|
||||||
|
#include <QwtPlotPanner>
|
||||||
|
#include <QwtPlotMagnifier>
|
||||||
|
#include <QwtScaleWidget>
|
||||||
|
#include <QThreadPool>
|
||||||
|
#include "BusyIndicator.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,6 +35,8 @@ ParticleTimeDifferenceView::ParticleTimeDifferenceView(QWidget *parent)
|
||||||
setupPlot();
|
setupPlot();
|
||||||
this->_menu = new QMenu(this);
|
this->_menu = new QMenu(this);
|
||||||
setupMenu();
|
setupMenu();
|
||||||
|
|
||||||
|
_busy_indicator = new BusyIndicator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleTimeDifferenceView::~ParticleTimeDifferenceView()
|
ParticleTimeDifferenceView::~ParticleTimeDifferenceView()
|
||||||
|
|
@ -48,7 +55,12 @@ void ParticleTimeDifferenceView::SetAnalyzeDataFilename(const QMap<QString, QVar
|
||||||
const QString& data_name = data_files_set.firstKey();
|
const QString& data_name = data_files_set.firstKey();
|
||||||
const QString& data_filename = data_files_set.first().toString();
|
const QString& data_filename = data_files_set.first().toString();
|
||||||
if (QFileInfo(data_filename).exists()) {
|
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);
|
_plot->setAxisTitle(QwtPlot::yLeft, count_label);
|
||||||
|
|
||||||
// set axis auto scale
|
// set axis auto scale
|
||||||
_plot->setAxisAutoScale(QwtPlot::xBottom, true);
|
_plot->setAxisAutoScale(QwtPlot::xBottom, false);
|
||||||
_plot->setAxisAutoScale(QwtPlot::yLeft, true);
|
_plot->setAxisAutoScale(QwtPlot::yLeft, false);
|
||||||
|
|
||||||
_plot->enableAxis(QwtPlot::xBottom);
|
_plot->enableAxis(QwtPlot::xBottom);
|
||||||
_plot->enableAxis(QwtPlot::yLeft);
|
_plot->enableAxis(QwtPlot::yLeft);
|
||||||
|
|
||||||
_plot->SetXaxisDragScale(true);
|
_plot->SetAxisDragScale(QwtPlot::xBottom, true);
|
||||||
_data_selector = new CustomQwtPlotXaxisSelector(_plot->canvas());
|
_plot->SetAxisDragScale(QwtPlot::yLeft, true);
|
||||||
_data_selector->setEnabled(false);
|
|
||||||
|
|
||||||
_histogram = new QwtPlotHistogram("粒子时间差分布");
|
_histogram = new QwtPlotHistogram("粒子时间差分布");
|
||||||
_histogram->setStyle(QwtPlotHistogram::Columns);
|
_histogram->setStyle(QwtPlotHistogram::Columns);
|
||||||
|
|
@ -95,14 +106,17 @@ void ParticleTimeDifferenceView::setupMenu()
|
||||||
connect(action_plot_reset, &QAction::triggered, [this]() {
|
connect(action_plot_reset, &QAction::triggered, [this]() {
|
||||||
this->_plot->ResetPlot();
|
this->_plot->ResetPlot();
|
||||||
});
|
});
|
||||||
|
this->_menu->addSeparator();
|
||||||
|
|
||||||
this->_menu->addSeparator();
|
this->_menu->addSeparator();
|
||||||
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
QAction* action_plot_config = this->_menu->addAction(QStringLiteral(u"图表配置"));
|
||||||
action_plot_config->setObjectName("plot_config");
|
action_plot_config->setObjectName("plot_config");
|
||||||
connect(action_plot_config, &QAction::triggered, this, &ParticleTimeDifferenceView::onActionPlotConfigure);
|
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 {
|
try {
|
||||||
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
|
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
|
||||||
std::string channel_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::double_quote_escape<',', '"'>,
|
||||||
io::throw_on_overflow,
|
io::throw_on_overflow,
|
||||||
io::empty_line_comment>
|
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);
|
reader.read_header(io::ignore_extra_column, board_id_str, channel_id_str, address_str, time_str);
|
||||||
|
|
||||||
QMap<double, unsigned long long> hist_map;
|
QMap<double, unsigned long long> hist_map;
|
||||||
|
|
@ -131,26 +145,42 @@ void ParticleTimeDifferenceView::loadDataFromFile(const QString &data_name, cons
|
||||||
hist_map[bin]++;
|
hist_map[bin]++;
|
||||||
time1 = time2;
|
time1 = time2;
|
||||||
}
|
}
|
||||||
unsigned long long max_count = 1;
|
double x_max = 0.0f, y_max = 0.0f;
|
||||||
QVector<QwtIntervalSample> samples;
|
QVector<QwtIntervalSample> samples;
|
||||||
for (const double& bin : hist_map.keys()) {
|
for (const double& bin : hist_map.keys()) {
|
||||||
const unsigned long long& count = hist_map.value(bin);
|
const unsigned long long& count = hist_map.value(bin);
|
||||||
samples.append(QwtIntervalSample(count, bin, bin + _bin_width));
|
double bin_max = bin + _bin_width;
|
||||||
if ( max_count < count ) {
|
samples.append(QwtIntervalSample(count, bin, bin_max));
|
||||||
max_count = count;
|
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));
|
_histogram->setData(new QwtIntervalSeriesData(samples));
|
||||||
|
_plot->SetAxisInitRange(QwtPlot::xBottom, 0.0f, _x_max);
|
||||||
|
_plot->SetAxisInitRange(QwtPlot::yLeft, 0.0f, y_max);
|
||||||
_plot->replot();
|
_plot->replot();
|
||||||
const QString& info = QStringLiteral(u"能谱数据处理完成.");
|
const QString& info = QStringLiteral(u"粒子时间差分析处理完成.");
|
||||||
LOG_INFO(info);
|
LOG_INFO(info);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
const QString& e_what = QString::fromStdString(e.what());
|
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::onActionPlotConfigure()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticleTimeDifferenceView::showEvent(QShowEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
if (_busy_indicator) {
|
||||||
|
_busy_indicator->setGeometry(this->rect());
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ class QMenu;
|
||||||
class CustomQwtPlot;
|
class CustomQwtPlot;
|
||||||
class CustomQwtPlotXaxisSelector;
|
class CustomQwtPlotXaxisSelector;
|
||||||
class QwtPlotHistogram;
|
class QwtPlotHistogram;
|
||||||
|
class BusyIndicator;
|
||||||
|
|
||||||
class ParticleTimeDifferenceView : public MeasureAnalysisView
|
class ParticleTimeDifferenceView : public MeasureAnalysisView
|
||||||
{
|
{
|
||||||
|
|
@ -23,18 +24,25 @@ public:
|
||||||
private:
|
private:
|
||||||
void setupPlot();
|
void setupPlot();
|
||||||
void setupMenu();
|
void setupMenu();
|
||||||
void loadDataFromFile(const QString &data_name, const QString& filename);
|
void loadDataFromFile();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onActionPlotConfigure();
|
void onActionPlotConfigure();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent* e) override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BusyIndicator* _busy_indicator = nullptr;
|
||||||
CustomQwtPlot* _plot = nullptr;
|
CustomQwtPlot* _plot = nullptr;
|
||||||
QMenu* _menu = nullptr;
|
QMenu* _menu = nullptr;
|
||||||
QDialog* _curve_show_setting_dlg = nullptr;
|
QDialog* _curve_show_setting_dlg = nullptr;
|
||||||
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
|
CustomQwtPlotXaxisSelector* _data_selector = nullptr;
|
||||||
double _bin_width = 50.0f;
|
double _bin_width = 50.0f;
|
||||||
|
double _x_max = 200.0f * 1e3;
|
||||||
|
double _y_max = 0.0f;
|
||||||
QwtPlotHistogram* _histogram = nullptr;
|
QwtPlotHistogram* _histogram = nullptr;
|
||||||
|
QString _data_filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTICLETIMEDIFFERENCEVIEW_H
|
#endif // PARTICLETIMEDIFFERENCEVIEW_H
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ MOC_DIR = $${BUILD_MOC}/$${TARGET}/moc
|
||||||
UI_DIR = $${BUILD_UI}/$${TARGET}/ui
|
UI_DIR = $${BUILD_UI}/$${TARGET}/ui
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
|
$${PWD}/BusyIndicator \
|
||||||
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
||||||
$${PWD}/ParticleCountPlotView \
|
$${PWD}/ParticleCountPlotView \
|
||||||
$${PWD}/ParticleInjectTimeView \
|
$${PWD}/ParticleInjectTimeView \
|
||||||
|
|
@ -45,6 +46,7 @@ INCLUDEPATH += \
|
||||||
|
|
||||||
|
|
||||||
DEPENDPATH += \
|
DEPENDPATH += \
|
||||||
|
$${PWD}/BusyIndicator \
|
||||||
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
||||||
$${PWD}/ParticleCountPlotView \
|
$${PWD}/ParticleCountPlotView \
|
||||||
$${PWD}/ParticleInjectTimeView \
|
$${PWD}/ParticleInjectTimeView \
|
||||||
|
|
@ -60,6 +62,7 @@ DEPENDPATH += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
AboutDlg.cpp \
|
AboutDlg.cpp \
|
||||||
|
BusyIndicator/BusyIndicator.cpp \
|
||||||
CountRateAnalysisView/CountRateAnalysisView.cpp \
|
CountRateAnalysisView/CountRateAnalysisView.cpp \
|
||||||
CustomQwtPlot.cpp \
|
CustomQwtPlot.cpp \
|
||||||
DataProcessWorkPool.cpp \
|
DataProcessWorkPool.cpp \
|
||||||
|
|
@ -98,6 +101,7 @@ SOURCES += \
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
AboutDlg.h \
|
AboutDlg.h \
|
||||||
AnalysisTypeDefine.h \
|
AnalysisTypeDefine.h \
|
||||||
|
BusyIndicator/BusyIndicator.h \
|
||||||
CountRateAnalysisView/CountRateAnalysisView.h \
|
CountRateAnalysisView/CountRateAnalysisView.h \
|
||||||
CustomQwtPlot.h \
|
CustomQwtPlot.h \
|
||||||
DataProcessWorkPool.h \
|
DataProcessWorkPool.h \
|
||||||
|
|
|
||||||
7
style/Resources.qrc
Normal file
7
style/Resources.qrc
Normal 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
BIN
style/gif/BusyIndicator.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 152 KiB |
111
style/stylesheet/default.qss
Normal file
111
style/stylesheet/default.qss
Normal 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
13
style/stylesheet/dock.qss
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
ads--CDockContainerWidget ads--CDockSplitter::handle {
|
||||||
|
background: #2a5caa;
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--CDockSplitter::handle:horizontal {
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--CDockSplitter::handle:vertical {
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
*/
|
||||||
Loading…
Reference in New Issue
Block a user