fix(nmPlot): 修正节点框绘制位置偏移

- 移除多余的半像素偏移,使节点框与折线节点对齐
- 同步调整普通节点框和吸附框,保持原有大小及颜色
feature/fix-result-persistence-20261118
lh 1 week ago
parent 5927ce15dc
commit 5f2e24ecb8

@ -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();
}

Loading…
Cancel
Save