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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<float>(i) / static_cast<float>(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<float>(PI); // unwrap the sector
|
||||
int steps = std::max(8, static_cast<int>((phi1 - phi0) * 180.0f / static_cast<float>(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<float>(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));
|
||||
|
||||
Reference in New Issue
Block a user