feat/dataset-detail-chart #5
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_grid.h>
|
||||
#include <qwt_plot_magnifier.h>
|
||||
#include <QSplitter>
|
||||
#include <qwt_plot_rescaler.h>
|
||||
|
||||
#include "PanelHeader.hpp"
|
||||
|
|
@ -112,10 +112,8 @@ GridDataChartView::GridDataChartView(QWidget* parent) : QWidget(parent) {
|
|||
plot_->setPalette(pal);
|
||||
}
|
||||
|
||||
// 交互:LivePanner(左键实时平移,x 底轴 + y 左轴)+ Magnifier(滚轮缩放,反向使上滚=放大)。
|
||||
// 交互:LivePanner 统一左键实时平移 + 滚轮缩放(消费滚轮事件,不冒泡触发滚动条)。
|
||||
new LivePanner(plot_, QwtPlot::xBottom, QwtPlot::yLeft, this);
|
||||
auto* magnifier = new QwtPlotMagnifier(plot_->canvas());
|
||||
magnifier->setWheelFactor(1.0 / 0.9);
|
||||
|
||||
plot_->setMinimumSize(0, 0);
|
||||
|
||||
|
|
@ -124,26 +122,34 @@ GridDataChartView::GridDataChartView(QWidget* parent) : QWidget(parent) {
|
|||
rescaler_->setAspectRatio(1.0);
|
||||
rescaler_->setEnabled(true);
|
||||
|
||||
lay->addWidget(plot_, 1);
|
||||
|
||||
// ---- 独立色阶条(固定高 36px)----
|
||||
// 图表区 = 绘图 + 色阶条(色阶条固定高 36)。
|
||||
colorBar_ = new ColorBarWidget(this);
|
||||
colorBar_->setObjectName(QStringLiteral("gridColorScaleBar"));
|
||||
lay->addWidget(colorBar_);
|
||||
auto* chartArea = new QWidget(this);
|
||||
auto* chartLay = new QVBoxLayout(chartArea);
|
||||
chartLay->setContentsMargins(0, 0, 0, 0);
|
||||
chartLay->setSpacing(0);
|
||||
chartLay->addWidget(plot_, 1);
|
||||
chartLay->addWidget(colorBar_);
|
||||
|
||||
// ---- 底部双页签(异常列表 / 描述),固定高约 200px ----
|
||||
// ---- 底部双页签(异常列表 / 描述)----
|
||||
anomalyTable_ = new AnomalyTablePanel(this);
|
||||
descriptionPanel_ = new DescriptionPanel(this);
|
||||
|
||||
const QVector<PanelTab> bottomTabs = {
|
||||
{Glyph::Anomaly, QStringLiteral("异常列表"), anomalyTable_, true},
|
||||
{Glyph::Property, QStringLiteral("描述"), descriptionPanel_, false},
|
||||
};
|
||||
auto tabbedBottom = buildTabbedPanel(bottomTabs, {});
|
||||
|
||||
auto* bottomContainer = tabbedBottom.container;
|
||||
bottomContainer->setFixedHeight(200);
|
||||
lay->addWidget(bottomContainer);
|
||||
// 图表区 | 底部表 用竖直 QSplitter:自适应 dock 高度、可拖拽、不强制固定 200px
|
||||
//(避免内容溢出滚动条;也使本页与「原数据」页高度互不耦合)。
|
||||
auto* splitter = new QSplitter(Qt::Vertical, this);
|
||||
splitter->addWidget(chartArea);
|
||||
splitter->addWidget(tabbedBottom.container);
|
||||
splitter->setStretchFactor(0, 3);
|
||||
splitter->setStretchFactor(1, 1);
|
||||
splitter->setChildrenCollapsible(false);
|
||||
lay->addWidget(splitter, 1);
|
||||
|
||||
// ---- 工具条开关 → 重建/重绘 ----
|
||||
connect(chkShowAnom, &QCheckBox::toggled, this, [this](bool on) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_scale_div.h>
|
||||
|
||||
|
|
@ -52,6 +53,26 @@ bool LivePanner::eventFilter(QObject* obj, QEvent* ev) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case QEvent::Wheel: {
|
||||
// 滚轮缩放(以光标为中心,上滚=放大),并 **消费事件**(return true)避免冒泡到外层
|
||||
// 滚动区域触发滚动条。两轴同因子缩放→保持锁定的真实比尺。
|
||||
auto* we = static_cast<QWheelEvent*>(ev);
|
||||
const int d = we->angleDelta().y();
|
||||
if (d == 0) return true;
|
||||
const double f = (d > 0) ? (1.0 / 1.15) : 1.15; // 上滚→区间缩小→放大
|
||||
const QPointF pos = we->position();
|
||||
const double cx = plot_->invTransform(xAxis_, pos.x());
|
||||
const double cy = plot_->invTransform(yAxis_, pos.y());
|
||||
const double xMin = plot_->axisScaleDiv(xAxis_).lowerBound();
|
||||
const double xMax = plot_->axisScaleDiv(xAxis_).upperBound();
|
||||
const double yMin = plot_->axisScaleDiv(yAxis_).lowerBound();
|
||||
const double yMax = plot_->axisScaleDiv(yAxis_).upperBound();
|
||||
plot_->setAxisScale(xAxis_, cx - (cx - xMin) * f, cx + (xMax - cx) * f);
|
||||
plot_->setAxisScale(yAxis_, cy - (cy - yMin) * f, cy + (yMax - cy) * f);
|
||||
plot_->replot();
|
||||
we->accept();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_canvas.h>
|
||||
#include <qwt_plot_magnifier.h>
|
||||
#include <qwt_plot_marker.h>
|
||||
#include <qwt_plot_grid.h>
|
||||
#include <qwt_plot_rescaler.h>
|
||||
|
|
@ -96,13 +95,9 @@ RawDataChartView::RawDataChartView(QWidget* parent) : QWidget(parent) {
|
|||
zeroY->setLinePen(QColor(180, 180, 180), 1.0);
|
||||
zeroY->attach(plot_);
|
||||
|
||||
// 交互:LivePanner(左键拖动实时平移,坐标轴+内容一起动)+ Magnifier(滚轮缩放)
|
||||
// 交互:LivePanner 统一处理左键实时平移 + 滚轮缩放(并消费滚轮事件,不冒泡触发滚动条)。
|
||||
new LivePanner(plot_, QwtPlot::xTop, QwtPlot::yLeft, this);
|
||||
|
||||
auto* magnifier = new QwtPlotMagnifier(plot_->canvas());
|
||||
// 反转滚轮方向:Qwt 默认 wheelFactor=0.9 → 上滚缩小;取倒数使「上滚=放大」(常规习惯)。
|
||||
magnifier->setWheelFactor(1.0 / 0.9);
|
||||
|
||||
// 允许随停靠面板自由收缩(不强制最小宽度)。
|
||||
plot_->setMinimumSize(0, 0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue