From 237bb95d6e1d84596e2f9facb28c6bbaa871f8e4 Mon Sep 17 00:00:00 2001 From: TianZD <1203886034@qq.com> Date: Wed, 22 Apr 2026 18:04:46 +0800 Subject: [PATCH] =?UTF-8?q?modify:=E8=A7=A3=E5=86=B3=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E5=90=8E=E5=8D=A1=E6=96=AD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/qcustomplot.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qcustomplot.cpp b/src/qcustomplot.cpp index 2ba5151..2330c70 100644 --- a/src/qcustomplot.cpp +++ b/src/qcustomplot.cpp @@ -24536,7 +24536,12 @@ double QCPGraph::pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer: { // line displayed, calculate distance to line segments: QVector lineData; - getLines(&lineData, QCPDataRange(0, dataCount())); // don't limit data range further since with sharp data spikes, line segments may be closer to test point than segments with closer key coordinate + // 中文注释:曲线点击命中测试原先会为每一条曲线生成整段可见折线,数据量和曲线数较大时单次选中会明显卡顿。 + // 这里复用上面已经按鼠标选择容差换算出的 key 区间,并依赖 findBegin/findEnd 的 expandedRange 保留边界相邻点; + // 这样仍能覆盖穿过鼠标附近的线段,同时把一次命中测试的计算量限制在光标附近的数据窗口内。 + const int beginIndex = int(begin - mDataContainer->constBegin()); + const int endIndex = int(end - mDataContainer->constBegin()); + getLines(&lineData, QCPDataRange(beginIndex, endIndex)); QCPVector2D p(pixelPoint); const int step = mLineStyle == lsImpulse ? 2 : 1; // impulse plot differs from other line styles in that the lineData points are only pairwise connected for (int i = 0; i < lineData.size() - 1; i += step)