From 5f2e24ecb85a691f2e9a4a400196cb46452189fb Mon Sep 17 00:00:00 2001 From: lh <2334563547@qq.com> Date: Thu, 19 Nov 2026 16:17:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(nmPlot):=20=E4=BF=AE=E6=AD=A3=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=A1=86=E7=BB=98=E5=88=B6=E4=BD=8D=E7=BD=AE=E5=81=8F?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除多余的半像素偏移,使节点框与折线节点对齐 - 同步调整普通节点框和吸附框,保持原有大小及颜色 --- Src/nmNum/nmPlot/nmObjBase.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Src/nmNum/nmPlot/nmObjBase.cpp b/Src/nmNum/nmPlot/nmObjBase.cpp index 689aee8b..8a97f218 100644 --- a/Src/nmNum/nmPlot/nmObjBase.cpp +++ b/Src/nmNum/nmPlot/nmObjBase.cpp @@ -55,9 +55,11 @@ void nmObjBase::paintNodeHandle(QPainter* painter, const QPointF& pt, painter->setPen(pen); painter->setBrush(fillColor.isValid() ? QBrush(fillColor) : QBrush(Qt::NoBrush)); - // 将一像素边线对齐到像素中心,并把边线本身计入节点框的总尺寸。 - const qreal left = qRound(screenPos.x() - nPixelSize * 0.5) + 0.5; - const qreal top = qRound(screenPos.y() - nPixelSize * 0.5) + 0.5; + // 关闭抗锯齿时,Qt 已将 1 像素边线落到像素格内,只需对左上角取整。 + // 不再额外加半像素,避免栅格化后节点框向右下偏离折线交点。 + // 路径宽高扣除边线,使可见外框仍为 nPixelSize 像素。 + const qreal left = qRound(screenPos.x() - nPixelSize * 0.5); + const qreal top = qRound(screenPos.y() - nPixelSize * 0.5); painter->drawRect(QRectF(left, top, nPixelSize - 1, nPixelSize - 1)); painter->restore(); }