From 33118ebe8b0911ca08dde6f9151bff7cf7735573 Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Fri, 19 Jun 2026 11:44:42 +0200 Subject: [PATCH] viewer: fix stray line from origin on full-ring azimuthal ROI The full-ring annulus built the inner ring as a separate QPainterPath and merged it with addPath, which stitched a spurious segment from (0,0) to the ring. Build both concentric rings as subpaths of one path, each begun with an explicit moveTo, so there is no connecting segment. Co-Authored-By: Claude Opus 4.8 --- .../image_viewer/JFJochDiffractionImage.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/viewer/image_viewer/JFJochDiffractionImage.cpp b/viewer/image_viewer/JFJochDiffractionImage.cpp index f82efa42..412845d0 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.cpp +++ b/viewer/image_viewer/JFJochDiffractionImage.cpp @@ -389,12 +389,14 @@ void JFJochDiffractionImage::DrawAzimuthalROI(const ROIAzimuthal &az, const QCol // Sample the boundary through the geometry so the wedge matches the ROI footprint. // ResPhiToPxl throws when the resolution is too high for the wavelength; skip such ROIs. - auto add_arc = [&](QPainterPath &path, float d, float phi_a, float phi_b, int steps) -> bool { + // move_to_start == true begins a new subpath (no connecting line); false continues + // the current one (used for the radial edge between a sector's outer and inner arc). + auto add_arc = [&](QPainterPath &path, float d, float phi_a, float phi_b, int steps, bool move_to_start) -> bool { for (int i = 0; i <= steps; i++) { float phi = phi_a + (phi_b - phi_a) * static_cast(i) / static_cast(steps); try { auto [px, py] = geom.ResPhiToPxl(d, phi); - if (path.elementCount() == 0) + if (move_to_start && i == 0) path.moveTo(px, py); else path.lineTo(px, py); @@ -409,18 +411,16 @@ void JFJochDiffractionImage::DrawAzimuthalROI(const ROIAzimuthal &az, const QCol float phi1 = deg2rad(az.GetPhiMax_deg()); if (phi1 < phi0) phi1 += 2.0f * static_cast(PI); // unwrap the sector int steps = std::max(8, static_cast((phi1 - phi0) * 180.0f / static_cast(PI) / 2.0f)); - if (!add_arc(path, d_outer, phi0, phi1, steps)) return; // outer arc - if (!add_arc(path, d_inner, phi1, phi0, steps)) return; // inner arc back + if (!add_arc(path, d_outer, phi0, phi1, steps, true)) return; // outer arc + if (!add_arc(path, d_inner, phi1, phi0, steps, false)) return; // inner arc; radial edges close it path.closeSubpath(); } else { - path.setFillRule(Qt::OddEvenFill); // annulus + path.setFillRule(Qt::OddEvenFill); // annulus: two concentric rings const float two_pi = 2.0f * static_cast(PI); - if (!add_arc(path, d_outer, 0, two_pi, 180)) return; + if (!add_arc(path, d_outer, 0, two_pi, 180, true)) return; + path.closeSubpath(); + if (!add_arc(path, d_inner, 0, two_pi, 180, true)) return; path.closeSubpath(); - QPainterPath inner; - if (!add_arc(inner, d_inner, 0, two_pi, 180)) return; - inner.closeSubpath(); - path.addPath(inner); } addOverlayItem(scene()->addPath(path, pen, brush));